Skip to content

Commit a4a157f

Browse files
author
Ioan Moldovan
committed
#5736 Group similar error reports (#5750)
* feat: group similar error reports * fix: remove unnecessary line * fix: simplify code * fix: pr reviews
1 parent 3b16204 commit a4a157f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

extension/js/common/platform/catch.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ export class Catch {
281281
}
282282
}
283283

284+
private static groupSimilarReports(value: string): string {
285+
return value
286+
.replace(/chrome-extension:\/\/[^\/]+\//, 'chrome-extension://EXTENSION_ID/')
287+
.replace(/https:\/\/www\.googleapis\.com\/gmail\/v1\/users\/me\/threads\/[^\/]+/, 'https://www.googleapis.com/gmail/v1/users/me/threads/THREAD_ID')
288+
.replace(/https:\/\/www\.googleapis\.com\/gmail\/v1\/users\/me\/messages\/[^\/]+/, 'https://www.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID')
289+
.replace(/https:\/\/www\.googleapis\.com\/gmail\/v1\/users\/me\/drafts\/[^\/]+/, 'https://www.googleapis.com/gmail/v1/users/me/drafts/DRAFT_ID');
290+
}
291+
284292
private static formatExceptionForReport(thrown: unknown, line?: number, col?: number): ErrorReport {
285293
if (!line || !col) {
286294
const { line: parsedLine, col: parsedCol } = Catch.getErrorLineAndCol(thrown);
@@ -298,11 +306,11 @@ export class Catch {
298306
const exception = Catch.formExceptionFromThrown(thrown);
299307
return {
300308
name: exception.name.substring(0, 50),
301-
message: exception.message.substring(0, 200),
302-
url: location.href.split('?')[0],
309+
message: Catch.groupSimilarReports(exception.message.substring(0, 200)),
310+
url: Catch.groupSimilarReports(location.href.split('?')[0]),
303311
line: line || 1,
304312
col: col || 1,
305-
trace: exception.stack || '',
313+
trace: Catch.groupSimilarReports(exception.stack || ''),
306314
version: VERSION,
307315
environment: Catch.RUNTIME_ENVIRONMENT,
308316
product: 'web-ext',

0 commit comments

Comments
 (0)