Commit Graph

1224 Commits

Author SHA1 Message Date
Eoghan Murray
46f1b252a5 Fix and test for bug #1457 (#1481)
* Fix and test for bug #1457 (Uncaught SyntaxError: Regular expression too large)

 - see test case which is extracted from a real world css file; the selector regex was able to traverse the curly brace as when looking for quotes, it wasn't taking into account that the start quote could be escaped

* Apply formatting changes

* Create fair-ducks-clean.md

* Fix @import regex bit which was stopping consumption in the middle of a url - need to consume quotes.

Thanks dave.kindel@pendo.io for reporting and isolating this case

---------

Co-authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
2024-05-22 13:07:55 +01:00
Colin Maxfield
03b5216a94 Replace Array.from with clean implementation (#1464)
This work is to try to provide support where rrweb might be included
in applications with various tools that might override Array.from
so that the 2nd parameter (the map function) will always work for
rrweb.

Co-authored-by: Michael Dellanoce <mdellanoce@pendo.io>
2024-05-17 17:32:02 +02:00
Eoghan Murray
cbbd1e55f1 Fixup for background-clip replacement (#1476)
* Fix that the `.replace()` function only replaces the first occurrence

* This should have been included in #1174

* Create fast-pets-exist.md
2024-05-17 17:28:37 +02:00
Eoghan Murray
26c331b3b7 yarn format - prettier improvements & add .editorconfig (#1471)
Some dev improvements:
* Add .editorconfig config file https://editorconfig.org/
* move the singleQuote spec into .editorconfig and add old .changesets/*.md to .prettierignore so that we don't incorrectly reformat new changeset files to single quote from the double quote which they can be autogenerated with in github
* .gitignore Ignore emacs chaff files
* Add `yarn format:head` a convenience command to run prettier against just those files in the head commit
* Some mention of `yarn format` in the docs
* Fix some test html closing tags; authoring mistakes, rather than deliberately malformed html — picked up by an explicit `yarn prettier --write '**/*.html'`
2024-05-13 11:53:08 +01:00
Eoghan Murray
e96f668c86 Fix that blob urls persist on the shared anchor element and can't be later modified (#1467)
* Fix that blob urls persist on the shared anchor element and can't be later modified

* Create nervous-kiwis-nail.md
2024-05-03 13:20:20 +02:00
Vinicius Lourenço
5e7943dbae perf(snapshot): avoid recreate element a every time (#1387)
perf(snapshot): avoid costly generation of <a> element on each call to `getHref`, instead cache an anchor element and reuse it's href attributed

---------

Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
2024-05-02 13:44:58 +01:00
Eoghan Murray
f1e6a51dc6 Ensure there is separation of timestamps (#1455)
* Ensure there is separation of timestamps so mutations can be evaluated separately - was failing in the github build process probably due to higher perf

* Remove space from test file

* Create curvy-balloons-brake.md

---------

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2024-05-01 17:14:05 +02:00
Eoghan Murray
ae6908dcdc perf: Avoid an extra function call and object clone during event emission (#1441)
performance: remove a nested function call and an object clone during event emission

 - rename `event` to `eventWithoutTime`, but maintain backwards compatibility
 - `eventWithTime` (with time) could be renamed to `event` in a future version

This is an extension of PR #1339 authored by: mydea <mydea@users.noreply.github.com>
2024-04-19 12:50:06 +01:00
David Newell
c0f83afab8 better splitting of selectors (#1440)
* better splitting of selectors - overlapping with #1401 
* Add test from example at https://github.com/PostHog/posthog/pull/21427
* ignore brackets inside selector strings
* Add another test as noticed that it's possible to escape strings
* Ensure we are ignoring commas within strings

Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
2024-04-18 23:46:17 +01:00
github-actions[bot]
bee92c8291 Version Packages (alpha) (#1436)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-18 16:21:24 +02:00
Stefan Sundin
c278d068a0 Add "types" field to fix error when using "moduleResolution": "NodeNext" (#1369)
* Add "types" field to fix error when using "moduleResolution": "NodeNext".

* Add changeset.
2024-04-18 11:42:28 +02:00
Daniel Engelke
f7c6973ae9 Fix for test cases mentioned in #1379 (#1401)
* Fix known issues

* Run format

* Fix linting errors

* Add comment in code for source of match logic

* Add changeset
2024-04-18 10:50:20 +02:00
Justin Halsall
123a81e12d Full overhawl of video & audio playback to make it more complete (#1432)
* Add support for capturing media attributes in rrweb-snapshot

* Add loop to mediaInteractionParam

* Add support for loop in RRMediaElement

* Add support for recording loop attribute on media elements

* Update video playback and fix bugs

* Update cross-origin iframe media attributes and player state
2024-04-17 15:49:23 +02:00
Eoghan Murray
eba5473770 I forgot to pay attention to yarn format during merge of #1408 (#1452) 2024-04-17 14:20:20 +01:00
Antonio Villegas
729361e66b Expose constant SKIP_TIME_THRESHOLD as inactivePeriodThreshold in replayer (#1408)
Expose constant SKIP_TIME_THRESHOLD as `inactivePeriodThreshold` config setting in replayer
2024-04-11 11:20:24 +01:00
David Newell
02f50d260c protect against no parent node (#1445)
* protect against a missing parent node during a mutation on an textNode
2024-04-10 16:46:06 +01:00
Manoel Aranda Neto
3d1877cff8 fix: createImageBitmap throws DOMException if source is 0 (#1422)
* fix: createImageBitmap throws DOMException if source is 0

* code review

* fix

* Create breezy-cats-heal.md

* fix format

---------

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2024-04-05 14:24:25 +02:00
Justin Halsall
e223399c7c Chore: Make inject script more robust on repl & stream (#1429)
* try/catch injection of recording script in rrweb repl and stream

* Add empty changesets
2024-04-05 12:15:14 +02:00
github-actions[bot]
104900263a Version Packages (alpha) (#1291)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-04 16:29:26 +02:00
Daniel Engelke
5e6a0be3a1 Add HowdyGo to Who's using rrweb (#1423)
* Add HowdyGo to Who's using rrweb

* Create twenty-goats-kneel.md

---------

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2024-03-26 17:11:04 +01:00
Eoghan Murray
a7c33f2093 Fix some css issues with :hover and rewrite max-device-width (#1431)
* We weren't recursing into media queries (or @supports etc.) to rewrite hover pseudoclasses

* The early return meant that the stylesWithHoverClass cache wasn't being populated if there were no hover selectors on the stylesheet

 - not committing the test, but modifying the existing 'add a hover class to a previously processed css string' as follows shows the problem:

--- a/packages/rrweb-snapshot/test/rebuild.test.ts
+++ b/packages/rrweb-snapshot/test/rebuild.test.ts
@@ -151,6 +185,7 @@ describe('rebuild', function () {
         path.resolve(__dirname, './css/benchmark.css'),
         'utf8',
       );
+      cssText = cssText.replace(/:hover/g, '');

       const start = process.hrtime();
       addHoverClass(cssText, cache);

* Replace `min-device-width` and similar with `min-width` as the former looks out at the browser viewport whereas we need it to look at the replayer iframe viewport

* Add some tests to show how the hover replacement works against selector lists. I believe these were failing in a previous version of rrweb as I had some local patches that no longer seem to be needed to handle these cases

* Update name of function to reflect that 'addHoverClass' does more than just :hover. I believe this function is only exported for the purposes of use in the tests

* Apply formatting changes

* Create rotten-spies-enjoy.md

* Apply formatting changes

* Add correct typing on `getSelectors`

* Refactor CSS interfaces to include optional rules

* Change `rules` to be non optional

---------

Co-authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2024-03-26 16:44:43 +01:00
juliecheng
e607e83b21 fix: scrolling can be incorrect when fast-forwarding (#1352)
* fix: scrolling can be incorrect when fast-forwarding

* add test case

* add changeset and remove duplicate diffProps process

---------

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2024-02-28 03:29:05 +08:00
xujiujiu
cc6c6874ca fix guide doc (#1415) 2024-02-23 18:21:49 +08:00
Andrew Pomeroy
314a8dde5a Capture stylesheets designated as rel="preload" (#1374)
* feat(Snapshot): Capture stylesheets designated as `rel="preload"`

* fix(Snapshot): Harden asset file extension matching

* Add changeset

* chore: Lint

* Tweak regex, add try-catch block on URL constructor
2024-02-12 18:19:17 +01:00
Antonio Villegas
5844f60fd8 Make properties x and y optional in mouseInteractionParam (#1375)
* Make properties x and y optional in mouseInteractionParam

The event representing a mouse interaction of focus an element does not include the properties x and y. Thus, they must be defined as optional.

* Fix typings
2024-02-10 09:12:56 +08:00
yz-yu
fc2feee60a fix the test CI (#1405)
* run tests without concurrency

* do not use cache in rpt2 during test
2024-01-28 14:13:14 +08:00
Patrick Lopes
ce8da12d56 Rrvideo receipe update (#1390)
* Update export-to-video.md

The file was pointing to the old Rrvideo repo The old repository soon is going to be closed as the Rrvideo was merged on Rrweb This change is pointing this recipe to the new and updated official doc.

* Update export-to-video.zh_CN.md

The file was pointing to the old Rrvideo repo The old repository soon is going to be closed as the Rrvideo was merged on Rrweb This change is pointing this recipe to the new and updated official doc.

Chinese version
2024-01-26 17:44:08 +08:00
Paul D'Ambra
af0962cc6c fix: console logger can serialize bigint values (#1403)
* fix: console logger can serialize bigint values

* teach test jsdom is present

* add a changeset
2024-01-25 16:55:52 +01:00
David Newell
1e0b273822 chore: export canvasMutation (#1383)
* chore: export canvasMutation

* add changeset
2024-01-22 16:32:32 +01:00
Justin Halsall
b2460a4991 Docs: Add rrweb presentation + open to consulting (#1388)
* Add rrweb presentation

Add Justin Halsall open to rrweb consulting

* Create few-rockets-travel.md

* Update README.md

* Update README.md

* Fix alignment
2024-01-05 12:20:10 +01:00
Buleandra Cristian
8aaca89234 Add UXWizz to Readme (#1371)
* Add UXWizz to Readme (CN)

* Add UXWizz to Readme

* Create hip-worms-relax.md

---------

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-12-11 14:09:18 +01:00
Justin Halsall
8e318c44f2 [chore] [ci] Update Node version to LTS (#1365)
* Update Node version to LTS

* Create silver-windows-float.md
2023-12-04 17:38:28 +01:00
Justin Halsall
dc52b38cad [chore] Update changesets (#1362) 2023-12-04 14:11:00 +01:00
huangkairan
0f004af18d perf(web-extension): conditional check (#1360)
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2023-12-04 21:45:53 +11:00
Paul D'Ambra
59208ad0f5 chore: update linters (#1355)
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-12-04 16:40:05 +11:00
Eoghan Murray
a2be77b828 Fix serialization and mutation of <textarea> elements (#1351)
* Fix serialization and mutation of <textarea> elements taking account the duality that the value can be set in either the child node, or in the value _parameter_ (not attribute)

* Backwards compatibility: Bug fix and regression test for #112
 - this is to fix up 'historical' recordings, as duplicate textarea content should no longer be being created at record time
 - new test shows what the snapshot generated by previous versions of rrweb used to look like, hence 'bad'
 - original 0efe23f04a fix either didn't work or no longer works due to childNodes being appended subsequent to this part of the code
 - during review, we also verified that the `_cssText` case should still be handled okay, as there's currently no scenario where csstext is present with css child nodes of a <style>

* Masking: Fix that textarea values were being missed by the masking system if the value was recorded as a child node
 - I didn't notice that form.html was used in other tests, so lucky that I noticed that those tests also should have the 'pre value' masked out

* Simplify by always storing the textarea value in the `.value` attribute (from it's DOM property) and not as a childNode. It should still be rebuilt as a childNode rather than a property
---------

Authored-by: eoghanmurray <eoghan@getthere.ie>
2023-12-01 13:18:58 +00:00
Eoghan Murray
07ac5c9e13 Masking: Avoid the repeated calls to closest when recursing through the DOM (#1349)
* masking performance: avoid the repeated calls to `closest` when recursing through the DOM
 - needsMask===true means that an ancestor has tested positively for masking, and so this node and all descendents should be masked
 - needsMask===false means that no ancestors have tested positively for masking, we should check each node encountered
 - needsMask===undefined means that we don't know whether ancestors are masked or not (e.g. after a mutation) and should look up the tree
* Add tests including an explicit characterData mutation tests 
* Further performance improvement: avoid calls to `el.matches` when on a leaf node, e.g. a `<br/>`
---------

Authored-by: eoghanmurray <eoghan@getthere.ie>
Based on initial PR #1338 by Alexey Babik <alexey.babik@noibu.com>
2023-11-24 16:06:02 +00:00
Yun Feng
8aea5b00a4 Feat: Add support for replaying :defined pseudo-class of custom elements (#1155)
* Feat: Add support for replaying :defined pseudo-class of custom elements

* add isCustom flag to serialized elements

Applying Justin's review suggestion

* fix code lint error

* add custom element event

* fix: tests (#1348)

* Update packages/rrweb/src/record/observer.ts

* Update packages/rrweb/src/record/observer.ts

---------

Co-authored-by: Nafees Nehar <nafees87n@gmail.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-11-07 15:26:13 +01:00
Eoghan Murray
dbd15a9492 Md create html document (#1321)
* only call createHTMLDocument where it is needed

* Perf: create the mutation document once as a 'singleton' as it can be reused

---------

Co-authored-by: Michael Dellanoce <mdellanoce@pendo.io>
2023-11-06 11:10:07 +01:00
Billy Vong
40f484d088 fix(web-extension): Fix types in vite config (#1333) 2023-11-04 09:23:49 +11:00
Lukas Boehler
5add06fd93 Added Gleap.io to "Who's using rrweb?" (#1332)
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-11-04 09:17:10 +11:00
huangkairan
9e65dda258 fix(web-extension): beforeunload logic (#1330) 2023-11-04 09:10:00 +11:00
Michael Dellanoce
05478c36dd perf(rrweb): attribute mutation optimization (#1343) 2023-11-04 09:03:59 +11:00
Francesco Novy
9c6edfe226 ref: Avoid unnecessary cloning of objects or arrays (#1340) 2023-11-03 12:09:21 +01:00
Justin Halsall
f362e7a84c Fix linting issues (#1347)
* Fix linting issues

* Apply formatting changes
2023-11-03 11:40:54 +01:00
蟹老板
1fe39ab0db Pref: export eventWithTime (#1324)
*  export eventWithTime for consumption in typescript code
2023-10-31 17:20:25 +00:00
huangkairan
8444cb2dad 🐞 fix(web-extension): typo (#1307)
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2023-10-20 14:10:21 +11:00
Francesco Novy
57a940afac fix: Fix checking for patchTarget in initAdoptedStyleSheetObserver (#1327) 2023-10-13 22:05:26 +11:00
Ben White
7c0dc9dfe1 Extended text masking function to include relevant HTMLElement (#1310)
* Extends maskTextFn to pass the HTMLElement to the deciding function

---------

Authored-by: benjackwhite <benjackwhite@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
2023-10-13 12:02:08 +01:00
Eoghan Murray
980a38c816 Add config option to turn off all snapshotting and related observers (#1311)
* Add config option to turn off all snapshotting and related observers

 - allows RRWEB to be used for click/movement tracking alone, e.g. for a heatmaps use case
 - could also be used if there was a separate process for recording the DOM (in which case a 3rd party library like https://github.com/antonmedv/finder could be added to record targets instead of the mirror)
---------

Authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-10-13 09:58:20 +01:00