Skip to content

Commit c68d937

Browse files
authored
fix: Empty fetch options doesn't attach header (getsentry#2119)
* fix: Empty fetch options doesn't attach header * ref: Remove trace id for now * fix: linter * meta: Changelog
1 parent 29c2f6f commit c68d937

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- [integrations] fix: Tracing integration fetch headers bug where trace header is not attached if there are no options.
6+
37
## 5.4.1
48

59
- [integrations] fix: Tracing integration fetch headers bug.

packages/integrations/src/tracing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { fill, getGlobalObject, isMatchingPattern, logger, supportsNativeFetch }
44
/** JSDoc */
55
interface TracingOptions {
66
tracingOrigins?: Array<string | RegExp>;
7-
traceXHR?: boolean;
87
traceFetch?: boolean;
8+
traceXHR?: boolean;
99
autoStartOnDomReady?: boolean;
1010
}
1111

@@ -147,7 +147,7 @@ export class Tracing implements Integration {
147147
const self = getCurrentHub().getIntegration(Tracing);
148148
if (self && self._options.tracingOrigins) {
149149
const url = args[0] as string;
150-
const options = args[1] as { [key: string]: any };
150+
const options = (args[1] = (args[1] as { [key: string]: any }) || {});
151151

152152
let whiteListed = false;
153153
self._options.tracingOrigins.forEach((whiteListUrl: string | RegExp) => {
@@ -156,7 +156,7 @@ export class Tracing implements Integration {
156156
}
157157
});
158158

159-
if (options && whiteListed) {
159+
if (whiteListed) {
160160
if (options.headers) {
161161
if (Array.isArray(options.headers)) {
162162
options.headers = [...options.headers, ...Object.entries(getCurrentHub().traceHeaders())];

packages/utils/src/supports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getGlobalObject } from './misc';
21
import { logger } from './logger';
2+
import { getGlobalObject } from './misc';
33

44
/**
55
* Tells whether current environment supports ErrorEvent objects

0 commit comments

Comments
 (0)