@@ -3,7 +3,7 @@ import type { Span } from '@sentry/types';
33import { afterUpdate , beforeUpdate , onMount } from 'svelte' ;
44import { current_component } from 'svelte/internal' ;
55
6- import { getRootSpan , startInactiveSpan , withActiveSpan } from '@sentry/core' ;
6+ import { startInactiveSpan } from '@sentry/core' ;
77import { DEFAULT_COMPONENT_NAME , UI_SVELTE_INIT , UI_SVELTE_UPDATE } from './constants' ;
88import type { TrackComponentOptions } from './types' ;
99
@@ -32,17 +32,16 @@ export function trackComponent(options?: TrackComponentOptions): void {
3232 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3333 const componentName = `<${ customComponentName || current_component . constructor . name || DEFAULT_COMPONENT_NAME } >` ;
3434
35- let initSpan : Span | undefined = undefined ;
3635 if ( mergedOptions . trackInit ) {
37- initSpan = recordInitSpan ( componentName ) ;
36+ recordInitSpan ( componentName ) ;
3837 }
3938
4039 if ( mergedOptions . trackUpdates ) {
41- recordUpdateSpans ( componentName , initSpan ) ;
40+ recordUpdateSpans ( componentName ) ;
4241 }
4342}
4443
45- function recordInitSpan ( componentName : string ) : Span | undefined {
44+ function recordInitSpan ( componentName : string ) : void {
4645 const initSpan = startInactiveSpan ( {
4746 onlyIfParent : true ,
4847 op : UI_SVELTE_INIT ,
@@ -53,35 +52,21 @@ function recordInitSpan(componentName: string): Span | undefined {
5352 onMount ( ( ) => {
5453 initSpan . end ( ) ;
5554 } ) ;
56-
57- return initSpan ;
5855}
5956
60- function recordUpdateSpans ( componentName : string , initSpan ?: Span ) : void {
57+ function recordUpdateSpans ( componentName : string ) : void {
6158 let updateSpan : Span | undefined ;
6259 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
6561 const activeSpan = getActiveSpan ( ) ;
6662 if ( ! activeSpan ) {
6763 return ;
6864 }
6965
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' } ,
8570 } ) ;
8671 } ) ;
8772
0 commit comments