File tree Expand file tree Collapse file tree 3 files changed +278
-100
lines changed Expand file tree Collapse file tree 3 files changed +278
-100
lines changed Original file line number Diff line number Diff line change 1
1
import { addBreadcrumb } from '@sentry/core' ;
2
2
import { Event } from '@sentry/types' ;
3
+ import { logger } from '@sentry/utils' ;
3
4
4
5
import { REPLAY_EVENT_NAME , UNABLE_TO_SEND_REPLAY } from '../constants' ;
5
6
import type { ReplayContainer } from '../types' ;
7
+ import { isRrwebError<
8000
/span> } from '../util/isRrwebError' ;
6
8
7
9
/**
8
10
* Returns a listener to be added to `addGlobalEventProcessor(listener)`.
9
11
*/
10
- export function handleGlobalEventListener ( replay : ReplayContainer ) : ( event : Event ) => Event {
12
+ export function handleGlobalEventListener ( replay : ReplayContainer ) : ( event : Event ) => Event | null {
11
13
return ( event : Event ) => {
12
14
// Do not apply replayId to the root event
13
15
if (
@@ -20,6 +22,13 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
20
22
return event ;
21
23
}
22
24
25
+ // Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
26
+ // As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
27
+ if ( isRrwebError ( event ) && ! replay . getOptions ( ) . _experiments ?. captureExceptions ) {
28
+ __DEBUG_BUILD__ && logger . log ( '[Replay] Ignoring error from rrweb internals' , event ) ;
29
+ return null ;
30
+ }
31
+
23
32
// Only tag transactions with replayId if not waiting for an error
24
33
// @ts -ignore private
25
34
if ( event . type !== 'transaction' || replay . recordingMode === 'session' ) {
Original file line number Diff line number Diff line change
1
+ import { Event } from '@sentry/types' ;
2
+
3
+ export function isRrwebError ( event : Event ) : boolean {
4
+ if ( event . type || ! event . exception ?. values ?. length ) {
5
+ return false ;
6
+ }
7
+
8
+ // Check if any exception originates from rrweb
9
+ return event . exception . values . some ( exception => {
10
+ if ( ! exception . stacktrace ?. frames ?. length ) {
11
+ return false ;
12
+ }
13
+
14
+ return exception . stacktrace . frames . some ( frame => frame . filename ?. includes ( '/rrweb/src/' ) ) ;
15
+ } ) ;
16
+ }
You can’t perform that action at this time.
0 commit comments