Skip to content

Commit 72a61c4

Browse files
committed
finding this took about 10 years of my life
1 parent a039505 commit 72a61c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/nextjs/src/client/routing/appRouterRoutingInstrumentation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ const GLOBAL_OBJ_WITH_NEXT_ROUTER = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
8787
/** Instruments the Next.js app router for navigation. */
8888
export function appRouterInstrumentNavigation(client: Client): void {
8989
routerTransitionHandler = (href, navigationType) => {
90-
const parameterizedPathname = maybeParameterizeRoute(href);
91-
const pathname = parameterizedPathname ?? new URL(href, WINDOW.location.href).pathname;
90+
const unparameterizedPathname = new URL(href, WINDOW.location.href).pathname;
91+
const parameterizedPathname = maybeParameterizeRoute(unparameterizedPathname);
92+
const pathname = parameterizedPathname ?? unparameterizedPathname;
9293

9394
if (navigationRoutingMode === 'router-patch') {
9495
navigationRoutingMode = 'transition-start-hook';
@@ -99,6 +100,7 @@ export function appRouterInstrumentNavigation(client: Client): void {
99100
currentNavigationSpan.updateName(pathname);
100101
currentNavigationSpan.setAttributes({
101102
'navigation.type': `router.${navigationType}`,
103+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: parameterizedPathname ? 'route' : 'url',
102104
});
103105
currentRouterPatchingNavigationSpanRef.current = undefined;
104106
} else {

0 commit comments

Comments
 (0)