Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Features

- Expose Android screenshot masking options (`screenshot.maskAllText`, `screenshot.maskAllImages`) for error screenshots ([#5763](https://github.com/getsentry/sentry-react-native/issues/5763))
Comment thread
antonis marked this conversation as resolved.
Outdated
- Enable "Open Sentry" button in Playground for Expo apps ([#5947](https://github.com/getsentry/sentry-react-native/pull/5947))
- Add `attachAllThreads` option to attach full stack traces for all threads to captured events on iOS ([#5960](https://github.com/getsentry/sentry-react-native/issues/5960))
- Add `strictTraceContinuation` and `orgId` options for trace continuation validation ([#5829](https://github.com/getsentry/sentry-react-native/pull/5829))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ static void getSentryAndroidOptions(
if (rnOptions.hasKey("attachScreenshot")) {
options.setAttachScreenshot(rnOptions.getBoolean("attachScreenshot"));
}
if (rnOptions.hasKey("screenshot")) {
@Nullable final ReadableMap screenshotOptions = rnOptions.getMap("screenshot");
if (screenshotOptions != null) {
if (screenshotOptions.hasKey("maskAllText")) {
options.getScreenshot().setMaskAllText(screenshotOptions.getBoolean("maskAllText"));
}
if (screenshotOptions.hasKey("maskAllImages")) {
options.getScreenshot().setMaskAllImages(screenshotOptions.getBoolean("maskAllImages"));
}
}
}
if (rnOptions.hasKey("attachViewHierarchy")) {
options.setAttachViewHierarchy(rnOptions.getBoolean("attachViewHierarchy"));
}
Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,29 @@ export interface BaseReactNativeOptions {
*/
attachScreenshot?: boolean;

/**
* Options for configuring screenshot masking on error screenshots (Android only).
* When `attachScreenshot` is enabled, these options control what gets masked in the screenshot.
*
* Requires `sentry-android-replay` module at runtime for masking to work.
*/
screenshot?: {
/**
* Mask all text content in error screenshots.
*
* @platform android
* @default true
*/
maskAllText?: boolean;
/**
* Mask all images in error screenshots.
*
* @platform android
* @default true
*/
maskAllImages?: boolean;
};

/**
* When enabled Sentry includes the current view hierarchy in the error attachments.
*
Expand Down
22 changes: 22 additions & 0 deletions packages/core/test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,28 @@ describe('Tests Native Wrapper', () => {
expect(initParameter.strictTraceContinuation).toBe(true);
});

test('passes screenshot options to native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: 'test',
enableNative: true,
autoInitializeNativeSdk: true,
screenshot: {
maskAllText: false,
maskAllImages: true,
},
devServerUrl: undefined,
defaultSidecarUrl: undefined,
mobileReplayOptions: undefined,
});

expect(RNSentry.initNativeSdk).toHaveBeenCalled();
const initParameter = (RNSentry.initNativeSdk as jest.MockedFunction<any>).mock.calls[0][0];
expect(initParameter.screenshot).toEqual({
maskAllText: false,
maskAllImages: true,
});
});

test('passes orgId option to native SDK', async () => {
await NATIVE.initNativeSdk({
dsn: 'test',
Expand Down
5 changes: 5 additions & 0 deletions samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ Sentry.init({
attachStacktrace: true,
// Attach screenshots to events.
attachScreenshot: true,
// Screenshot masking options (Android only).
screenshot: {
maskAllText: true,
maskAllImages: true,
},
// Attach view hierarchy to events.
attachViewHierarchy: true,
// Enables capture failed requests in JS and native.
Expand Down
Loading