Skip to content

Commit 65ef381

Browse files
committed
ref(replay): Avoid overwriting user checkoutEveryNms config
1 parent 5461fb2 commit 65ef381

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/replay/src/replay.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ export class ReplayContainer {
158158
// when an error will occur, so we need to keep a buffer of
159159
// replay events.
160160
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;
163161
this._waitForError = true;
164162
}
165163

@@ -187,6 +185,7 @@ export class ReplayContainer {
187185
try {
188186
this._stopRecording = record({
189187
...this.recordingOptions,
188+
...this._getRecordingOptionsOverwrites(),
190189
emit: this.handleRecordingEmit,
191190
});
192191
} catch (err) {
@@ -470,7 +469,6 @@ export class ReplayContainer {
470469
this._stopRecording();
471470
// Reset all "capture on error" configuration before
472471
// starting a new recording
473-
delete this.recordingOptions.checkoutEveryNms;
474472
this._waitForError = false;
475473
this.startRecording();
476474
}
@@ -1283,4 +1281,16 @@ export class ReplayContainer {
12831281

12841282
client.recordDroppedEvent = this._originalRecordDroppedEvent;
12851283
}
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+
}
12861296
}

0 commit comments

Comments
 (0)