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

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

PathSize% ChangeChange
@sentry/browser27.75 kB--
@sentry/browser - with treeshaking flags26.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 flags75.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/react29.54 kB--
@sentry/react (incl. Tracing)48.84 kB--
@sentry/vue33.17 kB--
@sentry/vue (incl. Tracing)48.52 kB+0.04%+16 B 🔺
@sentry/svelte27.78 kB--
CDN Bundle30.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 - uncompressed89.88 kB--
CDN Bundle (incl. Tracing) - uncompressed146.73 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.59 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed150.71 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed219.32 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed265.94 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed269.9 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed279.64 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed283.6 kB--
@sentry/nextjs (client)51.36 kB--
@sentry/sveltekit (client)46.99 kB--
@sentry/core/server78.65 kB--
@sentry/core/browser65.08 kB--
@sentry/node-core63.21 kB--
@sentry/node125.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/light51.32 kB+0.01%+1 B 🔺
@sentry/node - without tracing74.71 kB+0.01%+2 B 🔺
@sentry/aws-serverless83.95 kB--
@sentry/cloudflare (withSentry) - minified184 kB--
@sentry/cloudflare (withSentry)455.41 kB--

View base workflow run

@msonnb

Copy link
Copy Markdown
MemberAuthor

bugbot run

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

@msonnbmsonnb changed the title feat(vue): Set navigation.route.id from the Vue Router route namefeat(vue): Set navigation.route.id from the route nameJul 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 ownerJuly 20, 2026 07:22
@msonnb
msonnb requested review from chargome and nicohrubec and removed request for a teamJuly 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.

@chargomechargome 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?

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

Copy link
Copy Markdown
MemberAuthor

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 developJul 20, 2026
58 checks passed
@msonnb
msonnb deleted the ms/vue-navigation-route-id branch July 20, 2026 08:01
Sign up for freeto 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

@msonnb@Lms24@chargome