@@ -8,10 +8,15 @@ const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script e
88
99/** JSDoc */
1010interface 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 > ;
1520}
1621
1722/** Inbound filters configurable by the user */
@@ -25,7 +30,7 @@ export class InboundFilters implements Integration {
2530 */
2631 public static id : string = 'InboundFilters' ;
2732
28- public constructor ( private readonly _options : InboundFiltersOptions = { } ) { }
33+ public constructor ( private readonly _options : Partial < InboundFiltersOptions > = { } ) { }
2934
3035 /**
3136 * @inheritDoc
@@ -50,7 +55,7 @@ export class InboundFilters implements Integration {
5055 }
5156
5257 /** JSDoc */
53- private _shouldDropEvent ( event : Event , options : InboundFiltersOptions ) : boolean {
58+ private _shouldDropEvent ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
5459 if ( this . _isSentryError ( event , options ) ) {
5560 logger . warn ( `Event dropped due to being internal Sentry Error.\nEvent: ${ getEventDescription ( event ) } ` ) ;
5661 return true ;
@@ -61,17 +66,17 @@ export class InboundFilters implements Integration {
6166 ) ;
6267 return true ;
6368 }
64- if ( this . _isBlacklistedUrl ( event , options ) ) {
69+ if ( this . _isDeniedUrl ( event , options ) ) {
6570 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 (
6772 event ,
6873 ) } .\nUrl: ${ this . _getEventFilterUrl ( event ) } `,
6974 ) ;
7075 return true ;
7176 }
72- if ( ! this . _isWhitelistedUrl ( event , options ) ) {
77+ if ( ! this . _isAllowedUrl ( event , options ) ) {
7378 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 (
7580 event ,
7681 ) } .\nUrl: ${ this . _getEventFilterUrl ( event ) } `,
7782 ) ;
@@ -81,7 +86,7 @@ export class InboundFilters implements Integration {
8186 }
8287
8388 /** JSDoc */
84- private _isSentryError ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
89+ private _isSentryError ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
8590 if ( ! options . ignoreInternal ) {
8691 return false ;
8792 }
@@ -101,7 +106,7 @@ export class InboundFilters implements Integration {
101106 }
102107
103108 /** JSDoc */
104- private _isIgnoredError ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
109+ private _isIgnoredError ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
105110 if ( ! options . ignoreErrors || ! options . ignoreErrors . length ) {
106111 return false ;
107112 }
@@ -113,36 +118,47 @@ export class InboundFilters implements Integration {
113118 }
114119
115120 /** JSDoc */
116- private _isBlacklistedUrl ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
121+ private _isDeniedUrl ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
117122 // TODO: Use Glob instead?
118- if ( ! options . blacklistUrls || ! options . blacklistUrls . length ) {
123+ if ( ! options . denyUrls || ! options . denyUrls . length ) {
119124 return false ;
120125 }
121126 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 ) ) ;
123128 }
124129
125130 /** JSDoc */
126- private _isWhitelistedUrl ( event : Event , options : InboundFiltersOptions = { } ) : boolean {
131+ private _isAllowedUrl ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
127132 // TODO: Use Glob instead?
128- if ( ! options . whitelistUrls || ! options . whitelistUrls . length ) {
133+ if ( ! options . allowUrls || ! options . allowUrls . length ) {
129134 return true ;
130135 }
131136 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 ) ) ;
133138 }
134139
135140 /** JSDoc */
136- private _mergeOptions ( clientOptions : InboundFiltersOptions = { } ) : InboundFiltersOptions {
141+ private _mergeOptions ( clientOptions : Partial < InboundFiltersOptions > = { } ) : Partial < InboundFiltersOptions > {
142+ // tslint:disable:deprecation
137143 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+ ] ,
139156 ignoreErrors : [
140157 ...( this . _options . ignoreErrors || [ ] ) ,
141158 ...( clientOptions . ignoreErrors || [ ] ) ,
142159 ...DEFAULT_IGNORE_ERRORS ,
143160 ] ,
144161 ignoreInternal : typeof this . _options . ignoreInternal !== 'undefined' ? this . _options . ignoreInternal : true ,
145- whitelistUrls : [ ...( this . _options . whitelistUrls || [ ] ) , ...( clientOptions . whitelistUrls || [ ] ) ] ,
146162 } ;
147163 }
148164
0 commit comments