Skip to content

Commit b846a77

Browse files
committed
Try to strip usernames if they appear in error reports
1 parent 6ee2172 commit b846a77

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/error-tracking.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ export function initErrorTracking() {
5656
}
5757
}
5858
return breadcrumb;
59+
},
60+
beforeSend(event, hint) {
61+
if (event.exception && event.exception.values) {
62+
event.exception.values.forEach((value) => {
63+
if (!value.value) return;
64+
value.value = value.value
65+
// Strip any usernames that end up appearing within error values.
66+
// This helps to dedupe error reports, and it's good for privacy too
67+
.replace(/\/home\/[^\/]+\//g, '/home/<username>/')
68+
.replace(/\/Users\/[^\/]+\//g, '/Users/<username>/')
69+
.replace(/(\w):\\Users\\[^\\]+\\/gi, '$1:\\Users\\<username>\\')
70+
// Dedupe temp filenames in errors (from terminal script setup)
71+
.replace(/([a-zA-Z]+)\d{12,}\.temp/g, '$1<number>.temp');
72+
});
73+
}
74+
75+
return event;
5976
}
6077
});
6178

0 commit comments

Comments
 (0)