@@ -158,8 +158,6 @@ export class ReplayContainer {
158
158
// when an error will occur, so we need to keep a buffer of
159
159
// replay events.
160
160
if ( this . session . sampled === 'error' ) {
161
- // Checkout every minute, meaning we only get up-to one minute of events before the error happens
162
- this . recordingOptions . checkoutEveryNms = 60000 ;
163
161
this . _waitForError = true ;
164
162
}
165
163
@@ -187,6 +185,7 @@ export class ReplayContainer {
187
185
try {
188
186
this . _stopRecording = record ( {
189
187
...this . recordingOptions ,
188
+ ...this . _getRecordingOptionsOverwrites ( ) ,
190
189
emit : this . handleRecordingEmit ,
191
190
} ) ;
192
191
} catch ( err ) {
@@ -470,7 +469,6 @@ export class ReplayContainer {
470
469
this . _stopRecording ( ) ;
471
470
// Reset all "capture on error" configuration before
472
471
// starting a new recording
473
- delete this . recordingOptions . checkoutEveryNms ;
474
472
this . _waitForError = false ;
475
473
this . startRecording ( ) ;
476
474
}
@@ -1283,4 +1281,16 @@ export class ReplayContainer {
1283
1281
1284
1282
client . recordDroppedEvent = this . _originalRecordDroppedEvent ;
1285
1283
}
1284
+
1285
+ /** Additional recordingOptions that should take precedence over user config */
1286
+ private _getRecordingOptionsOverwrites ( ) : Partial < RecordingOptions > {
1287
+ return this . _waitForError
1288
+ ? {
1289
+ // Checkout every minute, meaning we only get up-to one minute of events before the error happens
1290
+ // Without this, it would record forever, until an error happens, which we don't want
1291
+ // instead, we'll always keep the last 60 seconds of replay before an error happened
1292
+ checkoutEveryNth : 60000 ,
1293
+ }
1294
+ : { } ;
1295
+ }
1286
1296
}
0 commit comments