Skip to content

Commit d3fd241

Browse files
chargomeclaude
andcommitted
ref(nextjs): Pass the client to the pageload URL filter and use conventions constants in the test
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 8ead4b1 commit d3fd241

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function appRouterInstrumentPageLoad(client: Client): void {
148148
[SENTRY_ORIGIN]: 'auto.pageload.nextjs.app_router_instrumentation',
149149
[SENTRY_SEGMENT_NAME_SOURCE]: parameterizedPathname ? 'route' : 'url',
150150
[URL_PATH]: WINDOW.location.pathname,
151-
[URL_FULL]: filterCollectedUrl(documentUrl),
151+
[URL_FULL]: filterCollectedUrl(documentUrl, client),
152152
...(parameterizedPathname && { [URL_TEMPLATE]: parameterizedPathname }),
153153
},
154154
};

‎packages/nextjs/test/client/appRouterRoutingInstrumentation.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// @vitest-environment jsdom
2+
import { SENTRY_OP, URL_FULL, URL_PATH } from '@sentry/conventions/attributes';
3+
import { PAGELOAD } from '@sentry/conventions/op';
24
import type { Client } from '@sentry/core';
35
import type * as SentryCore from '@sentry/core';
46
import type * as SentryReact from '@sentry/react';
@@ -300,11 +302,11 @@ describe('appRouterInstrumentPageLoad', () => {
300302
expect(span).not.toBe(spanBeforeSettling);
301303
const spanJson = core.spanToJSON(span!);
302304
expect(spanJson.name).toBe('/navigation');
303-
expect(spanJson.attributes?.['sentry.op']).toBe('pageload');
305+
expect(spanJson.attributes?.[SENTRY_OP]).toBe(PAGELOAD);
304306
expect(spanJson.attributes).toEqual(
305307
expect.objectContaining({
306-
'url.path': '/navigation',
307-
'url.full': 'http://localhost:3000/navigation?from=document',
308+
[URL_PATH]: '/navigation',
309+
[URL_FULL]: 'http://localhost:3000/navigation?from=document',
308310
}),
309311
);
310312
expect(core.getCurrentScope().getScopeData().sdkProcessingMetadata.normalizedRequest?.url).toBe(

0 commit comments

Comments
 (0)