feat(vue): Register Vue route provider - #23793
Conversation
size-limit report 📦
|
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you apply the label |
a1394dd to
ece4da5
Compare
ece4da5 to
a309ce7
Compare
a309ce7 to
3dbcc53
Compare
3dbcc53 to
227053e
Compare
22d7992 to
e741e61
Compare
|
bugbot run |
e741e61 to
b344925
Compare
| defaultIntegrations: [...getDefaultIntegrations(options), vueIntegration()], | ||
| // The router is read off the app on each call, so `app.use(router)` can run either side of `init`, and | ||
| // users who never pass `router` to the tracing integration still get parameterized routes. | ||
| ...(options.app && { routeProvider: createVueRouteProvider(() => getRouterFromApp(options.app)) }), |
There was a problem hiding this comment.
In Vue 2, this would be options.App (make sure to also test Vue 2 E2E)
There was a problem hiding this comment.
do we have a Vue 2 E2E? should I add one?
b344925 to
fa6bf94
Compare
|
👋 @chargome, @nicohrubec — Please review this PR when you get a chance! |
fa6bf94 to
57914a9
Compare
57914a9 to
63d9a6f
Compare
63d9a6f to
8a6336a
Compare
8a6336a to
3f219dc
Compare
3f219dc to
0b03209
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 89d893e. Configure here.
| // The router is looked up lazily because it may be installed after `init`. A user's `routeProvider` wins. | ||
| if (!getRouteProvider(client)) { | ||
| const { app, Vue } = options; | ||
| const getRouter = app ? () => getRouterFromApp(app) : captureRouterFromVue(Vue!); |
There was a problem hiding this comment.
Non-null assertion lacks required comment
Low Severity
A new non-null assertion on Vue has no comment explaining why a safer type is not possible. The earlier app/Vue guard makes the assertion valid, but the project rule still requires that comment on new ! uses in SDK source. Flagged because this was mentioned in the review rules file.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 89d893e. Configure here.
`vue-router` sets `app.config.globalProperties.$router` when it installs, and the SDK is already given the app, so the provider needs no new option and no router passed to the tracing integration. Registered from `init()`, so route parameterization no longer depends on tracing being enabled and works for users who never pass `router` to `browserTracingIntegration`. The router is looked up per call rather than captured, because `app.use(router)` may run either side of `Sentry.init()`. Returns the matched path rather than `route.name` even under `routeLabel: 'name'`: callers set `url.template` from this and a route name is an identifier, not a template. The navigation instrumentation still names the span after the route name when the user asked for it.
89d893e to
3b4b45e
Compare
s1gr1d
left a comment
There was a problem hiding this comment.
Looks good but I think you need to update the PR description now.


Registers a route provider for Vue so route parameterization works without tracing and without passing
routertobrowserTracingIntegration.The provider is registered in
vueIntegration'ssetup, so it picks upappwhether it's passed toinitor to the integration; arouteProviderpassed toinittakes precedence. On Vue 3 the router is read offapp.config.globalProperties.$routeron each call, sinceapp.use(router)may run either side ofSentry.init(). Vue 2 only exposes the router on instances, so abeforeCreatemixin picks it up from the rootnew Vue({ router }). Until that instance exists nothing resolves, so the Vue 2 pageload span keeps the raw URL.resolve()matches the router's own location, not the browser's, so URLs are converted first: the path comes from the hash in hash mode, and the router'sbaseis stripped otherwise (Vue Router 3 and 4).Returns the matched path rather than
route.name, even underrouteLabel: 'name'. Callers seturl.templatefrom this, and a route name is an identifier, not a template.The factory is exported as
_INTERNAL_createVueRouteProviderfor Nuxt; it isn't meant for users.Part of #23556