@@ -134,11 +134,15 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
134134 const [ input , init ] = args ;
135135 const rawUrl = getFetchUrl ( args ) ;
136136 const urlObject = new URL ( rawUrl ) ;
137- const sanitizedUrl = getSanitizedUrlString ( urlObject ) ;
138- const method = getFetchMethod ( args ) ;
137+ const requestData : SanitizedRequestData = {
138+ url : getSanitizedUrlString ( urlObject ) ,
139+ method : getFetchMethod ( args ) ,
140+ 'http.query' : urlObject . search ,
141+ 'http.fragment' : urlObject . hash ,
142+ } ;
139143
140144 // TODO: extract this to a util function (and use it in breadcrumbs integration as well)
141- if ( rawUrl . match ( / s e n t r y _ k e y / ) && method === 'POST' ) {
145+ if ( rawUrl . match ( / s e n t r y _ k e y / ) ) {
142146 // We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
143147 return wrappingTarget . apply ( thisArg , args ) ;
144148 }
@@ -170,19 +174,12 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
170174
171175 let fetchPromise : Promise < Response > ;
172176
173- const spanData : SanitizedRequestData = {
174- url : sanitizedUrl ,
175- method,
176- 'http.query' : urlObject . search ,
177- 'http.fragment' : urlObject . hash ,
178- } ;
179-
180177 if ( createSpan ) {
181178 fetchPromise = trace (
182179 {
183- name : `${ method } ${ sanitizedUrl } ` , // this will become the description of the span
180+ name : `${ requestData . method } ${ requestData . url } ` , // this will become the description of the span
184181 op : 'http.client' ,
185- data : spanData ,
182+ data : requestData ,
186183 parentSpanId : activeSpan && activeSpan . spanId ,
187184 } ,
188185 async span => {
@@ -198,7 +195,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
198195 }
199196
200197 if ( shouldAddFetchBreadcrumbs ) {
201- addFetchBreadcrumb ( fetchPromise , spanData , args ) ;
198+ addFetchBreadcrumb ( fetchPromise , requestData , args ) ;
202199 }
203200
204201 return fetchPromise ;
@@ -209,7 +206,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
209206/* Adds a breadcrumb for the given fetch result */
210207function addFetchBreadcrumb (
211208 fetchResult : Promise < Response > ,
212- spanData : SanitizedRequestData ,
209+ requestData : SanitizedRequestData ,
213210 args : Parameters < SvelteKitFetch > ,
214211) : void {
215212 const breadcrumbStartTimestamp = Date . now ( ) ;
@@ -220,7 +217,7 @@ function addFetchBreadcrumb(
220217 type : 'http' ,
221218 category : 'fetch' ,
222219 data : {
223- ...spanData ,
220+ ...requestData ,
224221 status_code : response . status ,
225222 } ,
226223 } ,
@@ -238,7 +235,7 @@ function addFetchBreadcrumb(
238235 type : 'http' ,
239236 category : 'fetch' ,
240237 level : 'error' ,
241- data : spanData ,
238+ data : requestData ,
242239 } ,
243240 {
244241 input : args ,
0 commit comments