Skip to content

Commit 5f05517

Browse files
committed
apply suggestions
1 parent d8e5e66 commit 5f05517

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

packages/sveltekit/src/client/load.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
108108

109109
const browserTracingIntegration =
110110
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);
112113

113114
const browserTracingOptions = browserTracingIntegration && browserTracingIntegration.options;
114115

@@ -133,22 +134,23 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
133134
apply: (wrappingTarget, thisArg, args: Parameters<LoadEvent['fetch']>) => {
134135
const [input, init] = args;
135136
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-
};
144137

145138
// TODO: extract this to a util function (and use it in breadcrumbs integration as well)
146139
if (rawUrl.match(/sentry_key/)) {
147140
// We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
148141
return wrappingTarget.apply(thisArg, args);
149142
}
150143

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 };
152154
const activeSpan = getCurrentHub().getScope().getSpan();
153155
const activeTransaction = activeSpan && activeSpan.transaction;
154156

packages/tracing-internal/src/browser/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export function addTracingHeadersToFetchRequest(
250250
newHeaders.append('sentry-trace', sentryTraceHeader);
251251

252252
if (sentryBaggageHeader) {
253-
// If the same header is appended miultiple times the browser will merge the values into a single request header.
253+
// If the same header is appended multiple times the browser will merge the values into a single request header.
254254
// Its therefore safe to simply push a "baggage" entry, even though there might already be another baggage header.
255255
newHeaders.append(BAGGAGE_HEADER_NAME, sentryBaggageHeader);
256256
}

0 commit comments

Comments
 (0)