11/* eslint-disable max-lines */ // TODO: We might want to split this file up
22import { addGlobalEventProcessor , getCurrentHub , Scope , setContext } from '@sentry/core' ;
33import { Breadcrumb , Client , Event , Integration } from '@sentry/types' ;
4- import { addInstrumentationHandler , createEnvelope } from '@sentry/utils' ;
4+ import { addInstrumentationHandler , createEnvelope , logger } from '@sentry/utils' ;
55import debounce from 'lodash.debounce' ;
66import { PerformanceObserverEntryList } from 'perf_hooks' ;
77import { EventType , record } from 'rrweb' ;
@@ -40,7 +40,6 @@ import { createPayload } from './util/createPayload';
4040import { dedupePerformanceEntries } from './util/dedupePerformanceEntries' ;
4141import { isExpired } from './util/isExpired' ;
4242import { isSessionExpired } from './util/isSessionExpired' ;
43- import { logger } from './util/logger' ;
4443
4544/**
4645 * Returns true to return control to calling function, otherwise continue with normal batching
@@ -300,7 +299,7 @@ export class Replay implements Integration {
300299 emit : this . handleRecordingEmit ,
301300 } ) ;
302301 } catch ( err ) {
303- logger . error ( err ) ;
302+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
304303 captureInternalException ( err ) ;
305304 }
306305 }
@@ -315,14 +314,14 @@ export class Replay implements Integration {
315314 }
316315
317316 try {
318- logger . log ( 'Stopping Replays' ) ;
317+ __DEBUG_BUILD__ && logger . log ( '[Replay] Stopping Replays' ) ;
319318 this . isEnabled = false ;
320319 this . removeListeners ( ) ;
321320 this . stopRecording ?.( ) ;
322321 this . eventBuffer ?. destroy ( ) ;
323322 this . eventBuffer = null ;
324323 } catch ( err ) {
325- logger . error ( err ) ;
324+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
326325 captureInternalException ( err ) ;
327326 }
328327 }
@@ -340,7 +339,7 @@ export class Replay implements Integration {
340339 this . stopRecording = undefined ;
341340 }
342341 } catch ( err ) {
343- logger . error ( err ) ;
342+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
344343 captureInternalException ( err ) ;
345344 }
346345 }
@@ -361,7 +360,7 @@ export class Replay implements Integration {
361360 deleteSession ( ) ;
362361 this . session = undefined ;
363362 } catch ( err ) {
364- logger . error ( err ) ;
363+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
365364 captureInternalException ( err ) ;
366365 }
367366 }
@@ -437,7 +436,7 @@ export class Replay implements Integration {
437436 this . hasInitializedCoreListeners = true ;
438437 }
439438 } catch ( err ) {
440- logger . error ( err ) ;
439+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
441440 captureInternalException ( err ) ;
442441 }
443442
@@ -487,7 +486,7 @@ export class Replay implements Integration {
487486 this . performanceObserver = null ;
488487 }
489488 } catch ( err ) {
490- logger . error ( err ) ;
489+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
491490 captureInternalException ( err ) ;
492491 }
493492 }
@@ -599,7 +598,7 @@ export class Replay implements Integration {
599598 ) => {
600599 // If this is false, it means session is expired, create and a new session and wait for checkout
601600 if ( ! this . checkAndHandleExpiredSession ( ) ) {
602- logger . error ( new Error ( ' Received replay event after session expired.') ) ;
601+ __DEBUG_BUILD__ && logger . error ( '[Replay] Received replay event after session expired.') ;
603602
604603 return ;
605604 }
@@ -827,7 +826,7 @@ export class Replay implements Integration {
827826 // If the user has come back to the page within VISIBILITY_CHANGE_TIMEOUT
828827 // ms, we will re-use the existing session, otherwise create a new
829828 // session
830- logger . log ( 'Document has become active, but session has expired' ) ;
829+ __DEBUG_BUILD__ && logger . log ( '[Replay] Document has become active, but session has expired' ) ;
831830 return ;
832831 }
833832
@@ -841,7 +840,7 @@ export class Replay implements Integration {
841840 * create a new Replay event.
842841 */
843842 triggerFullSnapshot ( ) : void {
844- logger . log ( 'Taking full rrweb snapshot' ) ;
843+ __DEBUG_BUILD__ && logger . log ( '[Replay] Taking full rrweb snapshot' ) ;
845844 record . takeFullSnapshot ( true ) ;
846845 }
847846
@@ -1131,12 +1130,12 @@ export class Replay implements Integration {
11311130 }
11321131
11331132 if ( ! this . checkAndHandleExpiredSession ( ) ) {
1134- logger . error ( new Error ( ' Attempting to finish replay event after session expired.') ) ;
1133+ __DEBUG_BUILD__ && logger . error ( '[Replay] Attempting to finish replay event after session expired.') ;
11351134 return ;
11361135 }
11371136
11381137 if ( ! this . session ?. id ) {
1139- console . error ( new Error ( '[Sentry ]: No transaction, no replay') ) ;
1138+ console . error ( '[Replay ]: No transaction, no replay') ;
11401139 return ;
11411140 }
11421141
0 commit comments