Skip to content

Commit

Permalink
#5736 Group similar error reports (#5750)
Browse files Browse the repository at this point in the history
* feat: group similar error reports

* fix: remove unnecessary line

* fix: simplify code

* fix: pr reviews
  • Loading branch information
ioanmo226 committed Jun 3, 2024
1 parent 3b16204 commit a4a157f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions extension/js/common/platform/catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ export class Catch {
}
}

private static groupSimilarReports(value: string): string {
return value
.replace(/chrome-extension:\/\/[^\/]+\//, 'chrome-extension://EXTENSION_ID/')
.replace(/https:\/\/www\.googleapis\.com\/gmail\/v1\/users\/me\/threads\/[^\/]+/, 'https://www.googleapis.com/gmail/v1/users/me/threads/THREAD_ID')
.replace(/https:\/\/www\.googleapis\.com\/gmail\/v1\/users\/me\/messages\/[^\/]+/, 'https://www.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID')
.replace(/https:\/\/www\.googleapis\.com\/gmail\/v1\/users\/me\/drafts\/[^\/]+/, 'https://www.googleapis.com/gmail/v1/users/me/drafts/DRAFT_ID');
}

private static formatExceptionForReport(thrown: unknown, line?: number, col?: number): ErrorReport {
if (!line || !col) {
const { line: parsedLine, col: parsedCol } = Catch.getErrorLineAndCol(thrown);
Expand All @@ -298,11 +306,11 @@ export class Catch {
const exception = Catch.formExceptionFromThrown(thrown);
return {
name: exception.name.substring(0, 50),
message: exception.message.substring(0, 200),
url: location.href.split('?')[0],
message: Catch.groupSimilarReports(exception.message.substring(0, 200)),
url: Catch.groupSimilarReports(location.href.split('?')[0]),
line: line || 1,
col: col || 1,
trace: exception.stack || '',
trace: Catch.groupSimilarReports(exception.stack || ''),
version: VERSION,
environment: Catch.RUNTIME_ENVIRONMENT,
product: 'web-ext',
Expand Down

0 comments on commit a4a157f

Please sign in to comment.