-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add storeEnvelope on SentryClient
Hybrid SDKs as react-native need a way to synchronously store an envelope to disk. Previously, this was possible by exposing SentryFileManager on the SentryClient, but this breaks users of react-native that use use_frameworks!, see getsentry/sentry-react-native#1171. A way to fix this would be to expose SentryFileManager and SentryCurrentDateProvider as proposed in #835. This has the downside of making classes public, that shouldn't be public. A better workaround is to expose storeEnvelope on the SentryClient.
- Loading branch information
1 parent
d84d6ca
commit 6470962
Showing
7 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ class SentryClientTest: XCTestCase { | |
let message: SentryMessage | ||
|
||
let user: User | ||
let fileManager: SentryFileManager | ||
|
||
init() { | ||
session = SentrySession(releaseName: "release") | ||
|
@@ -35,6 +36,8 @@ class SentryClientTest: XCTestCase { | |
|
||
user = User() | ||
user.email = "[email protected]" | ||
|
||
fileManager = try! SentryFileManager(dsn: TestConstants.dsn, andCurrentDateProvider: TestCurrentDateProvider()) | ||
} | ||
|
||
func getSut(configureOptions: (Options) -> Void = { _ in }) -> Client { | ||
|
@@ -45,7 +48,7 @@ class SentryClientTest: XCTestCase { | |
]) | ||
configureOptions(options) | ||
|
||
client = Client(options: options, andTransport: transport, andFileManager: try SentryFileManager(dsn: TestConstants.dsn, andCurrentDateProvider: TestCurrentDateProvider())) | ||
client = Client(options: options, andTransport: transport, andFileManager: fileManager) | ||
} catch { | ||
XCTFail("Options could not be created") | ||
} | ||
|
@@ -84,6 +87,7 @@ class SentryClientTest: XCTestCase { | |
override func setUp() { | ||
super.setUp() | ||
fixture = Fixture() | ||
fixture.fileManager.deleteAllEnvelopes() | ||
} | ||
|
||
func testCaptureMessage() { | ||
|
@@ -606,6 +610,11 @@ class SentryClientTest: XCTestCase { | |
} | ||
} | ||
|
||
func testStoreEnvelope_StoresEnvelopeToDisk() { | ||
fixture.getSut().store(SentryEnvelope(event: Event())) | ||
XCTAssertEqual(1, fixture.fileManager.getAllEnvelopes().count) | ||
} | ||
|
||
private func givenEventWithDebugMeta() -> Event { | ||
let event = Event(level: SentryLevel.fatal) | ||
let debugMeta = DebugMeta() | ||
|