From ebac4fd8c92421c8f5d900e679ca33e08b602565 Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:58:05 -0400 Subject: [PATCH 1/3] Manually leading double slashes --- static/app/bootstrap/initializeSdk.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/static/app/bootstrap/initializeSdk.tsx b/static/app/bootstrap/initializeSdk.tsx index f51a4b58835f36..27f4d4ec41f6f7 100644 --- a/static/app/bootstrap/initializeSdk.tsx +++ b/static/app/bootstrap/initializeSdk.tsx @@ -134,7 +134,13 @@ export function initializeSdk(config: Config) { if (event.transaction) { event.transaction = normalizeUrl(event.transaction, {forceCustomerDomain: true}); + + // Due to an unplesant interaction of the React Router 6 integration and our React Router 6 shims, some transaction names get prepended with a double slash. e.g., "//dashboard/:dashboardId/widget/:widgetIndex/edit/" Will hopefully be resolved in an upcoming version of the SDK. For now, manually cover this case by removing the first slash of two. + if (event.transaction.startsWith('//')) { + event.transaction = event.transaction.substring(1); + } } + return event; }, @@ -181,6 +187,12 @@ export function initializeSdk(config: Config) { addEndpointTagToRequestError(event); lastEventId = event.event_id || hint.event_id; + if (event.transaction) { + if (event.transaction.startsWith('//')) { + event.transaction = event.transaction.substring(1); + } + } + return event; }, }); From 458db762a521030a6f73dc12dc33ee5763188dcf Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Fri, 1 Nov 2024 02:04:57 -0400 Subject: [PATCH 2/3] Simplify --- static/app/bootstrap/initializeSdk.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/static/app/bootstrap/initializeSdk.tsx b/static/app/bootstrap/initializeSdk.tsx index 27f4d4ec41f6f7..7542ada9742b18 100644 --- a/static/app/bootstrap/initializeSdk.tsx +++ b/static/app/bootstrap/initializeSdk.tsx @@ -135,10 +135,7 @@ export function initializeSdk(config: Config) { if (event.transaction) { event.transaction = normalizeUrl(event.transaction, {forceCustomerDomain: true}); - // Due to an unplesant interaction of the React Router 6 integration and our React Router 6 shims, some transaction names get prepended with a double slash. e.g., "//dashboard/:dashboardId/widget/:widgetIndex/edit/" Will hopefully be resolved in an upcoming version of the SDK. For now, manually cover this case by removing the first slash of two. - if (event.transaction.startsWith('//')) { - event.transaction = event.transaction.substring(1); - } + event.transaction = stripDoubleLeadingSlash(event.transaction); } return event; @@ -188,9 +185,7 @@ export function initializeSdk(config: Config) { lastEventId = event.event_id || hint.event_id; if (event.transaction) { - if (event.transaction.startsWith('//')) { - event.transaction = event.transaction.substring(1); - } + event.transaction = stripDoubleLeadingSlash(event.transaction); } return event; @@ -341,3 +336,12 @@ export function addEndpointTagToRequestError(event: Event): void { event.tags = {...event.tags, endpoint: messageMatch[1]}; } } + +/** Due to an unplesant interaction of the React Router 6 integration and our React Router 6 shims, some transaction names get prepended with a double slash. e.g., "//dashboard/:dashboardId/widget/:widgetIndex/edit/" Will hopefully be resolved in an upcoming version of the SDK. For now, manually cover this case by removing the first slash of two. */ +function stripDoubleLeadingSlash(transactionName: string) { + if (transactionName.startsWith('//')) { + return transactionName.substring(1); + } + + return transactionName; +} From 16f6e8ad384273e92c7da35639c3e91b78e7dc56 Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Fri, 27 Dec 2024 12:05:25 -0500 Subject: [PATCH 3/3] Update comment --- static/app/bootstrap/initializeSdk.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/bootstrap/initializeSdk.tsx b/static/app/bootstrap/initializeSdk.tsx index 7542ada9742b18..478b751b34c353 100644 --- a/static/app/bootstrap/initializeSdk.tsx +++ b/static/app/bootstrap/initializeSdk.tsx @@ -337,7 +337,7 @@ export function addEndpointTagToRequestError(event: Event): void { } } -/** Due to an unplesant interaction of the React Router 6 integration and our React Router 6 shims, some transaction names get prepended with a double slash. e.g., "//dashboard/:dashboardId/widget/:widgetIndex/edit/" Will hopefully be resolved in an upcoming version of the SDK. For now, manually cover this case by removing the first slash of two. */ +/** Due to an unplesant interaction of the React Router 6 integration and our React Router 6 shims, some transaction names get prepended with a double slash. e.g., "//dashboard/:dashboardId/widget/:widgetIndex/edit/" Will hopefully be resolved in an upcoming version of the SDK, or improved when we remove the routing shims. For now, manually cover this case by removing the first slash of two. */ function stripDoubleLeadingSlash(transactionName: string) { if (transactionName.startsWith('//')) { return transactionName.substring(1);