Skip to content

Commit 4085036

Browse files
committed
Guard against window not being available
1 parent 72040c1 commit 4085036

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/vue/src/tanstackrouter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ export function tanstackRouterBrowserTracingIntegration<R extends AnyRouter>(
9292

9393
const navigationLocation = WINDOW.location;
9494
const navigationSpan = startBrowserTracingNavigationSpan(client, {
95-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
96-
name: onBeforeNavigateLastMatch ? onBeforeNavigateLastMatch.routeId : navigationLocation.pathname,
95+
name: onBeforeNavigateLastMatch
96+
? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
97+
onBeforeNavigateLastMatch.routeId
98+
: // In SSR/non-browser contexts, WINDOW.location may be undefined, so fall back to the router's location
99+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
100+
navigationLocation?.pathname || onBeforeNavigateArgs.toLocation.pathname,
97101
attributes: {
98102
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
99103
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.vue.tanstack_router',

0 commit comments

Comments
 (0)