@@ -32,7 +32,7 @@ const HOOKS: { [key in Operation]: Hook[] } = {
32
32
} ;
33
33
34
34
/** Finish top-level component span and activity with a debounce configured using `timeout` option */
35
- function finishRootComponentSpan ( vm : VueSentry , timestamp : number , timeout : number ) : void {
35
+ function maybeEndRootComponentSpan ( vm : VueSentry , timestamp : number , timeout : number ) : void {
36
36
if ( vm . $_sentryRootComponentSpanTimer ) {
37
37
clearTimeout ( vm . $_sentryRootComponentSpanTimer ) ;
38
38
}
@@ -66,6 +66,8 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
66
66
67
67
const mixins : Mixins = { } ;
68
68
69
+ const rootComponentSpanFinalTimeout = options . timeout || 2000 ;
70
+
69
71
for ( const operation of hooks ) {
70
72
// Retrieve corresponding hooks from Vue lifecycle.
71
73
// eg. mount => ['beforeMount', 'mounted']
@@ -91,6 +93,9 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
91
93
} ,
92
94
onlyIfParent : true ,
93
95
} ) ;
96
+
97
+ // call debounced end function once directly, just in case no child components call it
98
+ maybeEndRootComponentSpan ( this , timestampInSeconds ( ) , rootComponentSpanFinalTimeout ) ;
94
99
}
95
100
96
101
// 2. Component tracking filter
@@ -102,7 +107,10 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
102
107
? findTrackComponent ( options . trackComponents , componentName )
103
108
: options . trackComponents ) ;
104
109
110
+ // We always want to track root component
105
111
if ( ! shouldTrack ) {
112
+ // even if we don't track `this` component, we still want to end the root span eventually
113
+ maybeEndRootComponentSpan ( this , timestampInSeconds ( ) , rootComponentSpanFinalTimeout ) ;
106
114
return ;
107
115
}
108
116
@@ -143,7 +151,7 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
143
151
span . end ( ) ;
144
152
145
153
// For any "after" hook, also schedule the root component span to finish
146
- finishRootComponentSpan ( this , timestampInSeconds ( ) , options . timeout || 2000 ) ;
154
+ maybeEndRootComponentSpan ( this , timestampInSeconds ( ) , options . timeout || 2000 ) ;
147
155
}
148
156
} ;
149
157
}
0 commit comments