From d99584ca95cd87e9113dc2fcf5e789ce1ce369dc Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Fri, 17 Oct 2025 13:26:54 -0300 Subject: [PATCH 1/9] chore: Fix RNSentry after SentryFramesTracker conversion to swift --- .../RNSentryCocoaTester.xcodeproj/project.pbxproj | 8 ++++---- .../RNSentryDependencyContainerTests.h | 8 -------- .../RNSentryDependencyContainerTests.m | 2 +- .../RNSentryFramesTrackerListenerTests.h | 8 -------- .../RNSentryFramesTrackerListenerTests.m | 3 ++- .../RNSentryOnDrawReporter+Test.h | 1 + packages/core/ios/RNSentry.mm | 2 +- packages/core/ios/RNSentryDependencyContainer.h | 3 ++- packages/core/ios/RNSentryDependencyContainer.m | 1 + packages/core/ios/RNSentryEmitNewFrameEvent.h | 3 +++ packages/core/ios/RNSentryFramesTrackerListener.h | 4 ++-- packages/core/ios/RNSentryFramesTrackerListener.m | 2 ++ packages/core/ios/RNSentryOnDrawReporter.h | 3 ++- packages/core/ios/RNSentryOnDrawReporter.m | 2 ++ packages/core/ios/RNSentryRNSScreen.m | 4 ++-- 15 files changed, 25 insertions(+), 29 deletions(-) delete mode 100644 packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.h delete mode 100644 packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.h create mode 100644 packages/core/ios/RNSentryEmitNewFrameEvent.h diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj b/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj index 02284f6023..e3ee9ff032 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj @@ -40,9 +40,7 @@ 338739072A7D7D2800950DDD /* RNSentryReplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryReplay.h; path = ../ios/RNSentryReplay.h; sourceTree = ""; }; 33958C672BFCEF5A00AD1FB6 /* RNSentryOnDrawReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSentryOnDrawReporter.h; path = ../ios/RNSentryOnDrawReporter.h; sourceTree = ""; }; 33AFDFEC2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSentryFramesTrackerListenerTests.m; sourceTree = ""; }; - 33AFDFEE2B8D14C200AAB120 /* RNSentryFramesTrackerListenerTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNSentryFramesTrackerListenerTests.h; sourceTree = ""; }; 33AFDFF02B8D15E500AAB120 /* RNSentryDependencyContainerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSentryDependencyContainerTests.m; sourceTree = ""; }; - 33AFDFF22B8D15F600AAB120 /* RNSentryDependencyContainerTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNSentryDependencyContainerTests.h; sourceTree = ""; }; 33AFE0132B8F31AF00AAB120 /* RNSentryDependencyContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSentryDependencyContainer.h; path = ../ios/RNSentryDependencyContainer.h; sourceTree = ""; }; 33DEDFE92D8DBE5B006066E4 /* RNSentryOnDrawReporterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNSentryOnDrawReporterTests.swift; sourceTree = ""; }; 33DEDFEB2D8DC800006066E4 /* RNSentryOnDrawReporter+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNSentryOnDrawReporter+Test.h"; sourceTree = ""; }; @@ -52,6 +50,8 @@ 33F58ACF2977037D008F60EA /* RNSentryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSentryTests.m; sourceTree = ""; }; 650CB718ACFBD05609BF2126 /* libPods-RNSentryCocoaTesterTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNSentryCocoaTesterTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; E2321E7CFA55AB617247098E /* Pods-RNSentryCocoaTesterTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSentryCocoaTesterTests.debug.xcconfig"; path = "Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests.debug.xcconfig"; sourceTree = ""; }; + F48F26542EA2A481008A185E /* RNSentryEmitNewFrameEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryEmitNewFrameEvent.h; path = ../ios/RNSentryEmitNewFrameEvent.h; sourceTree = SOURCE_ROOT; }; + F48F26552EA2A4D4008A185E /* RNSentryFramesTrackerListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryFramesTrackerListener.h; path = ../ios/RNSentryFramesTrackerListener.h; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -108,9 +108,7 @@ 33F58ACF2977037D008F60EA /* RNSentryTests.m */, 3339C4802D6625570088EB3A /* RNSentryUserTests.m */, 33AFDFEC2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m */, - 33AFDFEE2B8D14C200AAB120 /* RNSentryFramesTrackerListenerTests.h */, 33AFDFF02B8D15E500AAB120 /* RNSentryDependencyContainerTests.m */, - 33AFDFF22B8D15F600AAB120 /* RNSentryDependencyContainerTests.h */, 3360843C2C340C76008CC412 /* RNSentryBreadcrumbTests.swift */, 332D33462CDBDBB600547D76 /* RNSentryReplayOptionsTests.swift */, 3380C6C32CE25ECA0018B9B6 /* RNSentryReplayPostInitTests.swift */, @@ -138,6 +136,8 @@ 33958C672BFCEF5A00AD1FB6 /* RNSentryOnDrawReporter.h */, 33AFE0132B8F31AF00AAB120 /* RNSentryDependencyContainer.h */, 338739072A7D7D2800950DDD /* RNSentryReplay.h */, + F48F26542EA2A481008A185E /* RNSentryEmitNewFrameEvent.h */, + F48F26552EA2A4D4008A185E /* RNSentryFramesTrackerListener.h */, ); name = RNSentry; sourceTree = ""; diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.h deleted file mode 100644 index c987776703..0000000000 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.h +++ /dev/null @@ -1,8 +0,0 @@ -#import "SentryFramesTracker.h" -#import -#import - -@interface SentryDependencyContainer : NSObject -+ (instancetype)sharedInstance; -@property (nonatomic, strong) SentryFramesTracker *framesTracker; -@end diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m index 1cef19682c..eb53a6322e 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m @@ -1,8 +1,8 @@ -#import "RNSentryDependencyContainerTests.h" #import "RNSentryDependencyContainer.h" #import #import #import +@import Sentry; @interface RNSentryDependencyContainerTests : XCTestCase diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.h deleted file mode 100644 index c987776703..0000000000 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.h +++ /dev/null @@ -1,8 +0,0 @@ -#import "SentryFramesTracker.h" -#import -#import - -@interface SentryDependencyContainer : NSObject -+ (instancetype)sharedInstance; -@property (nonatomic, strong) SentryFramesTracker *framesTracker; -@end diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m index 7a877795d6..933d913cb5 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m @@ -1,8 +1,9 @@ -#import "RNSentryFramesTrackerListenerTests.h" #import "RNSentryDependencyContainer.h" +#import "RNSentryFramesTrackerListener.h" #import #import #import +@import Sentry; @interface RNSentryFramesTrackerListenerTests : XCTestCase diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h index 8a9df3a94e..5579beb6b4 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h @@ -1,4 +1,5 @@ #import "RNSentryOnDrawReporter.h" +#import "RNSentryEmitNewFrameEvent.h" #import @interface RNSentryOnDrawReporterView (Testing) diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 0305af0a08..af9efa6f8b 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -49,7 +49,7 @@ #endif #if SENTRY_HAS_UIKIT -# import "RNSentryFramesTrackerListener.h" +# import "RNSentryEmitNewFrameEvent.h" # import "RNSentryRNSScreen.h" #endif diff --git a/packages/core/ios/RNSentryDependencyContainer.h b/packages/core/ios/RNSentryDependencyContainer.h index cd3eca59c7..b3b3ff5233 100644 --- a/packages/core/ios/RNSentryDependencyContainer.h +++ b/packages/core/ios/RNSentryDependencyContainer.h @@ -1,6 +1,7 @@ #import -#import "RNSentryFramesTrackerListener.h" +#import "RNSentryEmitNewFrameEvent.h" +@class RNSentryFramesTrackerListener; @interface RNSentryDependencyContainer : NSObject SENTRY_NO_INIT diff --git a/packages/core/ios/RNSentryDependencyContainer.m b/packages/core/ios/RNSentryDependencyContainer.m index e91cac7f81..9afaf4a6a8 100644 --- a/packages/core/ios/RNSentryDependencyContainer.m +++ b/packages/core/ios/RNSentryDependencyContainer.m @@ -1,5 +1,6 @@ #import "RNSentryDependencyContainer.h" #import +#import "RNSentryFramesTrackerListener.h" @implementation RNSentryDependencyContainer { NSObject *sentryDependencyContainerLock; diff --git a/packages/core/ios/RNSentryEmitNewFrameEvent.h b/packages/core/ios/RNSentryEmitNewFrameEvent.h new file mode 100644 index 0000000000..473c91cc77 --- /dev/null +++ b/packages/core/ios/RNSentryEmitNewFrameEvent.h @@ -0,0 +1,3 @@ +#import + +typedef void (^RNSentryEmitNewFrameEvent)(NSNumber *newFrameTimestampInSeconds); diff --git a/packages/core/ios/RNSentryFramesTrackerListener.h b/packages/core/ios/RNSentryFramesTrackerListener.h index 627b3059f4..737a3fe8eb 100644 --- a/packages/core/ios/RNSentryFramesTrackerListener.h +++ b/packages/core/ios/RNSentryFramesTrackerListener.h @@ -4,9 +4,9 @@ # import # import -# import +# import "RNSentryEmitNewFrameEvent.h" -typedef void (^RNSentryEmitNewFrameEvent)(NSNumber *newFrameTimestampInSeconds); +@import Sentry; @protocol RNSentryFramesTrackerListenerProtocol diff --git a/packages/core/ios/RNSentryFramesTrackerListener.m b/packages/core/ios/RNSentryFramesTrackerListener.m index 4a3c7d99cd..2e090bc711 100644 --- a/packages/core/ios/RNSentryFramesTrackerListener.m +++ b/packages/core/ios/RNSentryFramesTrackerListener.m @@ -2,6 +2,8 @@ #if SENTRY_HAS_UIKIT +@import Sentry; + @implementation RNSentryFramesTrackerListener - (instancetype)initWithSentryFramesTracker:(SentryFramesTracker *)framesTracker diff --git a/packages/core/ios/RNSentryOnDrawReporter.h b/packages/core/ios/RNSentryOnDrawReporter.h index 5c4083015d..b462dc4f0b 100644 --- a/packages/core/ios/RNSentryOnDrawReporter.h +++ b/packages/core/ios/RNSentryOnDrawReporter.h @@ -2,10 +2,11 @@ #if SENTRY_HAS_UIKIT -# import "RNSentryFramesTrackerListener.h" # import # import +@protocol RNSentryFramesTrackerListenerProtocol; + @interface RNSentryOnDrawReporter : RCTViewManager @end diff --git a/packages/core/ios/RNSentryOnDrawReporter.m b/packages/core/ios/RNSentryOnDrawReporter.m index dc11bc9c51..84f330f562 100644 --- a/packages/core/ios/RNSentryOnDrawReporter.m +++ b/packages/core/ios/RNSentryOnDrawReporter.m @@ -1,5 +1,7 @@ #import "RNSentryOnDrawReporter.h" #import "RNSentryTimeToDisplay.h" +#import "RNSentryFramesTrackerListener.h" +#import "RNSentryEmitNewFrameEvent.h" #if SENTRY_HAS_UIKIT diff --git a/packages/core/ios/RNSentryRNSScreen.m b/packages/core/ios/RNSentryRNSScreen.m index 20c42ab4c4..05c574fd6a 100644 --- a/packages/core/ios/RNSentryRNSScreen.m +++ b/packages/core/ios/RNSentryRNSScreen.m @@ -3,10 +3,10 @@ #if SENTRY_HAS_UIKIT # import -# import # import - # import "RNSentryDependencyContainer.h" +# import "RNSentryFramesTrackerListener.h" +@import Sentry; @implementation RNSentryRNSScreen From ca44d59406ad1254be2c1bb48a504c7e7db3bb77 Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Fri, 17 Oct 2025 14:54:06 -0300 Subject: [PATCH 2/9] Run linter --- .../RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h | 2 +- .../RNSentryCocoaTesterTests/RNSentryTests.m | 2 +- packages/core/ios/RNSentryDependencyContainer.m | 2 +- packages/core/ios/RNSentryFramesTrackerListener.h | 2 +- packages/core/ios/RNSentryOnDrawReporter.m | 4 ++-- packages/core/ios/RNSentryRNSScreen.m | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h index 5579beb6b4..753983baae 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h @@ -1,5 +1,5 @@ -#import "RNSentryOnDrawReporter.h" #import "RNSentryEmitNewFrameEvent.h" +#import "RNSentryOnDrawReporter.h" #import @interface RNSentryOnDrawReporterView (Testing) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 66556e6e27..c87fc8b7e7 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -348,7 +348,7 @@ - (void)testCreateOptionsWithDictionaryEnableLogsDisabled XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); - + BOOL enableLogs = [[actualOptions valueForKey:@"enableLogs"] boolValue]; XCTAssertFalse(enableLogs, @"enableLogs should be disabled"); } diff --git a/packages/core/ios/RNSentryDependencyContainer.m b/packages/core/ios/RNSentryDependencyContainer.m index 9afaf4a6a8..a137554224 100644 --- a/packages/core/ios/RNSentryDependencyContainer.m +++ b/packages/core/ios/RNSentryDependencyContainer.m @@ -1,6 +1,6 @@ #import "RNSentryDependencyContainer.h" -#import #import "RNSentryFramesTrackerListener.h" +#import @implementation RNSentryDependencyContainer { NSObject *sentryDependencyContainerLock; diff --git a/packages/core/ios/RNSentryFramesTrackerListener.h b/packages/core/ios/RNSentryFramesTrackerListener.h index 737a3fe8eb..630f0daeee 100644 --- a/packages/core/ios/RNSentryFramesTrackerListener.h +++ b/packages/core/ios/RNSentryFramesTrackerListener.h @@ -2,9 +2,9 @@ #if SENTRY_HAS_UIKIT +# import "RNSentryEmitNewFrameEvent.h" # import # import -# import "RNSentryEmitNewFrameEvent.h" @import Sentry; diff --git a/packages/core/ios/RNSentryOnDrawReporter.m b/packages/core/ios/RNSentryOnDrawReporter.m index 84f330f562..14f322bd99 100644 --- a/packages/core/ios/RNSentryOnDrawReporter.m +++ b/packages/core/ios/RNSentryOnDrawReporter.m @@ -1,7 +1,7 @@ #import "RNSentryOnDrawReporter.h" -#import "RNSentryTimeToDisplay.h" -#import "RNSentryFramesTrackerListener.h" #import "RNSentryEmitNewFrameEvent.h" +#import "RNSentryFramesTrackerListener.h" +#import "RNSentryTimeToDisplay.h" #if SENTRY_HAS_UIKIT diff --git a/packages/core/ios/RNSentryRNSScreen.m b/packages/core/ios/RNSentryRNSScreen.m index 05c574fd6a..ee7c422bcc 100644 --- a/packages/core/ios/RNSentryRNSScreen.m +++ b/packages/core/ios/RNSentryRNSScreen.m @@ -2,10 +2,10 @@ #if SENTRY_HAS_UIKIT -# import -# import # import "RNSentryDependencyContainer.h" # import "RNSentryFramesTrackerListener.h" +# import +# import @import Sentry; @implementation RNSentryRNSScreen From 4c0fb3470bc14dcd72dddcae2f99f11da6b2cfb3 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Fri, 17 Oct 2025 22:58:20 -0400 Subject: [PATCH 3/9] Remove unused debug image provider imports --- .../RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m | 1 - packages/core/ios/RNSentry+fetchNativeStack.m | 1 - packages/core/ios/RNSentry.h | 1 - packages/core/ios/RNSentry.mm | 1 - 4 files changed, 4 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index c87fc8b7e7..01692c862a 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -1,7 +1,6 @@ #import "RNSentryTests.h" #import #import -#import #import #import @import Sentry; diff --git a/packages/core/ios/RNSentry+fetchNativeStack.m b/packages/core/ios/RNSentry+fetchNativeStack.m index ffb404fa22..95a0cdf02f 100644 --- a/packages/core/ios/RNSentry+fetchNativeStack.m +++ b/packages/core/ios/RNSentry+fetchNativeStack.m @@ -4,7 +4,6 @@ #import #import #import -#import #import #import #import diff --git a/packages/core/ios/RNSentry.h b/packages/core/ios/RNSentry.h index 78f48f5f4b..373d1aec46 100644 --- a/packages/core/ios/RNSentry.h +++ b/packages/core/ios/RNSentry.h @@ -8,7 +8,6 @@ #import #import -#import typedef int (*SymbolicateCallbackType)(const void *, Dl_info *); diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index af9efa6f8b..7b20dd7a7d 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -21,7 +21,6 @@ #import #import #import -#import #import #import #import From d61ca6db52c0880d5f3119c391783f319bb10dc4 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Tue, 21 Oct 2025 15:39:18 -0400 Subject: [PATCH 4/9] Remove imports --- packages/core/ios/RNSentry+fetchNativeStack.m | 1 - packages/core/ios/RNSentry.mm | 1 - packages/core/ios/RNSentryDependencyContainer.m | 1 - packages/core/ios/RNSentryOnDrawReporter.m | 2 -- packages/core/ios/RNSentryRNSScreen.m | 1 - 5 files changed, 6 deletions(-) diff --git a/packages/core/ios/RNSentry+fetchNativeStack.m b/packages/core/ios/RNSentry+fetchNativeStack.m index 95a0cdf02f..04f5e7e140 100644 --- a/packages/core/ios/RNSentry+fetchNativeStack.m +++ b/packages/core/ios/RNSentry+fetchNativeStack.m @@ -5,7 +5,6 @@ #import #import #import -#import #import #import #import diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 7b20dd7a7d..9b6e9bbc6d 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -22,7 +22,6 @@ #import #import #import -#import #import #import #import diff --git a/packages/core/ios/RNSentryDependencyContainer.m b/packages/core/ios/RNSentryDependencyContainer.m index a137554224..0147e0b395 100644 --- a/packages/core/ios/RNSentryDependencyContainer.m +++ b/packages/core/ios/RNSentryDependencyContainer.m @@ -1,6 +1,5 @@ #import "RNSentryDependencyContainer.h" #import "RNSentryFramesTrackerListener.h" -#import @implementation RNSentryDependencyContainer { NSObject *sentryDependencyContainerLock; diff --git a/packages/core/ios/RNSentryOnDrawReporter.m b/packages/core/ios/RNSentryOnDrawReporter.m index 14f322bd99..44d8024a6f 100644 --- a/packages/core/ios/RNSentryOnDrawReporter.m +++ b/packages/core/ios/RNSentryOnDrawReporter.m @@ -5,8 +5,6 @@ #if SENTRY_HAS_UIKIT -# import - @implementation RNSentryOnDrawReporter RCT_EXPORT_MODULE(RNSentryOnDrawReporter) diff --git a/packages/core/ios/RNSentryRNSScreen.m b/packages/core/ios/RNSentryRNSScreen.m index ee7c422bcc..90b2e733d3 100644 --- a/packages/core/ios/RNSentryRNSScreen.m +++ b/packages/core/ios/RNSentryRNSScreen.m @@ -4,7 +4,6 @@ # import "RNSentryDependencyContainer.h" # import "RNSentryFramesTrackerListener.h" -# import # import @import Sentry; From 6a25cb9e7dbc02ef27490ef9cc1f6bfc744655c5 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Wed, 22 Oct 2025 11:08:34 -0400 Subject: [PATCH 5/9] chore: Remove deprecated user property --- .../RNSentryCocoaTesterTests/RNSentryUserTests.m | 5 ----- packages/core/ios/RNSentry.mm | 4 ---- 2 files changed, 9 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUserTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUserTests.m index 0111e8ddcf..987dc6d2e1 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUserTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUserTests.m @@ -14,7 +14,6 @@ - (void)testValidUser [expected setIpAddress:@"192.168.1.1"]; [expected setEmail:@"test@example.com"]; [expected setUsername:@"testuser"]; - [expected setSegment:@"testsegment"]; [expected setData:@{ @"foo" : @"bar", @"baz" : @123, @@ -26,7 +25,6 @@ - (void)testValidUser @"ip_address" : @"192.168.1.1", @"email" : @"test@example.com", @"username" : @"testuser", - @"segment" : @"testsegment", } otherUserKeys:@{ @"foo" : @"bar", @@ -67,7 +65,6 @@ - (void)testInvalidUser @"ip_address" : @ {}, @"email" : @ {}, @"username" : @ {}, - @"segment" : @[], } otherUserKeys:nil]; @@ -84,7 +81,6 @@ - (void)testPartiallyInvalidUser @"ip_address" : @ {}, @"email" : @ {}, @"username" : @ {}, - @"segment" : @[], } otherUserKeys:nil]; @@ -100,7 +96,6 @@ - (void)testNullValuesUser @"ip_address" : [NSNull null], @"email" : [NSNull null], @"username" : [NSNull null], - @"segment" : [NSNull null], } otherUserKeys:nil]; diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 9b6e9bbc6d..1d6c8f1887 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -709,10 +709,6 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys if ([username isKindOfClass:NSString.class]) { [userInstance setUsername:username]; } - id segment = [userKeys valueForKey:@"segment"]; - if ([segment isKindOfClass:NSString.class]) { - [userInstance setSegment:segment]; - } if ([userDataKeys isKindOfClass:NSDictionary.class]) { [userInstance setData:userDataKeys]; From 1bda8024366c3e3cad5246504b6a46a82344fdb2 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Fri, 24 Oct 2025 02:03:51 -0400 Subject: [PATCH 6/9] chore: Remove use of deprecate integrations API (#5304) --- .../RNSentryCocoaTesterTests/RNSentryTests.m | 3 +-- packages/core/ios/RNSentry.mm | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 01692c862a..34db8a3d40 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -132,8 +132,7 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); - XCTAssertEqual([actualOptions.integrations containsObject:@"SentryCrashIntegration"], false, - @"Did not disable native crash handling"); + XCTAssertFalse(actualOptions.enableCrashHandler, @"Did not disable native crash handling"); } - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDisabled diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 1d6c8f1887..e9a0684569 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -261,9 +261,7 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) BOOL enableNativeCrashHandling = [mutableOptions[@"enableNativeCrashHandling"] boolValue]; if (!enableNativeCrashHandling) { - NSMutableArray *integrations = sentryOptions.integrations.mutableCopy; - [integrations removeObject:@"SentryCrashIntegration"]; - sentryOptions.integrations = integrations; + sentryOptions.enableCrashHandler = NO; } } From 0327771ba20101489d5fbe3ede3b7d5b6fea770c Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Mon, 27 Oct 2025 10:37:41 -0400 Subject: [PATCH 7/9] Remove use of integrations in tests --- .../RNSentryCocoaTesterTests/RNSentryTests.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 34db8a3d40..6a694670fb 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -65,8 +65,7 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); - XCTAssertEqual([actualOptions.integrations containsObject:@"SentryCrashIntegration"], true, - @"Did not set native crash handling"); + XCTAssertTrue(actualOptions.enableCrashHandler, @"Did not set native crash handling"); } - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDefault @@ -98,8 +97,7 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingEnabled error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); - XCTAssertEqual([actualOptions.integrations containsObject:@"SentryCrashIntegration"], true, - @"Did not set native crash handling"); + XCTAssertTrue(actualOptions.enableCrashHandler, @"Did not set native crash handling"); } - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingEnabled From 80af135c9c351698401a41461afdc167391b2985 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Fri, 31 Oct 2025 04:11:07 -0400 Subject: [PATCH 8/9] chore: Remove use of deprecated prop (#5322) --- .../RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift index 5dcd2be3ec..340833a1e3 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift @@ -178,7 +178,7 @@ final class RNSentryReplayOptions: XCTestCase { let actualOptions = try! SentryOptionsInternal.initWithDict(optionsDict as! [String: Any]) - XCTAssertTrue(actualOptions.sessionReplay.enableExperimentalViewRenderer) + XCTAssertTrue(actualOptions.sessionReplay.enableViewRendererV2) } func testEnableExperimentalViewRendererTrue() { From b407fd2db7502b95588fc1cc4a1f30932787defe Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Thu, 6 Nov 2025 10:44:15 -0500 Subject: [PATCH 9/9] ref: Move options to wrapper --- .../project.pbxproj | 4 + .../RNSentryCocoaTesterTests/RNSentryTests.m | 184 +++++++++------- packages/core/ios/RNSentry+fetchNativeStack.m | 8 - packages/core/ios/RNSentry.h | 3 +- packages/core/ios/RNSentry.mm | 200 +++++------------- packages/core/ios/SentrySDKWrapper.h | 14 ++ packages/core/ios/SentrySDKWrapper.m | 128 +++++++++++ 7 files changed, 303 insertions(+), 238 deletions(-) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj b/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj index e3ee9ff032..1645b60166 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTester.xcodeproj/project.pbxproj @@ -51,6 +51,7 @@ 650CB718ACFBD05609BF2126 /* libPods-RNSentryCocoaTesterTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNSentryCocoaTesterTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; E2321E7CFA55AB617247098E /* Pods-RNSentryCocoaTesterTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSentryCocoaTesterTests.debug.xcconfig"; path = "Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests.debug.xcconfig"; sourceTree = ""; }; F48F26542EA2A481008A185E /* RNSentryEmitNewFrameEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryEmitNewFrameEvent.h; path = ../ios/RNSentryEmitNewFrameEvent.h; sourceTree = SOURCE_ROOT; }; + FADF868E2EBD053E00D6652D /* SentrySDKWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySDKWrapper.h; path = ../ios/SentrySDKWrapper.h; sourceTree = SOURCE_ROOT; }; F48F26552EA2A4D4008A185E /* RNSentryFramesTrackerListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryFramesTrackerListener.h; path = ../ios/RNSentryFramesTrackerListener.h; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -134,6 +135,7 @@ 3360843A2C32E3A8008CC412 /* RNSentryReplayBreadcrumbConverter.h */, 330F308D2C0F385A002A0D4E /* RNSentryBreadcrumb.h */, 33958C672BFCEF5A00AD1FB6 /* RNSentryOnDrawReporter.h */, + FADF868E2EBD053E00D6652D /* SentrySDKWrapper.h */, 33AFE0132B8F31AF00AAB120 /* RNSentryDependencyContainer.h */, 338739072A7D7D2800950DDD /* RNSentryReplay.h */, F48F26542EA2A481008A185E /* RNSentryEmitNewFrameEvent.h */, @@ -244,6 +246,8 @@ ); outputPaths = ( ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNSentryCocoaTesterTests/Pods-RNSentryCocoaTesterTests-resources.sh\"\n"; diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index 6a694670fb..949492a35a 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -1,4 +1,6 @@ #import "RNSentryTests.h" +#import "RNSentryReplay.h" +#import "SentrySDKWrapper.h" #import #import #import @@ -25,8 +27,10 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties , @"enableTracing" : @YES, } ; -SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; +mockedReactNativeDictionary = [rnSentry prepareOptions:mockedReactNativeDictionary]; +SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -39,14 +43,14 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties - (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]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -55,14 +59,14 @@ - (void)testCaptureFailedRequestsIsDisabled - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault { - 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]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertTrue(actualOptions.enableCrashHandler, @"Did not set native crash handling"); @@ -70,14 +74,14 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDefault { - 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]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertEqual( @@ -86,15 +90,15 @@ - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDefault - (void)testCreateOptionsWithDictionaryNativeCrashHandlingEnabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"enableNativeCrashHandling" : @YES, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertTrue(actualOptions.enableCrashHandler, @"Did not set native crash handling"); @@ -102,15 +106,15 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingEnabled - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingEnabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"enableAutoPerformanceTracing" : @YES, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertEqual( @@ -119,15 +123,15 @@ - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingEnabled - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"enableNativeCrashHandling" : @NO, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertFalse(actualOptions.enableCrashHandler, @"Did not disable native crash handling"); @@ -135,15 +139,15 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDisabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"enableAutoPerformanceTracing" : @NO, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertEqual(actualOptions.enableAutoPerformanceTracing, false, @@ -152,7 +156,6 @@ - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDisabled - (void)testCreateOptionsWithDictionarySpotlightEnabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @@ -160,8 +163,9 @@ - (void)testCreateOptionsWithDictionarySpotlightEnabled @"spotlight" : @YES, @"defaultSidecarUrl" : @"http://localhost:8969/teststream", }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertTrue(actualOptions.enableSpotlight, @"Did not enable spotlight"); @@ -170,7 +174,6 @@ - (void)testCreateOptionsWithDictionarySpotlightEnabled - (void)testCreateOptionsWithDictionarySpotlightOne { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @@ -178,8 +181,9 @@ - (void)testCreateOptionsWithDictionarySpotlightOne @"spotlight" : @1, @"defaultSidecarUrl" : @"http://localhost:8969/teststream", }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertTrue(actualOptions.enableSpotlight, @"Did not enable spotlight"); @@ -188,15 +192,15 @@ - (void)testCreateOptionsWithDictionarySpotlightOne - (void)testCreateOptionsWithDictionarySpotlightUrl { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"spotlight" : @"http://localhost:8969/teststream", }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertTrue(actualOptions.enableSpotlight, @"Did not enable spotlight"); @@ -205,15 +209,15 @@ - (void)testCreateOptionsWithDictionarySpotlightUrl - (void)testCreateOptionsWithDictionarySpotlightDisabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"spotlight" : @NO, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertFalse(actualOptions.enableSpotlight, @"Did not disable spotlight"); @@ -221,15 +225,15 @@ - (void)testCreateOptionsWithDictionarySpotlightDisabled - (void)testCreateOptionsWithDictionarySpotlightZero { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"spotlight" : @0, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); XCTAssertFalse(actualOptions.enableSpotlight, @"Did not disable spotlight"); @@ -237,7 +241,6 @@ - (void)testCreateOptionsWithDictionarySpotlightZero - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Enabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @@ -246,8 +249,9 @@ - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Enabled @"enableUnhandledCPPExceptionsV2" : @YES, }, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -263,7 +267,6 @@ - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Enabled - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Disabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @@ -272,8 +275,9 @@ - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Disabled @"enableUnhandledCPPExceptionsV2" : @NO, }, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -289,14 +293,14 @@ - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Disabled - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Default { - 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]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -313,15 +317,15 @@ - (void)testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Default - (void)testCreateOptionsWithDictionaryEnableLogsEnabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"enableLogs" : @YES, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -332,15 +336,15 @@ - (void)testCreateOptionsWithDictionaryEnableLogsEnabled - (void)testCreateOptionsWithDictionaryEnableLogsDisabled { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"https://abcd@efgh.ingest.sentry.io/123456", @"enableLogs" : @NO, }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNotNil(actualOptions, @"Did not create sentry options"); XCTAssertNil(error, @"Should not pass no error"); @@ -351,14 +355,14 @@ - (void)testCreateOptionsWithDictionaryEnableLogsDisabled - (void)testPassesErrorOnWrongDsn { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedReactNativeDictionary = @{ @"dsn" : @"not_a_valid_dsn", }; - SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary:mockedReactNativeDictionary - error:&error]; + SentryOptions *actualOptions = + [SentrySDKWrapper createOptionsWithDictionary:mockedReactNativeDictionary + error:&error]; XCTAssertNil(actualOptions, @"Created invalid sentry options"); XCTAssertNotNil(error, @"Did not created error on invalid dsn"); @@ -373,8 +377,9 @@ - (void)testBeforeBreadcrumbsCallbackFiltersOutSentryDsnRequestBreadcrumbs @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"devServerUrl" : @"http://localhost:8081" }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; - + mockedDictionary = [rnSentry prepareOptions:mockedDictionary]; + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedDictionary + error:&error]; SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; breadcrumb.type = @"http"; breadcrumb.data = @{ @"url" : @"https://def.ingest.sentry.io/1234567" }; @@ -386,15 +391,14 @@ - (void)testBeforeBreadcrumbsCallbackFiltersOutSentryDsnRequestBreadcrumbs - (void)testBeforeBreadcrumbsCallbackFiltersOutDevServerRequestBreadcrumbs { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSString *mockDevServer = @"http://localhost:8081"; NSDictionary *_Nonnull mockedDictionary = @{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"devServerUrl" : mockDevServer }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; - + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedDictionary + error:&error]; SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; breadcrumb.type = @"http"; breadcrumb.data = @{ @"url" : mockDevServer }; @@ -406,15 +410,14 @@ - (void)testBeforeBreadcrumbsCallbackFiltersOutDevServerRequestBreadcrumbs - (void)testBeforeBreadcrumbsCallbackDoesNotFiltersOutNonDevServerOrDsnRequestBreadcrumbs { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedDictionary = @{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"devServerUrl" : @"http://localhost:8081" }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; - + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedDictionary + error:&error]; SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; breadcrumb.type = @"http"; breadcrumb.data = @{ @"url" : @"http://testurl.com/service" }; @@ -426,14 +429,13 @@ - (void)testBeforeBreadcrumbsCallbackDoesNotFiltersOutNonDevServerOrDsnRequestBr - (void)testBeforeBreadcrumbsCallbackKeepsBreadcrumbWhenDevServerUrlIsNotPassedAndDsnDoesNotMatch { - RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; NSDictionary *_Nonnull mockedDictionary = @{ // dsn is always validated in SentryOptions initialization @"dsn" : @"https://abc@def.ingest.sentry.io/1234567" }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; - + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedDictionary + error:&error]; SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; breadcrumb.type = @"http"; breadcrumb.data = @{ @"url" : @"http://testurl.com/service" }; @@ -614,11 +616,13 @@ - (void)testIgnoreErrorsDropsMatchingExceptionValue { RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; - NSDictionary *mockedOptions = @{ + NSMutableDictionary *mockedOptions = [@{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"ignoreErrorsRegex" : @[ @"IgnoreMe.*" ] - }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedOptions error:&error]; + } mutableCopy]; + mockedOptions = [rnSentry prepareOptions:mockedOptions]; + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedOptions + error:&error]; XCTAssertNotNil(options); XCTAssertNil(error); SentryEvent *event = [[SentryEvent alloc] init]; @@ -633,11 +637,14 @@ - (void)testIgnoreErrorsDropsMatchingEventMessage { RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; - NSDictionary *mockedOptions = @{ + NSMutableDictionary *mockedOptions = [@{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"ignoreErrorsStr" : @[ @"DropThisError" ] - }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedOptions error:&error]; + } mutableCopy]; + mockedOptions = [rnSentry prepareOptions:mockedOptions]; + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedOptions + error:&error]; + XCTAssertNotNil(options); XCTAssertNotNil(options); XCTAssertNil(error); SentryEvent *event = [[SentryEvent alloc] init]; @@ -652,11 +659,14 @@ - (void)testIgnoreErrorsDoesNotDropNonMatchingEvent { RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; - NSDictionary *mockedOptions = @{ + NSMutableDictionary *mockedOptions = [@{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"ignoreErrorsRegex" : @[ @"IgnoreMe.*" ] - }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedOptions error:&error]; + } mutableCopy]; + mockedOptions = [rnSentry prepareOptions:mockedOptions]; + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedOptions + error:&error]; + XCTAssertNotNil(options); XCTAssertNotNil(options); XCTAssertNil(error); SentryEvent *event = [[SentryEvent alloc] init]; @@ -674,11 +684,14 @@ - (void)testIgnoreErrorsDropsMatchingExactString { RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; - NSDictionary *mockedOptions = @{ + NSMutableDictionary *mockedOptions = [@{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"ignoreErrorsStr" : @[ @"ExactError" ] - }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedOptions error:&error]; + } mutableCopy]; + mockedOptions = [rnSentry prepareOptions:mockedOptions]; + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedOptions + error:&error]; + XCTAssertNotNil(options); XCTAssertNotNil(options); XCTAssertNil(error); SentryEvent *event = [[SentryEvent alloc] init]; @@ -693,13 +706,16 @@ - (void)testIgnoreErrorsRegexAndStringBothWork { RNSentry *rnSentry = [[RNSentry alloc] init]; NSError *error = nil; - NSDictionary *mockedOptions = @{ + NSMutableDictionary *mockedOptions = [@{ @"dsn" : @"https://abc@def.ingest.sentry.io/1234567", @"ignoreErrorsStr" : @[ @"ExactError" ], @"ignoreErrorsRegex" : @[ @"IgnoreMe.*" ], - }; - SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedOptions error:&error]; + } mutableCopy]; + mockedOptions = [rnSentry prepareOptions:mockedOptions]; + SentryOptions *options = [SentrySDKWrapper createOptionsWithDictionary:mockedOptions + error:&error]; + XCTAssertNotNil(options); XCTAssertNotNil(options); XCTAssertNil(error); // Test regex match @@ -725,4 +741,8 @@ - (void)testIgnoreErrorsRegexAndStringBothWork XCTAssertNotNil(result3, @"Event with non-matching error should not be dropped"); } + + + + @end diff --git a/packages/core/ios/RNSentry+fetchNativeStack.m b/packages/core/ios/RNSentry+fetchNativeStack.m index 04f5e7e140..d10f82108c 100644 --- a/packages/core/ios/RNSentry+fetchNativeStack.m +++ b/packages/core/ios/RNSentry+fetchNativeStack.m @@ -2,14 +2,6 @@ #import "RNSentryBreadcrumb.h" #import "RNSentryId.h" #import -#import -#import -#import -#import -#import -#import -#import -#import @import Sentry; // This method was moved to a new category so we can use `@import Sentry` to use Sentry's Swift diff --git a/packages/core/ios/RNSentry.h b/packages/core/ios/RNSentry.h index 373d1aec46..5b163baca9 100644 --- a/packages/core/ios/RNSentry.h +++ b/packages/core/ios/RNSentry.h @@ -20,8 +20,7 @@ typedef int (*SymbolicateCallbackType)(const void *, Dl_info *); @interface RNSentry : RCTEventEmitter -- (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options - error:(NSError *_Nullable *_Nonnull)errorPointer; +- (NSMutableDictionary *)prepareOptions:(NSDictionary *)options; - (void)setEventOriginTag:(SentryEvent *)event; diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index e9a0684569..ecba51576a 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -25,8 +25,6 @@ #import #import #import -#import -#import #import // This guard prevents importing Hermes in JSC apps @@ -84,24 +82,64 @@ - (instancetype)init return self; } +- (NSMutableDictionary *)prepareOptions:(NSDictionary *)options +{ + SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event) { + // We don't want to send an event after startup that came from a Unhandled JS Exception of + // React Native because we sent it already before the app crashed. + if (nil != event.exceptions.firstObject.type && + [event.exceptions.firstObject.type rangeOfString:@"Unhandled JS Exception"].location + != NSNotFound) { + return nil; + } + + // Regex and Str are set when one of them has value so we only need to check one of them. + if (self->_ignoreErrorPatternsStr || self->_ignoreErrorPatternsRegex) { + for (SentryException *exception in event.exceptions) { + if ([self shouldIgnoreError:exception.value]) { + return nil; + } + } + if ([self shouldIgnoreError:event.message.message]) { + return nil; + } + } + + [self setEventOriginTag:event]; + return event; + }; + + NSMutableDictionary *mutableOptions = [options mutableCopy]; + [mutableOptions setValue:beforeSend forKey:@"beforeSend"]; + + // remove performance traces sample rate and traces sampler since we don't want to synchronize + // these configurations to the Native SDKs. The user could tho initialize the SDK manually and + // set themselves. + [mutableOptions removeObjectForKey:@"tracesSampleRate"]; + [mutableOptions removeObjectForKey:@"tracesSampler"]; + [mutableOptions removeObjectForKey:@"enableTracing"]; + + [self trySetIgnoreErrors:mutableOptions]; + + return mutableOptions; +} + RCT_EXPORT_MODULE() RCT_EXPORT_METHOD(initNativeSdk : (NSDictionary *_Nonnull)options resolve : ( RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { + NSMutableDictionary *mutableOptions = [self prepareOptions:options]; +#if SENTRY_TARGET_REPLAY_SUPPORTED + [RNSentryReplay updateOptions:mutableOptions]; +#endif NSError *error = nil; - SentryOptions *sentryOptions = [self createOptionsWithDictionary:options error:&error]; + [SentrySDKWrapper setupWithDictionary:mutableOptions + error:&error]; if (error != nil) { reject(@"SentryReactNative", error.localizedDescription, error); return; } - NSString *sdkVersion = [PrivateSentrySDKOnly getSdkVersionString]; - [PrivateSentrySDKOnly setSdkName:NATIVE_SDK_NAME andVersionString:sdkVersion]; - [PrivateSentrySDKOnly addSdkPackage:REACT_NATIVE_SDK_PACKAGE_NAME - version:REACT_NATIVE_SDK_PACKAGE_VERSION]; - - [SentrySDKWrapper startWithOptions:sentryOptions]; - #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST BOOL appIsActive = [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive; @@ -112,8 +150,8 @@ - (instancetype)init // If the app is active/in foreground, and we have not sent the SentryHybridSdkDidBecomeActive // notification, send it. if (appIsActive && !sentHybridSdkDidBecomeActive - && (PrivateSentrySDKOnly.options.enableAutoSessionTracking - || PrivateSentrySDKOnly.options.enableWatchdogTerminationTracking)) { + && ([SentrySDKWrapper enableAutoSessionTracking] || + [SentrySDKWrapper enableWatchdogTerminationTracking])) { [[NSNotificationCenter defaultCenter] postNotificationName:@"SentryHybridSdkDidBecomeActive" object:nil]; @@ -127,7 +165,7 @@ - (instancetype)init resolve(@YES); } -- (void)trySetIgnoreErrors:(NSMutableDictionary *)options +- (void)trySetIgnoreErrors:(NSDictionary *)options { NSArray *ignoreErrorsStr = nil; NSArray *ignoreErrorsRegex = nil; @@ -193,136 +231,6 @@ - (BOOL)shouldIgnoreError:(NSString *)message return NO; } -- (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options - error:(NSError *_Nonnull *_Nonnull)errorPointer -{ - SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event) { - // We don't want to send an event after startup that came from a Unhandled JS Exception of - // React Native because we sent it already before the app crashed. - if (nil != event.exceptions.firstObject.type && - [event.exceptions.firstObject.type rangeOfString:@"Unhandled JS Exception"].location - != NSNotFound) { - return nil; - } - - // Regex and Str are set when one of them has value so we only need to check one of them. - if (self->_ignoreErrorPatternsStr || self->_ignoreErrorPatternsRegex) { - for (SentryException *exception in event.exceptions) { - if ([self shouldIgnoreError:exception.value]) { - return nil; - } - } - if ([self shouldIgnoreError:event.message.message]) { - return nil; - } - } - - [self setEventOriginTag:event]; - return event; - }; - - NSMutableDictionary *mutableOptions = [options mutableCopy]; - [mutableOptions setValue:beforeSend forKey:@"beforeSend"]; - - // remove performance traces sample rate and traces sampler since we don't want to synchronize - // these configurations to the Native SDKs. The user could tho initialize the SDK manually and - // set themselves. - [mutableOptions removeObjectForKey:@"tracesSampleRate"]; - [mutableOptions removeObjectForKey:@"tracesSampler"]; - [mutableOptions removeObjectForKey:@"enableTracing"]; - -#if SENTRY_TARGET_REPLAY_SUPPORTED - [RNSentryReplay updateOptions:mutableOptions]; -#endif - - SentryOptions *sentryOptions = [SentryOptionsInternal initWithDict:mutableOptions - didFailWithError:errorPointer]; - if (*errorPointer != nil) { - return nil; - } - - // Exclude Dev Server and Sentry Dsn request from Breadcrumbs - NSString *dsn = [self getURLFromDSN:[mutableOptions valueForKey:@"dsn"]]; - NSString *devServerUrl = [mutableOptions valueForKey:@"devServerUrl"]; - sentryOptions.beforeBreadcrumb - = ^SentryBreadcrumb *_Nullable(SentryBreadcrumb *_Nonnull breadcrumb) - { - NSString *url = breadcrumb.data[@"url"] ?: @""; - - if ([@"http" isEqualToString:breadcrumb.type] - && ((dsn != nil && [url hasPrefix:dsn]) - || (devServerUrl != nil && [url hasPrefix:devServerUrl]))) { - return nil; - } - return breadcrumb; - }; - - if ([mutableOptions valueForKey:@"enableNativeCrashHandling"] != nil) { - BOOL enableNativeCrashHandling = [mutableOptions[@"enableNativeCrashHandling"] boolValue]; - - if (!enableNativeCrashHandling) { - sentryOptions.enableCrashHandler = NO; - } - } - - // Set spotlight option - if ([mutableOptions valueForKey:@"spotlight"] != nil) { - id spotlightValue = [mutableOptions valueForKey:@"spotlight"]; - if ([spotlightValue isKindOfClass:[NSString class]]) { - NSLog(@"Using Spotlight on address: %@", spotlightValue); - sentryOptions.enableSpotlight = true; - sentryOptions.spotlightUrl = spotlightValue; - } else if ([spotlightValue isKindOfClass:[NSNumber class]]) { - sentryOptions.enableSpotlight = [spotlightValue boolValue]; - id defaultSpotlightUrl = [mutableOptions valueForKey:@"defaultSidecarUrl"]; - if (defaultSpotlightUrl != nil) { - sentryOptions.spotlightUrl = defaultSpotlightUrl; - } - } - } - - if ([mutableOptions valueForKey:@"enableLogs"] != nil) { - id enableLogsValue = [mutableOptions valueForKey:@"enableLogs"]; - if ([enableLogsValue isKindOfClass:[NSNumber class]]) { - [RNSentryExperimentalOptions setEnableLogs:[enableLogsValue boolValue] - sentryOptions:sentryOptions]; - } - } - [self trySetIgnoreErrors:mutableOptions]; - - // Enable the App start and Frames tracking measurements - if ([mutableOptions valueForKey:@"enableAutoPerformanceTracing"] != nil) { - BOOL enableAutoPerformanceTracing = - [mutableOptions[@"enableAutoPerformanceTracing"] boolValue]; - PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracing; -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST - PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracing; -#endif - } - - // Failed requests can only be enabled in one SDK to avoid duplicates - sentryOptions.enableCaptureFailedRequests = NO; - - NSDictionary *experiments = options[@"_experiments"]; - if (experiments != nil && [experiments isKindOfClass:[NSDictionary class]]) { - BOOL enableUnhandledCPPExceptions = - [experiments[@"enableUnhandledCPPExceptionsV2"] boolValue]; - [RNSentryExperimentalOptions setEnableUnhandledCPPExceptionsV2:enableUnhandledCPPExceptions - sentryOptions:sentryOptions]; - } - - return sentryOptions; -} - -- (NSString *_Nullable)getURLFromDSN:(NSString *)dsn -{ - NSURL *url = [NSURL URLWithString:dsn]; - if (!url) { - return nil; - } - return [NSString stringWithFormat:@"%@://%@", url.scheme, url.host]; -} - - (void)setEventOriginTag:(SentryEvent *)event { if (event.sdk != nil) { @@ -451,7 +359,7 @@ - (void)stopObserving contexts[@"os"] = os; } - NSString *releaseName = SentrySDKInternal.options.releaseName; + NSString *releaseName = [SentrySDKWrapper releaseName]; if (releaseName) { contexts[@"release"] = releaseName; } @@ -483,7 +391,7 @@ - (void)stopObserving RCT_EXPORT_METHOD(fetchNativeDeviceContexts : (RCTPromiseResolveBlock)resolve rejecter : ( RCTPromiseRejectBlock)reject) { - if (PrivateSentrySDKOnly.options.debug) { + if ([SentrySDKWrapper debug]) { NSLog(@"Bridge call to: deviceContexts"); } __block NSMutableDictionary *serializedScope; @@ -498,7 +406,7 @@ - (void)stopObserving forKey:@"user"]; } - if (PrivateSentrySDKOnly.options.debug) { + if ([SentrySDKWrapper debug]) { NSData *data = [NSJSONSerialization dataWithJSONObject:serializedScope options:0 error:nil]; diff --git a/packages/core/ios/SentrySDKWrapper.h b/packages/core/ios/SentrySDKWrapper.h index 9040d032ab..483b0bcdac 100644 --- a/packages/core/ios/SentrySDKWrapper.h +++ b/packages/core/ios/SentrySDKWrapper.h @@ -15,4 +15,18 @@ + (void)startWithOptions:(SentryOptions *)options; ++ (SentryOptions *)createOptionsWithDictionary:(NSDictionary *)options + error:(NSError **)errorPointer; + ++ (void)setupWithDictionary:(NSDictionary *)options + error:(NSError **)errorPointer; + ++ (BOOL)debug; + ++ (NSString *)releaseName; + ++ (BOOL)enableAutoSessionTracking; + ++ (BOOL)enableWatchdogTerminationTracking; + @end diff --git a/packages/core/ios/SentrySDKWrapper.m b/packages/core/ios/SentrySDKWrapper.m index 0845f1ff3e..dc26761b1e 100644 --- a/packages/core/ios/SentrySDKWrapper.m +++ b/packages/core/ios/SentrySDKWrapper.m @@ -1,4 +1,6 @@ #import "SentrySDKWrapper.h" +#import "RNSentryExperimentalOptions.h" +#import "RNSentryVersion.h" @import Sentry; @implementation SentrySDKWrapper @@ -28,4 +30,130 @@ + (void)configureScope:(void (^)(SentryScope *scope))callback [SentrySDK configureScope:callback]; } ++ (SentryOptions *)createOptionsWithDictionary:(NSDictionary *)options + error:(NSError *__autoreleasing *)errorPointer +{ + NSString *dsn = [self getURLFromDSN:[options valueForKey:@"dsn"]]; + SentryOptions *sentryOptions = [SentryOptionsInternal initWithDict:options + didFailWithError:errorPointer]; + if (*errorPointer != nil) { + return nil; + } + + // Exclude Dev Server and Sentry Dsn request from Breadcrumbs + NSString *devServerUrl = [options valueForKey:@"devServerUrl"]; + sentryOptions.beforeBreadcrumb + = ^SentryBreadcrumb *_Nullable(SentryBreadcrumb *_Nonnull breadcrumb) + { + NSString *url = breadcrumb.data[@"url"] ?: @""; + + if ([@"http" isEqualToString:breadcrumb.type] + && ((dsn != nil && [url hasPrefix:dsn]) + || (devServerUrl != nil && [url hasPrefix:devServerUrl]))) { + return nil; + } + return breadcrumb; + }; + + if ([options valueForKey:@"enableNativeCrashHandling"] != nil) { + BOOL enableNativeCrashHandling = [options[@"enableNativeCrashHandling"] boolValue]; + + if (!enableNativeCrashHandling) { + sentryOptions.enableCrashHandler = NO; + } + } + + // Set spotlight option + if ([options valueForKey:@"spotlight"] != nil) { + id spotlightValue = [options valueForKey:@"spotlight"]; + if ([spotlightValue isKindOfClass:[NSString class]]) { + NSLog(@"Using Spotlight on address: %@", spotlightValue); + sentryOptions.enableSpotlight = true; + sentryOptions.spotlightUrl = spotlightValue; + } else if ([spotlightValue isKindOfClass:[NSNumber class]]) { + sentryOptions.enableSpotlight = [spotlightValue boolValue]; + id defaultSpotlightUrl = [options valueForKey:@"defaultSidecarUrl"]; + if (defaultSpotlightUrl != nil) { + sentryOptions.spotlightUrl = defaultSpotlightUrl; + } + } + } + + if ([options valueForKey:@"enableLogs"] != nil) { + id enableLogsValue = [options valueForKey:@"enableLogs"]; + if ([enableLogsValue isKindOfClass:[NSNumber class]]) { + [RNSentryExperimentalOptions setEnableLogs:[enableLogsValue boolValue] + sentryOptions:sentryOptions]; + } + } + + // Enable the App start and Frames tracking measurements + if ([options valueForKey:@"enableAutoPerformanceTracing"] != nil) { + BOOL enableAutoPerformanceTracing = [options[@"enableAutoPerformanceTracing"] boolValue]; + PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracing; +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracing; +#endif + } + + // Failed requests can only be enabled in one SDK to avoid duplicates + sentryOptions.enableCaptureFailedRequests = NO; + + NSDictionary *experiments = options[@"_experiments"]; + if (experiments != nil && [experiments isKindOfClass:[NSDictionary class]]) { + BOOL enableUnhandledCPPExceptions = + [experiments[@"enableUnhandledCPPExceptionsV2"] boolValue]; + [RNSentryExperimentalOptions setEnableUnhandledCPPExceptionsV2:enableUnhandledCPPExceptions + sentryOptions:sentryOptions]; + } + + return sentryOptions; +} + ++ (NSString *_Nullable)getURLFromDSN:(NSString *)dsn +{ + NSURL *url = [NSURL URLWithString:dsn]; + if (!url) { + return nil; + } + return [NSString stringWithFormat:@"%@://%@", url.scheme, url.host]; +} + ++ (void)setupWithDictionary:(NSDictionary *_Nonnull)options + error:(NSError *_Nonnull *_Nonnull)errorPointer +{ + SentryOptions *sentryOptions = [self createOptionsWithDictionary:options + error:errorPointer]; + if (!options) { + return; + } + + NSString *sdkVersion = [PrivateSentrySDKOnly getSdkVersionString]; + [PrivateSentrySDKOnly setSdkName:NATIVE_SDK_NAME andVersionString:sdkVersion]; + [PrivateSentrySDKOnly addSdkPackage:REACT_NATIVE_SDK_PACKAGE_NAME + version:REACT_NATIVE_SDK_PACKAGE_VERSION]; + + [SentrySDKWrapper startWithOptions:sentryOptions]; +} + ++ (BOOL)debug +{ + return PrivateSentrySDKOnly.options.debug; +} + ++ (NSString *)releaseName +{ + return PrivateSentrySDKOnly.options.releaseName; +} + ++ (BOOL)enableAutoSessionTracking +{ + return PrivateSentrySDKOnly.options.enableAutoSessionTracking; +} + ++ (BOOL)enableWatchdogTerminationTracking +{ + return PrivateSentrySDKOnly.options.enableWatchdogTerminationTracking; +} + @end