Skip to content

Commit 9d125ca

Browse files
committed
Add surrogate entity metadata to tracker events
1 parent cd39dc1 commit 9d125ca

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

injected/integration-test/tracker-protection.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ test('tracker-protection: loads surrogate for matching rule', async ({ page }, t
5656
const injected = await collector.waitForMessage('surrogateInjected', 1);
5757
expect(injected[0].payload.params.url).toBe('https://tracker.example/scripts/analytics.js');
5858
expect(injected[0].payload.params.isSurrogate).toBe(true);
59+
expect(injected[0].payload.params.entityName).toBe('Tracker Inc');
60+
expect(injected[0].payload.params.ownerName).toBe('Tracker Inc');
5961
});
6062

6163
test('tracker-protection: reports non-tracker third-party URL as thirdPartyRequest', async ({ page }, testInfo) => {

injected/src/features/tracker-protection.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ export class TrackerProtection extends ContentFeature {
476476
reason: result.reason,
477477
isSurrogate: true,
478478
pageUrl: this._topLevelUrl?.href || '',
479+
entityName: result.entity?.displayName || result.tracker?.owner?.displayName || null,
480+
ownerName: result.tracker?.owner?.name || null,
479481
});
480482
}
481483

injected/src/messages/tracker-protection/surrogateInjected.notify.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
"pageUrl": {
2525
"type": "string",
2626
"description": "The URL of the page where the tracker was detected"
27+
},
28+
"entityName": {
29+
"type": ["string", "null"],
30+
"description": "The display name of the tracker entity"
31+
},
32+
"ownerName": {
33+
"type": ["string", "null"],
34+
"description": "The owner name of the tracker"
2735
}
2836
}
2937
}

injected/src/types/tracker-protection.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export interface SurrogateInjected {
4343
* The URL of the page where the tracker was detected
4444
*/
4545
pageUrl: string;
46+
/**
47+
* The display name of the tracker entity
48+
*/
49+
entityName?: string | null;
50+
/**
51+
* The owner name of the tracker
52+
*/
53+
ownerName?: string | null;
4654
}
4755
/**
4856
* Generated from @see "../messages/tracker-protection/trackerDetected.notify.json"

0 commit comments

Comments
 (0)