@@ -16,51 +16,54 @@ export function handleGlobalEventListener(
16
16
) : ( event : Event , hint : EventHint ) => Event | null {
17
17
const afterSendHandler = includeAfterSendEventHandling ? handleAfterSendEvent ( replay ) : undefined ;
18
18
19
- return ( event : Event , hint : EventHint ) => {
20
- // Do nothing if replay has been disabled
21
- if ( ! replay . isEnabled ( ) ) {
22
- return event ;
23
- }
19
+ return Object . assign (
20
+ ( event : Event , hint : EventHint ) => {
21
+ // Do nothing if replay has been disabled
22
+ if ( ! replay . isEnabled ( ) ) {
23
+ return event ;
24
+ }
24
25
25
- if ( isReplayEvent ( event ) ) {
26
- // Replays have separate set of breadcrumbs, do not include breadcrumbs
27
- // from core SDK
28
- delete event . breadcrumbs ;
29
- return event ;
30
- }
26
+ if ( isReplayEvent ( event ) ) {
27
+ // Replays have separate set of breadcrumbs, do not include breadcrumbs
28
+ // from core SDK
29
+ delete event . breadcrumbs ;
30
+ return event ;
31
+ }
31
32
32
- // We only want to handle errors & transactions, nothing else
33
- if ( ! isErrorEvent ( event ) && ! isTransactionEvent ( event ) ) {
34
- return event ;
35
- }
33
+ // We only want to handle errors & transactions, nothing else
34
+ if ( ! isErrorEvent ( event ) && ! isTransactionEvent ( event ) ) {
35
+ return event ;
36
+ }
36
37
37
- // Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
38
- // As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
39
- if ( isRrwebError ( event , hint ) && ! replay . getOptions ( ) . _experiments . captureExceptions ) {
40
- __DEBUG_BUILD__ && logger . log ( '[Replay] Ignoring error from rrweb internals' , event ) ;
41
- return null ;
42
- }
38
+ // Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
39
+ // As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
40
+ if ( isRrwebError ( event , hint ) && ! replay . getOptions ( ) . _experiments . captureExceptions ) {
41
+ __DEBUG_BUILD__ && logger . log ( '[Replay] Ignoring error from rrweb internals' , event ) ;
42
+ return null ;
43
+ }
43
44
44
- // When in buffer mode, we decide to sample here.
45
- // Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
46
- // And convert the buffer session to a full session
47
- const isErrorEventSampled = shouldSampleForBufferEvent ( replay , event ) ;
45
+ // When in buffer mode, we decide to sample here.
46
+ // Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
47
+ // And convert the buffer session to a full session
48
+ const isErrorEventSampled = shouldSampleForBufferEvent ( replay , event ) ;
48
49
49
- // Tag errors if it has been sampled in buffer mode, or if it is session mode
50
- // Only tag transactions if in session mode
51
- const shouldTagReplayId = isErrorEventSampled || replay . recordingMode === 'session' ;
50
+ // Tag errors if it has been sampled in buffer mode, or if it is session mode
51
+ // Only tag transactions if in session mode
52
+ const shouldTagReplayId = isErrorEventSampled || replay . recordingMode === 'session' ;
52
53
53
- if ( shouldTagReplayId ) {
54
- event . tags = { ...event . tags , replayId : replay . getSessionId ( ) } ;
55
- }
54
+ if ( shouldTagReplayId ) {
55
+ event . tags = { ...event . tags , replayId : replay . getSessionId ( ) } ;
56
+ }
56
57
57
- // In cases where a custom client is used that does not support the new hooks (yet),
58
- // we manually call this hook method here
59
- if ( afterSendHandler ) {
60
- // Pretend the error had a 200 response so we always capture it
61
- afterSendHandler ( event , { statusCode : 200 } ) ;
62
- }
58
+ // In cases where a custom client is used that does not support the new hooks (yet),
59
+ // we manually call this hook method here
60
+ if ( afterSendHandler ) {
61
+ // Pretend the error had a 200 response so we always capture it
62
+ afterSendHandler ( event , { statusCode : 200 } ) ;
63
+ }
63
64
64
- return event ;
65
- } ;
65
+ return event ;
66
+ } ,
67
+ { id : 'Replay' } ,
68
+ ) ;
66
69
}
0 commit comments