From f7abbec35552ae479a41a0c64a1e58072b75730c Mon Sep 17 00:00:00 2001 From: Ioan Moldovan Date: Mon, 8 Dec 2025 04:55:10 -0500 Subject: [PATCH 1/2] fix: strip gmail url from report --- extension/js/common/platform/catch.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extension/js/common/platform/catch.ts b/extension/js/common/platform/catch.ts index 79496a4f775..6be92e02a8d 100644 --- a/extension/js/common/platform/catch.ts +++ b/extension/js/common/platform/catch.ts @@ -262,12 +262,14 @@ export class Catch { } } const exception = Catch.formExceptionFromThrown(thrown); + const reportUrl = location.href.split('?')[0]; return { name: exception.name.substring(0, 50), message: Catch.groupSimilarReports(exception.message.substring(0, 200)), - // Use https://mail.google.com/mail as URL for content script errors + // Strip Gmail URLs to group similar errors from different threads/messages // https://github.com/FlowCrypt/flowcrypt-browser/issues/6031 - url: Catch.RUNTIME_ENVIRONMENT === 'ex:s:gmail' ? 'https://mail.google.com/mail' : Catch.groupSimilarReports(location.href.split('?')[0]), + // https://github.com/FlowCrypt/flowcrypt-browser/issues/6128 + url: Catch.RUNTIME_ENVIRONMENT.endsWith(':ex:s:gmail') ? 'https://mail.google.com/mail/' : Catch.groupSimilarReports(reportUrl), line: line || 1, col: col || 1, trace: Catch.groupSimilarReports(exception.stack || ''), From 3f23561083be57e8e8d46f5c4e37be151931f854 Mon Sep 17 00:00:00 2001 From: Ioan Moldovan Date: Fri, 12 Dec 2025 08:11:10 -0500 Subject: [PATCH 2/2] feat: added test --- extension/js/common/platform/catch.ts | 2 +- .../tests/browser-unit-tests/unit-Catch.js | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/extension/js/common/platform/catch.ts b/extension/js/common/platform/catch.ts index 6be92e02a8d..77ed6dffba9 100644 --- a/extension/js/common/platform/catch.ts +++ b/extension/js/common/platform/catch.ts @@ -174,7 +174,7 @@ export class Catch { public static environment(url = location.href): string { const browserName = Catch.browser().name; - const origin = new URL(location.href).origin; + const origin = new URL(url).origin; let env = 'unknown'; if (url.includes('bnjglocicd')) { env = 'ex:prod'; diff --git a/test/source/tests/browser-unit-tests/unit-Catch.js b/test/source/tests/browser-unit-tests/unit-Catch.js index 888a8d187cb..b3223022f98 100644 --- a/test/source/tests/browser-unit-tests/unit-Catch.js +++ b/test/source/tests/browser-unit-tests/unit-Catch.js @@ -70,3 +70,34 @@ BROWSER_UNIT_TEST_NAME(`Catcher does not include query string on report`); } return 'pass'; })(); + +BROWSER_UNIT_TEST_NAME(`Catcher reports correct URL for Gmail environment`); +(async () => { + const originalEnv = Catch.RUNTIME_ENVIRONMENT; + + // https://github.com/FlowCrypt/flowcrypt-browser/issues/6128 + const sensitivePaths = [ + '/mail/u/0/#inbox/WhctKLbvMNLndrHSj', + '/mail/u/0/#sent/KtbxLzFrMS', + '/mail/u/1/#inbox/rtjXfHsNNgrJVZL', + '/mail/u/1/#search/MSCGwzQrb', + ]; + + try { + for (const path of sensitivePaths) { + const fullUrl = 'https://mail.google.com' + path; + + // Simulate environment detection based on the URL + const env = Catch.environment(fullUrl); + Catch.RUNTIME_ENVIRONMENT = env; + + const formatted = Catch.formatExceptionForReport({ name: 'Error' }); + if (formatted.url !== 'https://mail.google.com/mail/') { + throw new Error(`For path ${path}, expected URL to be 'https://mail.google.com/mail/' but got '${formatted.url}' (env: ${env})`); + } + } + } finally { + Catch.RUNTIME_ENVIRONMENT = originalEnv; + } + return 'pass'; +})(); \ No newline at end of file