@@ -233,13 +233,22 @@ export class ReplayContainer implements ReplayContainerInterface {
233233 * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
234234 * does not support a teardown
235235 */
236- public stop ( ) : void {
236+ public stop ( reason ?: string ) : void {
237237 if ( ! this . _isEnabled ) {
238238 return ;
239239 }
240240
241241 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+
243252 this . _isEnabled = false ;
244253 this . _removeListeners ( ) ;
245254 this . stopRecording ( ) ;
@@ -426,7 +435,7 @@ export class ReplayContainer implements ReplayContainerInterface {
426435 this . session = session ;
427436
428437 if ( ! this . session . sampled ) {
429- this . stop ( ) ;
438+ this . stop ( 'session unsampled' ) ;
430439 return false ;
431440 }
432441
@@ -810,7 +819,7 @@ export class ReplayContainer implements ReplayContainerInterface {
810819 // This means we retried 3 times and all of them failed,
811820 // or we ran into a problem we don't want to retry, like rate limiting.
812821 // In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
813- this . stop ( ) ;
822+ this . stop ( 'sendReplay' ) ;
814823
815824 const client = getCurrentHub ( ) . getClient ( ) ;
816825
0 commit comments