diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fb250b130..26502bf6b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ }); ``` +### Fixes + +- Apply `Sentry.Mask` and `Sentry.Unmask` on iOS when you start a replay manually with both replay sample rates at `0` ([#7008](https://github.com/getsentry/sentry-react-native/pull/7008)) + ### Dependencies - Bump Android SDK from v8.62.0 to v8.63.0 ([#6990](https://github.com/getsentry/sentry-react-native/pull/6990)) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 4e7b3d0da2..049b51eaea 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -290,6 +290,23 @@ - (void)testStartWithDictionaryRemovesPerformanceProperties // Tracing is disabled by setting tracesSampleRate and tracesSampler to nil } +- (void)testStartRunsReplayPostInitWhenSampleRatesAreZero +{ + id replayMock = OCMClassMock([RNSentryReplay class]); + NSError *error = nil; + + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", + @"replaysSessionSampleRate" : @0, + @"replaysOnErrorSampleRate" : @0, + }; + [RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error]; + + XCTAssertNil(error); + OCMVerify(ClassMethod([replayMock postInit])); + [replayMock stopMocking]; +} + - (void)testStartCaptureFailedRequestsIsDisabled { NSError *error = nil; diff --git a/packages/core/ios/RNSentryStart.m b/packages/core/ios/RNSentryStart.m index 87591dae79..c56bd40267 100644 --- a/packages/core/ios/RNSentryStart.m +++ b/packages/core/ios/RNSentryStart.m @@ -59,10 +59,8 @@ + (void)startWithOptions:(SentryOptions *)options jsSdkVersion:(NSString *_Nulla [SentrySDK startWithOptions:options]; #if SENTRY_TARGET_REPLAY_SUPPORTED - if (options.sessionReplay.sessionSampleRate > 0 - || options.sessionReplay.onErrorSampleRate > 0) { - [RNSentryReplay postInit]; - } + // Replay can start manually with both sample rates at 0, so always register the RN classes. + [RNSentryReplay postInit]; #endif [self postDidBecomeActiveNotification];