Skip to content

feat: Expose screenshot masking options for error screenshots#6007

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

feat: Expose screenshot masking options for error screenshots#6007
antonis wants to merge 11 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
  • chore(deps): update Android SDK to v8.39.1 by github-actions in #6010
  • chore(deps): update JavaScript SDK to v10.49.0 by github-actions in #6011
  • ci: Integrate Warden for AI-powered PR code review by antonis in #6003
  • chore(lint): Fixes lint issue on main by antonis in #6013
  • feat(expo): Warn when prebuilt native projects are missing Sentry config by alwx in #5984

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against df9b912

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
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Apr 17, 2026
antonis and others added 2 commits April 17, 2026 14:52
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…onary:)

The SentryViewScreenshotOptions.init(dictionary:) convenience
initializer is internal (not @objc exposed) and not accessible from
Objective-C. Set properties directly on the default instance instead.

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

sentry bot commented Apr 17, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.8.0 (83) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1235.85 ms 1231.10 ms -4.75 ms
Size 3.38 MiB 4.76 MiB 1.38 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3817909+dirty 1183.90 ms 1187.50 ms 3.60 ms
3ce5254+dirty 1219.93 ms 1221.90 ms 1.96 ms
04207c4+dirty 1191.27 ms 1189.78 ms -1.48 ms
7ac3378+dirty 1213.37 ms 1218.15 ms 4.78 ms
5c1e987+dirty 1204.30 ms 1222.15 ms 17.85 ms
0d9949d+dirty 1211.38 ms 1219.67 ms 8.29 ms
4953e94+dirty 1212.06 ms 1214.83 ms 2.77 ms
df5d108+dirty 1225.90 ms 1220.14 ms -5.76 ms
a50b33d+dirty 1197.74 ms 1197.17 ms -0.57 ms
3d377b5+dirty 1218.48 ms 1219.51 ms 1.03 ms

App size

Revision Plain With Sentry Diff
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3ce5254+dirty 3.38 MiB 4.76 MiB 1.38 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB
7ac3378+dirty 3.38 MiB 4.76 MiB 1.38 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3d377b5+dirty 3.38 MiB 4.76 MiB 1.38 MiB

@github-actions
Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 421.29 ms 449.96 ms 28.67 ms
Size 43.75 MiB 48.14 MiB 4.39 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7ac3378+dirty 404.78 ms 439.84 ms 35.06 ms
4953e94+dirty 442.02 ms 456.52 ms 14.50 ms
3ce5254+dirty 410.57 ms 448.48 ms 37.91 ms
0d9949d+dirty 403.57 ms 437.00 ms 33.43 ms
5c1e987+dirty 423.52 ms 471.64 ms 48.12 ms
2c735cc+dirty 414.09 ms 438.47 ms 24.38 ms
a50b33d+dirty 500.81 ms 532.11 ms 31.30 ms
04207c4+dirty 459.19 ms 518.54 ms 59.35 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
df5d108+dirty 527.06 ms 603.58 ms 76.52 ms

App size

Revision Plain With Sentry Diff
7ac3378+dirty 43.75 MiB 48.13 MiB 4.37 MiB
4953e94+dirty 43.75 MiB 48.08 MiB 4.33 MiB
3ce5254+dirty 43.75 MiB 48.12 MiB 4.37 MiB
0d9949d+dirty 43.75 MiB 48.13 MiB 4.37 MiB
5c1e987+dirty 43.75 MiB 48.08 MiB 4.33 MiB
2c735cc+dirty 43.75 MiB 48.08 MiB 4.33 MiB
a50b33d+dirty 43.75 MiB 48.08 MiB 4.33 MiB
04207c4+dirty 43.75 MiB 48.12 MiB 4.37 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
df5d108+dirty 43.75 MiB 48.08 MiB 4.33 MiB

@github-actions
Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1237.09 ms 1224.70 ms -12.39 ms
Size 3.38 MiB 4.76 MiB 1.38 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3817909+dirty 1210.76 ms 1215.64 ms 4.89 ms
3ce5254+dirty 1217.70 ms 1224.69 ms 6.99 ms
04207c4+dirty 1228.55 ms 1226.04 ms -2.51 ms
7ac3378+dirty 1202.35 ms 1198.31 ms -4.04 ms
5c1e987+dirty 1208.43 ms 1220.72 ms 12.29 ms
0d9949d+dirty 1203.94 ms 1202.27 ms -1.67 ms
4953e94+dirty 1217.41 ms 1223.53 ms 6.12 ms
df5d108+dirty 1207.34 ms 1210.50 ms 3.16 ms
a50b33d+dirty 1207.11 ms 1212.10 ms 5.00 ms
3d377b5+dirty 1201.55 ms 1201.80 ms 0.25 ms

App size

Revision Plain With Sentry Diff
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3ce5254+dirty 3.38 MiB 4.76 MiB 1.38 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB
7ac3378+dirty 3.38 MiB 4.76 MiB 1.38 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3d377b5+dirty 3.38 MiB 4.76 MiB 1.38 MiB

@github-actions
Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 450.12 ms 470.19 ms 20.07 ms
Size 43.94 MiB 49.00 MiB 5.06 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7ac3378+dirty 410.67 ms 442.60 ms 31.92 ms
4953e94+dirty 398.80 ms 431.81 ms 33.01 ms
3ce5254+dirty 373.90 ms 427.84 ms 53.94 ms
0d9949d+dirty 414.88 ms 428.68 ms 13.81 ms
5c1e987+dirty 444.71 ms 475.13 ms 30.42 ms
2c735cc+dirty 435.20 ms 459.48 ms 24.28 ms
a50b33d+dirty 353.21 ms 398.48 ms 45.27 ms
04207c4+dirty 395.40 ms 456.55 ms 61.15 ms
3817909+dirty 357.52 ms 391.52 ms 34.00 ms
df5d108+dirty 434.82 ms 447.39 ms 12.57 ms

App size

Revision Plain With Sentry Diff
7ac3378+dirty 43.94 MiB 48.99 MiB 5.05 MiB
4953e94+dirty 43.94 MiB 48.94 MiB 5.00 MiB
3ce5254+dirty 43.94 MiB 48.98 MiB 5.04 MiB
0d9949d+dirty 43.94 MiB 48.99 MiB 5.05 MiB
5c1e987+dirty 43.94 MiB 48.94 MiB 5.00 MiB
2c735cc+dirty 43.94 MiB 48.94 MiB 5.00 MiB
a50b33d+dirty 43.94 MiB 48.94 MiB 5.00 MiB
04207c4+dirty 43.94 MiB 48.98 MiB 5.04 MiB
3817909+dirty 43.94 MiB 48.94 MiB 5.00 MiB
df5d108+dirty 43.94 MiB 48.94 MiB 5.00 MiB

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

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose Android screenshot masking options

1 participant