Skip to content

Commit 26b17b4

Browse files
antonisclaude
andcommitted
fix(ios): honor _experiments.enableUnhandledCPPExceptionsV2 on v8
Same dead-code issue as the profiling fix — `SentrySDKWrapper` parses `_experiments.enableUnhandledCPPExceptionsV2`, but `RNSentryStart` (the live init path since v8.0.0) does not. Port the handling into the `_experiments` block just introduced for `profilingOptions`, and add enabled/disabled/default XCTest coverage on `RNSentryStart`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d1acea0 commit 26b17b4

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
### Fixes
1616

1717
- Fix iOS UI profiling options being silently ignored since v8.0.0 ([#6012](https://github.com/getsentry/sentry-react-native/pull/6012))
18+
- Fix `_experiments.enableUnhandledCPPExceptionsV2` being silently ignored on iOS since v8.0.0
1819

1920
## 8.8.0
2021

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,60 @@ - (void)testStartCreateOptionsWithDictionaryEmptyExperimentsDoesNotInstallConfig
14701470
}
14711471
#endif
14721472

1473+
- (void)testStartCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Enabled
1474+
{
1475+
NSError *error = nil;
1476+
1477+
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1478+
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1479+
@"_experiments" : @ {
1480+
@"enableUnhandledCPPExceptionsV2" : @YES,
1481+
},
1482+
};
1483+
SentryOptions *actualOptions =
1484+
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1485+
1486+
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1487+
XCTAssertNil(error, @"Should not pass no error");
1488+
XCTAssertTrue(actualOptions.experimental.enableUnhandledCPPExceptionsV2,
1489+
@"enableUnhandledCPPExceptionsV2 should be enabled");
1490+
}
1491+
1492+
- (void)testStartCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Disabled
1493+
{
1494+
NSError *error = nil;
1495+
1496+
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1497+
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1498+
@"_experiments" : @ {
1499+
@"enableUnhandledCPPExceptionsV2" : @NO,
1500+
},
1501+
};
1502+
SentryOptions *actualOptions =
1503+
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1504+
1505+
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1506+
XCTAssertNil(error, @"Should not pass no error");
1507+
XCTAssertFalse(actualOptions.experimental.enableUnhandledCPPExceptionsV2,
1508+
@"enableUnhandledCPPExceptionsV2 should be disabled");
1509+
}
1510+
1511+
- (void)testStartCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Default
1512+
{
1513+
NSError *error = nil;
1514+
1515+
NSDictionary *_Nonnull mockedReactNativeDictionary = @{
1516+
@"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456",
1517+
};
1518+
SentryOptions *actualOptions =
1519+
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
1520+
1521+
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
1522+
XCTAssertNil(error, @"Should not pass no error");
1523+
XCTAssertFalse(actualOptions.experimental.enableUnhandledCPPExceptionsV2,
1524+
@"enableUnhandledCPPExceptionsV2 should default to disabled");
1525+
}
1526+
14731527
- (void)testStartEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags
14741528
{
14751529
SentryEvent *testEvent = [[SentryEvent alloc] init];

packages/core/ios/RNSentryStart.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,15 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
100100
}
101101
}
102102

103-
// Configure iOS UI Profiling from _experiments.profilingOptions
103+
// Configure experimental options from _experiments
104104
NSDictionary *experiments = mutableOptions[@"_experiments"];
105105
if (experiments != nil && [experiments isKindOfClass:[NSDictionary class]]) {
106+
BOOL enableUnhandledCPPExceptions =
107+
[experiments[@"enableUnhandledCPPExceptionsV2"] boolValue];
108+
[RNSentryExperimentalOptions setEnableUnhandledCPPExceptionsV2:enableUnhandledCPPExceptions
109+
sentryOptions:sentryOptions];
110+
111+
// Configure iOS UI Profiling
106112
NSDictionary *profilingOptions = experiments[@"profilingOptions"];
107113
if (profilingOptions != nil && [profilingOptions isKindOfClass:[NSDictionary class]]) {
108114
[RNSentryExperimentalOptions configureProfilingWithOptions:profilingOptions

0 commit comments

Comments
 (0)