rrweb
rrweb copied to clipboard
feat: Allow for masking of attributes
~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 detected
Latest commit: 74819490049a975272031ba074ced48ed31a7042
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
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?