@@ -8,10 +8,15 @@ const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script e
8
8
9
9
/** JSDoc */
10
10
interface InboundFiltersOptions {
11
- blacklistUrls ?: Array < string | RegExp > ;
12
- ignoreErrors ?: Array < string | RegExp > ;
13
- ignoreInternal ?: boolean ;
14
- whitelistUrls ?: Array < string | RegExp > ;
11
+ allowUrls : Array < string | RegExp > ;
12
+ denyUrls : Array < string | RegExp > ;
13
+ ignoreErrors : Array < string | RegExp > ;
14
+ ignoreInternal : boolean ;
15
+
16
+ /** @deprecated use {@link InboundFiltersOptions.allowUrls} instead. */
17
+ whitelistUrls : Array < string | RegExp > ;
18
+ /** @deprecated use {@link InboundFiltersOptions.denyUrls} instead. */
19
+ blacklistUrls : Array < string | RegExp > ;
15
20
}
16
21
17
22
/** Inbound filters configurable by the user */
@@ -25,7 +30,7 @@ export class InboundFilters implements Integration {
25
30
*/
26
31
public static id : string = 'InboundFilters' ;
27
32
28
- public constructor ( private readonly _options : InboundFiltersOptions = { } ) { }
33
+ public constructor ( private readonly _options : Partial < InboundFiltersOptions > = { } ) { }
29
34
30
35
/**
31
36
* @inheritDoc
@@ -50,7 +55,7 @@ export class InboundFilters implements Integration {
50
55
}
51
56
52
57
/** JSDoc */
53
- private _shouldDropEvent ( event : Event , options : InboundFiltersOptions ) : boolean {
58
+ private _shouldDropEvent ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
54
59
if ( this . _isSentryError ( event , options ) ) {
55
60
logger . warn ( `Event dropped due to being internal Sentry Error.\nEvent: ${ getEventDescription ( event ) } ` ) ;
56
61
return true ;
@@ -61,17 +66,17 @@ export class InboundFilters implements Integration {
61
66
) ;
62
67
return true ;
63
68
}
64
- if ( this . _isBlacklistedUrl ( event , options ) ) {
69
+ if ( this . _isDeniedUrl ( event , options ) ) {
65
70
logger . warn (
66
- `Event dropped due to being matched by \`blacklistUrls \` option.\nEvent: ${ getEventDescription (
71
+ `Event dropped due to being matched by \`denyUrls \` option.\nEvent: ${ getEventDescription (
67
72
event ,
68
73
) } .\nUrl: ${ this . _getEventFilterUrl ( event ) } `,
69
74
) ;
70
75
return true ;
71
76
}
72
- if ( ! this . _isWhitelistedUrl ( event , options ) ) {
77
+ if ( ! this . _isAllowedUrl ( event , options ) ) {
73
78
logger . warn (
74
- `Event dropped due to not being matched by \`whitelistUrls \` option.\nEvent: ${ getEventDescription (
79
+ `Event dropped due to not being matched by \`allowUrls \` option.\nEvent: ${ getEventDescription (
75
80
event ,
76
81
) } .\nUrl: ${ this . _getEventFilterUrl ( event ) } `,
77
82
) ;
@@ -81,7 +86,7 @@ export class InboundFilters implements Integration {
81
86
}
82
87
83
88
/** JSDoc */
84
- private _isSentryError ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
89
+ private _isSentryError ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
85
90
if ( ! options . ignoreInternal ) {
86
91
return false ;
87
92
}
@@ -101,7 +106,7 @@ export class InboundFilters implements Integration {
101
106
}
102
107
103
108
/** JSDoc */
104
- private _isIgnoredError ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
109
+ private _isIgnoredError ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
105
110
if ( ! options . ignoreErrors || ! options . ignoreErrors . length ) {
106
111
return false ;
107
112
}
@@ -113,36 +118,47 @@ export class InboundFilters implements Integration {
113
118
}
114
119
115
120
/** JSDoc */
116
- private _isBlacklistedUrl ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
121
+ private _isDeniedUrl ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
117
122
// TODO: Use Glob instead?
118
- if ( ! options . blacklistUrls || ! options . blacklistUrls . length ) {
123
+ if ( ! options . denyUrls || ! options . denyUrls . length ) {
119
124
return false ;
120
125
}
121
126
const url = this . _getEventFilterUrl ( event ) ;
122
- return ! url ? false : options . blacklistUrls . some ( pattern => isMatchingPattern ( url , pattern ) ) ;
127
+ return ! url ? false : options . denyUrls . some ( pattern => isMatchingPattern ( url , pattern ) ) ;
123
128
}
124
129
125
130
/** JSDoc */
126
- private _isWhitelistedUrl ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
131
+ private _isAllowedUrl ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
127
132
// TODO: Use Glob instead?
128
- if ( ! options . whitelistUrls || ! options . whitelistUrls . length ) {
133
+ if ( ! options . allowUrls || ! options . allowUrls . length ) {
129
134
return true ;
130
135
}
131
136
const url = this . _getEventFilterUrl ( event ) ;
132
- return ! url ? true : options . whitelistUrls . some ( pattern => isMatchingPattern ( url , pattern ) ) ;
137
+ return ! url ? true : options . allowUrls . some ( pattern => isMatchingPattern ( url , pattern ) ) ;
133
138
}
134
139
135
140
/** JSDoc */
136
- private _mergeOptions ( clientOptions : InboundFiltersOptions = { } ) : InboundFiltersOptions {
141
+ private _mergeOptions ( clientOptions : Partial < InboundFiltersOptions > = { } ) : Partial < InboundFiltersOptions > {
142
+ // tslint:disable:deprecation
137
143
return {
138
- blacklistUrls : [ ...( this . _options . blacklistUrls || [ ] ) , ...( clientOptions . blacklistUrls || [ ] ) ] ,
144
+ allowUrls : [
145
+ ...( this . _options . whitelistUrls || [ ] ) ,
146
+ ...( this . _options . allowUrls || [ ] ) ,
147
+ ...( clientOptions . whitelistUrls || [ ] ) ,
148
+ ...( clientOptions . allowUrls || [ ] ) ,
149
+ ] ,
150
+ denyUrls : [
151
+ ...( this . _options . blacklistUrls || [ ] ) ,
152
+ ...( this . _options . denyUrls || [ ] ) ,
153
+ ...( clientOptions . blacklistUrls || [ ] ) ,
154
+ ...( clientOptions . denyUrls || [ ] ) ,
155
+ ] ,
139
156
ignoreErrors : [
140
157
...( this . _options . ignoreErrors || [ ] ) ,
141
158
...( clientOptions . ignoreErrors || [ ] ) ,
142
159
...DEFAULT_IGNORE_ERRORS ,
143
160
] ,
144
161
ignoreInternal : typeof this . _options . ignoreInternal !== 'undefined' ? this . _options . ignoreInternal : true ,
145
- whitelistUrls : [ ...( this . _options . whitelistUrls || [ ] ) , ...( clientOptions . whitelistUrls || [ ] ) ] ,
146
162
} ;
147
163
}
148
164
0 commit comments