Skip to content

Commit

Permalink
In the sequence: 1. frozen mutation buffers building up 2. throttled …
Browse files Browse the repository at this point in the history
…mousemove initiated 3. mouseclick, then ensure that the mutation emission gets the timestamp of when the mousemove started
  • Loading branch information
eoghanmurray committed Jul 8, 2021
1 parent 53c1b4e commit 17c9efd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ function record<T = eventWithTime>(
let lastFullSnapshotEvent: eventWithTime;
let incrementalSnapshotCount = 0;
wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {

if (ongoingMove) {
// emit any ongoing (but throttled) mouse or touch move;
// emitting now creates more events, but ensures events are emitted in
// sequence without any overlap from the negative Move timeOffset
ongoingMove(e.timestamp);
}

if (
mutationBuffers[0]?.isFrozen() &&
e.type !== EventType.FullSnapshot &&
Expand All @@ -141,12 +149,6 @@ function record<T = eventWithTime>(
// all DOM changes that have been buffering during paused state
mutationBuffers.forEach((buf) => buf.unfreeze(mtimestamp));
}
if (ongoingMove) {
// emit any ongoing (but throttled) mouse or touch move;
// emitting now creates more events, but ensures events are emitted in
// sequence without any overlap from the negative Move timeOffset
ongoingMove(e.timestamp);
}

emit(((packFn ? packFn(e) : e) as unknown) as T, isCheckout);
if (e.type === EventType.FullSnapshot) {
Expand Down

0 comments on commit 17c9efd

Please sign in to comment.