From 9385d74e04969875ca82c1aa773c11128c1024fe Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:23:19 +0100 Subject: [PATCH] fix(ios): Disable HTTP Client errors in sentry-cocoa to avoid duplicates (#4347) --- CHANGELOG.md | 1 + .../RNSentryCocoaTesterTests/RNSentryTests.mm | 16 ++++++++++++++++ packages/core/ios/RNSentry.mm | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94e8f03e90..7bf0372f0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Return `lastEventId` export from `@sentry/core` ([#4315](https://github.com/getsentry/sentry-react-native/pull/4315)) - Don't log file not found errors when loading envs in `sentry-expo-upload-sourcemaps` ([#4332](https://github.com/getsentry/sentry-react-native/pull/4332)) - Navigation Span should have no parent by default ([#4326](https://github.com/getsentry/sentry-react-native/pull/4326)) +- Disable HTTP Client Errors on iOS ([#4347](https://github.com/getsentry/sentry-react-native/pull/4347)) ### Dependencies diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.mm b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.mm index df720ee1af..6e63793b85 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.mm +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.mm @@ -38,6 +38,22 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties XCTAssertEqual(actualOptions.enableTracing, false, @"EnableTracing should not be passed to native"); } +- (void)testCaptureFailedRequestsIsDisabled +{ + RNSentry *rnSentry = [[RNSentry alloc] init]; + NSError *error = nil; + + NSDictionary *_Nonnull mockedReactNativeDictionary = @{ + @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", + }; + SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; + + XCTAssertNotNil(actualOptions, @"Did not create sentry options"); + XCTAssertNil(error, @"Should not pass no error"); + XCTAssertFalse(actualOptions.enableCaptureFailedRequests); +} + - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault { RNSentry *rnSentry = [[RNSentry alloc] init]; diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index ab22df9ec8..fc4091d220 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -215,7 +215,7 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) } // Failed requests can only be enabled in one SDK to avoid duplicates - sentryOptions.enableCaptureFailedRequests = @NO; + sentryOptions.enableCaptureFailedRequests = NO; return sentryOptions; }