@@ -11,9 +11,18 @@ describe('svelteKitSpansIntegration', () => {
1111 expect ( typeof integration . preprocessEvent ) . toBe ( 'function' ) ;
1212 } ) ;
1313
14- it ( 'enhances spans from SvelteKit' , ( ) => {
14+ it ( 'enhances spans from SvelteKit, if root span was emitted by SvelteKit ' , ( ) => {
1515 const event : TransactionEvent = {
1616 type : 'transaction' ,
17+ contexts : {
18+ trace : {
19+ span_id : '123' ,
20+ trace_id : 'abc' ,
21+ data : {
22+ 'sveltekit.tracing.original_name' : 'sveltekit.handle.root' ,
23+ } ,
24+ } ,
25+ } ,
1726 spans : [
1827 {
1928 description : 'sveltekit.resolve' ,
@@ -37,6 +46,39 @@ describe('svelteKitSpansIntegration', () => {
3746 expect ( event . spans ?. [ 0 ] ?. data [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] ) . toBe ( 'auto.http.sveltekit' ) ;
3847 } ) ;
3948
49+ it ( 'does not enhance spans from SvelteKit, if root span was not emitted by SvelteKit' , ( ) => {
50+ const event : TransactionEvent = {
51+ type : 'transaction' ,
52+ contexts : {
53+ trace : {
54+ span_id : '123' ,
55+ trace_id : 'abc' ,
56+ data : { } ,
57+ } ,
58+ } ,
59+ spans : [
60+ {
61+ description : 'sveltekit.resolve' ,
62+ data : {
63+ someAttribute : 'someValue' ,
64+ } ,
65+ span_id : '123' ,
66+ trace_id : 'abc' ,
67+ start_timestamp : 0 ,
68+ } ,
69+ ] ,
70+ } ;
71+
72+ // @ts -expect-error -- passing in an empty option for client but it is unused in the integration
73+ svelteKitSpansIntegration ( ) . preprocessEvent ?.( event , { } , { } ) ;
74+
75+ expect ( event . spans ) . toHaveLength ( 1 ) ;
76+ expect ( event . spans ?. [ 0 ] ?. op ) . toBeUndefined ( ) ;
77+ expect ( event . spans ?. [ 0 ] ?. origin ) . toBeUndefined ( ) ;
78+ expect ( event . spans ?. [ 0 ] ?. data [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] ) . toBeUndefined ( ) ;
79+ expect ( event . spans ?. [ 0 ] ?. data [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] ) . toBeUndefined ( ) ;
80+ } ) ;
81+
4082 describe ( '_enhanceKitSpan' , ( ) => {
4183 it . each ( [
4284 [ 'sveltekit.resolve' , 'function.sveltekit.resolve' , 'auto.http.sveltekit' ] ,
0 commit comments