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 11import { addBreadcrumb } from '@sentry/core' ;
22import { Event } from '@sentry/types' ;
3+ import { logger } from '@sentry/utils' ;
34
45import { REPLAY_EVENT_NAME , UNABLE_TO_SEND_REPLAY } from '../constants' ;
56import type { ReplayContainer } from '../types' ;
7+ import { isRrwebError } from '../util/isRrwebError' ;
68
79/**
810 * Returns a listener to be added to `addGlobalEventProcessor(listener)`.
911 */
10- export function handleGlobalEventListener ( replay : ReplayContainer ) : ( event : Event ) => Event {
12+ export function handleGlobalEventListener ( replay : ReplayContainer ) : ( event : Event ) => Event | null {
1113 return ( event : Event ) => {
1214 // Do not apply replayId to the root event
1315 if (
@@ -20,6 +22,13 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
2022 return event ;
2123 }
2224
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+
2332 // Only tag transactions with replayId if not waiting for an error
2433 // @ts -ignore private
2534 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