Skip to content

Commit

Permalink
Expose tracker parent owner (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron authored Sep 2, 2024
1 parent 1403e17 commit 5de0a61
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Sources/TrackerRadarKit/TrackerData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
Expand Down
26 changes: 26 additions & 0 deletions Tests/TrackerRadarKitTests/KnownTrackerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
26 changes: 22 additions & 4 deletions Tests/TrackerRadarKitTests/Resources/trackerData.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 5de0a61

Please sign in to comment.