1
1
/* eslint-disable max-lines */ // TODO: We might want to split this file up
2
2
import { addGlobalEventProcessor , getCurrentHub , Scope , setContext } from '@sentry/core' ;
3
3
import { Breadcrumb , Client , Event , Integration } from '@sentry/types' ;
4
- import { addInstrumentationHandler , createEnvelope } from '@sentry/utils' ;
4
+ import { addInstrumentationHandler , createEnvelope , logger } from '@sentry/utils' ;
5
5
import debounce from 'lodash.debounce' ;
6
6
import { PerformanceObserverEntryList } from 'perf_hooks' ;
7
7
import { EventType , record } from 'rrweb' ;
@@ -40,7 +40,6 @@ import { createPayload } from './util/createPayload';
40
40
import { dedupePerformanceEntries } from './util/dedupePerformanceEntries' ;
41
41
import { isExpired } from './util/isExpired' ;
42
42
import { isSessionExpired } from './util/isSessionExpired' ;
43
- import { logger } from './util/logger' ;
44
43
45
44
/**
46
45
* Returns true to return control to calling function, otherwise continue with normal batching
@@ -300,7 +299,7 @@ export class Replay implements Integration {
300
299
emit : this . handleRecordingEmit ,
301
300
} ) ;
302
301
} catch ( err ) {
303
- logger . error ( err ) ;
302
+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
304
303
captureInternalException ( err ) ;
305
304
}
306
305
}
@@ -315,14 +314,14 @@ export class Replay implements Integration {
315
314
}
316
315
317
316
try {
318
- logger . log ( 'Stopping Replays' ) ;
317
+ __DEBUG_BUILD__ && logger . log ( '[Replay] Stopping Replays' ) ;
319
318
this . isEnabled = false ;
320
319
this . removeListeners ( ) ;
321
320
this . stopRecording ?.( ) ;
322
321
this . eventBuffer ?. destroy ( ) ;
323
322
this . eventBuffer = null ;
324
323
} catch ( err ) {
325
- logger . error ( err ) ;
324
+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
326
325
captureInternalException ( err ) ;
327
326
}
328
327
}
@@ -340,7 +339,7 @@ export class Replay implements Integration {
340
339
this . stopRecording = undefined ;
341
340
}
342
341
} catch ( err ) {
343
- logger . error ( err ) ;
342
+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
344
343
captureInternalException ( err ) ;
345
344
}
346
345
}
@@ -361,7 +360,7 @@ export class Replay implements Integration {
361
360
deleteSession ( ) ;
362
361
this . session = undefined ;
363
362
} catch ( err ) {
364
- logger . error ( err ) ;
363
+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
365
364
captureInternalException ( err ) ;
366
365
}
367
366
}
@@ -437,7 +436,7 @@ export class Replay implements Integration {
437
436
this . hasInitializedCoreListeners = true ;
438
437
}
439
438
} catch ( err ) {
440
- logger . error ( err ) ;
439
+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
441
440
captureInternalException ( err ) ;
442
441
}
443
442
@@ -487,7 +486,7 @@ export class Replay implements Integration {
487
486
this . performanceObserver = null ;
488
487
}
489
488
} catch ( err ) {
490
- logger . error ( err ) ;
489
+ __DEBUG_BUILD__ && logger . error ( '[Replay]' , err ) ;
491
490
captureInternalException ( err ) ;
492
491
}
493
492
}
@@ -599,7 +598,7 @@ export class Replay implements Integration {
599
598
) => {
600
599
// If this is false, it means session is expired, create and a new session and wait for checkout
601
600
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.') ;
603
602
604
603
return ;
605
604
}
@@ -827,7 +826,7 @@ export class Replay implements Integration {
827
826
// If the user has come back to the page within VISIBILITY_CHANGE_TIMEOUT
828
827
// ms, we will re-use the existing session, otherwise create a new
829
828
// 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' ) ;
831
830
return ;
832
831
}
833
832
@@ -841,7 +840,7 @@ export class Replay implements Integration {
841
840
* create a new Replay event.
842
841
*/
843
842
triggerFullSnapshot ( ) : void {
844
- logger . log ( 'Taking full rrweb snapshot' ) ;
843
+ __DEBUG_BUILD__ && logger . log ( '[Replay] Taking full rrweb snapshot' ) ;
845
844
record . takeFullSnapshot ( true ) ;
846
845
}
847
846
@@ -1131,12 +1130,12 @@ export class Replay implements Integration {
1131
1130
}
1132
1131
1133
1132
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.') ;
1135
1134
return ;
1136
1135
}
1137
1136
1138
1137
if ( ! this . session ?. id ) {
1139
- console . error ( new Error ( '[Sentry ]: No transaction, no replay') ) ;
1138
+ console . error ( '[Replay ]: No transaction, no replay') ;
1140
1139
return ;
1141
1140
}
1142
1141
0 commit comments