@@ -133,10 +133,15 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
133133 const [ input , init ] = args ;
134134 const { url : rawUrl , method } = parseFetchArgs ( args ) ;
135135 const urlObject = new URL ( rawUrl ) ;
136- const sanitizedUrl = getSanitizedUrlString ( urlObject ) ;
136+ const requestData : SanitizedRequestData = {
137+ url : getSanitizedUrlString ( urlObject ) ,
138+ method,
139+ 'http.query' : urlObject . search ,
140+ 'http.fragment' : urlObject . hash ,
141+ } ;
137142
138143 // TODO: extract this to a util function (and use it in breadcrumbs integration as well)
139- if ( rawUrl . match ( / s e n t r y _ k e y / ) && method === 'POST' ) {
144+ if ( rawUrl . match ( / s e n t r y _ k e y / ) ) {
140145 // We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
141146 return wrappingTarget . apply ( thisArg , args ) ;
142147 }
@@ -168,19 +173,12 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
168173
169174 let fetchPromise : Promise < Response > ;
170175
171- const spanData : SanitizedRequestData = {
172- url : sanitizedUrl ,
173- method,
174- 'http.query' : urlObject . search ,
175- 'http.fragment' : urlObject . hash ,
176- } ;
177-
178176 if ( createSpan ) {
179177 fetchPromise = trace (
180178 {
181- name : `${ method } ${ sanitizedUrl } ` , // this will become the description of the span
179+ name : `${ requestData . method } ${ requestData . url } ` , // this will become the description of the span
182180 op : 'http.client' ,
183- data : spanData ,
181+ data : requestData ,
184182 parentSpanId : activeSpan && activeSpan . spanId ,
185183 } ,
186184 async span => {
@@ -196,7 +194,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
196194 }
197195
198196 if ( shouldAddFetchBreadcrumbs ) {
199- addFetchBreadcrumb ( fetchPromise , spanData , args ) ;
197+ addFetchBreadcrumb ( fetchPromise , requestData , args ) ;
200198 }
201199
202200 return fetchPromise ;
@@ -207,7 +205,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
207205/* Adds a breadcrumb for the given fetch result */
208206function addFetchBreadcrumb (
209207 fetchResult : Promise < Response > ,
210- spanData : SanitizedRequestData ,
208+ requestData : SanitizedRequestData ,
211209 args : Parameters < SvelteKitFetch > ,
212210) : void {
213211 const breadcrumbStartTimestamp = Date . now ( ) ;
@@ -218,7 +216,7 @@ function addFetchBreadcrumb(
218216 type : 'http' ,
219217 category : 'fetch' ,
220218 data : {
221- ...spanData ,
219+ ...requestData ,
222220 status_code : response . status ,
223221 } ,
224222 } ,
@@ -236,7 +234,7 @@ function addFetchBreadcrumb(
236234 type : 'http' ,
237235 category : 'fetch' ,
238236 level : 'error' ,
239- data : spanData ,
237+ data : requestData ,
240238 } ,
241239 {
242240 input : args ,
0 commit comments