@@ -134,11 +134,15 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
134
134
const [ input , init ] = args ;
135
135
const rawUrl = getFetchUrl ( args ) ;
136
136
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
+ } ;
139
143
140
144
// 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 / ) ) {
142
146
// We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
143
147
return wrappingTarget . apply ( thisArg , args ) ;
144
148
}
@@ -170,19 +174,12 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
170
174
171
175
let fetchPromise : Promise < Response > ;
172
176
173
- const spanData : SanitizedRequestData = {
174
- url : sanitizedUrl ,
175
- method,
176
- 'http.query' : urlObject . search ,
177
- 'http.fragment' : urlObject . hash ,
178
- } ;
179
-
180
177
if ( createSpan ) {
181
178
fetchPromise = trace (
182
179
{
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
184
181
op : 'http.client' ,
185
- data : spanData ,
182
+ data : requestData ,
186
183
parentSpanId : activeSpan && activeSpan . spanId ,
187
184
} ,
188
185
async span => {
@@ -198,7 +195,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
198
195
}
199
196
200
197
if ( shouldAddFetchBreadcrumbs ) {
201
- addFetchBreadcrumb ( fetchPromise , spanData , args ) ;
198
+ addFetchBreadcrumb ( fetchPromise , requestData , args ) ;
202
199
}
203
200
204
201
return fetchPromise ;
@@ -209,7 +206,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
209
206
/* Adds a breadcrumb for the given fetch result */
210
207
function addFetchBreadcrumb (
211
208
fetchResult : Promise < Response > ,
212
- spanData : SanitizedRequestData ,
209
+ requestData : SanitizedRequestData ,
213
210
args : Parameters < SvelteKitFetch > ,
214
211
) : void {
215
212
const breadcrumbStartTimestamp = Date . now ( ) ;
@@ -220,7 +217,7 @@ function addFetchBreadcrumb(
220
217
type : 'http' ,
221
218
category : 'fetch' ,
222
219
data : {
223
- ...spanData ,
220
+ ...requestData ,
224
221
status_code : response . status ,
225
222
} ,
226
223
} ,
@@ -238,7 +235,7 @@ function addFetchBreadcrumb(
238
235
type : 'http' ,
239
236
category : 'fetch' ,
240
237
level : 'error' ,
241
- data : spanData ,
238
+ data : requestData ,
242
239
} ,
243
240
{
244
241
input : args ,
0 commit comments