@@ -108,7 +108,8 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
108
108
109
109
const browserTracingIntegration =
110
110
client . getIntegrationById && ( client . getIntegrationById ( 'BrowserTracing' ) as BrowserTracing | undefined ) ;
111
- const breadcrumbsIntegration = client . getIntegrationById ( 'Breadcrumbs' ) as Breadcrumbs | undefined ;
111
+ const breadcrumbsIntegration =
112
+ client . getIntegrationById && ( client . getIntegrationById ( 'Breadcrumbs' ) as Breadcrumbs | undefined ) ;
112
113
113
114
const browserTracingOptions = browserTracingIntegration && browserTracingIntegration . options ;
114
115
@@ -133,22 +134,23 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
133
134
apply : ( wrappingTarget , thisArg , args : Parameters < LoadEvent [ 'fetch' ] > ) => {
134
135
const [ input , init ] = args ;
135
136
const { url : rawUrl , method } = parseFetchArgs ( args ) ;
136
- const urlObject = parseUrl ( rawUrl ) ;
137
-
138
- const requestData : SanitizedRequestData = {
139
- url : getSanitizedUrlString ( urlObject ) ,
140
- method,
141
- 'http.query' : urlObject . search ,
142
- 'http.fragment' : urlObject . hash ,
143
- } ;
144
137
145
138
// TODO: extract this to a util function (and use it in breadcrumbs integration as well)
146
139
if ( rawUrl . match ( / s e n t r y _ k e y / ) ) {
147
140
// We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
148
141
return wrappingTarget . apply ( thisArg , args ) ;
149
142
}
150
143
151
- const patchedInit : RequestInit = { ...init } || { } ;
144
+ const urlObject = parseUrl ( rawUrl ) ;
145
+
146
+ const requestData : SanitizedRequestData = {
147
+ url : getSanitizedUrlString ( urlObject ) ,
148
+ method,
149
+ ...( urlObject . search && { 'http.query' : urlObject . search . substring ( 1 ) } ) ,
150
+ ...( urlObject . hash && { 'http.hash' : urlObject . hash . substring ( 1 ) } ) ,
151
+ } ;
152
+
153
+ const patchedInit : RequestInit = { ...init } ;
152
154
const activeSpan = getCurrentHub ( ) . getScope ( ) . getSpan ( ) ;
153
155
const activeTransaction = activeSpan && activeSpan . transaction ;
154
156
0 commit comments