Skip to content

Commit 9ea01f9

Browse files
committed
Ensure logged-in users aren't identifiable in Sentry
1 parent d9312d2 commit 9ea01f9

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@fortawesome/free-regular-svg-icons": "^5.12.1",
4343
"@fortawesome/free-solid-svg-icons": "^5.12.1",
4444
"@fortawesome/react-fontawesome": "^0.1.8",
45-
"@httptoolkit/accounts": "^2.2.0",
45+
"@httptoolkit/accounts": "^2.3.0",
4646
"@httptoolkit/httpsnippet": "^2.1.7",
4747
"@open-rpc/meta-schema": "^1.14.2",
4848
"@phosphor-icons/react": "^2.1.5",

src/errors.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,18 @@ export function initSentry(dsn: string | undefined) {
6565
});
6666
}
6767

68-
export function logErrorsAsUser(email: string | undefined) {
68+
export function logErrorsAsUser(id: string | undefined) {
6969
if (!sentryInitialized) return;
7070

71-
Sentry.getCurrentScope().setUser({
72-
id: email,
73-
email: email
74-
});
71+
if (!id) {
72+
Sentry.getCurrentScope().setUser(null);
73+
} else {
74+
// We track errors by user id - this ensures that any actual identities are
75+
// never exposed to Sentry (you need access to our user DB to link user error
76+
// reports and the corresponding Sentry data).
77+
id = id.replace('email|', '');
78+
Sentry.getCurrentScope().setUser({ id: id });
79+
}
7580
}
7681

7782
function addErrorTag(key: string, value: string) {

src/model/account/account-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ export class AccountStore {
129129
this.user = yield getLatestUserData();
130130
this.accountDataLastUpdated = Date.now();
131131

132-
// Include the user email in error reports whilst they're logged in.
132+
// Include the user id in error reports whilst they're logged in.
133133
// Useful generally, but especially for checkout/subscription issues.
134-
logErrorsAsUser(this.user.email);
134+
logErrorsAsUser(this.user.userId);
135135

136136
if (this.user.banned) {
137137
alert('Your account has been blocked for abuse. Please contact [email protected].');

0 commit comments

Comments
 (0)