Commit Graph

52 Commits

Author SHA1 Message Date
yz-yu
5fc6c193fd plugin API (#598)
* temp: plugin API

* fix a bug in the replay handler and rename some type names.

* update integration test

* improve plugin types and handle legacy log data

* use different naming in record and replay bundles

* delete unreferenced types

Co-authored-by: Lucky Feng <294889365@qq.com>
2021-06-28 00:09:09 +08:00
Justin Halsall
fee48f084c Add ability to mask passwords (#494)
* add ability to mask passwords

* remove duplicate mask snapshot

* make sure only one click happens at a time
2021-06-22 19:47:30 +08:00
Justin Halsall
8a9212fed4 Tests: Iframe event order (#568)
* add failing test

* assert order of events

* defer attaching of iframe till FullSnapshot is done
Fixes: https://github.com/rrweb-io/rrweb/issues/567

* correct event order in iframe integration test snapshot

* trigger build

* trigger build

* Move settimeout responsibility to snapshot
https://github.com/rrweb-io/rrweb-snapshot/pull/78

* upgrade rrweb-snapshot to 1.1.4

* DRY record tests

* cleanup

* Upgrade puppeteer to 9.1.1
for (hopefully) more consistent behaviour between CI and development

* make input bigger to prevent triggering scroll events

* page.waitFor is deprecated
more info: https://github.com/puppeteer/puppeteer/issues/6214

* Set os and distro for Travis ci

Co-authored-by: yz-yu <yanzhen@smartx.com>
2021-06-17 21:02:42 +08:00
Yanzhen Yu
1062770e20 shadow DOM recording GA
1. record shadow DOM event target by parsing composed path
2. nested record scroll event in shadow DOM
2021-06-10 19:26:00 +08:00
Yanzhen Yu
995d80a26f create mirror during record 2021-05-25 23:37:07 +08:00
re-fort
18ad3dae1a Add options to mask texts (#540)
* feat: add options to mask texts

* feat: add the default mask function

* refactor: rename options to identify the difference between  mask text and mask input

* test: add tests about masking

* doc: add options about masking

* chore: bump up rrweb-snapshot version
2021-04-22 16:03:52 +08:00
Yanzhen Yu
df7537b01d impl shadow DOM manager
part of #38
1. observe DOM mutations in shadow DOM
2. rebuild DOM mutations in shadow DOM
2021-03-28 18:16:54 +08:00
Yanzhen Yu
2e723a2010 impl #507 export takeFullSnapshot as a public API 2021-03-08 13:30:54 +08:00
Yanzhen Yu
860ff38e90 close #501 do not count attach iframe event in checkout 2021-02-27 13:32:21 +08:00
yz-yu
f3d7fa3451 Impl record iframe (#481)
* Impl record iframe

* iframe observe

* temp: add bundle file to git

* update bundle

* update with pick

* update bundle

* fix fragment map remove

* feat: add an option to determine whether to pause CSS animation when playback is paused (#428)

set pauseAnimation to true by default

* fix: elements would lose some states like scroll position because of "virtual parent" optimization (#427)

* fix: elements would lose some state like scroll position because of "virtual parent" optimization

* refactor: the bugfix code

bug: elements would lose some state like scroll position because of "virtual parent" optimization

* fix: an error occured at applyMutation(remove nodes part)

error message:
Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node

* pick fixes

* revert ignore file

* re-impl iframe record

* re-impl iframe replay

* code housekeeping

* move multi layer dimension calculation to replay side

* update test cases

* teardown test server

* upgrade rrweb-snapshot with iframe load timeout

Co-authored-by: Lucky Feng <yun.feng@smartx.com>
2021-02-10 21:44:25 +08:00
Eoghan Murray
9187bec814 Discovered that the common case of mouse movement or scrolling happening during takeFullSnapshot was causing mutations to be immediately emitted, contrary to the goal of https://github.com/rrweb-io/rrweb/pull/385 (#470) 2021-01-31 21:43:36 +08:00
Lucky Feng
4e7146e72b feat: enable rrweb to record and replay log messages in console (#424)
* wip: working on rrweb logger

* wip: can record and replay some simple log

* wip: can record and replay log's stack

* wip: try to serialize object

* wip: record and replay console logger

hijack all of the console functions.
add listener to thrown errors

* wip: record and replay console logger
add limit to the max number of log records

* feat: enable rrweb to record and replay log messages in console

this is the implementation of new feature request(issue #234)

here are a few points of description.
1. users need to set recordLog option in rrweb.record's parameter to record log messages.  The log recorder is off by default.
2. support recording and replaying all kinds of console functions. But the reliability of them should be tested more
3. the stringify function in  stringify.ts needs improvement. e.g. robustness, handler for cyclical structures and better support for more kinds of object
4. we can replay the log messages in a simulated html console like LogRocket by implementing the interface "ReplayLogger" in the future

* improve: the stringify function

1. handle cyclical structures
2. add stringify option to limit the length of result
3. handle function type

* refactor: simplify the type definition of ReplayLogger
2020-11-29 18:12:03 +08:00
Yanzhen Yu
23a1883dfc pick #286 allow short cut for slim DOM options 2020-11-29 14:54:05 +08:00
Yanzhen Yu
5a6acbd5f0 fix type error of slim DOM options 2020-11-29 14:26:39 +08:00
Yanzhen Yu
3d5f2e2719 pick #286, export slim DOM options 2020-11-29 14:19:25 +08:00
Yanzhen Yu
a42b6419c3 expose blockSelector as a public option 2020-11-29 13:59:25 +08:00
Yanzhen Yu
7d817be155 upgrade to rrweb-snapshot v1.0 2020-11-29 13:54:37 +08:00
Yaozu Lv
a2cd3e2da0 Add record option maskInputFn for custom mask input function (#409) 2020-11-15 16:39:17 +08:00
Yanzhen Yu
7d5d003325 upgrade rrweb-snapshot 2020-10-24 16:36:06 +08:00
Eoghan Murray
665567119d Suspend mutations during snapshot (#385)
* The `processMutations` function needed to be bound to the `mutationBuffer` object, as otherwise `this` referred to the `MutationObserver` object itself

* Enable external pausing of mutation buffer emissions

 - no automatic pausing based on e.g. pageVisibility yet, assuming such a thing is desirable
   https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
 - user code has to call new API method `freezePage` e.g. when page is hidden or after a timeout
 - automatically unpauses when the next user initiated event occurs
   (am assuming everything that isn't a mutation event counts as 'user initiated'
   either way think this is the correct thing to do until I see a counterexample
   of an event that shouldn't cause the mutations to be unbufferred)

* Avoid a build up of duplicate `adds` by delaying pushing to adds until emission time

* Need to export freezePage in order to use it from rrweb.min.js

* Add a test to check if mutations can be turned off with the `freezePage` method

* I noticed out of order ids (in terms of a DOM walk) in a FullSnapshot.  A DOM mutation was executed against the mirror asynchronously before it could be fully processed. This would lead to a situation in replay where a mutation is executed against a DOM tree that already has the mutation applied. This changeset fixes that by freezing any mutations until the snapshot is completed.

* Remove attribute modifications from a mutation event that were incorrect in that they were repeating the attributes of those nodes present in the 'adds' array of the same mutation

* I've manually verified that this empty text node is actually removed when the dropdown is opened:

document.getElementById('select2-results-1').childNodes
NodeList(2) [li.select2-results-dept-0.select2-result.select2-result-selectable.select2-highlighted, li.select2-results-dept-0.select2-result.select2-result-selectable]

and also that it is not reinstated after the second `await page.click('.select2-container');`

* Rearrange when removal happens in order to satisfy tests. I'm also reverting a recent test change (2600fe7) so that tests pass after this rearrangement; I believe that test change to still be the correct way of doing it, but maybe it is not strictly important that there are extra mutations on attributes of just added nodes

* As mutations are now paused during FullSnapshots, we shouldn't be counting this as a 'user emission'. We automatically emit mutations after unpause anyway ('emit anything queued up now')

* Ensure that we clear arrays before emitting, as the mutation could have the side effect of triggering a FullSnapshot (checkoutEveryNth), which would otherwise re-trigger emission of same mutation (through the new pause/fullsnapshot/mutationemit/unpause process)

* Don't let the programattic pausing during TakeFullSnapshot accidentally unpause a manual call to the API method `freezePage`

* Rename paused -> frozen for consistency and change to use getter/setter access methods
2020-10-04 20:54:10 +08:00
Yanzhen Yu
2440701926 impl #309 observe font face set changes 2020-09-17 02:11:34 +08:00
yz-yu
772c0e021a 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
2020-08-22 16:44:02 +08:00
yz-yu
7de7eb5e54 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.
2020-07-18 15:05:19 +08:00
Yanzhen Yu
f159d7711f upgrade TS 2020-04-12 00:06:57 +08:00
Eoghan Murray
1bb7ffd8fc Fix for certain websites which don't scroll on their document.documentElement (#193)
- document.documentElement.scrollTop may be zero, but document.body.scrollTop may have the actual scrolling amount
 - main fallback idea taken from https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX
 - modified as `(document.documentElement || document.body).scrollTop` will incorrectly report zero.
 - version here supported by https://github.com/mochi/mochikit/blob/master/MochiKit/Position.js#L23
2020-04-11 23:15:10 +08:00
yz-yu
4f36d0e57d Packer (#172)
* introduce pako and add general packer interface

* add tests for packer

* use function API instead of class API for better tree shaking support

* refcatoring the rollup bundle config
2020-04-07 18:03:47 +08:00
David Cramer
046936b3e8 Add observers for stylesheet mutations (#177)
* hack together stylesheet observer

* Add test coverage for insertRule/deleteRule on stylesheets

* Add new observers

* update patch based on changes to master

* Functioning event recording

* Remove print statements

* Fix ID usage and mark add vs remove

* Correct type

Co-authored-by: Jon Perl <perl.jonathan@gmail.com>
2020-02-22 12:59:55 +08:00
Yanzhen Yu
abfb90a778 impl media interactions recording
close #159
close #72
listen to HTMLMediaElement's play/pause events, and replay them
by programmatically play and pause the target element.
2020-01-12 21:37:01 +08:00
mpstv
6a5d0610b7 Try add configurable threshold for events throttling (#147) 2019-11-16 21:25:34 +08:00
yz-yu
b64e1492ab add hooks API (#132) 2019-09-17 23:33:38 +08:00
Yanzhen Yu
487165791a re-add addCustomEvent function via function property 2019-08-12 21:52:24 +08:00
Yanzhen Yu
3beb57273e Revert "temp revert #81"
This reverts commit 835161c737.
2019-08-12 21:26:35 +08:00
Yanzhen Yu
835161c737 temp revert #81
This patch introduce a breaking change in rrweb-record's API, so
we will revert it in 0.7.x and release it in 0.8.
2019-08-12 21:21:53 +08:00
Yanzhen Yu
3269089e1f fix#110 add NodeList forEach polyfill 2019-08-07 23:51:40 +08:00
Yanzhen Yu
56c025fde3 close #84 set mousemoveData's source by event source 2019-08-04 15:06:06 +08:00
Yanzhen Yu
f78070a824 impl #81 custom event
This is the record side impl of custom event, according to the
issue, we may also add first-class support for the custom event
tag like display color labels in the replayer-ui.
2019-07-24 22:32:11 +08:00
Yanzhen Yu
52ec5d435b pass mask input option to snapshot 2019-06-15 14:45:42 +08:00
Sebastian Jakob
189df87b9d Option to mask inputs (#80)
* Option to mask inputs

Added option 'maskAllInputs' to replace all user inputs with an Asterisk.

* Update types.d.ts
2019-06-15 12:52:08 +08:00
Yanzhen Yu
107296eee3 add the inline stylesheet option when recording 2019-05-12 21:10:34 +08:00
Yanzhen Yu
c04e4bf0a5 impl #23 add custom privacy selectors 2019-04-02 00:25:08 +08:00
yz-yu
cedc87c69e add checkout config to recorder (#36)
* add checkout config to recorder

* add test cases for checkout feature and extract assertSnapshot method
2019-01-11 10:52:04 +08:00
Yanzhen Yu
78967192fc return stopper function as the result of record 2018-12-02 22:37:28 +08:00
Yanzhen Yu
eab30bd274 improve prevent default event when replay 2018-11-23 18:06:19 +08:00
Yanzhen Yu
a88a79d821 add meta event and fix childList observer, also update related replayer 2018-10-22 10:48:56 +08:00
Yanzhen Yu
49cd7b4db3 align id map by skip extra added nodes 2018-10-16 15:29:52 +08:00
Yanzhen Yu
85a56d2047 fix scroll value and record viewport when loaded 2018-10-12 13:08:03 +08:00
Yanzhen Yu
c07cce74bf improve record method and bump 0.2.0 2018-10-11 17:30:54 +08:00
Yanzhen Yu
40f29e5353 add input event observer and hook the value setter 2018-10-11 16:12:32 +08:00
Yanzhen Yu
1f10b70d30 add scroll and viewport resize observers 2018-10-09 10:33:24 +08:00
Yanzhen Yu
64d4c541ee add mouse interactions observer 2018-10-08 18:37:40 +08:00