diff --git a/CHANGELOG.md b/CHANGELOG.md index 150c44ce88..7cfca588fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ ### Fixes - Fix iOS UI profiling options being silently ignored ([#6012](https://github.com/getsentry/sentry-react-native/pull/6012)) +- Fix `_experiments.enableUnhandledCPPExceptionsV2` being silently ignored on iOS ([#6014](https://github.com/getsentry/sentry-react-native/pull/6014)) - Check `captureReplay` return value in iOS bridge to avoid linking error events to uncaptured replays ([#6008](https://github.com/getsentry/sentry-react-native/pull/6008)) - Report the expected properties file path and any missing keys when using `flavorAware` on Android, instead of failing with an opaque `Illegal null value provided in this collection` error ([#6031](https://github.com/getsentry/sentry-react-native/pull/6031)) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 1aeb6015cc..a15639423b 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -1471,6 +1471,60 @@ - (void)testStartCreateOptionsWithDictionaryEmptyExperimentsDoesNotInstallConfig } #endif +- (void)testStartCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Enabled +{ + NSError *error = nil; + + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", + @"_experiments" : @ { + @"enableUnhandledCPPExceptionsV2" : @YES, + }, + }; + SentryOptions *actualOptions = + [RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; + + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); + XCTAssertNil(error, @"Should not pass no error"); + XCTAssertTrue(actualOptions.experimental.enableUnhandledCPPExceptionsV2, + @"enableUnhandledCPPExceptionsV2 should be enabled"); +} + +- (void)testStartCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Disabled +{ + NSError *error = nil; + + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", + @"_experiments" : @ { + @"enableUnhandledCPPExceptionsV2" : @NO, + }, + }; + SentryOptions *actualOptions = + [RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; + + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); + XCTAssertNil(error, @"Should not pass no error"); + XCTAssertFalse(actualOptions.experimental.enableUnhandledCPPExceptionsV2, + @"enableUnhandledCPPExceptionsV2 should be disabled"); +} + +- (void)testStartCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Default +{ + NSError *error = nil; + + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", + }; + SentryOptions *actualOptions = + [RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; + + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); + XCTAssertNil(error, @"Should not pass no error"); + XCTAssertFalse(actualOptions.experimental.enableUnhandledCPPExceptionsV2, + @"enableUnhandledCPPExceptionsV2 should default to disabled"); +} + - (void)testStartEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags { SentryEvent *testEvent = [[SentryEvent alloc] init]; diff --git a/packages/core/ios/RNSentryStart.m b/packages/core/ios/RNSentryStart.m index 4d07f8816b..2542da23b6 100644 --- a/packages/core/ios/RNSentryStart.m +++ b/packages/core/ios/RNSentryStart.m @@ -140,9 +140,15 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) } } - // Configure iOS UI Profiling from _experiments.profilingOptions + // Configure experimental options from _experiments NSDictionary *experiments = mutableOptions[@"_experiments"]; if (experiments != nil && [experiments isKindOfClass:[NSDictionary class]]) { + BOOL enableUnhandledCPPExceptions = + [experiments[@"enableUnhandledCPPExceptionsV2"] boolValue]; + [RNSentryExperimentalOptions setEnableUnhandledCPPExceptionsV2:enableUnhandledCPPExceptions + sentryOptions:sentryOptions]; + + // Configure iOS UI Profiling NSDictionary *profilingOptions = experiments[@"profilingOptions"]; if (profilingOptions != nil && [profilingOptions isKindOfClass:[NSDictionary class]]) { [RNSentryExperimentalOptions configureProfilingWithOptions:profilingOptions