Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4328298
chore: Initialize `RNSentryTimeToDisplay` during native module `init`…
krystofwoldrich Jan 14, 2025
27d76de
ref(ios): Extract Cocoa SDK init into standalone file
krystofwoldrich Jan 14, 2025
5a28c03
fix lint
krystofwoldrich Jan 14, 2025
8b67bf1
rename rnsentrysdk to rnsentrystart
krystofwoldrich Jan 14, 2025
05cef29
rename class name also to rnsentrystart, fix tests
krystofwoldrich Jan 14, 2025
778478f
explicitly import only used classes
krystofwoldrich Jan 14, 2025
3d3d0b4
fix call cocoa start not itself
krystofwoldrich Jan 14, 2025
e2e40fa
also extract didBecomeActive notification
krystofwoldrich Jan 14, 2025
83106a7
add explanation comment to native crash handling
krystofwoldrich Jan 14, 2025
742f28c
explain notification purpose
krystofwoldrich Jan 14, 2025
4897aa3
fix sdk name
krystofwoldrich Jan 14, 2025
d37ebdd
fix native sdk not react native package
krystofwoldrich Jan 14, 2025
13a0b89
fix lint sentry start
krystofwoldrich Jan 14, 2025
d7270b1
add changelog
krystofwoldrich Jan 14, 2025
580590b
feat(experimental): Add native `startWithConfigureOptions` for Apple …
krystofwoldrich Jan 14, 2025
2cc92f2
feat: Read `sentry.options.json` during cocoa init
krystofwoldrich Jan 14, 2025
592b903
Update CHANGELOG.md
krystofwoldrich Jan 15, 2025
a2717bd
remove global processor
krystofwoldrich Jan 15, 2025
5ecd6b2
Merge remote-tracking branch 'origin/kw-add-read-ios-options-file' in…
krystofwoldrich Jan 15, 2025
890133a
Update code docs for start methods
krystofwoldrich Jan 15, 2025
2d021e8
Merge branch 'main' into kw-ref-ios-sdk-init
krystofwoldrich Jan 20, 2025
cfc6293
fix lint
krystofwoldrich Jan 20, 2025
f2a041e
remove unused rnSentry
krystofwoldrich Jan 20, 2025
fc4ff7e
fix changelog
krystofwoldrich Jan 20, 2025
879044f
Merge branch 'kw-ref-ios-sdk-init' into kw-add-react-native-ios-manua…
krystofwoldrich Jan 20, 2025
dec9869
wip! add manual init tests
krystofwoldrich Jan 20, 2025
22e88c7
add tests
krystofwoldrich Jan 21, 2025
4ac4896
Merge branch 'kw-add-react-native-ios-manual-init' into kw-add-read-i…
krystofwoldrich Jan 21, 2025
1baac18
add tests
krystofwoldrich Jan 21, 2025
f92edd9
remove unavailable and unused global events processors import
krystofwoldrich Jan 21, 2025
2662dbd
Merge branch 'kw-add-react-native-ios-manual-init' into kw-add-read-i…
krystofwoldrich Jan 21, 2025
7baad41
fix c-format
krystofwoldrich Jan 21, 2025
1a2aca8
feat: Automatically load `sentry.options.json` file
krystofwoldrich Jan 21, 2025
6d81a10
remove old sentry-cocoa init code
krystofwoldrich Jan 22, 2025
92c32e9
Merge remote-tracking branch 'origin/capture-app-start-errors' into k…
krystofwoldrich Jan 22, 2025
dcfdc6c
Merge remote-tracking branch 'origin/kw-add-read-ios-options-file' in…
krystofwoldrich Jan 22, 2025
7eb1786
fix copy options json only if destination set and file exists
krystofwoldrich Jan 22, 2025
dae191b
Merge branch 'kw-add-read-ios-options-file' into kw-add-options-file-…
krystofwoldrich Jan 22, 2025
0909148
fix types, handle errors, add logs, add support for expo projects
krystofwoldrich Jan 23, 2025
82f2a87
add json options for expo project
krystofwoldrich Jan 23, 2025
21d2880
fix bail todo
krystofwoldrich Jan 23, 2025
539892c
fix lint
krystofwoldrich Jan 23, 2025
c4b2bdd
add tests
krystofwoldrich Jan 23, 2025
55ed3fa
Merge branch 'capture-app-start-errors' into kw-add-options-file-init…
krystofwoldrich Jan 24, 2025
2cdcd60
Update CHANGELOG.md
krystofwoldrich Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(experimental): Add native startWithConfigureOptions for Apple …
…platforms`
  • Loading branch information
krystofwoldrich committed Jan 14, 2025
commit 580590ba8b7d9a91922a7e089b24237fd5254fcb
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- Rename `navigation.processing` span to more expressive `Navigation dispatch to screen A mounted/navigation cancelled` ([#4423](https://github.com/getsentry/sentry-react-native/pull/4423))
- Add RN SDK package to `sdk.packages` for Cocoa ([#4381](https://github.com/getsentry/sentry-react-native/pull/4381))
- Add experimental version of `startWithConfigureOptions` for Apple platforms ([#4444](https://github.com/getsentry/sentry-react-native/pull/4444))

### Internal

Expand Down
2 changes: 1 addition & 1 deletion packages/core/RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pod::Spec.new do |s|
s.preserve_paths = '*.js'

s.source_files = 'ios/**/*.{h,m,mm}'
s.public_header_files = 'ios/RNSentry.h'
s.public_header_files = 'ios/RNSentry.h', 'ios/RNSentrySDK.h'

s.compiler_flags = other_cflags

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
332D334A2CDCC8EB00547D76 /* RNSentryCocoaTesterTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNSentryCocoaTesterTests-Bridging-Header.h"; sourceTree = "<group>"; };
333B58A82D35BA93000F8D04 /* RNSentryStart.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryStart.h; path = ../ios/RNSentryStart.h; sourceTree = SOURCE_ROOT; };
333B58A92D35BB2D000F8D04 /* RNSentryStart+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "RNSentryStart+Test.h"; path = "RNSentryCocoaTesterTests/RNSentryStart+Test.h"; sourceTree = SOURCE_ROOT; };
333B58AF2D36A7FD000F8D04 /* RNSentrySDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentrySDK.h; path = ../ios/RNSentrySDK.h; sourceTree = SOURCE_ROOT; };
336084382C32E382008CC412 /* RNSentryReplayBreadcrumbConverterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNSentryReplayBreadcrumbConverterTests.swift; sourceTree = "<group>"; };
3360843A2C32E3A8008CC412 /* RNSentryReplayBreadcrumbConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSentryReplayBreadcrumbConverter.h; path = ../ios/RNSentryReplayBreadcrumbConverter.h; sourceTree = "<group>"; };
3360843C2C340C76008CC412 /* RNSentryBreadcrumbTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNSentryBreadcrumbTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -118,6 +119,7 @@
33AFE0122B8F319000AAB120 /* RNSentry */ = {
isa = PBXGroup;
children = (
333B58AF2D36A7FD000F8D04 /* RNSentrySDK.h */,
333B58A92D35BB2D000F8D04 /* RNSentryStart+Test.h */,
333B58A82D35BA93000F8D04 /* RNSentryStart.h */,
3380C6C02CDEC56B0018B9B6 /* Replay */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#import "RNSentryStart+Test.h"
#import <OCMock/OCMock.h>
#import <RNSentry/RNSentry.h>
#import <Sentry/PrivateSentrySDKOnly.h>
#import <Sentry/SentryDebugImageProvider+HybridSDKs.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
Expand All @@ -12,9 +13,8 @@ @interface RNSentryInitNativeSdkTests : XCTestCase

@implementation RNSentryInitNativeSdkTests

- (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties
- (void)testStartWithDictionaryRemovesPerformanceProperties
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary =
Expand All @@ -26,9 +26,8 @@ - (void)testCreateOptionsWithDictionaryRemovesPerformanceProperties
, @"enableTracing" : @YES,
}
;
SentryOptions *actualOptions =
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];

[RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error];
SentryOptions *actualOptions = PrivateSentrySDKOnly.options;
XCTAssertNotNil(actualOptions, @"Did not create sentry options");
XCTAssertNil(error, @"Should not pass no error");
XCTAssertNotNil(
Expand All @@ -41,14 +40,13 @@ - (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 =
[RNSentryStart createOptionsWithDictionary:mockedReactNativeDictionary error:&error];
[RNSentryStart startWithOptions:mockedReactNativeDictionary error:&error];
SentryOptions *actualOptions = PrivateSentrySDKOnly.options;

XCTAssertNotNil(actualOptions, @"Did not create sentry options");
XCTAssertNil(error, @"Should not pass no error");
Expand All @@ -57,7 +55,6 @@ - (void)testCaptureFailedRequestsIsDisabled

- (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -73,7 +70,6 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDefault

- (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDefault
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -89,7 +85,6 @@ - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDefault

- (void)testCreateOptionsWithDictionaryNativeCrashHandlingEnabled
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -106,7 +101,6 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingEnabled

- (void)testCreateOptionsWithDictionaryAutoPerformanceTracingEnabled
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -123,7 +117,6 @@ - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingEnabled

- (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -140,7 +133,6 @@ - (void)testCreateOptionsWithDictionaryNativeCrashHandlingDisabled

- (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDisabled
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -157,7 +149,6 @@ - (void)testCreateOptionsWithDictionaryAutoPerformanceTracingDisabled

- (void)testCreateOptionsWithDictionarySpotlightEnabled
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -175,7 +166,6 @@ - (void)testCreateOptionsWithDictionarySpotlightEnabled

- (void)testCreateOptionsWithDictionarySpotlightOne
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -193,7 +183,6 @@ - (void)testCreateOptionsWithDictionarySpotlightOne

- (void)testCreateOptionsWithDictionarySpotlightUrl
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -210,7 +199,6 @@ - (void)testCreateOptionsWithDictionarySpotlightUrl

- (void)testCreateOptionsWithDictionarySpotlightDisabled
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -226,7 +214,6 @@ - (void)testCreateOptionsWithDictionarySpotlightDisabled

- (void)testCreateOptionsWithDictionarySpotlightZero
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -242,7 +229,6 @@ - (void)testCreateOptionsWithDictionarySpotlightZero

- (void)testPassesErrorOnWrongDsn
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedReactNativeDictionary = @{
Expand All @@ -257,7 +243,6 @@ - (void)testPassesErrorOnWrongDsn

- (void)testBeforeBreadcrumbsCallbackFiltersOutSentryDsnRequestBreadcrumbs
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedDictionary = @{
Expand All @@ -278,7 +263,6 @@ - (void)testBeforeBreadcrumbsCallbackFiltersOutSentryDsnRequestBreadcrumbs

- (void)testBeforeBreadcrumbsCallbackFiltersOutDevServerRequestBreadcrumbs
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSString *mockDevServer = @"http://localhost:8081";
Expand All @@ -299,7 +283,6 @@ - (void)testBeforeBreadcrumbsCallbackFiltersOutDevServerRequestBreadcrumbs

- (void)testBeforeBreadcrumbsCallbackDoesNotFiltersOutNonDevServerOrDsnRequestBreadcrumbs
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedDictionary = @{
Expand All @@ -320,7 +303,6 @@ - (void)testBeforeBreadcrumbsCallbackDoesNotFiltersOutNonDevServerOrDsnRequestBr

- (void)testBeforeBreadcrumbsCallbackKeepsBreadcrumbWhenDevServerUrlIsNotPassedAndDsnDoesNotMatch
{
RNSentry *rnSentry = [[RNSentry alloc] init];
NSError *error = nil;

NSDictionary *_Nonnull mockedDictionary = @{ // dsn is always validated in SentryOptions initialization
Expand All @@ -340,7 +322,6 @@ - (void)testBeforeBreadcrumbsCallbackKeepsBreadcrumbWhenDevServerUrlIsNotPassedA

- (void)testEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags
{
RNSentry *rnSentry = [[RNSentry alloc] init];
SentryEvent *testEvent = [[SentryEvent alloc] init];
testEvent.sdk = @{
@"name" : @"sentry.cocoa.react-native",
Expand All @@ -354,7 +335,6 @@ - (void)testEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags

- (void)testEventFromSentryReactNativeOriginAndEnvironmentTagsAreOverwritten
{
RNSentry *rnSentry = [[RNSentry alloc] init];
SentryEvent *testEvent = [[SentryEvent alloc] init];
testEvent.sdk = @{
@"name" : @"sentry.cocoa.react-native",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/ios/RNSentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#import <Sentry/SentryDebugImageProvider.h>
#import <Sentry/SentryOptions.h>

// This import exposes public RNSentrySDK start
#import "RNSentrySDK.h"

typedef int (*SymbolicateCallbackType)(const void *, Dl_info *);

@interface
Expand Down
4 changes: 1 addition & 3 deletions packages/core/ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ - (instancetype)init
: (RCTPromiseRejectBlock)reject)
{
NSError *error = nil;
SentryOptions *sentryOptions = [RNSentryStart createOptionsWithDictionary:options error:&error];
[RNSentryStart startWithOptions:options error:&error];
if (error != nil) {
reject(@"SentryReactNative", error.localizedDescription, error);
return;
}

[RNSentryStart startWithOptions:sentryOptions];
resolve(@YES);
}

Expand Down
17 changes: 17 additions & 0 deletions packages/core/ios/RNSentrySDK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#import <Sentry/Sentry.h>

@interface RNSentrySDK : NSObject
SENTRY_NO_INIT

/**
* @experimental
* Inits and configures Sentry for React Native applications. Make sure to
* set a valid DSN.
*
* @discussion Call this method on the main thread. When calling it from a background thread, the
* SDK starts on the main thread async.
*/
+ (void)startWithConfigureOptions:(void (^)(SentryOptions *options))configureOptions
NS_SWIFT_NAME(start(configureOptions:));

@end
15 changes: 15 additions & 0 deletions packages/core/ios/RNSentrySDK.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#import "RNSentrySDK.h"
#import "RNSentryStart.h"

@implementation RNSentrySDK

+ (void)startWithConfigureOptions:(void (^)(SentryOptions *options))configureOptions
{
SentryOptions *options = [[SentryOptions alloc] init];
[RNSentryStart updateWithReactDefaults:options];
configureOptions(options);
[RNSentryStart updateWithReactFinals:options];
[RNSentryStart startWithOptions:options];
}

@end
6 changes: 6 additions & 0 deletions packages/core/ios/RNSentryStart.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
@interface RNSentryStart : NSObject
SENTRY_NO_INIT

+ (void)startWithOptions:(NSDictionary *_Nonnull)javascriptOptions
error:(NSError *_Nonnull *_Nonnull)errorPointer;

+ (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options
error:(NSError *_Nonnull *_Nonnull)errorPointer;

+ (void)updateWithReactDefaults:(SentryOptions *)options;
+ (void)updateWithReactFinals:(SentryOptions *)options;

/**
* @experimental
* Inits and configures Sentry for React Native applications. Make sure to
Expand Down
Loading
Loading