From 966cc0548003e9a54ff097b9f6bc54aae214eacd Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 21 Feb 2023 11:36:09 +0100 Subject: [PATCH] fix(replay): Do not depend on `event.type` to infer `isCheckout` This relies on https://github.com/getsentry/rrweb/pull/56 to be merged & released first. --- packages/replay/src/replay.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/replay/src/replay.ts b/packages/replay/src/replay.ts index 413286af5e82..3a44efdb5ad9 100644 --- a/packages/replay/src/replay.ts +++ b/packages/replay/src/replay.ts @@ -534,7 +534,7 @@ export class ReplayContainer implements ReplayContainerInterface { // when an error occurs. Clear any state that happens before this current // checkout. This needs to happen before `addEvent()` which updates state // dependent on this reset. - if (this.recordingMode === 'error' && event.type === 2) { + if (this.recordingMode === 'error' && isCheckout) { this._setInitialState(); } @@ -542,9 +542,8 @@ export class ReplayContainer implements ReplayContainerInterface { // incremental event updates and should be appended void addEvent(this, event, isCheckout); - // Different behavior for full snapshots (type=2), ignore other event types - // See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16 - if (event.type !== 2) { + // Different behavior for checkouts, ignore other event types + if (!isCheckout) { return false; }