Skip to content

feat(vue): Set navigation.route.id from the route name#22372

Merged
msonnb merged 1 commit into
developfrom
ms/vue-navigation-route-id
Jul 20, 2026
Merged

feat(vue): Set navigation.route.id from the route name#22372
msonnb merged 1 commit into
developfrom
ms/vue-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 Vue Router route name (to.name).

ref #22069

Sets the navigation.route.id attribute (from @sentry/conventions) on
pageload and navigation spans, sourced from the Vue Router route name
(to.name). This is the framework-assigned route identifier, which Relay
prefers over url.template for span description inference.

The attribute is set independently of the routeLabel option: routeLabel
only controls the span name/source, whereas the route id identifies the
route regardless. This is most valuable when to.name drives the span
(source 'custom'), where url.template is not set today, so
navigation.route.id becomes the only structured route identifier.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 27.75 kB - -
@sentry/browser - with treeshaking flags 26.18 kB - -
@sentry/browser (incl. Tracing) 46.56 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.37 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.36 kB - -
@sentry/browser (incl. Tracing, Replay) 85.83 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.46 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.55 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.2 kB - -
@sentry/browser (incl. Feedback) 44.93 kB - -
@sentry/browser (incl. sendFeedback) 32.55 kB - -
@sentry/browser (incl. FeedbackAsync) 37.69 kB - -
@sentry/browser (incl. Metrics) 28.83 kB - -
@sentry/browser (incl. Logs) 29.05 kB - -
@sentry/browser (incl. Metrics & Logs) 29.76 kB - -
@sentry/react 29.54 kB - -
@sentry/react (incl. Tracing) 48.84 kB - -
@sentry/vue 33.17 kB - -
@sentry/vue (incl. Tracing) 48.52 kB +0.04% +16 B 🔺
@sentry/svelte 27.78 kB - -
CDN Bundle 30.14 kB - -
CDN Bundle (incl. Tracing) 48.53 kB - -
CDN Bundle (incl. Logs, Metrics) 31.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.83 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.98 kB - -
CDN Bundle (incl. Tracing, Replay) 86.04 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.34 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.84 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.11 kB - -
CDN Bundle - uncompressed 89.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.73 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.71 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.32 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.94 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.9 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.6 kB - -
@sentry/nextjs (client) 51.36 kB - -
@sentry/sveltekit (client) 46.99 kB - -
@sentry/core/server 78.65 kB - -
@sentry/core/browser 65.08 kB - -
@sentry/node-core 63.21 kB - -
@sentry/node 125.54 kB - -
@sentry/node (incl. diagnostics channel injection) 148.49 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB - -
@sentry/node/light 51.32 kB +0.01% +1 B 🔺
@sentry/node - without tracing 74.71 kB +0.01% +2 B 🔺
@sentry/aws-serverless 83.95 kB - -
@sentry/cloudflare (withSentry) - minified 184 kB - -
@sentry/cloudflare (withSentry) 455.41 kB - -

View base workflow run

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c098258. Configure here.

@msonnb msonnb changed the title feat(vue): Set navigation.route.id from the Vue Router route name feat(vue): Set navigation.route.id from the route name Jul 17, 2026
@msonnb
msonnb marked this pull request as ready for review July 20, 2026 07:22
@msonnb
msonnb requested a review from a team as a code owner July 20, 2026 07:22
@msonnb
msonnb requested review from chargome and nicohrubec and removed request for a team July 20, 2026 07:22
Comment on lines +109 to +111
if (to.name) {
attributes[NAVIGATION_ROUTE_ID] = to.name.toString();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: When a Vue route name is a Symbol, to.name.toString() incorrectly serializes it to the format "Symbol(routeName)" for the navigation.route.id attribute.
Severity: LOW

Suggested Fix

Before setting the attribute, check if to.name is a Symbol. If it is, use its description property to get a clean identifier. For other types, continue using toString(). For example: const routeId = typeof to.name === 'symbol' ? to.name.description : to.name?.toString(); if (routeId) { attributes[NAVIGATION_ROUTE_ID] = routeId; }.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/vue/src/router.ts#L109-L111

Potential issue: The code at `packages/vue/src/router.ts` sets the `navigation.route.id`
attribute by calling `to.name.toString()`. While Vue Router's type definitions allow a
route's `name` to be a `Symbol`, calling `toString()` on a `Symbol` (e.g.,
`Symbol('about')`) produces a string like `"Symbol(about)"`. This results in a verbose
and likely unintended value for the `navigation.route.id` attribute when developers use
`Symbol`-named routes, which are a supported, albeit uncommon, feature of Vue Router.

Did we get this right? 👍 / 👎 to inform future reviews.

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but there's also tanstackrouter for vue which will likely need the same?

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thanks!

(I'm not sure about TanStack Router if it provides the same route names like Vue router. If it does, we can also add the id. If it doesn't that's fine, too :) )

@msonnb

msonnb commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

TanStack Router's routeId would just be the parametrized route, so the same as in url.template. should this also be covered by navigation.route.id @Lms24? (would then also apply to other frameworks like SvelteKit's route.id)

@msonnb
msonnb merged commit 8e20a26 into develop Jul 20, 2026
58 checks passed
@msonnb
msonnb deleted the ms/vue-navigation-route-id branch July 20, 2026 08:01
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.

3 participants