@@ -2,6 +2,7 @@ import type { Client, Event, EventHint, Integration, StackFrame } from '@sentry/
2
2
import { getEventDescription , logger , stringMatchesSomePattern } from '@sentry/utils' ;
3
3
4
4
import { DEBUG_BUILD } from '../debug-build' ;
5
+ import { convertIntegrationFnToClass , makeIntegrationFn } from '../integration' ;
5
6
6
7
// "Script error." is hard coded into browsers for errors that it can't read.
7
8
// this is the result of a script being pulled in from an external domain and CORS.
@@ -28,42 +29,21 @@ export interface InboundFiltersOptions {
28
29
disableTransactionDefaults : boolean ;
29
30
}
30
31
31
- /** Inbound filters configurable by the user */
32
- export class InboundFilters implements Integration {
33
- /**
34
- * @inheritDoc
35
- */
36
- public static id : string = 'InboundFilters' ;
37
-
38
- /**
39
- * @inheritDoc
40
- */
41
- public name : string ;
42
-
43
- private readonly _options : Partial < InboundFiltersOptions > ;
44
-
45
- public constructor ( options : Partial < InboundFiltersOptions > = { } ) {
46
- this . name = InboundFilters . id ;
47
- this . _options = options ;
48
- }
49
-
50
- /**
51
- * @inheritDoc
52
- */
53
- public setupOnce ( _addGlobalEventProcessor : unknown , _getCurrentHub : unknown ) : void {
54
- // noop
32
+ const inboundFiltersIntegration = makeIntegrationFn ( 'InboundFilters' , ( options : Partial < InboundFiltersOptions > ) => {
33
+ return {
34
+ processEvent ( event , _hint , client ) {
35
+ const clientOptions = client . getOptions ( ) ;
36
+ const mergedOptions = _mergeOptions ( options , clientOptions ) ;
37
+ return _shouldDropEvent ( event , mergedOptions ) ? null : event ;
38
+ }
55
39
}
40
+ } ) ;
56
41
57
- /** @inheritDoc */
58
- public processEvent ( event : Event , _eventHint : EventHint , client : Client ) : Event | null {
59
- const clientOptions = client . getOptions ( ) ;
60
- const options = _mergeOptions ( this . _options , clientOptions ) ;
61
- return _shouldDropEvent ( event , options ) ? null : event ;
62
- }
63
- }
42
+ /** Inbound filters configurable by the user */
43
+ // eslint-disable-next-line deprecation/deprecation
44
+ export const InboundFilters = convertIntegrationFnToClass ( inboundFiltersIntegration ) ;
64
45
65
- /** JSDoc */
66
- export function _mergeOptions (
46
+ function _mergeOptions (
67
47
internalOptions : Partial < InboundFiltersOptions > = { } ,
68
48
clientOptions : Partial < InboundFiltersOptions > = { } ,
69
49
) : Partial < InboundFiltersOptions > {
@@ -84,8 +64,7 @@ export function _mergeOptions(
84
64
} ;
85
65
}
86
66
87
- /** JSDoc */
88
- export function _shouldDropEvent ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
67
+ function _shouldDropEvent ( event : Event , options : Partial < InboundFiltersOptions > ) : boolean {
89
68
if ( options . ignoreInternal && _isSentryError ( event ) ) {
90
69
DEBUG_BUILD &&
91
70
logger . warn ( `Event dropped due to being internal Sentry Error.\nEvent: ${ getEventDescription ( event ) } ` ) ;
0 commit comments