diff --git a/CHANGELOG.md b/CHANGELOG.md index 29b8df1fc6..8eb448395a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Expose `enableNetworkBreadcrumbs` (iOS) to disable native HTTP request breadcrumbs ([#6764](https://github.com/getsentry/sentry-react-native/pull/6764)) - Expose `enableNetworkEventBreadcrumbs` (Android) to disable native network connectivity breadcrumbs ([#6764](https://github.com/getsentry/sentry-react-native/pull/6764)) - Expose native breadcrumb off-switches: `enableAutoBreadcrumbTracking` (iOS); `enableActivityLifecycleBreadcrumbs`, `enableAppLifecycleBreadcrumbs`, `enableSystemEventBreadcrumbs`, `enableAppComponentBreadcrumbs` (Android) ([#6768](https://github.com/getsentry/sentry-react-native/pull/6768)) +- Expose `reportAccessibilityIdentifier` (iOS) to omit PII accessibility identifiers from the view hierarchy ([#6771](https://github.com/getsentry/sentry-react-native/pull/6771)) ### Fixes diff --git a/packages/core/etc/sentry-react-native.api.md b/packages/core/etc/sentry-react-native.api.md index 81d56e48d9..a172cb95d9 100644 --- a/packages/core/etc/sentry-react-native.api.md +++ b/packages/core/etc/sentry-react-native.api.md @@ -215,6 +215,7 @@ export interface BaseReactNativeOptions { replaysOnErrorSampleRate?: number; replaysSessionQuality?: SentryReplayQuality; replaysSessionSampleRate?: number; + reportAccessibilityIdentifier?: boolean; screenshot?: { maskAllText?: boolean; maskAllImages?: boolean; diff --git a/packages/core/src/js/options.ts b/packages/core/src/js/options.ts index 8b735588a0..b77b0dc115 100644 --- a/packages/core/src/js/options.ts +++ b/packages/core/src/js/options.ts @@ -401,6 +401,20 @@ export interface BaseReactNativeOptions { */ attachViewHierarchy?: boolean; + /** + * When enabled, the native iOS SDK includes each view's `accessibilityIdentifier` in the + * captured view hierarchy (see `attachViewHierarchy`). + * + * Accessibility identifiers are developer-defined and may contain personally identifiable + * information (PII). Set this to `false` to omit them from the view hierarchy. Note that the + * native SDK does not gate this on `sendDefaultPii`, so it defaults to `true` regardless of + * that option. + * + * @default true + * @platform ios + */ + reportAccessibilityIdentifier?: boolean; + /** * When enabled, Sentry will capture failed XHR/Fetch requests. This option also enabled HTTP Errors on iOS. * [Sentry Android Gradle Plugin](https://docs.sentry.io/platforms/android/configuration/integrations/okhttp/) diff --git a/packages/core/test/wrapper.test.ts b/packages/core/test/wrapper.test.ts index d536db278f..5501c45146 100644 --- a/packages/core/test/wrapper.test.ts +++ b/packages/core/test/wrapper.test.ts @@ -274,6 +274,23 @@ describe('Tests Native Wrapper', () => { expect(initParameter.enableAppComponentBreadcrumbs).toBe(false); }); + test('forwards reportAccessibilityIdentifier to the Native SDK', async () => { + await NATIVE.initNativeSdk({ + dsn: VALID_DSN, + enableNative: true, + autoInitializeNativeSdk: true, + reportAccessibilityIdentifier: false, + devServerUrl: undefined, + defaultSidecarUrl: undefined, + mobileReplayOptions: undefined, + }); + + expect(RNSentry.initNativeSdk).toHaveBeenCalled(); + // @ts-expect-error mock value + const initParameter = RNSentry.initNativeSdk.mock.calls[0][0]; + expect(initParameter.reportAccessibilityIdentifier).toBe(false); + }); + test('filter beforeSend when initializing Native SDK', async () => { await NATIVE.initNativeSdk({ dsn: VALID_DSN,