Skip to content

Commit 7d6fd3a

Browse files
antonisclaude
andauthored
fix(ios): honor _experiments.enableUnhandledCPPExceptionsV2 on v8 (#6014)
* fix(profiling): iOS UI profiling on v8 `RNSentryStart.createOptionsWithDictionary` (the live iOS init path since v8.0.0) did not read `_experiments.profilingOptions`, silently dropping `profileSessionSampleRate`, `lifecycle`, and `startOnAppStart`. The handling existed in `SentrySDKWrapper`, but that surface hasn't been called from `initNativeSdk` since #5582#5611 added the block to the wrong file. Port the handling to `RNSentryStart` and add XCTest coverage for the `startWithOptions` entry point that `initNativeSdk` uses, so this regression can't slip through again. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * review: house-style CHANGELOG and verify profiling fields land on probe - Rewrite CHANGELOG entry to match the descriptive + PR-link format. - Strengthen the two positive profiling tests to invoke the installed callback on a fresh SentryProfileOptions probe and assert that sessionSampleRate, lifecycle, and profileAppStarts land correctly, so a future regression that installs an incomplete callback is caught. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 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> * changelog: simplify profiling fix wording --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 01e214f commit 7d6fd3a

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
@@ -21,6 +21,7 @@
2121
### Fixes
2222

2323
- Fix iOS UI profiling options being silently ignored ([#6012](https://github.com/getsentry/sentry-react-native/pull/6012))
24+
- Fix `_experiments.enableUnhandledCPPExceptionsV2` being silently ignored on iOS ([#6014](https://github.com/getsentry/sentry-react-native/pull/6014))
2425
- 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))
2526
- 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))
2627

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m

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

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

packages/core/ios/RNSentryStart.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,15 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
140140
}
141141
}
142142

143-
// Configure iOS UI Profiling from _experiments.profilingOptions
143+
// Configure experimental options from _experiments
144144
NSDictionary *experiments = mutableOptions[@"_experiments"];
145145
if (experiments != nil && [experiments isKindOfClass:[NSDictionary class]]) {
146+
BOOL enableUnhandledCPPExceptions =
147+
[experiments[@"enableUnhandledCPPExceptionsV2"] boolValue];
148+
[RNSentryExperimentalOptions setEnableUnhandledCPPExceptionsV2:enableUnhandledCPPExceptions
149+
sentryOptions:sentryOptions];
150+
151+
// Configure iOS UI Profiling
146152
NSDictionary *profilingOptions = experiments[@"profilingOptions"];
147153
if (profilingOptions != nil && [profilingOptions isKindOfClass:[NSDictionary class]]) {
148154
[RNSentryExperimentalOptions configureProfilingWithOptions:profilingOptions

0 commit comments

Comments
 (0)