Skip to content

Commit 420e93d

Browse files
committed
Set __sentry_navigation_name_set__
1 parent d669065 commit 420e93d

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

packages/react/src/reactrouter-compat-utils/instrumentation.tsx

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,8 @@ function cancelScheduledCallback(id: number): void {
8989
}
9090

9191
/**
92-
* Computes a location key that uniquely identifies a navigation including pathname, search, and hash.
93-
*
94-
* Normalizes undefined/null search and hash to empty strings to ensure consistency between
95-
* partial location objects (from <Routes location="/path">) and full location objects
96-
* (from history state). This prevents duplicate navigation spans when using the location
97-
* prop with string values (common in modal routes and SSR).
98-
*
92+
* Computes location key for duplicate detection. Normalizes undefined/null to empty strings.
9993
* Exported for testing.
100-
*
101-
* @example
102-
* // Partial location (from <Routes location="/users">)
103-
* computeLocationKey({ pathname: '/users', search: undefined, hash: undefined })
104-
* // Returns: '/users'
105-
*
106-
* // Full location (from history)
107-
* computeLocationKey({ pathname: '/users', search: '', hash: '' })
108-
* // Returns: '/users' (same key - duplicate detection works correctly)
10994
*/
11095
export function computeLocationKey(location: Location): string {
11196
return `${location.pathname}${location.search || ''}${location.hash || ''}`;
@@ -184,11 +169,6 @@ export interface ReactRouterOptions {
184169
*
185170
* Defaults to 3× the configured `idleTimeout` (default: 3000ms).
186171
*
187-
* **Note**: This option only works with data routers (createBrowserRouter/createMemoryRouter)
188-
* that use `patchRoutesOnNavigation`. Component-based routes (<Routes>/useRoutes) that use
189-
* React.lazy() for code splitting cannot track lazy loads at the router level, so spans
190-
* will finalize immediately regardless of this setting.
191-
*
192172
* @default idleTimeout * 3
193173
*/
194174
lazyRouteTimeout?: number;
@@ -570,10 +550,6 @@ export function createReactRouterV6CompatibleTracingIntegration(
570550
setup(client) {
571551
integration.setup(client);
572552

573-
// Get idleTimeout from browserTracingIntegration options (passed through)
574-
// idleTimeout from browserTracingIntegration (default: 1000ms)
575-
// Note: options already contains idleTimeout if user passed it to browserTracingIntegration
576-
// Calculate default: 3× idleTimeout, allow explicit override
577553
const defaultMaxWait = (options.idleTimeout ?? 1000) * 3;
578554
const configuredMaxWait = lazyRouteTimeout ?? defaultMaxWait;
579555

@@ -807,6 +783,11 @@ export function handleNavigation(opts: {
807783
const oldName = trackedNav.routeName;
808784
trackedNav.span.updateName(name);
809785
trackedNav.span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source as 'route' | 'url' | 'custom');
786+
addNonEnumerableProperty(
787+
trackedNav.span as { __sentry_navigation_name_set__?: boolean },
788+
'__sentry_navigation_name_set__',
789+
true,
790+
);
810791
trackedNav.routeName = name;
811792
DEBUG_BUILD && debug.log(`[Tracing] Updated navigation span name from "${oldName}" to "${name}"`);
812793
} else {

0 commit comments

Comments
 (0)