diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b8b527af..9308a100c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Fixes +- Fix `_experiments.enableUnhandledCPPExceptionsV2` being silently ignored on iOS ([#6014](https://github.com/getsentry/sentry-react-native/pull/6014)) - Fix iOS UI profiling options being silently ignored ([#6012](https://github.com/getsentry/sentry-react-native/pull/6012)) ### Dependencies diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index b09a2073d0..8720db3b93 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -1470,6 +1470,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 c7faf91dae..75cd626515 100644 --- a/packages/core/ios/RNSentryStart.m +++ b/packages/core/ios/RNSentryStart.m @@ -100,9 +100,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