Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 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
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
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@

- 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))
- Add initialization using `sentry.options.json` for Apple platforms ([#4447](https://github.com/getsentry/sentry-react-native/pull/4447))

### Internal

- Initialize `RNSentryTimeToDisplay` during native module `init` on iOS ([#4443](https://github.com/getsentry/sentry-react-native/pull/4443))
- Extract iOS native initialization to standalone structures ([#4442](https://github.com/getsentry/sentry-react-native/pull/4442))

### Dependencies

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 @@ -11,6 +11,11 @@
336084392C32E382008CC412 /* RNSentryReplayBreadcrumbConverterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 336084382C32E382008CC412 /* RNSentryReplayBreadcrumbConverterTests.swift */; };
3380C6C42CE25ECA0018B9B6 /* RNSentryReplayPostInitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3380C6C32CE25ECA0018B9B6 /* RNSentryReplayPostInitTests.swift */; };
33958C692BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33958C682BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m */; };
339C6C3C2D3EB25100CA72ED /* RNSentryStartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 339C6C3B2D3EB23B00CA72ED /* RNSentryStartTests.swift */; };
339C6C422D3FD3AE00CA72ED /* RNSentryStartFromFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 339C6C412D3FD39500CA72ED /* RNSentryStartFromFileTests.swift */; };
339C6C482D3FD9A700CA72ED /* invalid.options.json in Resources */ = {isa = PBXBuildFile; fileRef = 339C6C462D3FD91900CA72ED /* invalid.options.json */; };
339C6C492D3FD9A700CA72ED /* invalid.options.txt in Resources */ = {isa = PBXBuildFile; fileRef = 339C6C452D3FD90200CA72ED /* invalid.options.txt */; };
339C6C4B2D3FD9B200CA72ED /* valid.options.json in Resources */ = {isa = PBXBuildFile; fileRef = 339C6C4A2D3FD9AB00CA72ED /* valid.options.json */; };
33AFDFED2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33AFDFEC2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m */; };
33AFDFF12B8D15E500AAB120 /* RNSentryDependencyContainerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 33AFDFF02B8D15E500AAB120 /* RNSentryDependencyContainerTests.m */; };
33F58AD02977037D008F60EA /* RNSentryTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F58ACF2977037D008F60EA /* RNSentryTests.mm */; };
Expand All @@ -25,6 +30,9 @@
332D33482CDBDC7300547D76 /* RNSentry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentry.h; path = ../ios/RNSentry.h; sourceTree = SOURCE_ROOT; };
332D33492CDCC8E100547D76 /* RNSentryTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNSentryTests.h; sourceTree = "<group>"; };
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 All @@ -35,6 +43,13 @@
338739072A7D7D2800950DDD /* RNSentryReplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryReplay.h; path = ../ios/RNSentryReplay.h; sourceTree = "<group>"; };
33958C672BFCEF5A00AD1FB6 /* RNSentryOnDrawReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSentryOnDrawReporter.h; path = ../ios/RNSentryOnDrawReporter.h; sourceTree = "<group>"; };
33958C682BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSentryOnDrawReporterTests.m; sourceTree = "<group>"; };
339C6C3B2D3EB23B00CA72ED /* RNSentryStartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNSentryStartTests.swift; sourceTree = "<group>"; };
339C6C3D2D3FA04D00CA72ED /* RNSentryVersion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNSentryVersion.h; path = ../ios/RNSentryVersion.h; sourceTree = SOURCE_ROOT; };
339C6C412D3FD39500CA72ED /* RNSentryStartFromFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNSentryStartFromFileTests.swift; sourceTree = "<group>"; };
339C6C442D3FD62D00CA72ED /* RNSentrySDK+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNSentrySDK+Test.h"; sourceTree = "<group>"; };
339C6C452D3FD90200CA72ED /* invalid.options.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = invalid.options.txt; sourceTree = "<group>"; };
339C6C462D3FD91900CA72ED /* invalid.options.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = invalid.options.json; sourceTree = "<group>"; };
339C6C4A2D3FD9AB00CA72ED /* valid.options.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = valid.options.json; sourceTree = "<group>"; };
33AFDFEC2B8D14B300AAB120 /* RNSentryFramesTrackerListenerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSentryFramesTrackerListenerTests.m; sourceTree = "<group>"; };
33AFDFEE2B8D14C200AAB120 /* RNSentryFramesTrackerListenerTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNSentryFramesTrackerListenerTests.h; sourceTree = "<group>"; };
33AFDFF02B8D15E500AAB120 /* RNSentryDependencyContainerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSentryDependencyContainerTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -69,6 +84,7 @@
3360896929524163007C7730 = {
isa = PBXGroup;
children = (
339C6C432D3FD41C00CA72ED /* TestAssets */,
33AFE0122B8F319000AAB120 /* RNSentry */,
3360899029524164007C7730 /* RNSentryCocoaTesterTests */,
3360897329524163007C7730 /* Products */,
Expand All @@ -88,6 +104,8 @@
3360899029524164007C7730 /* RNSentryCocoaTesterTests */ = {
isa = PBXGroup;
children = (
339C6C412D3FD39500CA72ED /* RNSentryStartFromFileTests.swift */,
339C6C3B2D3EB23B00CA72ED /* RNSentryStartTests.swift */,
332D334A2CDCC8EB00547D76 /* RNSentryCocoaTesterTests-Bridging-Header.h */,
332D33492CDCC8E100547D76 /* RNSentryTests.h */,
336084382C32E382008CC412 /* RNSentryReplayBreadcrumbConverterTests.swift */,
Expand All @@ -113,9 +131,24 @@
path = Replay;
sourceTree = "<group>";
};
339C6C432D3FD41C00CA72ED /* TestAssets */ = {
isa = PBXGroup;
children = (
339C6C4A2D3FD9AB00CA72ED /* valid.options.json */,
339C6C462D3FD91900CA72ED /* invalid.options.json */,
339C6C452D3FD90200CA72ED /* invalid.options.txt */,
);
path = TestAssets;
sourceTree = "<group>";
};
33AFE0122B8F319000AAB120 /* RNSentry */ = {
isa = PBXGroup;
children = (
339C6C442D3FD62D00CA72ED /* RNSentrySDK+Test.h */,
339C6C3D2D3FA04D00CA72ED /* RNSentryVersion.h */,
333B58AF2D36A7FD000F8D04 /* RNSentrySDK.h */,
333B58A92D35BB2D000F8D04 /* RNSentryStart+Test.h */,
333B58A82D35BA93000F8D04 /* RNSentryStart.h */,
3380C6C02CDEC56B0018B9B6 /* Replay */,
332D33482CDBDC7300547D76 /* RNSentry.h */,
3360843A2C32E3A8008CC412 /* RNSentryReplayBreadcrumbConverter.h */,
Expand Down Expand Up @@ -146,6 +179,7 @@
3360898929524164007C7730 /* Sources */,
BB7D14838753E6599863899B /* Frameworks */,
CC7959F3721CB3AD7CB6A047 /* [CP] Copy Pods Resources */,
339C6C472D3FD99900CA72ED /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -190,6 +224,19 @@
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
339C6C472D3FD99900CA72ED /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
339C6C482D3FD9A700CA72ED /* invalid.options.json in Resources */,
339C6C4B2D3FD9B200CA72ED /* valid.options.json in Resources */,
339C6C492D3FD9A700CA72ED /* invalid.options.txt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
30F19D4E16BEEFEC68733838 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -239,7 +286,9 @@
files = (
AEFB00422CC90C4B00EC8A9A /* RNSentryBreadcrumbTests.swift in Sources */,
332D33472CDBDBB600547D76 /* RNSentryReplayOptionsTests.swift in Sources */,
339C6C3C2D3EB25100CA72ED /* RNSentryStartTests.swift in Sources */,
33AFDFF12B8D15E500AAB120 /* RNSentryDependencyContainerTests.m in Sources */,
339C6C422D3FD3AE00CA72ED /* RNSentryStartFromFileTests.swift in Sources */,
336084392C32E382008CC412 /* RNSentryReplayBreadcrumbConverterTests.swift in Sources */,
33F58AD02977037D008F60EA /* RNSentryTests.mm in Sources */,
33958C692BFCF12600AD1FB6 /* RNSentryOnDrawReporterTests.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
#import "RNSentryReplayBreadcrumbConverter.h"
#import "RNSentryReplayMask.h"
#import "RNSentryReplayUnmask.h"
#import "RNSentrySDK+Test.h"
#import "RNSentryStart.h"
#import "RNSentryVersion.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import "RNSentryStart.h"

@interface
RNSentryStart (Test)

+ (void)setEventOriginTag:(SentryEvent *)event;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import XCTest

final class RNSentryStartFromFileTests: XCTestCase {

func testNoThrowOnMissingOptionsFile() {
var wasConfigurationCalled = false

RNSentrySDK.start(getNonExistingOptionsPath(), configureOptions: { _ in
wasConfigurationCalled = true
})

XCTAssertTrue(wasConfigurationCalled)

let actualOptions = PrivateSentrySDKOnly.options
XCTAssertNil(actualOptions.dsn)
XCTAssertNil(actualOptions.parsedDsn)
}

func testNoThrowOnInvalidFileType() {
var wasConfigurationCalled = false

RNSentrySDK.start(getInvalidOptionsTypePath(), configureOptions: { _ in
wasConfigurationCalled = true
})

XCTAssertTrue(wasConfigurationCalled)

let actualOptions = PrivateSentrySDKOnly.options
XCTAssertNil(actualOptions.dsn)
XCTAssertNil(actualOptions.parsedDsn)
}

func testNoThrowOnInvalidOptions() {
var wasConfigurationCalled = false

RNSentrySDK.start(getInvalidOptionsPath(), configureOptions: { _ in
wasConfigurationCalled = true
})

XCTAssertTrue(wasConfigurationCalled)

let actualOptions = PrivateSentrySDKOnly.options
XCTAssertNil(actualOptions.dsn)
XCTAssertNotNil(actualOptions.parsedDsn)
XCTAssertEqual(actualOptions.environment, "environment-from-invalid-file")
}

func testLoadValidOptions() {
var wasConfigurationCalled = false

RNSentrySDK.start(getValidOptionsPath(), configureOptions: { _ in
wasConfigurationCalled = true
})

XCTAssertTrue(wasConfigurationCalled)

let actualOptions = PrivateSentrySDKOnly.options
XCTAssertNil(actualOptions.dsn)
XCTAssertNotNil(actualOptions.parsedDsn)
XCTAssertEqual(actualOptions.environment, "environment-from-valid-file")
}

func testOptionsFromFileInConfigureOptions() {
var wasConfigurationCalled = false

RNSentrySDK.start(getValidOptionsPath()) { options in
wasConfigurationCalled = true
XCTAssertEqual(options.environment, "environment-from-valid-file")
}

XCTAssertTrue(wasConfigurationCalled)
}

func testOptionsOverwrittenInConfigureOptions() {
RNSentrySDK.start(getValidOptionsPath()) { options in
options.environment = "new-environment"
}

let actualOptions = PrivateSentrySDKOnly.options
XCTAssertEqual(actualOptions.environment, "new-environment")
}

func getNonExistingOptionsPath() -> String {
return "/non-existing.options.json"
}

func getInvalidOptionsTypePath() -> String {
guard let path = getTestBundle().path(forResource: "invalid.options", ofType: "txt") else {
fatalError("Could not get invalid type options path")
}
return path
}

func getInvalidOptionsPath() -> String {
guard let path = getTestBundle().path(forResource: "invalid.options", ofType: "json") else {
fatalError("Could not get invalid options path")
}
return path
}

func getValidOptionsPath() -> String {
guard let path = getTestBundle().path(forResource: "valid.options", ofType: "json") else {
fatalError("Could not get invalid options path")
}
return path
}

func getTestBundle() -> Bundle {
let maybeBundle = Bundle.allBundles.first(where: { $0.bundlePath.hasSuffix(".xctest") })
guard let bundle = maybeBundle else {
fatalError("Could not find test bundle")
}
return bundle
}
}
Loading
Loading