@@ -40,7 +40,6 @@ describe('browserTracingIntegration', () => {
40
40
...txnCtx ,
41
41
updateName : vi . fn ( ) ,
42
42
setAttribute : vi . fn ( ) ,
43
- setTag : vi . fn ( ) ,
44
43
} ;
45
44
return createdRootSpan ;
46
45
} ) ;
@@ -52,7 +51,6 @@ describe('browserTracingIntegration', () => {
52
51
...txnCtx ,
53
52
updateName : vi . fn ( ) ,
54
53
setAttribute : vi . fn ( ) ,
55
- setTag : vi . fn ( ) ,
56
54
} ;
57
55
return createdRootSpan ;
58
56
} ) ;
@@ -138,6 +136,29 @@ describe('browserTracingIntegration', () => {
138
136
expect ( startBrowserTracingPageLoadSpanSpy ) . toHaveBeenCalledTimes ( 0 ) ;
139
137
} ) ;
140
138
139
+ it ( "updates the current scope's transactionName once it's resolved during pageload" , ( ) => {
140
+ const scopeSetTransactionNameSpy = vi . fn ( ) ;
141
+
142
+ // @ts -expect-error - only returning a partial scope here, that's fine
143
+ vi . spyOn ( SentrySvelte , 'getCurrentScope' ) . mockImplementation ( ( ) => {
144
+ return {
145
+ setTransactionName : scopeSetTransactionNameSpy ,
146
+ } ;
147
+ } ) ;
148
+
149
+ const integration = browserTracingIntegration ( ) ;
150
+ // @ts -expect-error - the fakeClient doesn't satisfy Client but that's fine
151
+ integration . afterAllSetup ( fakeClient ) ;
152
+
153
+ // We emit an update to the `page` store to simulate the SvelteKit router lifecycle
154
+ // @ts -expect-error - page is a writable but the types say it's just readable
155
+ page . set ( { route : { id : 'testRoute/:id' } } ) ;
156
+
157
+ // This should update the transaction name with the parameterized route:
158
+ expect ( scopeSetTransactionNameSpy ) . toHaveBeenCalledTimes ( 3 ) ;
159
+ expect ( scopeSetTransactionNameSpy ) . toHaveBeenLastCalledWith ( 'testRoute/:id' ) ;
160
+ } ) ;
161
+
141
162
it ( "doesn't start a navigation span when `instrumentNavigation` is false" , ( ) => {
142
163
const integration = browserTracingIntegration ( {
143
164
instrumentNavigation : false ,
@@ -185,7 +206,6 @@ describe('browserTracingIntegration', () => {
185
206
} ,
186
207
} ) ;
187
208
188
- // eslint-disable-next-line deprecation/deprecation
189
209
expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith ( {
190
210
op : 'ui.sveltekit.routing' ,
191
211
name : 'SvelteKit Route Change' ,
@@ -248,7 +268,6 @@ describe('browserTracingIntegration', () => {
248
268
} ,
249
269
} ) ;
250
270
251
- // eslint-disable-next-line deprecation/deprecation
252
271
expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith ( {
253
272
op : 'ui.sveltekit.routing' ,
254
273
name : 'SvelteKit Route Change' ,
0 commit comments