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