@@ -3,7 +3,7 @@ import type { Span } from '@sentry/types';
3
3
import { afterUpdate , beforeUpdate , onMount } from 'svelte' ;
4
4
import { current_component } from 'svelte/internal' ;
5
5
6
- import { getRootSpan , startInactiveSpan , withActiveSpan } from '@sentry/core' ;
6
+ import { startInactiveSpan } from '@sentry/core' ;
7
7
import { DEFAULT_COMPONENT_NAME , UI_SVELTE_INIT , UI_SVELTE_UPDATE } from './constants' ;
8
8
import type { TrackComponentOptions } from './types' ;
9
9
@@ -32,17 +32,16 @@ export function trackComponent(options?: TrackComponentOptions): void {
32
32
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
33
33
const componentName = `<${ customComponentName || current_component . constructor . name || DEFAULT_COMPONENT_NAME } >` ;
34
34
35
- let initSpan : Span | undefined = undefined ;
36
35
if ( mergedOptions . trackInit ) {
37
- initSpan = recordInitSpan ( componentName ) ;
36
+ recordInitSpan ( componentName ) ;
38
37
}
39
38
40
39
if ( mergedOptions . trackUpdates ) {
41
- recordUpdateSpans ( componentName , initSpan ) ;
40
+ recordUpdateSpans ( componentName ) ;
42
41
}
43
42
}
44
43
45
- function recordInitSpan ( componentName : string ) : Span | undefined {
44
+ function recordInitSpan ( componentName : string ) : void {
46
45
const initSpan = startInactiveSpan ( {
47
46
onlyIfParent : true ,
48
47
op : UI_SVELTE_INIT ,
@@ -53,35 +52,21 @@ function recordInitSpan(componentName: string): Span | undefined {
53
52
onMount ( ( ) => {
54
53
initSpan . end ( ) ;
55
54
} ) ;
56
-
57
- return initSpan ;
58
55
}
59
56
60
- function recordUpdateSpans ( componentName : string , initSpan ?: Span ) : void {
57
+ function recordUpdateSpans ( componentName : string ) : void {
61
58
let updateSpan : Span | undefined ;
62
59
beforeUpdate ( ( ) => {
63
- // We need to get the active transaction again because the initial one could
64
- // already be finished or there is currently no transaction going on.
60
+ // If there is no active span, we skip
65
61
const activeSpan = getActiveSpan ( ) ;
66
62
if ( ! activeSpan ) {
67
63
return ;
68
64
}
69
65
70
- // If we are initializing the component when the update span is started, we start it as child
71
- // of the init span. Else, we start it as a child of the transaction.
72
- const parentSpan =
73
- initSpan && initSpan . isRecording ( ) && getRootSpan ( initSpan ) === getRootSpan ( activeSpan )
74
- ? initSpan
75
- : getRootSpan ( activeSpan ) ;
76
-
77
- if ( ! parentSpan ) return ;
78
-
79
- updateSpan = withActiveSpan ( parentSpan , ( ) => {
80
- return startInactiveSpan ( {
81
- op : UI_SVELTE_UPDATE ,
82
- name : componentName ,
83
- attributes : { [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.svelte' } ,
84
- } ) ;
66
+ updateSpan = startInactiveSpan ( {
67
+ op : UI_SVELTE_UPDATE ,
68
+ name : componentName ,
69
+ attributes : { [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.svelte' } ,
85
70
} ) ;
86
71
} ) ;
87
72
0 commit comments