Skip to content

feat(react-router): Set navigation.route.id from the matched route id#22373

Draft
msonnb wants to merge 1 commit into
developfrom
ms/react-router-navigation-route-id
Draft

feat(react-router): Set navigation.route.id from the matched route id#22373
msonnb wants to merge 1 commit into
developfrom
ms/react-router-navigation-route-id

Conversation

@msonnb

@msonnb msonnb commented Jul 17, 2026

Copy link
Copy Markdown
Member

Sets the navigation.route.id attribute on pageload and navigation spans, sourced from the leaf matched route's id. This is the framework-assigned, file-based route identifier (e.g. routes/blog.$slug).

ref #22069

Sets the navigation.route.id attribute (from @sentry/conventions) on
pageload and navigation spans, sourced from the leaf matched route's id
(route.id). This is the framework-assigned, file-based route identifier
(e.g. routes/blog.$slug), which is distinct from the parameterized path
used for url.template, and which Relay prefers for span description
inference.

The id is set at every url.template set-site across both instrumentation
modes: the data-router patching path (hydratedRouter + numeric-navigation
finalize in utils) and the native instrumentation API path
(createClientInstrumentation, threaded through updateRootSpanRoute). A
getRouteId helper centralizes reading the id from RouterState. The
attribute is omitted when no id is present.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@msonnb

msonnb commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f597246. Configure here.

[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
[URL_TEMPLATE]: routeName,
...(routeId && { [NAVIGATION_ROUTE_ID]: routeId }),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-leaf route id can stick

Medium Severity

In the instrumentation-API path, navigation.route.id is taken from whichever route's loader/action hook runs, not from the leaf match. Once that sets sentry.source to route, the hydrated-router subscribe path early-returns and never corrects it via getRouteId. Nested apps where only a parent has a client loader can therefore keep a parent route id on the navigation span.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f597246. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is fine since we just follow the exisitng behavior of url.template here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant