File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ ### Fixes
6+
7+ - Don't run onCrashedLastSession for nil Events (#3785 )
8+
39## 8.22.4
410
511### Fixes
Original file line number Diff line number Diff line change @@ -664,7 +664,8 @@ - (SentryEvent *_Nullable)prepareEvent:(SentryEvent *)event
664664 }
665665 }
666666
667- if (isCrashEvent && nil != self.options .onCrashedLastRun && !SentrySDK.crashedLastRunCalled ) {
667+ if (event != nil && isCrashEvent && nil != self.options .onCrashedLastRun
668+ && !SentrySDK.crashedLastRunCalled ) {
668669 // We only want to call the callback once. It can occur that multiple crash events are
669670 // about to be sent.
670671 SentrySDK.crashedLastRunCalled = YES ;
Original file line number Diff line number Diff line change @@ -1444,6 +1444,22 @@ class SentryClientTest: XCTestCase {
14441444 XCTAssertTrue ( onCrashedLastRunCalled)
14451445 }
14461446
1447+ func testOnCrashedLastRun_DontRunIfBeforeSendReturnsNill( ) {
1448+ let event = TestData . event
1449+
1450+ var onCrashedLastRunCalled = false
1451+ fixture. getSut ( configureOptions: { options in
1452+ options. beforeSend = { _ in
1453+ return nil
1454+ }
1455+ options. onCrashedLastRun = { _ in
1456+ onCrashedLastRunCalled = true
1457+ }
1458+ } ) . captureCrash ( event, with: fixture. session, with: fixture. scope)
1459+
1460+ XCTAssertFalse ( onCrashedLastRunCalled)
1461+ }
1462+
14471463 func testOnCrashedLastRun_WithTwoCrashes_OnlyInvokeCallbackOnce( ) {
14481464 let event = TestData . event
14491465
You can’t perform that action at this time.
0 commit comments