From 5de0a610a7927b638a5fd463a53032c9934a2c3b Mon Sep 17 00:00:00 2001 From: Alessandro Boron Date: Mon, 2 Sep 2024 10:40:57 +1000 Subject: [PATCH] Expose tracker parent owner (#23) --- Sources/TrackerRadarKit/TrackerData.swift | 4 ++- .../KnownTrackerTests.swift | 26 +++++++++++++++++++ .../Resources/trackerData.json | 26 ++++++++++++++++--- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Sources/TrackerRadarKit/TrackerData.swift b/Sources/TrackerRadarKit/TrackerData.swift index 1824378..d5f3d85 100644 --- a/Sources/TrackerRadarKit/TrackerData.swift +++ b/Sources/TrackerRadarKit/TrackerData.swift @@ -81,10 +81,12 @@ public struct KnownTracker: Codable, Equatable { public let name: String? public let displayName: String? + public let ownedBy: String? - public init(name: String?, displayName: String?) { + public init(name: String?, displayName: String?, ownedBy: String?) { self.name = name self.displayName = displayName + self.ownedBy = ownedBy } } diff --git a/Tests/TrackerRadarKitTests/KnownTrackerTests.swift b/Tests/TrackerRadarKitTests/KnownTrackerTests.swift index e4d7ced..e9beda0 100644 --- a/Tests/TrackerRadarKitTests/KnownTrackerTests.swift +++ b/Tests/TrackerRadarKitTests/KnownTrackerTests.swift @@ -45,4 +45,30 @@ class KnownTrackerTests: XCTestCase { XCTAssertNil(tracker.category) } + func testWhenTrackerIsOwnedByParentThenOwnedByIsNotEmpty() throws { + // GIVEN + let trackerData = try JSONDecoder().decode(TrackerData.self, from: JSONTestDataLoader.trackerData) + + // WHEN + var owner = trackerData.trackers["instagram.com"]?.owner + // THEN assert Instagram is owned by Facebook + XCTAssertEqual(owner?.ownedBy, "Facebook, Inc.") + + // WHEN + owner = trackerData.trackers["youtube.com"]?.owner + // Assert Youtube.com is owned by Google + XCTAssertEqual(owner?.ownedBy, "Google LLC") + } + + func testWhenTrackerIsNotOwnedByParentThenOwnedByIsEmpty() throws { + // GIVEN + let trackerData = try JSONDecoder().decode(TrackerData.self, from: JSONTestDataLoader.trackerData) + + // WHEN + let owner = try XCTUnwrap(trackerData.trackers["insightexpressai.com"]).owner + + // THEN + XCTAssertNil(owner?.ownedBy) + } + } diff --git a/Tests/TrackerRadarKitTests/Resources/trackerData.json b/Tests/TrackerRadarKitTests/Resources/trackerData.json index 5d26329..6bd90c5 100644 --- a/Tests/TrackerRadarKitTests/Resources/trackerData.json +++ b/Tests/TrackerRadarKitTests/Resources/trackerData.json @@ -12875,10 +12875,10 @@ "instagram.com": { "domain": "instagram.com", "owner": { - "name": "Facebook, Inc.", - "displayName": "Facebook", - "privacyPolicy": "https://help.instagram.com/402411646841720", - "url": "http://instagram.com" + "name": "Instagram", + "displayName": "Instagram (Facebook)", + "localizedName": "Instagram", + "ownedBy": "Facebook, Inc." }, "prevalence": 0.00754, "fingerprinting": 2, @@ -29325,6 +29325,24 @@ } ] }, + "youtube.com": { + "domain": "youtube.com", + "owner": { + "name": "Youtube", + "displayName": "Youtube (Google)", + "localizedName": "Youtube", + "ownedBy": "Google LLC" + }, + "prevalence": 0.0694, + "fingerprinting": 3, + "cookies": 0.0628, + "categories": [ + "Ad Motivated Tracking", + "Content Delivery", + "Embedded Content" + ], + "default": "ignore" + }, "zadn.vn": { "domain": "zadn.vn", "owner": {