Skip to content

Commit dd109a6

Browse files
ref: Update Amplitude page view sanitization (#3739)
1 parent 594a732 commit dd109a6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/services/events/amplitude/amplitude.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,16 @@ describe('pageViewTrackingSanitization', () => {
7373
event_properties: {
7474
'[Amplitude] Page Counter': 1,
7575
'[Amplitude] Page Domain': 'app.codecov.io',
76+
'[Amplitude] Page Title': 'Codecov',
7677
'[Amplitude] Page Path': '/sensitive/info',
7778
'[Amplitude] Page Location': 'https://app.codecov.io/sensitive/info',
79+
'[Amplitude] Page URL': 'https://app.codecov.io/sensitive/info',
7880
},
7981
} as Event)
8082
expect(event?.event_properties).toMatchObject({
8183
'[Amplitude] Page Counter': 1,
8284
'[Amplitude] Page Domain': 'app.codecov.io',
85+
'[Amplitude] Page Title': 'Codecov',
8386
path: undefined,
8487
})
8588
}

src/services/events/amplitude/amplitude.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ export const pageViewTrackingSanitization = (): EnrichmentPlugin => {
1414
type: 'enrichment',
1515
setup: async () => undefined,
1616
execute: async (event) => {
17+
/* eslint-disable camelcase */
1718
if (event.event_type === '[Amplitude] Page Viewed') {
18-
/* eslint-disable camelcase */
19-
event.event_properties = {
20-
'[Amplitude] Page Counter':
21-
event.event_properties?.['[Amplitude] Page Counter'],
22-
'[Amplitude] Page Domain':
23-
event.event_properties?.['[Amplitude] Page Domain'],
24-
path: eventTracker().context.path,
19+
if (event.event_properties) {
20+
// Remove any information containing names and/or ids.
21+
delete event.event_properties['[Amplitude] Page Location'] // location.href
22+
delete event.event_properties['[Amplitude] Page Path'] // Full path of current page
23+
delete event.event_properties['[Amplitude] Page URL'] // Full URL of current page
24+
delete event.event_properties.referrer // Full URL of previous page
25+
26+
event.event_properties.path = eventTracker().context.path // Add the React path match
2527
}
2628
}
2729

0 commit comments

Comments
 (0)