Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add support for replaying :defined pseudo-class of custom elements #1155

Merged
merged 11 commits into from
Nov 7, 2023

Conversation

YunFeng0817
Copy link
Member

Some websites use :defined pseudo-class for custom elements, e.g. https://store.google.com/us/product/pixel_7?hl=en-US
In the previous implementation, we don't define any custom elements during the playback so all :defined styles are not applied.
In this pull request, I add the support for replaying :defined pseudo-class of custom elements.

Replayer before this PR:
image

Replayer after this PR:
image

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2023

🦋 Changeset detected

Latest commit: 8cb6266

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/types Patch
@rrweb/web-extension Patch
rrvideo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Juice10
Copy link
Contributor

Juice10 commented Feb 27, 2023

This is great @YunFeng0817! One thing I’m wondering is if CustomElementRegistry.define() was never called during recording time this might lead to unexpected behavior. Maybe we should monkeypatch CustomElementRegistry.define() to make sure these are accurately captured

@YunFeng0817
Copy link
Member Author

Good suggestion. Do you think it's OK to change the data structure SerializedElement to this

export type elementNode = {
  type: NodeType.Element;
  tagName: string;
  attributes: attributes;
  childNodes: serializedNodeWithId[];
  isSVG?: true;
  needBlock?: boolean;
  isCustom?: boolean; // determine whether this is a defined custom element
};

@Juice10
Copy link
Contributor

Juice10 commented Feb 27, 2023

@YunFeng0817 yes I think that works

Applying Justin's review suggestion
@Juice10
Copy link
Contributor

Juice10 commented Mar 2, 2023

@YunFeng0817 I think I've found another edge case for you that currently isn't handled by this PR

  • An element gets added to the dom eg. special-element (not yet :defined or isCustom
  • After a couple seconds CustomElementRegistry.define() gets called and special-element is officially defined, triggering :defined styles

Copy link
Contributor

@Juice10 Juice10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great! Thanks @YunFeng0817!

@Juice10
Copy link
Contributor

Juice10 commented Mar 5, 2023

Looks like you have a failing type check. When that's fixed feel free to merge this

@bruno-garcia
Copy link

Hey folks, any blockers to merging this? It does help! Sentry has cherry picked this fix into our fork.

billyvg added a commit to getsentry/rrweb that referenced this pull request Sep 21, 2023
Brings this library up to date w/ upstream. Includes additional commits for enhanced privacy and Sentry release workflows.

Cherry picks include the following upstream PRs:

* rrweb-io#1096
* rrweb-io#1155
* rrweb-io#1257
* rrweb-io#1262


Cherry picks from getsentry fork:
* #70
* #103
*
064d8c4
*
e274f88
*
cffefa2
* #20

---------

Co-authored-by: Michael Dellanoce <mdellanoce@pendo.io>
Co-authored-by: mdellanoce <mdellanoce@users.noreply.github.com>
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
@nafees87n
Copy link
Contributor

Any blockers to this PR? We really need this fix

billyvg added a commit to getsentry/rrweb that referenced this pull request Oct 20, 2023
Brings this library up to date w/ upstream. Includes additional commits for enhanced privacy and Sentry release workflows.

Cherry picks include the following upstream PRs:

* rrweb-io#1096
* rrweb-io#1155
* rrweb-io#1257
* rrweb-io#1262

Cherry picks from getsentry fork:
* #70
* #103
*
064d8c4
*
e274f88
*
cffefa2
* #20

---------

Co-authored-by: Michael Dellanoce <mdellanoce@pendo.io>
Co-authored-by: mdellanoce <mdellanoce@users.noreply.github.com>
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
@Juice10 Juice10 merged commit 8aea5b0 into master Nov 7, 2023
11 checks passed
@Juice10 Juice10 deleted the defined-pseudo-class branch November 7, 2023 14:26
billyvg pushed a commit to getsentry/rrweb that referenced this pull request Dec 8, 2023
…nts (rrweb-io#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 (rrweb-io#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>
billyvg added a commit to getsentry/rrweb that referenced this pull request Jan 31, 2024
…stom elements (rrweb-io#1155) (#138)

cherry-picks rrweb-io#1155 which was
merged in our fork in #107 (prior
to rrweb-io#1155 being merged). This results in only 2 small stylistic changes.

Feat: Add support for replaying :defined pseudo-class of custom elements
rrweb-io#1155

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
Co-authored-by: Nafees Nehar <nafees87n@gmail.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
billyvg added a commit to getsentry/rrweb that referenced this pull request Apr 26, 2024
Brings this library up to date w/ upstream. Includes additional commits for enhanced privacy and Sentry release workflows.

Cherry picks include the following upstream PRs:

* rrweb-io#1096
* rrweb-io#1155
* rrweb-io#1257
* rrweb-io#1262

Cherry picks from getsentry fork:
* #70
* #103
*
064d8c4
*
e274f88
*
cffefa2
* #20

---------

Co-authored-by: Michael Dellanoce <mdellanoce@pendo.io>
Co-authored-by: mdellanoce <mdellanoce@users.noreply.github.com>
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
jxiwang pushed a commit to amplitude/rrweb that referenced this pull request Jul 31, 2024
…nts (rrweb-io#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 (rrweb-io#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants