Commit Graph

303 Commits

Author SHA1 Message Date
Yanzhen Yu
6ba84ee5d0 Release 0.9.1 2026-04-01 12:00:00 +08:00
Yanzhen Yu
f83f4e7b13 close #161 support "addEvent" in any state 2026-04-01 12:00:00 +08:00
Yanzhen Yu
cd5720644f close #300 upgrade rrweb-snapshot 2026-04-01 12:00:00 +08:00
Yanzhen Yu
51863e9ce8 close #215 catch delete rule errors 2026-04-01 12:00:00 +08:00
Yanzhen Yu
dc782096cb close #319 handle undefined nextId
Looks like some serializer will omit field with null value, so we
do some checks in the replayer to avoid of dead loop.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
0dff4e13fa close #320 use emitter handler to catch before load state 2026-04-01 12:00:00 +08:00
Yanzhen Yu
4bf7bb9bb1 close #303 use a fork version of smooth scroll polyfill
The forked version support customize target window and document,
so we can polyfill it to the iframe.
2026-04-01 12:00:00 +08:00
Yanzhen Yu
04a5dfceef catch unexpected errors during replay media interactions 2026-04-01 12:00:00 +08:00
Justin Halsall
1cec65f565 Only trigger waitForStylesheetLoad if not seeking (#326) 2026-04-01 12:00:00 +08:00
Justin Halsall
d15f4ce8ff Update lastPlayedEvent in live mode (#327)
* Update lastPlayedEvent in live mode

* tricking travis-ci into running again
2026-04-01 12:00:00 +08:00
Justin Halsall
6ebfe69363 Fix live mode (#310)
* add failing test

* paused -> live now possible
2026-04-01 12:00:00 +08:00
yz-yu
6fad7f642c record canvas mutations (#296)
* record canvas mutations

close #60, #261

This patch implements the canvas mutation observer.
It consists of both the record and the replay side changes.

In the record side, we add a `recordCanvas` flag to indicate
whether to record canvas elements and the flag defaults to false.
Different from our other observers, the canvas observer was
disabled by default. Because some applications with heavy canvas
usage may emit a lot of data as canvas changed, especially the
scenarios that use a lot of `drawImage` API.
So the behavior should be audited by users and only record canvas
when the flag was set to true.

In the replay side, we add a `UNSAFE_replayCanvas` flag to indicate
whether to replay canvas mutations.
Similar to the `recordCanvas` flag, `UNSAFE_replayCanvas` defaults
to false. But unlike the record canvas implementation is stable and
safe, the replay canvas implementation is UNSAFE.
It's unsafe because we need to add `allow-scripts` to the replay
sandbox, which may cause some unexpected script execution. Currently,
users should be aware of this implementation detail and enable this
feature carefully.

* update canvas integration test
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
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
e1c0631eeb Release 0.9.0 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
9d686d4302 remove the internal use of resume API 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
a31efdc169 close #274 implement the new state management proposal 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
fc66a7eb79 Release 0.8.5 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
cf272f65ef Release 0.8.4 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
6c87b03e0d close #240 fix block class to handle text node changes 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
e056f1ae88 add the patch function to utils 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
520ddf3a4f close #244 pass fullsnapshot event to the callback 2026-04-01 12:00:00 +08:00
Yanzhen Yu
50406c27ee fix unit tests 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
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
yz-yu
a8b493799b fix the skip event calculation (#242) 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
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
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
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
Eoghan Murray
7d7def23d1 Ensure api method .play() can be called by external code without worrying about the internal state of the finite state machine (#236) 2026-04-01 12:00:00 +08:00
Jin
dacaf57b0e :Update guide.zh_CN.md (#238)
Co-authored-by: jinwentao <jinwentao@huya.com>
2026-04-01 12:00:00 +08:00
slimlime
d83501d896 📚 Quick typo check. Update replay.md (#237)
Precise typo check of inprecise -> imprecise
2026-04-01 12:00:00 +08:00
Jeff Loiselle
730aafa5bd Update observer.md (#233) 2026-04-01 12:00:00 +08:00
Yanzhen Yu
d7086b50e8 add sponsor info 2026-04-01 12:00:00 +08:00
yz-yu
36e2a67191 Create FUNDING.yml 2026-04-01 12:00:00 +08:00
Yanzhen Yu
9c7e00a6b1 Release 0.8.2 2026-04-01 12:00:00 +08:00
Yanzhen Yu
9a5873005f hotfix: fix es module entry path 2026-04-01 12:00:00 +08:00
Yanzhen Yu
90a42a31da Release 0.8.1 2026-04-01 12:00:00 +08:00
Yanzhen Yu
42a205e4c5 update typings entry 2026-04-01 12:00:00 +08:00
Yanzhen Yu
ccb2dd0562 Release 0.8.0 2026-04-01 12:00:00 +08:00
Yanzhen Yu
191908aa1d continue #199: redesign the bundled file structure
According to @eoghanmurray's suggestion, we can support three
main scenarios:
1. record only
2. replay only
3. all in one

Since we have implemented the packer feature, which has a big
influence in bundle size, we provide another three bundles:
1. record and pack
2. replay and unpack
3. all in one with pack and unpack
2026-04-01 12:00:00 +08:00
Yanzhen Yu
81b3407dd7 export utils as public API 2026-04-01 12:00:00 +08:00