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: Allow for masking of attributes #1257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

billyvg
Copy link
Contributor

@billyvg billyvg commented Jul 12, 2023

Note: this is more of an RFC
Ideally this would allow users to be able to mask attributes of DOM nodes. An example of this is placeholder which can be a bit suspicious to our users when our default state is that everything is masked.

This currently adds a new API, maskAttributesFn: (key: string, value: string, el: HTMLElement) => string, that is used as a callback in transformAttribute. I prefer this API as it gives more flexibility for users (though it may need to pass the el node for most flexibility), but it is a bit inconsistent with maskTextFn and maskInputFn.

other options:

* Rename this to something else (open to ideas)

  • Change this to pass value, and dom element (similar to MaskInputFn) to customize masking instead of decision maker of when to mask and introduce a simpler declarative API for what attributes to mask
    * ???

@changeset-bot
Copy link

changeset-bot bot commented Jul 12, 2023

🦋 Changeset detected

Latest commit: 7481949

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

This PR includes changesets to release 8 packages
Name Type
rrweb-snapshot Patch
rrweb 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

@billyvg billyvg marked this pull request as ready for review July 17, 2023 23:03
@billyvg billyvg force-pushed the feat-add-custom-attribute-transform-mask branch from 1baa127 to b9e2abe Compare July 17, 2023 23:08
@billyvg billyvg changed the title feat: Allow for masking of attributes [WIP] feat: Allow for masking of attributes Jul 18, 2023
This currently adds a new API, `maskAttributesFn: (key: string, value: string, element: HTMLElement) => string`, that is used as a callback in `transformAttribute`. I prefer this API as it gives more flexibility for users (though it may need to pass the el node for most flexibility), but it is inconsistent with `maskTextFn` and `maskInputFn`.

other options:

* Rename this to something else (open to ideas)
* Change this to pass value, and dom element (similar to MaskInputFn) to customize masking instead of decision maker of when to mask and introduce a simpler declarative API for what attributes to mask
* ???
@billyvg billyvg force-pushed the feat-add-custom-attribute-transform-mask branch from b9e2abe to 7481949 Compare July 18, 2023 13:56
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>
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>
@colingm
Copy link
Contributor

colingm commented Dec 7, 2023

Just wanted to say that it is awesome to see this, we were going to be bringing up attribute masking from Pendo pretty soon anyways 😅

So in your solution you opt for just always calling the maskAttributeFn instead of having another option that specifies a list of attributes to mask (that could take a wildcard or something) and then only call the function on those particular attributes. Would an option like that provide much performance benefit? I guess it means we would save calling to the function on elements that never even have the attribute in the first place.

Another thought would be if we don't want a list of attributes as an option would it instead be better to just call the maskAttributeFn once per element and then let the function decide to mask multiple attributes all at once?

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>
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.

2 participants