Session Replay: maskAttributes isn't applied to nodes added after the first snapshot; please move off @amplitude/rrweb-record 2.0.0-alpha.40
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start with the MutationBuffer call in packages/rrweb/src/record/mutation.ts at the referenced lines, then run the provided jsdom reproduction with a node added after the first snapshot. Check the session replay package dependencies for the pinned @amplitude/rrweb-record, @amplitude/rrweb-types, and @amplitude/rrweb-plugin-console-record versions. Done means added-node title and aria-label values are masked and the alpha dependency or local patch is no longer required.
Written by the indexing model from the issue text.
Description
Expected Behavior
With privacyConfig.maskAttributes: ["title", "aria-label"], Session Replay masks those attributes on every recorded node, including nodes added after the first full snapshot.
Current Behavior
Only the first full snapshot gets masked. When a DOM mutation adds a node later, rrweb records its attributes as raw values. In a single-page app that's every page after the first, so a name shown in title or aria-label lands in the replay in plain text. We found member names this way in our own replays.
For added nodes, MutationBuffer passes maskTextFn and maskInputFn to serializeNodeWithId but leaves out maskAttributeFn:
@amplitude/rrweb-record 2.0.0-alpha.40, which @amplitude/[email protected] pins, has the gap. So does 2.1.4.
Possible Solution
- Add
maskAttributeFn: this.maskAttributeFnto thatserializeNodeWithIdcall. We ship this as apnpm patchfor now. - Move
@amplitude/session-replay-browseroff the exact2.0.0-alpha.40pin and onto the stable 2.1.x line of@amplitude/rrweb-record,@amplitude/rrweb-typesand@amplitude/rrweb-plugin-console-record, with the fix in. We'd rather not ship an alpha dependency or carry a patch.
Related: #2026. The plugin drops maskAttributes before it reaches the recorder.
Steps to Reproduce
import { record } from "@amplitude/rrweb-record";
const events: unknown[] = [];
record({
emit: (event) => events.push(event),
maskAttributeFn: (_key, value) => value.replace(/\S/g, "*"),
});
const row = document.createElement("button");
row.title = "Jane Member";
document.body.append(row);
// once the mutation event is emitted:
JSON.stringify(events).includes("Jane"); // true, expected false
Environment
- JS SDK Version:
@amplitude/analytics-browser2.47.2,@amplitude/plugin-session-replay-browser1.35.5,@amplitude/session-replay-browser1.51.0,@amplitude/rrweb-record2.0.0-alpha.40 - Installation Method: pnpm
- Browser and Version: Chrome; also reproduces in jsdom
- Dominant language
- TypeScript
- Stars
- 181
- Forks
- 66
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 41
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from amplitude/Amplitude-TypeScript
-
[analytics-core] getQueryParams does not decode `+` as space and truncates values containing `=`Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
amplitude/Amplitude-TypeScript#2179 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
amplitude/Amplitude-TypeScript#1615 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
amplitude/Amplitude-TypeScript#1367 · 5 comments · 24 reactions ·
Maintainers usually reply within 2 days
-
Session Replay keeps observing blocked iframes, retaining their documents until recording stopsOpenbug customer-reported
Difficulty 3/5 1-2 days Newbie friendliness 58/100
amplitude/Amplitude-TypeScript#2119 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 1/100
amplitude/Amplitude-TypeScript#1736 ·
Maintainers usually reply within 2 days
All issues in amplitude/Amplitude-TypeScript
Similar issues
-
ci good first issue severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
TMHSDigital/GH-Arcade#111 ·
-
AsnIntegerConverter.toASN coerces strings with +value, rounding integers outside safe-integer rangeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PeculiarVentures/asn1-schema#189 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anaisbetts/spawn-rx#38 ·