diff --git a/CHANGELOG.md b/CHANGELOG.md index c540316f1e..84a645527d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - Fix `event.origin` and `event.environment` on unhandled exception ([#3041](https://github.com/getsentry/sentry-react-native/pull/3041)) +- Don't pass `enableTracing` from RN to `sentry-cocoa` options ([#3042](https://github.com/getsentry/sentry-react-native/pull/3042)) ## 5.4.1 diff --git a/RNSentryTester/RNSentryTesterTests/RNSentry+initNativeSdk.mm b/RNSentryTester/RNSentryTesterTests/RNSentry+initNativeSdk.mm index db570468d0..a6acb64294 100644 --- a/RNSentryTester/RNSentryTesterTests/RNSentry+initNativeSdk.mm +++ b/RNSentryTester/RNSentryTesterTests/RNSentry+initNativeSdk.mm @@ -18,8 +18,11 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn": @"https://abcd@efgh.ingest.sentry.io/123456", @"beforeSend": @"will_be_overwritten", - @"enableNativeCrashHandling": @YES, - + @"tracesSampleRate": @1, + @"tracesSampler": ^(SentrySamplingContext *_Nonnull samplingContext) { + return @1; + }, + @"enableTracing": @YES, }; SentryOptions* actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; @@ -28,6 +31,7 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties XCTAssertNotNil(actualOptions.beforeSend, @"Before send is overwriten by the native RNSentry implementation"); XCTAssertEqual(actualOptions.tracesSampleRate, nil, @"Traces sample rate should not be passed to native"); XCTAssertEqual(actualOptions.tracesSampler, nil, @"Traces sampler should not be passed to native"); + XCTAssertEqual(actualOptions.enableTracing, false, @"EnableTracing should not be passed to native"); } - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault @@ -44,7 +48,7 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault XCTAssertEqual([actualOptions.integrations containsObject:@"SentryCrashIntegration"], true, @"Did not set native crash handling"); } -- (void)testCreateOptionsWithDictionaryPerformanceTrackingDefault +- (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDefault { RNSentry * rnSentry = [[RNSentry alloc] init]; NSError* error = nil; @@ -73,7 +77,7 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingEnabled XCTAssertEqual([actualOptions.integrations containsObject:@"SentryCrashIntegration"], true, @"Did not set native crash handling"); } -- (void)testCreateOptionsWithDictionaryPerformanceTrackingEnabled +- (void)testCreateOptionsWithDictionaryAutoPerformanceTracingEnabled { RNSentry * rnSentry = [[RNSentry alloc] init]; NSError* error = nil; @@ -81,7 +85,6 @@ - (void)testCreateOptionsWithDictionaryPerformanceTrackingEnabled NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn": @"https://abcd@efgh.ingest.sentry.io/123456", @"enableAutoPerformanceTracing": @YES, - }; SentryOptions* actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); @@ -97,7 +100,6 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn": @"https://abcd@efgh.ingest.sentry.io/123456", @"enableNativeCrashHandling": @NO, - }; SentryOptions* actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); @@ -105,7 +107,7 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled XCTAssertEqual([actualOptions.integrations containsObject:@"SentryCrashIntegration"], false, @"Did not disable native crash handling"); } -- (void)testCreateOptionsWithDictionaryPerformanceTrackingDisabled +- (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDisabled { RNSentry * rnSentry = [[RNSentry alloc] init]; NSError* error = nil; @@ -113,7 +115,6 @@ - (void)testCreateOptionsWithDictionaryPerformanceTrackingDisabled NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn": @"https://abcd@efgh.ingest.sentry.io/123456", @"enableAutoPerformanceTracing": @NO, - }; SentryOptions* actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); @@ -127,7 +128,7 @@ - (void)testPassesErrorOnWrongDsn NSError* error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ - @"dsn": @"not_a_valid_dsn" + @"dsn": @"not_a_valid_dsn", }; SentryOptions* actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary error:&error]; @@ -140,7 +141,7 @@ - (void)testEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags RNSentry* rnSentry = [[RNSentry alloc] init]; SentryEvent* testEvent = [[SentryEvent alloc] init]; testEvent.sdk = @{ - @"name": @"sentry.cocoa.react-native" + @"name": @"sentry.cocoa.react-native", }; [rnSentry setEventOriginTag: testEvent]; @@ -154,11 +155,11 @@ - (void)testEventFromSentryReactNativeOriginAndEnvironmentTagsAreOverwritten RNSentry* rnSentry = [[RNSentry alloc] init]; SentryEvent* testEvent = [[SentryEvent alloc] init]; testEvent.sdk = @{ - @"name": @"sentry.cocoa.react-native" + @"name": @"sentry.cocoa.react-native", }; testEvent.tags = @{ @"event.origin": @"testEventOriginTag", - @"event.environment": @"testEventEnvironmentTag" + @"event.environment": @"testEventEnvironmentTag", }; [rnSentry setEventOriginTag: testEvent]; diff --git a/ios/RNSentry.mm b/ios/RNSentry.mm index 35aa601cab..8a0159b18a 100644 --- a/ios/RNSentry.mm +++ b/ios/RNSentry.mm @@ -106,6 +106,7 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) // The user could tho initialize the SDK manually and set themselves. [mutableOptions removeObjectForKey:@"tracesSampleRate"]; [mutableOptions removeObjectForKey:@"tracesSampler"]; + [mutableOptions removeObjectForKey:@"enableTracing"]; SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions didFailWithError:errorPointer]; if (*errorPointer != nil) {