From b0bdeceff4ce20ad500a8b35526cb1fea7c477ae Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Mon, 23 Sep 2024 13:52:25 -0600 Subject: [PATCH] only harvest if snapshot has already been seen --- src/features/session_replay/aggregate/index.js | 2 +- src/features/session_replay/shared/recorder.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/features/session_replay/aggregate/index.js b/src/features/session_replay/aggregate/index.js index 9333e239c..25c47e029 100644 --- a/src/features/session_replay/aggregate/index.js +++ b/src/features/session_replay/aggregate/index.js @@ -241,7 +241,7 @@ export class Aggregate extends AggregateBase { } prepareHarvest ({ opts } = {}) { - if (!this.recorder || !this.timeKeeper?.ready) return + if (!this.recorder || !this.timeKeeper?.ready || !this.recorder.hasSeenSnapshot) return const recorderEvents = this.recorder.getEvents() // get the event type and use that to trigger another harvest if needed if (!recorderEvents.events.length || (this.mode !== MODE.FULL) || this.blocked) return diff --git a/src/features/session_replay/shared/recorder.js b/src/features/session_replay/shared/recorder.js index e9fbcdb7c..d968834af 100644 --- a/src/features/session_replay/shared/recorder.js +++ b/src/features/session_replay/shared/recorder.js @@ -29,6 +29,8 @@ export class Recorder { this.recording = false /** The pointer to the current bucket holding rrweb events */ this.currentBufferTarget = this.#events + /** Only set to true once a snapshot node has been processed. Used to block preload harvests from sending before we know we have a snapshot */ + this.hasSeenSnapshot = false /** Hold on to the last meta node, so that it can be re-inserted if the meta and snapshot nodes are broken up due to harvesting */ this.lastMeta = false /** The parent class that instantiated the recorder */ @@ -190,6 +192,7 @@ export class Recorder { // snapshot event if (event.type === RRWEB_EVENT_TYPES.FullSnapshot) { this.currentBufferTarget.hasSnapshot = true + this.hasSeenSnapshot = true } this.currentBufferTarget.add(event)