@@ -4,7 +4,7 @@ import { DEFAULT_HOOKS, DEFAULT_ROOT_SPAN_TIMEOUT } from './constants';
44import { DEBUG_BUILD } from './debug-build' ;
55import { attachErrorHandler } from './errorhandler' ;
66import { instrumentAppMountWithoutMixin } from './rootInstrumentation' ;
7- import { createVueRouteProvider , getRouterFromApp } from './routeProvider' ;
7+ import { captureRouterFromVue , createVueRouteProvider , getRouterFromApp } from './routeProvider' ;
88import { createTracingMixins } from './tracing' ;
99import type { Options , TracingOptions , Vue , VueOptions } from './types' ;
1010
@@ -40,16 +40,14 @@ export const vueIntegration = defineIntegration((integrationOptions: Partial<Vue
4040 return ;
4141 }
4242
43- if ( options . app ) {
44- const { app } = options ;
45- // Read per call because `app.use(router)` may run after `init`. A user's `routeProvider` wins.
46- if ( ! getRouteProvider ( client ) ) {
47- setRouteProvider (
48- createVueRouteProvider ( ( ) => getRouterFromApp ( app ) ) ,
49- client ,
50- ) ;
51- }
43+ // The router is looked up lazily because it may be installed after `init`. A user's `routeProvider` wins.
44+ if ( ! getRouteProvider ( client ) ) {
45+ const { app, Vue } = options ;
46+ const getRouter = app ? ( ) => getRouterFromApp ( app ) : captureRouterFromVue ( Vue ! ) ;
47+ setRouteProvider ( createVueRouteProvider ( getRouter ) , client ) ;
48+ }
5249
50+ if ( options . app ) {
5351 const apps = Array . isArray ( options . app ) ? options . app : [ options . app ] ;
5452 apps . forEach ( app => vueInit ( app , options ) ) ;
5553 } else if ( options . Vue ) {
0 commit comments