Skip to content

feat: Expose screenshot masking options for error screenshots#6007

Open
antonis wants to merge 8 commits intomainfrom
feat/screenshot-masking-options
Open

feat: Expose screenshot masking options for error screenshots#6007
antonis wants to merge 8 commits intomainfrom
feat/screenshot-masking-options

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 16, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds screenshot options to control masking of sensitive content in error screenshots on both Android and iOS.

Sentry.init({
  dsn: '...',
  attachScreenshot: true,
  screenshot: {
    maskAllText: true,        // default: true
    maskAllImages: true,       // default: true
    maskedViewClasses: ['com.mapbox.maps.MapView'],  // native class names
    unmaskedViewClasses: ['com.example.SafeView'],
  },
});

Options:

  • maskAllText / maskAllImages — toggle automatic masking of text and images (default: true)
  • maskedViewClasses / unmaskedViewClasses — mask or unmask specific native view classes (useful for third-party libraries like map SDKs, payment forms, video players)

Platform support:

  • Android: Bridges to SentryScreenshotOptions via options.getScreenshot() (available since sentry-android 8.34.0, current: 8.38.0)
  • iOS: Bridges to SentryViewScreenshotOptions via init(dictionary:) (Cocoa SDK 9.10.0)

💡 Motivation and Context

Both native SDKs support screenshot masking for error screenshots, but the React Native SDK only exposed attachScreenshot as a boolean with no way to configure masking. This meant error screenshots could contain sensitive data (text, images) with no opt-out.

Closes #5763

💚 How did you test it?

  • Added unit test in wrapper.test.ts verifying screenshot options pass through to the native module
  • Added iOS native tests in RNSentryStartTests.swift for screenshot masking options and defaults
  • TypeScript compiles successfully (yarn build)
  • All existing tests pass (yarn test)
  • Added usage to the React Native sample app

📝 Checklist

🔮 Next steps

Add `screenshot.maskAllText` and `screenshot.maskAllImages` options to control
masking of sensitive content in error screenshots on Android. These options
bridge to the Android SDK's `SentryScreenshotOptions` API (available since
sentry-android 8.34.0).

Closes #5763

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

github-actions bot commented Apr 16, 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: Expose screenshot masking options for error screenshots by antonis in #6007

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 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 af14ae9

antonis added a commit to getsentry/sentry-docs that referenced this pull request Apr 16, 2026
Document the new `screenshot.maskAllText` and `screenshot.maskAllImages`
options for error screenshot masking on Android.

Companion SDK PR: getsentry/sentry-react-native#6007

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread CHANGELOG.md Outdated
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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5c3c299. Configure here.

antonis and others added 3 commits April 16, 2026 16:01
Bridge screenshot masking options to iOS via the Cocoa SDK's
SentryViewScreenshotOptions init(dictionary:) API. Both platforms
(Android and iOS) now support screenshot.maskAllText and
screenshot.maskAllImages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@antonis antonis changed the title feat(android): Expose screenshot masking options for error screenshots feat: Expose screenshot masking options for error screenshots Apr 16, 2026
Comment thread packages/core/ios/RNSentryStart.m Outdated
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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 566760f. Configure here.

antonis and others added 2 commits April 16, 2026 16:36
…ions

Support masking/unmasking specific native view classes in error
screenshots. Useful for third-party native views like map SDKs,
payment forms, or video players.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Screenshot masking depends on UIKit, not session replay. Use
SENTRY_HAS_UIKIT to match the guard used by the Cocoa SDK for
attachScreenshot.

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

antonis commented Apr 16, 2026

@sentry review

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a504753. Configure here.

@antonis antonis marked this pull request as ready for review April 16, 2026 15:00
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.

Expose Android screenshot masking options

1 participant