Skip to content

Commit

Permalink
revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed Oct 31, 2024
1 parent 915ef6e commit b30aae8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/replay-internal/src/util/addEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,20 @@ async function _addEvent(
event: RecordingEvent,
isCheckout?: boolean,
): Promise<AddEventResult | null> {
const { eventBuffer } = replay;

if (!eventBuffer || (eventBuffer.waitForCheckout && !isCheckout)) {
if (!replay.eventBuffer || (replay.eventBuffer.waitForCheckout && !isCheckout)) {
return null;
}

const isBufferMode = replay.recordingMode === 'buffer';

try {
if (isCheckout && isBufferMode) {
eventBuffer.clear();
replay.eventBuffer.clear();
}

if (isCheckout) {
eventBuffer.hasCheckout = true;
eventBuffer.waitForCheckout = false;
replay.eventBuffer.hasCheckout = true;
replay.eventBuffer.waitForCheckout = false;
}

const replayOptions = replay.getOptions();
Expand All @@ -80,15 +78,15 @@ async function _addEvent(
return;
}

return await eventBuffer.addEvent(eventAfterPossibleCallback);
return await replay.eventBuffer.addEvent(eventAfterPossibleCallback);
} catch (error) {
const isExceeded = error && error instanceof EventBufferSizeExceededError;
const reason = isExceeded ? 'addEventSizeExceeded' : 'addEvent';

if (isExceeded && isBufferMode) {
// Clear buffer and wait for next checkout
eventBuffer.clear();
eventBuffer.waitForCheckout = true;
replay.eventBuffer.clear();
replay.eventBuffer.waitForCheckout = true;

return null;
}
Expand Down

0 comments on commit b30aae8

Please sign in to comment.