Skip to content

feat(core): Extract text from children of touched components for breadcrumb labels#6106

Open
antonis wants to merge 10 commits intomainfrom
antonis/issue-6097
Open

feat(core): Extract text from children of touched components for breadcrumb labels#6106
antonis wants to merge 10 commits intomainfrom
antonis/issue-6097

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented May 7, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Walks the React fiber tree downward (child/sibling pointers) to extract text content from children of touched components. This text is used as a lowest-priority label fallback when no explicit label (sentry-label, custom labelKey) is set.

For example, a button like:

<TouchableOpacity onPress={save}>
  <Text>Save workout</Text>
</TouchableOpacity>

will now produce a breadcrumb with label "Save workout" instead of just "TouchableOpacity".

Masking behavior

  • When maskAllText is enabled (the default for replay users): text extraction is automatically disabled to avoid leaking masked content via breadcrumbs. No behavior change for these users.
  • When maskAllText is explicitly false: text extraction is enabled.
  • When MobileReplay integration is not installed: text extraction is enabled. This is a behavior change — users without replay will now see text labels in their touch breadcrumbs where previously they only saw component names. This can surface new data in breadcrumbs (component text content). Users can opt out via extractTextFromChildren: false on TouchEventBoundary.
  • Per-view Sentry.Mask boundaries are respected: text inside <Sentry.Mask> is never extracted.

Safety limits

  • Max text length: 64 characters (truncated with ...)
  • Max depth: 3 levels of child traversal
  • Max siblings: 5 per level (prevents runaway traversal in long lists)

New prop

extractTextFromChildren (default true) — set to false to opt out entirely.

Label priority (lowest to highest)

  1. Extracted text children ← new
  2. Custom labelKey prop value
  3. sentry-label prop

💡 Motivation and Context

Touch breadcrumbs currently produce unhelpful labels like "Touch event within element: View" which makes Session Replay AI summaries and issue debugging less useful. This change automatically extracts meaningful labels from component text content.

Closes #6097

💚 How did you test it?

  • 11 new unit tests covering: basic extraction, nested children, siblings, truncation, masking gate (maskAllText: true, false, undefined), Sentry.Mask boundary, priority over extracted text, extractTextFromChildren: false opt-out, raw text fiber nodes, integration without options
  • All 31 touchevents tests pass
  • Type check passes (no new TS errors)
  • Lint passes (0 warnings, 0 errors)

📝 Checklist

🔮 Next steps

antonis and others added 2 commits May 7, 2026 10:57
…dcrumb labels

Walks the React fiber tree downward (child/sibling) to extract text content
from touched components as a lowest-priority label fallback. Gated on Session
Replay's maskAllText setting and respects per-view Sentry.Mask boundaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(core): Extract text from children of touched components for breadcrumb labels by antonis in #6106
  • test(replay): Add passthrough tests for device-state replay breadcrumbs by antonis in #6115
  • chore(deps): update JavaScript SDK to v10.52.0 by github-actions in #6108
  • chore(deps): bump basic-ftp from 5.3.0 to 5.3.1 by dependabot in #6111

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f14d1f9

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented May 7, 2026

@sentry review

@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented May 7, 2026

@cursor review

Comment thread packages/core/src/js/touchevents.tsx
antonis and others added 4 commits May 7, 2026 11:43
…raction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The prop defaults to true but effective behavior depends on maskAllText,
which defaults to true in mobileReplayIntegration, disabling extraction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis antonis marked this pull request as ready for review May 7, 2026 11:05
Comment thread CHANGELOG.md Outdated
Comment thread packages/core/src/js/touchevents.tsx
…child fibers

In real React Native fiber trees, <Text>Hello</Text> has both
memoizedProps.children = 'Hello' on the Text fiber and a child HostText
fiber with memoizedProps = 'Hello'. Skip child recursion when
props.children is a string to avoid collecting the same text twice.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f14d1f9. Configure here.

Comment thread packages/core/src/js/touchevents.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract text children from touchable components for breadcrumb labels

1 participant