Skip to content

Commit f2bc4ac

Browse files
piyalbasuclaude
andcommitted
Address review: clear Sentry user on opt-out, stub getUserId in jest mock
- Clear the per-install user id (Sentry.setUser(null)) before Sentry.close on data-sharing opt-out. Sentry.close may still report (anonymized) until the next refresh; without this those reports would keep the id attached. - Add getUserId to the helpers/metrics jest mock in setupTests so rendering ErrorTracking under test doesn't call an undefined mock. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 459c3af commit f2bc4ac

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

config/jest/setupTests.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jest.mock("helpers/metrics", () => ({
7979
registerHandler: () => {},
8080
emitMetric: () => {},
8181
initAmplitude: () => {},
82+
getUserId: () => "test-user-id",
8283
metricsMiddleware: jest.fn(
8384
() => () => (next: any) => (action: any) => next(action),
8485
),

extension/src/popup/components/ErrorTracking/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ export const ErrorTracking = () => {
5656
}
5757

5858
if (!isDataSharingAllowed) {
59-
/*
60-
Note: Sentry.close does not completely disable calls to Sentry. Sentry will still report, but with a completely anonymized payload.
59+
/*
60+
Note: Sentry.close does not completely disable calls to Sentry. Sentry will still report, but with a completely anonymized payload.
6161
When you refresh/reopen the app after disabling tracking, it will not initialize Sentry, thus disabling *all* calls to Sentry
6262
*/
6363

64+
// Clear the per-install user id before closing. Sentry.close may still
65+
// report (anonymized) until the next refresh; without this, those reports
66+
// would keep the user id attached and defeat the anonymization.
67+
Sentry.setUser(null);
6468
Sentry.close(500);
6569
}
6670

0 commit comments

Comments
 (0)