Skip to content

Commit 2232458

Browse files
committed
add browser-specific source updates after calling updateName
1 parent 0f12ced commit 2232458

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function appRouterInstrumentNavigation(client: Client): void {
6161
WINDOW.addEventListener('popstate', () => {
6262
if (currentNavigationSpan && currentNavigationSpan.isRecording()) {
6363
currentNavigationSpan.updateName(WINDOW.location.pathname);
64+
currentNavigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'url');
6465
} else {
6566
currentNavigationSpan = startBrowserTracingNavigationSpan(client, {
6667
name: WINDOW.location.pathname,
@@ -105,9 +106,11 @@ export function appRouterInstrumentNavigation(client: Client): void {
105106

106107
if (routerFunctionName === 'push') {
107108
span?.updateName(transactionNameifyRouterArgument(argArray[0]));
109+
span?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'url');
108110
span?.setAttribute('navigation.type', 'router.push');
109111
} else if (routerFunctionName === 'replace') {
110112
span?.updateName(transactionNameifyRouterArgument(argArray[0]));
113+
span?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'url');
111114
span?.setAttribute('navigation.type', 'router.replace');
112115
} else if (routerFunctionName === 'back') {
113116
span?.setAttribute('navigation.type', 'router.back');

packages/solid/src/solidrouter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ function withSentryRouterRoot(Root: Component<RouteSectionProps>): Component<Rou
8282
const rootSpan = getActiveRootSpan();
8383

8484
if (rootSpan) {
85-
const { op, description } = spanToJSON(rootSpan);
85+
const { op, description, data } = spanToJSON(rootSpan);
8686

8787
// We only need to update navigation spans that have been created by
8888
// a browser back-button navigation (stored as `-1` by solid router)
8989
// everything else was already instrumented correctly in `useBeforeLeave`
9090
if (op === 'navigation' && description === '-1') {
9191
rootSpan.updateName(name);
92+
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, data && data[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]);
9293
}
9394
}
9495
});

0 commit comments

Comments
 (0)