Skip to content

Commit 3c775eb

Browse files
committed
fix: CR
1 parent 21d76f4 commit 3c775eb

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

packages/integrations/src/tracing.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ export class Tracing implements Integration {
3939
if (!Array.isArray(_options.tracingOrigins) || _options.tracingOrigins.length === 0) {
4040
consoleSandbox(() => {
4141
const defaultTracingOrigins = ['localhost', /^\//];
42-
// tslint:disable: no-unsafe-any
4342
// @ts-ignore
44-
console.warning(
43+
console.warn(
4544
'Sentry: You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.',
4645
);
4746
// @ts-ignore
48-
console.warning(`Sentry: We added a reasonable default for you: ${defaultTracingOrigins}`);
49-
// tslint:enable: no-unsafe-any
47+
console.warn(`Sentry: We added a reasonable default for you: ${defaultTracingOrigins}`);
48+
_options.tracingOrigins = defaultTracingOrigins;
5049
});
5150
}
5251
}
@@ -119,18 +118,12 @@ export class Tracing implements Integration {
119118
const self = getCurrentHub().getIntegration(Tracing);
120119
if (self && self._xhrUrl) {
121120
const headers = getCurrentHub().traceHeaders();
122-
let whiteList = false;
123-
124121
// tslint:disable-next-line: prefer-for-of
125-
for (let index = 0; index < self._options.tracingOrigins.length; index++) {
126-
const whiteListUrl = self._options.tracingOrigins[index];
127-
whiteList = isMatchingPattern(self._xhrUrl, whiteListUrl);
128-
if (whiteList) {
129-
break;
130-
}
131-
}
122+
const isWhitelisted = self._options.tracingOrigins.some((origin: string | RegExp) =>
123+
isMatchingPattern(self._xhrUrl, origin),
124+
);
132125

133-
if (whiteList && this.setRequestHeader) {
126+
if (isWhitelisted && this.setRequestHeader) {
134127
Object.keys(headers).forEach(key => {
135128
this.setRequestHeader(key, headers[key]);
136129
});

0 commit comments

Comments
 (0)