Skip to content

Differentiate manual vs auto-injected sentry-label for masking #6147

Description

@antonis

Problem Statement

When Session Replay masking is active (maskAllText: true, the default), the SDK skips all sentry-label props to prevent leaking masked text content into breadcrumbs. However, this also silently ignores manually set sentry-label props that developers use for component tracking — these are developer-provided identifiers (like "checkout-button"), not user-visible text, and should not be affected by masking.

The SDK cannot distinguish between the two at runtime because both are just sentry-label string props.

Proposed Solution

Use a different prop name for auto-injected labels in the Babel plugin (e.g., data-sentry-label), and update the SDK to handle them separately:

  • sentry-label (manual) — always read, never skipped by masking
  • data-sentry-label (auto-injected) — skipped when maskAllText is enabled or inside a Sentry.Mask boundary

This requires a coordinated change in:

  1. @sentry/babel-plugin-component-annotate — inject as data-sentry-label instead of sentry-label
  2. @sentry/react-native — update getLabelValue() in touchevents.tsx to read both props with different masking behavior

Context

Part of the "Making breadcrumbs data more useful" project. The masking behavior was introduced in #6142, and the auto-injection in #6141.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions