@@ -39,14 +39,13 @@ export class Tracing implements Integration {
39
39
if ( ! Array . isArray ( _options . tracingOrigins ) || _options . tracingOrigins . length === 0 ) {
40
40
consoleSandbox ( ( ) => {
41
41
const defaultTracingOrigins = [ 'localhost' , / ^ \/ / ] ;
42
- // tslint:disable: no-unsafe-any
43
42
// @ts -ignore
44
- console . warning (
43
+ console . warn (
45
44
'Sentry: You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.' ,
46
45
) ;
47
46
// @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 ;
50
49
} ) ;
51
50
}
52
51
}
@@ -119,18 +118,12 @@ export class Tracing implements Integration {
119
118
const self = getCurrentHub ( ) . getIntegration ( Tracing ) ;
120
119
if ( self && self . _xhrUrl ) {
121
120
const headers = getCurrentHub ( ) . traceHeaders ( ) ;
122
- let whiteList = false ;
123
-
124
121
// 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
+ ) ;
132
125
133
- if ( whiteList && this . setRequestHeader ) {
126
+ if ( isWhitelisted && this . setRequestHeader ) {
134
127
Object . keys ( headers ) . forEach ( key => {
135
128
this . setRequestHeader ( key , headers [ key ] ) ;
136
129
} ) ;
0 commit comments