@@ -233,13 +233,22 @@ export class ReplayContainer implements ReplayContainerInterface {
233
233
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK
234
234
* does not support a teardown
235
235
*/
236
- public stop ( ) : void {
236
+ public stop ( reason ?: string ) : void {
237
237
if ( ! this . _isEnabled ) {
238
238
return ;
239
239
}
240
240
241
241
try {
242
- __DEBUG_BUILD__ && logger . log ( '[Replay] Stopping Replays' ) ;
242
+ if ( __DEBUG_BUILD__ ) {
243
+ const msg = `[Replay] Stopping Replay${ reason ? ` triggered by ${ reason } ` : '' } ` ;
244
+
245
+ // When `traceInternals` is enabled, we want to log this to the console
246
+ // Else, use the regular debug output
247
+ // eslint-disable-next-line
248
+ const log = this . getOptions ( ) . _experiments . traceInternals ? console . warn : logger . log ;
249
+ log ( msg ) ;
250
+ }
251
+
243
252
this . _isEnabled = false ;
244
253
this . _removeListeners ( ) ;
245
254
this . stopRecording ( ) ;
@@ -426,7 +435,7 @@ export class ReplayContainer implements ReplayContainerInterface {
426
435
this . session = session ;
427
436
428
437
if ( ! this . session . sampled ) {
429
- this . stop ( ) ;
438
+ this . stop ( 'session unsampled' ) ;
430
439
return false ;
431
440
}
432
441
@@ -810,7 +819,7 @@ export class ReplayContainer implements ReplayContainerInterface {
810
819
// This means we retried 3 times and all of them failed,
811
820
// or we ran into a problem we don't want to retry, like rate limiting.
812
821
// In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
813
- this . stop ( ) ;
822
+ this . stop ( 'sendReplay' ) ;
814
823
815
824
const client = getCurrentHub ( ) . getClient ( ) ;
816
825
0 commit comments