From 9142f936e82b26b5933f36e978656f38c2d8d0ff Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Thu, 21 Nov 2024 07:46:13 -0500 Subject: [PATCH 1/3] Set up `shouldCreateSpanForRequest` option for sentry `browserTracingIntegration` and filter spans for requests to 'sentry.io' --- app/scripts/lib/setupSentry.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index e268d25b2810..b2286777c32f 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -86,7 +86,12 @@ function getClientOptions() { integrations: [ Sentry.dedupeIntegration(), Sentry.extraErrorDataIntegration(), - Sentry.browserTracingIntegration(), + Sentry.browserTracingIntegration({ + shouldCreateSpanForRequest: (url) => { + // Do not create spans for outgoing requests to a 'sentry.io' domain. + return !url.match(/sentry\.io\/?$/u); + }, + }), filterEvents({ getMetaMetricsEnabled, log }), ], release: RELEASE, From cfdcfcc6fc3ec9f4dd4865a4e19e7f3e8d705c85 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Fri, 22 Nov 2024 09:35:56 -0500 Subject: [PATCH 2/3] Fix regex for Sentry urls and add checks to ensure that correct domain is matched --- app/scripts/lib/setupSentry.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index b2286777c32f..1a8d9cf64b78 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -89,7 +89,9 @@ function getClientOptions() { Sentry.browserTracingIntegration({ shouldCreateSpanForRequest: (url) => { // Do not create spans for outgoing requests to a 'sentry.io' domain. - return !url.match(/sentry\.io\/?$/u); + return !url.match( + /^https?:\/\/([\w\d.@-]+\.)?sentry\.io(\/|$)/u + ); }, }), filterEvents({ getMetaMetricsEnabled, log }), From 0552f103e15d4c8639266127fe5096e5ca616fbd Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Fri, 22 Nov 2024 12:23:19 -0500 Subject: [PATCH 3/3] Linter fix --- app/scripts/lib/setupSentry.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 1a8d9cf64b78..72c246826ab5 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -89,9 +89,7 @@ function getClientOptions() { Sentry.browserTracingIntegration({ shouldCreateSpanForRequest: (url) => { // Do not create spans for outgoing requests to a 'sentry.io' domain. - return !url.match( - /^https?:\/\/([\w\d.@-]+\.)?sentry\.io(\/|$)/u - ); + return !url.match(/^https?:\/\/([\w\d.@-]+\.)?sentry\.io(\/|$)/u); }, }), filterEvents({ getMetaMetricsEnabled, log }),