Skip to content

docs(replay): best practices for integrating masking/blocking in app code - #19298

Merged
jameskeane merged 8 commits into
masterfrom
jameskeane/replay-masking-best-practices
Sep 9, 2026
Merged

docs(replay): best practices for integrating masking/blocking in app code#19298
jameskeane merged 8 commits into
masterfrom
jameskeane/replay-masking-best-practices

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Adds a "Best Practices for Masking and Blocking in Your Codebase" section to the JS Session Replay privacy page (docs/platforms/javascript/common/session-replay/privacy.mdx), per the discussion in #discuss-replay about giving coding agents (and humans) concrete integration patterns instead of relying on hand-written skills.

Covers:

  • Global i18n hook — track strings emitted by your translation function (t()/formatMessage()) and use a custom maskFn to unmask only known-safe static copy, mirroring the pattern Sentry's own web app uses (isStaticString + maskFn in useReplayInit).
  • Explicit mask/block/unmask in shared React components — wrapper components and a withReplayMask HOC so privacy rules live in design-system primitives, not individual pages.
  • Blocking profile image/avatar components — call out that div avatars using CSS background-image (letter-avatar fallbacks, Gravatar, custom pipelines) aren't covered by the default img/svg/video block list, with a worked ProfileAvatar example using data-sentry-block.

First pass per James's request — happy to iterate on tone/placement.

via james.keane.

--

View Junior Session [Sentry]

…app code

Adds guidance for hooking global masking rules into an i18n layer,
making mask/block/unmask explicit in shared React components, and
blocking profile-image/avatar components that use CSS background-image
instead of <img> (not covered by the default block list).

Co-Authored-By: James Keane <james.keane@sentry.io>
@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-docs Ready Ready Preview Sep 8, 2026 8:26pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
develop-docs Ignored Ignored Preview Sep 8, 2026 8:26pm UTC

Request Review

@codeowner-assignment
codeowner-assignment Bot requested a review from a team September 8, 2026 17:51
@github-actions github-actions Bot added the Priority: Needs Triage The PR description is missing valid priority information label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Please update the IS YOUR CHANGE URGENT? section of the PR description:

  • Select exactly one option.
  • If you selected an urgent or other deadline, provide the date as YYYY-MM-DD.

This information helps the Docs team prioritize your review.

Comment thread docs/platforms/javascript/common/session-replay/privacy.mdx
Comment thread docs/platforms/javascript/common/session-replay/privacy.mdx
- export/import staticStrings across the i18n.js/sentry.js examples so
  the maskFn snippet doesn't throw a ReferenceError
- add a warning that data-sentry-unmask requires opting into the
  unmask selector explicitly on SDK v8+ (unmask/unblock no longer
  ship default DOM selectors)
@codeowner-assignment
codeowner-assignment Bot requested a review from a team September 8, 2026 17:56
Comment thread docs/platforms/javascript/common/session-replay/privacy.mdx
Match the prose (which mentions both sentry-unmask and
data-sentry-unmask) by including .sentry-unmask in the unmask config
example, not just the data attribute selector.
Comment thread docs/platforms/javascript/common/session-replay/privacy.mdx Outdated
Only cache a translated string as safe-to-unmask when it has no
interpolated placeholders. An interpolated result (e.g. 'Hello Ryan')
can contain user data even though its template ('Hello {name}') is
static copy.
@codeowner-assignment
codeowner-assignment Bot requested a review from a team September 8, 2026 18:05
Comment thread docs/platforms/javascript/common/session-replay/privacy.mdx Outdated
Comment thread docs/platforms/javascript/common/session-replay/privacy.mdx Outdated
@codeowner-assignment
codeowner-assignment Bot requested a review from a team September 8, 2026 18:08
…n bugs

A <span> wrapper produces invalid HTML (and SSR hydration mismatches)
if the wrapped component renders a block-level element. Switch to a
<div> wrapper and note why.
@jameskeane

Copy link
Copy Markdown

@sentry-junior Fix this 404 error:

Errors in docs/platforms/javascript/common/session-replay/privacy.mdx
[404] https://github.com/getsentry/sentry-javascript/blob/master/packages/replay/MIGRATION.md#upgrading-replay-from-7340-to-7350---6645

@jameskeane
jameskeane merged commit 7cef263 into master Sep 9, 2026
22 checks passed
@jameskeane
jameskeane deleted the jameskeane/replay-masking-best-practices branch September 9, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Needs Triage The PR description is missing valid priority information

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants