@@ -12,11 +12,11 @@ type Mixins = Parameters<Vue['mixin']>[0];
12
12
13
13
interface VueSentry extends ViewModel {
14
14
readonly $root : VueSentry ;
15
- $_sentrySpans ?: {
15
+ $_sentryComponentSpans ?: {
16
16
[ key : string ] : Span | undefined ;
17
17
} ;
18
- $_sentryRootSpan ?: Span ;
19
- $_sentryRootSpanTimer ?: ReturnType < typeof setTimeout > ;
18
+ $_sentryRootComponentSpan ?: Span ;
19
+ $_sentryRootComponentSpanTimer ?: ReturnType < typeof setTimeout > ;
20
20
}
21
21
22
22
// Mappings from operation to corresponding lifecycle hook.
@@ -31,16 +31,16 @@ const HOOKS: { [key in Operation]: Hook[] } = {
31
31
update : [ 'beforeUpdate' , 'updated' ] ,
32
32
} ;
33
33
34
- /** Finish top-level span and activity with a debounce configured using `timeout` option */
35
- function finishRootSpan ( vm : VueSentry , timestamp : number , timeout : number ) : void {
36
- if ( vm . $_sentryRootSpanTimer ) {
37
- clearTimeout ( vm . $_sentryRootSpanTimer ) ;
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 {
36
+ if ( vm . $_sentryRootComponentSpanTimer ) {
37
+ clearTimeout ( vm . $_sentryRootComponentSpanTimer ) ;
38
38
}
39
39
40
- vm . $_sentryRootSpanTimer = setTimeout ( ( ) => {
41
- if ( vm . $root ?. $_sentryRootSpan ) {
42
- vm . $root . $_sentryRootSpan . end ( timestamp ) ;
43
- vm . $root . $_sentryRootSpan = undefined ;
40
+ vm . $_sentryRootComponentSpanTimer = setTimeout ( ( ) => {
41
+ if ( vm . $root ?. $_sentryRootComponentSpan ) {
42
+ vm . $root . $_sentryRootComponentSpan . end ( timestamp ) ;
43
+ vm . $root . $_sentryRootComponentSpan = undefined ;
44
44
}
45
45
} , timeout ) ;
46
46
}
@@ -77,12 +77,12 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
77
77
78
78
for ( const internalHook of internalHooks ) {
79
79
mixins [ internalHook ] = function ( this : VueSentry ) {
80
- const isRoot = this . $root === this ;
80
+ const isRootComponent = this . $root === this ;
81
81
82
- // 1. Root span creation
83
- if ( isRoot ) {
84
- this . $_sentryRootSpan =
85
- this . $_sentryRootSpan ||
82
+ // 1. Root Component span creation
83
+ if ( isRootComponent ) {
84
+ this . $_sentryRootComponentSpan =
85
+ this . $_sentryRootComponentSpan ||
86
86
startInactiveSpan ( {
87
87
name : 'Application Render' ,
88
88
op : `${ VUE_OP } .render` ,
@@ -97,7 +97,7 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
97
97
const componentName = formatComponentName ( this , false ) ;
98
98
99
99
const shouldTrack =
100
- isRoot || // We always want to track the root component
100
+ isRootComponent || // We always want to track the root component
101
101
( Array . isArray ( options . trackComponents )
102
102
? findTrackComponent ( options . trackComponents , componentName )
103
103
: options . trackComponents ) ;
@@ -106,11 +106,11 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
106
106
return ;
107
107
}
108
108
109
- this . $_sentrySpans = this . $_sentrySpans || { } ;
109
+ this . $_sentryComponentSpans = this . $_sentryComponentSpans || { } ;
110
110
111
111
// 3. Span lifecycle management based on the hook type
112
112
const isBeforeHook = internalHook === internalHooks [ 0 ] ;
113
- const activeSpan = this . $root ?. $_sentryRootSpan || getActiveSpan ( ) ;
113
+ const activeSpan = this . $root ?. $_sentryRootComponentSpan || getActiveSpan ( ) ;
114
114
115
115
if ( isBeforeHook ) {
116
116
// Starting a new span in the "before" hook
@@ -119,12 +119,12 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
119
119
// We're actually not sure if it will ever be the case that cleanup hooks were not called.
120
120
// However, we had users report that spans didn't get finished, so we finished the span before
121
121
// starting a new one, just to be sure.
122
- const oldSpan = this . $_sentrySpans [ operation ] ;
122
+ const oldSpan = this . $_sentryComponentSpans [ operation ] ;
123
123
if ( oldSpan ) {
124
124
oldSpan . end ( ) ;
125
125
}
126
126
127
- this . $_sentrySpans [ operation ] = startInactiveSpan ( {
127
+ this . $_sentryComponentSpans [ operation ] = startInactiveSpan ( {
128
128
name : `Vue ${ componentName } ` ,
129
129
op : `${ VUE_OP } .${ operation } ` ,
130
130
attributes : {
@@ -136,14 +136,14 @@ export const createTracingMixins = (options: Partial<TracingOptions> = {}): Mixi
136
136
}
137
137
} else {
138
138
// The span should already be added via the first handler call (in the 'before' hook)
139
- const span = this . $_sentrySpans [ operation ] ;
139
+ const span = this . $_sentryComponentSpans [ operation ] ;
140
140
// The before hook did not start the tracking span, so the span was not added.
141
141
// This is probably because it happened before there is an active transaction
142
142
if ( ! span ) return ; // Skip if no span was created in the "before" hook
143
143
span . end ( ) ;
144
144
145
- // For any "after" hook, also schedule the root span to finish
146
- finishRootSpan ( this , timestampInSeconds ( ) , options . timeout || 2000 ) ;
145
+ // For any "after" hook, also schedule the root component span to finish
146
+ finishRootComponentSpan ( this , timestampInSeconds ( ) , options . timeout || 2000 ) ;
147
147
}
148
148
} ;
149
149
}
0 commit comments