1319 Commits

Author SHA1 Message Date
Yanzhen Yu
9a4c21c30f refactor rebuild implementation which mount DOM onto the target document object 2026-04-01 12:00:00 +08:00
Justin Halsall
4206203036 Add regression tests and pause(timeOffset) test (#288)
* increase timeout from 2 (default to 10 seconds

* add regression tests for playing multiple times

* add pause at tests
2026-04-01 12:00:00 +08:00
Yanzhen Yu
19eca4da6d use document object from params instead of the one in the current scope 2026-04-01 12:00:00 +08:00
yz-yu
6de74d7bca close #280. Improve the performance of the DOM mutation observer. (#284)
This issue was originally reported in #280 but may also relate
to #167 and other potential performance issues in the recording.

In #206 I implemented the new mutation observer which will defer
the serialization of DOM, which helps us to have a consistent DOM
order for the replay.

In this implementation, we use an array to represent the `addQueue`.
Whenever we need to consume the queue, we will iterate it to make
sure there is no dead loop, and then shift the first item to see
whether it can be serialized at the new timing.

But this implementation may be very slow when there are a lot of newly
added DOM since it will do an O(n^2) iteration.

For example, if we have three newly added DOM `n1`, `n2`, `n3`,
the iteration looks like this:
```
[n1, n2, n3]
	n1 -> n2 -> n3, consume n3
[n1, n2]
	n1 -> n2, consume n2
[n1]
	n1, consume n1
```
We should have a better performance if te iteration looks like this:
```
[n1, n2, n3]
	n3, consume n3
[n1, n2]
	n2, consume n2
[n1]
	n1, consume n1
```

Simply reverse the mutation payload does not work, because it does
not always as same as the DOM order.

So in this patch, we replace the `addQueue` with a double linked list,
which can:
1. represent the DOM order in its data structure
2. has an O(1) time complexity when looking up the sibling of a list item
3. has an O(1) time complexity when removing a list item
2026-04-01 12:00:00 +08:00
Yanzhen Yu
349d78e02b fix style content url normalizer and add some tests 2026-04-01 12:00:00 +08:00
Yanzhen Yu
e1c0631eeb Release 0.9.0 2026-04-01 12:00:00 +08:00
Yanzhen Yu
bbf23157c5 export reset id function 2026-04-01 12:00:00 +08:00
Yanzhen Yu
3acaeadb93 close #268 subscribe latest player state before resume 2026-04-01 12:00:00 +08:00
Yanzhen Yu
14dac7c0cc fix npm package files and bump version 2026-04-01 12:00:00 +08:00
Yanzhen Yu
9d686d4302 remove the internal use of resume API 2026-04-01 12:00:00 +08:00
Yanzhen Yu
fe174248e1 bump 0.4.0 2026-04-01 12:00:00 +08:00
Yanzhen Yu
c17606630e remove global body style 2026-04-01 12:00:00 +08:00
Yanzhen Yu
f3b456270b update README and add travis 2026-04-01 12:00:00 +08:00
Yanzhen Yu
a31efdc169 close #274 implement the new state management proposal 2026-04-01 12:00:00 +08:00
Yanzhen Yu
875385552d impl the extra child data attribute to align id map 2026-04-01 12:00:00 +08:00
Eoghan Murray
9362baac3e Reset the lastPlayedEvent as it would otherwise be used to discard events in machine.ts as follows: (#250) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
99fa24f711 bump 0.3.1 2026-04-01 12:00:00 +08:00
Yanzhen Yu
fc66a7eb79 Release 0.8.5 2026-04-01 12:00:00 +08:00
Yanzhen Yu
e7753e1c24 change relative path into absolute path 2026-04-01 12:00:00 +08:00
Yanzhen Yu
0d6fe56b80 close #263 Since we improved the block class strategy,
we need to check parent node before pushAdd.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
87ff591cd1 use jest-snapshot to apply the snapshot testing 2026-04-01 12:00:00 +08:00
Yanzhen Yu
cf272f65ef Release 0.8.4 2026-04-01 12:00:00 +08:00
Yanzhen Yu
cb3efd427f add data attribute to element when rebuild 2026-04-01 12:00:00 +08:00
Yanzhen Yu
98f08f333c close #254 hotfix: only use virtual parent in sync mode 2026-04-01 12:00:00 +08:00
Yanzhen Yu
0434129b00 return id node map when rebuild 2026-04-01 12:00:00 +08:00
Yanzhen Yu
6c87b03e0d close #240 fix block class to handle text node changes 2026-04-01 12:00:00 +08:00
Yanzhen Yu
b170c3de59 update the bundle config 2026-04-01 12:00:00 +08:00
Yanzhen Yu
c8cc397418 Release 0.8.3 2026-04-01 12:00:00 +08:00
Yanzhen Yu
9cf2c4c7ed export serializeNodeWithId so rrweb could serialize newly added nodes 2026-04-01 12:00:00 +08:00
Yanzhen Yu
e056f1ae88 add the patch function to utils 2026-04-01 12:00:00 +08:00
Yanzhen Yu
cfc8798b53 return id node map when snapshot 2026-04-01 12:00:00 +08:00
Yanzhen Yu
2a133f8214 close #228 safe access content document, which may be destroyed manually 2026-04-01 12:00:00 +08:00
Yanzhen Yu
ac5293f162 add strict null check and fix codes 2026-04-01 12:00:00 +08:00
Yanzhen Yu
520ddf3a4f close #244 pass fullsnapshot event to the callback 2026-04-01 12:00:00 +08:00
Yanzhen Yu
c496e3edea bump 0.2.0 2026-04-01 12:00:00 +08:00
Yanzhen Yu
50406c27ee fix unit tests 2026-04-01 12:00:00 +08:00
Yanzhen Yu
546743004b update declaration file 2026-04-01 12:00:00 +08:00
yz-yu
8bb1c791f5 mask input options and sampling options (#252)
* part of #80, support mask input options

* close #188 enhance sampling options
Use a more general sampling strategy interface to describe the
configuration of sampling events collection.

Implemented mousmove, mouse interaction, scroll and input sampling
strategy.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
9e3e590935 add iframe tests and update urls in test file 2026-04-01 12:00:00 +08:00
Eoghan Murray
5b0539419c Restore functioning of #200 - this got broken after #242 (#246)
- What was broken was that it would just play activity from the first page view, but then would stop at the second page view (meta) as actions after that had been discarded
 - This restores the functionality given by the comment 'return the events from last meta to the end.' - we never want to discard events that are after the baseline time
 - I believe 'session' is the incorrect terminology for this function name, as a session in web analytics usually means a series of page views
2026-04-01 12:00:00 +08:00
Yanzhen Yu
51737d9b53 try to inline linked stylesheet when in same origin 2026-04-01 12:00:00 +08:00
yz-yu
a8b493799b fix the skip event calculation (#242) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
7fadc986ec refactor the test infra: use puppeteer instead of jsdom to get rid of some hack implementations 2026-04-01 12:00:00 +08:00
Yanzhen Yu
ae71cf106a tweak the code of getting last session, without splice events array 2026-04-01 12:00:00 +08:00
Yanzhen Yu
0e35b86d87 refactor test infra so most test cases could be implemented by pure HTML 2026-04-01 12:00:00 +08:00
Yanzhen Yu
19acba745a fast-forward implementation v1
related to #6

Since the currently 'play at any time offset' implementation is pretty simple,
there are many things we can do to optimize its performance.

In this patch, we do the following optimizations:
1. Ignore some of the events during fast forward.
   For example, when we are going to fast forward to 10 minutes later,
   we do not need to perform mouse movement events during this period.
2. Use a fragment element as the 'virtual parent node'.
   So newly added DOM nodes will be appended to this fragment node,
   and finally being appended into the document as a batch operation.
These changes reduce a lot of time which was spent on reflow/repaint previously.
I've seen a 10 times performance improvement within these approaches.

And there are still some things we can do better but not in this patch.
1. We can build a virtual DOM tree to store the mutations of DOM.
   This will minimize the number of DOM operations.
2. Another thing that may help UX is to make the fast forward process async and cancellable.
   This may make the drag and drop interactions in the player's UI looks smooth.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
e9cf631934 replace script tag with noscript and inline the states of form field components 2026-04-01 12:00:00 +08:00
Eoghan Murray
c19aaa7ec0 Only execute events since most recent pageload when playing from an offset (#200)
On recordings with many full pageloads, dom state and mutations were being applied only to be discarded when a new pageload came in, resulting in very slow time to rebuild - and inability to interactively 'scrub' through these recordings
2026-04-01 12:00:00 +08:00
Yanzhen Yu
ed2bc918e0 setup tests 2026-04-01 12:00:00 +08:00
Eoghan Murray
753ee25832 Expose startTime and endTime in the getMetaData() call. I was using player.events[0].timestamp but player.events has gone away (since a78da77 I believe) (#235) 2026-04-01 12:00:00 +08:00