Skip to content

Commit

Permalink
only harvest if snapshot has already been seen
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah committed Sep 23, 2024
1 parent 81349b8 commit b0bdece
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/features/session_replay/aggregate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/features/session_replay/shared/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b0bdece

Please sign in to comment.