Skip to content

Commit 0e3a747

Browse files
committed
Add manifest fallback for navigation spans
1 parent 8487544 commit 0e3a747

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,7 @@ export function handleNavigation(opts: {
827827
return;
828828
}
829829

830-
// No manifest fallback needed here (unlike updatePageloadTransaction) because React Router
831-
// only updates state.location when navigation completes (idle), so routes are already resolved.
830+
// When branches are available, use them directly. Otherwise, fall back to the manifest below.
832831
if ((navigationType === 'PUSH' || navigationType === 'POP') && branches) {
833832
const [name, source] = resolveRouteNameAndSource(
834833
location,
@@ -918,6 +917,33 @@ export function handleNavigation(opts: {
918917
// If no span was created, remove the placeholder
919918
activeNavigationSpans.delete(client);
920919
}
920+
} else if (
921+
(navigationType === 'PUSH' || navigationType === 'POP') &&
922+
_enableAsyncRouteHandlers &&
923+
_lazyRouteManifest &&
924+
_lazyRouteManifest.length > 0
925+
) {
926+
// Manifest fallback: branches not yet available, try manifest for parameterized name.
927+
const [name, source] = resolveRouteNameAndSource(
928+
location,
929+
allRoutes || routes,
930+
allRoutes || routes,
931+
[] as RouteMatch[],
932+
basename,
933+
_lazyRouteManifest,
934+
_enableAsyncRouteHandlers,
935+
);
936+
937+
if (source === 'route') {
938+
startBrowserTracingNavigationSpan(client, {
939+
name,
940+
attributes: {
941+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
942+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
943+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.reactrouter_v${version}`,
944+
},
945+
});
946+
}
921947
}
922948
}
923949

0 commit comments

Comments
 (0)