@@ -2,7 +2,7 @@ import type { BaseClient } from '@sentry/core';
22import { getCurrentHub , trace } from '@sentry/core' ;
33import type { Breadcrumbs , BrowserTracing } from '@sentry/svelte' ;
44import { captureException } from '@sentry/svelte' ;
5- import type { ClientOptions , RequestSpanData } from '@sentry/types' ;
5+ import type { ClientOptions , SanitizedRequestData } from '@sentry/types' ;
66import {
77 addExceptionMechanism ,
88 addTracingHeadersToFetchRequest ,
@@ -170,21 +170,19 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
170170
171171 let fetchPromise : Promise < Response > ;
172172
173- if ( createSpan ) {
174- const spanData : RequestSpanData = {
175- url : sanitizedUrl ,
176- method,
177- 'http.query' : urlObject . search ,
178- 'http.fragment' : urlObject . hash ,
179- } ;
173+ const spanData : SanitizedRequestData = {
174+ url : sanitizedUrl ,
175+ method,
176+ 'http.query' : urlObject . search ,
177+ 'http.fragment' : urlObject . hash ,
178+ } ;
180179
180+ if ( createSpan ) {
181181 fetchPromise = trace (
182182 {
183183 name : `${ method } ${ sanitizedUrl } ` , // this will become the description of the span
184184 op : 'http.client' ,
185- data : {
186- ...spanData ,
187- } ,
185+ data : spanData ,
188186 parentSpanId : activeSpan && activeSpan . spanId ,
189187 } ,
190188 async span => {
@@ -200,19 +198,18 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
200198 }
201199
202200 if ( shouldAddFetchBreadcrumbs ) {
203- addFetchBreadcrumbs ( fetchPromise , method , sanitizedUrl , args ) ;
201+ addFetchBreadcrumb ( fetchPromise , spanData , args ) ;
204202 }
205203
206204 return fetchPromise ;
207205 } ,
208206 } ) ;
209207}
210208
211- /* Adds breadcrumbs for the given fetch result */
212- function addFetchBreadcrumbs (
209+ /* Adds a breadcrumb for the given fetch result */
210+ function addFetchBreadcrumb (
213211 fetchResult : Promise < Response > ,
214- method : string ,
215- sanitizedUrl : string ,
212+ spanData : SanitizedRequestData ,
216213 args : Parameters < SvelteKitFetch > ,
217214) : void {
218215 const breadcrumbStartTimestamp = Date . now ( ) ;
@@ -223,8 +220,7 @@ function addFetchBreadcrumbs(
223220 type : 'http' ,
224221 category : 'fetch' ,
225222 data : {
226- method : method ,
227- url : sanitizedUrl ,
223+ ...spanData ,
228224 status_code : response . status ,
229225 } ,
230226 } ,
@@ -242,10 +238,7 @@ function addFetchBreadcrumbs(
242238 type : 'http' ,
243239 category : 'fetch' ,
244240 level : 'error' ,
245- data : {
246- method : method ,
247- url : sanitizedUrl ,
248- } ,
241+ data : spanData ,
249242 } ,
250243 {
251244 input : args ,
0 commit comments