rrweb-io / rrweb

record and replay the web
https://www.rrweb.io/
MIT License
16.83k stars 1.43k forks source link

[Feature Request]: ability to mask attributes #1581

Open pauldambra opened 1 month ago

pauldambra commented 1 month ago

Preflight Checklist

What package is this feature request for?

rrweb

Problem Description

see https://posthog.com/questions/scrubbing-html-attributes-from-dom-in-session-recordings

where a customer asks us for the ability to mask the content of an element's attribute - in that case aria-label might contain PII and they'd like to ensure it isn't captured

we can mask an element's text or an input's value

i believe it isn't possible to mask an element's attribute

Proposed Solution

addition of a function maskElement(element: Element) => Element | null

this would run ahead of other processing of a node and let you carry out arbitrary masking for this case you could iterate and mask attributes in practice it lets you carry out arbitrary alteration of the element

Alternatives Considered

if arbitrary alterations of the captured element are undesirable

then add a maskAttributes(attributes: SomeType[]) => SomeType[] | null

Additional Information

No response