From 1d404f3e0d747bb13f8053b7adca150f7cc096c1 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 9 Nov 2022 13:43:14 +0100 Subject: [PATCH 1/9] Don't immediately update the session's error count Only do this after running the beforeSend block --- Sources/Sentry/SentryClient.m | 5 +++++ Sources/Sentry/SentryHub.m | 2 +- Sources/Sentry/include/SentryHub+Private.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index 3f916aa5ba7..2219956b598 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -220,6 +220,11 @@ - (SentryId *)captureError:(NSError *)error { SentryEvent *event = [self buildErrorEvent:error]; event = [self prepareEvent:event withScope:scope alwaysAttachStacktrace:YES]; + + if (event != nil) { + session = [SentrySDK.currentHub incrementSessionErrors]; + } + return [self sendEvent:event withSession:session withScope:scope]; } diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index 1c3b7699fa7..96c20baf578 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -438,7 +438,7 @@ - (SentryId *)captureError:(NSError *)error - (SentryId *)captureError:(NSError *)error withScope:(SentryScope *)scope { - SentrySession *currentSession = [self incrementSessionErrors]; + SentrySession *currentSession = _session; SentryClient *client = _client; if (nil != client) { if (nil != currentSession) { diff --git a/Sources/Sentry/include/SentryHub+Private.h b/Sources/Sentry/include/SentryHub+Private.h index d02295caf82..7d4c09dc876 100644 --- a/Sources/Sentry/include/SentryHub+Private.h +++ b/Sources/Sentry/include/SentryHub+Private.h @@ -53,6 +53,8 @@ SentryHub (Private) withScope:(SentryScope *)scope additionalEnvelopeItems:(NSArray *)additionalEnvelopeItems; +- (nullable SentrySession *)incrementSessionErrors; + @end NS_ASSUME_NONNULL_END From 0bb922ca78405d0437e98ccb5855054abdd425bf Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 9 Nov 2022 13:51:02 +0100 Subject: [PATCH 2/9] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3be7f3c06e8..e04e1f3ec7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fix issue with invalid profiles uploading (#2358 and #2359) - Call UIDevice methods on the main thread (#2369) +- Don't increase session's error count for dropped events (#2374) ## 7.30.0 From a774225c24ffc77947bf369d47a14345564ac227 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Mon, 14 Nov 2022 11:33:45 +0100 Subject: [PATCH 3/9] Do the same for exceptions --- Sources/Sentry/SentryClient.m | 5 +++++ Sources/Sentry/SentryHub.m | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index 138cbd0f805..4b046ab1d18 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -189,6 +189,11 @@ - (SentryId *)captureException:(NSException *)exception { SentryEvent *event = [self buildExceptionEvent:exception]; event = [self prepareEvent:event withScope:scope alwaysAttachStacktrace:YES]; + + if (event != nil) { + session = [SentrySDK.currentHub incrementSessionErrors]; + } + return [self sendEvent:event withSession:session withScope:scope]; } diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index 96c20baf578..96b49b0f2c3 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -457,8 +457,7 @@ - (SentryId *)captureException:(NSException *)exception - (SentryId *)captureException:(NSException *)exception withScope:(SentryScope *)scope { - SentrySession *currentSession = [self incrementSessionErrors]; - + SentrySession *currentSession = _session; SentryClient *client = _client; if (nil != client) { if (nil != currentSession) { From 0db19e3149a0df1bae014d57b2cd482c50e648ba Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Tue, 15 Nov 2022 14:58:07 +0100 Subject: [PATCH 4/9] Use the new logic as discussed with Philipp --- Sources/Sentry/SentryClient.m | 17 ++---- Sources/Sentry/SentryHub.m | 20 ++++++- Sources/Sentry/include/SentryClient+Private.h | 8 +-- Tests/SentryTests/SentryClientTests.swift | 60 ++++++++++++------- Tests/SentryTests/TestClient.swift | 10 ++-- 5 files changed, 72 insertions(+), 43 deletions(-) diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index 4b046ab1d18..782b491e5f8 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -184,15 +184,13 @@ - (SentryId *)captureException:(NSException *)exception withScope:(SentryScope * } - (SentryId *)captureException:(NSException *)exception - withSession:(SentrySession *)session withScope:(SentryScope *)scope + withSession:(SentrySession * (^)(BOOL withErrorIncremented))sessionBlock { SentryEvent *event = [self buildExceptionEvent:exception]; event = [self prepareEvent:event withScope:scope alwaysAttachStacktrace:YES]; - if (event != nil) { - session = [SentrySDK.currentHub incrementSessionErrors]; - } + SentrySession *session = sessionBlock(event != nil); return [self sendEvent:event withSession:session withScope:scope]; } @@ -220,15 +218,13 @@ - (SentryId *)captureError:(NSError *)error withScope:(SentryScope *)scope } - (SentryId *)captureError:(NSError *)error - withSession:(SentrySession *)session withScope:(SentryScope *)scope + withSession:(SentrySession * (^)(BOOL withErrorIncremented))sessionBlock { SentryEvent *event = [self buildErrorEvent:error]; event = [self prepareEvent:event withScope:scope alwaysAttachStacktrace:YES]; - if (event != nil) { - session = [SentrySDK.currentHub incrementSessionErrors]; - } + SentrySession *session = sessionBlock(event != nil); return [self sendEvent:event withSession:session withScope:scope]; } @@ -409,10 +405,9 @@ - (SentryId *)sendEvent:(SentryEvent *)event [self.transportAdapter sendEvent:event session:session attachments:attachments]; return event.eventId; - } else { - [self captureSession:session]; - return SentryId.empty; } + + return SentryId.empty; } - (void)captureSession:(SentrySession *)session diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index 96b49b0f2c3..c30f4664ccc 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -442,7 +442,15 @@ - (SentryId *)captureError:(NSError *)error withScope:(SentryScope *)scope SentryClient *client = _client; if (nil != client) { if (nil != currentSession) { - return [client captureError:error withSession:currentSession withScope:scope]; + return [client captureError:error + withScope:scope + withSession:^(BOOL withErrorIncremented) { + if (withErrorIncremented) { + return [self incrementSessionErrors]; + } else { + return currentSession; + } + }]; } else { return [client captureError:error withScope:scope]; } @@ -461,7 +469,15 @@ - (SentryId *)captureException:(NSException *)exception withScope:(SentryScope * SentryClient *client = _client; if (nil != client) { if (nil != currentSession) { - return [client captureException:exception withSession:currentSession withScope:scope]; + return [client captureException:exception + withScope:scope + withSession:^(BOOL withErrorIncremented) { + if (withErrorIncremented) { + return [self incrementSessionErrors]; + } else { + return currentSession; + } + }]; } else { return [client captureException:exception withScope:scope]; } diff --git a/Sources/Sentry/include/SentryClient+Private.h b/Sources/Sentry/include/SentryClient+Private.h index dc71e7e3c6c..d3f5c7008ad 100644 --- a/Sources/Sentry/include/SentryClient+Private.h +++ b/Sources/Sentry/include/SentryClient+Private.h @@ -26,12 +26,12 @@ SentryClient (Private) - (SentryFileManager *)fileManager; - (SentryId *)captureError:(NSError *)error - withSession:(SentrySession *)session - withScope:(SentryScope *)scope; + withScope:(SentryScope *)scope + withSession:(SentrySession * (^)(BOOL withErrorIncremented))sessionBlock; - (SentryId *)captureException:(NSException *)exception - withSession:(SentrySession *)session - withScope:(SentryScope *)scope; + withScope:(SentryScope *)scope + withSession:(SentrySession * (^)(BOOL withErrorIncremented))sessionBlock; - (SentryId *)captureCrashEvent:(SentryEvent *)event withScope:(SentryScope *)scope; diff --git a/Tests/SentryTests/SentryClientTests.swift b/Tests/SentryTests/SentryClientTests.swift index a9acfa07fed..b8614802a94 100644 --- a/Tests/SentryTests/SentryClientTests.swift +++ b/Tests/SentryTests/SentryClientTests.swift @@ -269,29 +269,31 @@ class SentryClientTest: XCTestCase { sut.add(processor) sut.capture(event: event) - let sendedAttachments = fixture.transportAdapter.sendEventWithTraceStateInvocations.first?.attachments ?? [] + let sentAttachments = fixture.transportAdapter.sendEventWithTraceStateInvocations.first?.attachments ?? [] wait(for: [expectProcessorCall], timeout: 1) - XCTAssertEqual(sendedAttachments.count, 1) - XCTAssertEqual(extraAttachment, sendedAttachments.first) + XCTAssertEqual(sentAttachments.count, 1) + XCTAssertEqual(extraAttachment, sentAttachments.first) } func test_AttachmentProcessor_CaptureError_WithSession() { let sut = fixture.getSut() let error = NSError(domain: "test", code: -1) let extraAttachment = Attachment(data: Data(), filename: "ExtraAttachment") - + let processor = TestAttachmentProcessor { atts, _ in var result = atts ?? [] result.append(extraAttachment) return result } - + sut.add(processor) - sut.captureError(error, with: fixture.session, with: Scope()) - + sut.captureError(error, with: Scope()) { _ in + self.fixture.session + } + let sentAttachments = fixture.transportAdapter.sentEventsWithSessionTraceState.first?.attachments ?? [] - + XCTAssertEqual(sentAttachments.count, 1) XCTAssertEqual(extraAttachment, sentAttachments.first) } @@ -308,12 +310,14 @@ class SentryClientTest: XCTestCase { } sut.add(processor) - sut.captureError(error, with: SentrySession(releaseName: ""), with: Scope()) + sut.captureError(error, with: Scope()) { _ in + return SentrySession(releaseName: "") + } - let sendedAttachments = fixture.transportAdapter.sendEventWithTraceStateInvocations.first?.attachments ?? [] + let sentAttachments = fixture.transportAdapter.sendEventWithTraceStateInvocations.first?.attachments ?? [] - XCTAssertEqual(sendedAttachments.count, 1) - XCTAssertEqual(extraAttachment, sendedAttachments.first) + XCTAssertEqual(sentAttachments.count, 1) + XCTAssertEqual(extraAttachment, sentAttachments.first) } func testCaptureEventWithDsnSetAfterwards() { @@ -445,8 +449,10 @@ class SentryClientTest: XCTestCase { } func testCaptureErrorWithSession() { - let eventId = fixture.getSut().captureError(error, with: fixture.session, with: Scope()) - + let eventId = fixture.getSut().captureError(error, with: Scope()) { _ in + self.fixture.session + } + eventId.assertIsNotEmpty() XCTAssertNotNil(fixture.transportAdapter.sentEventsWithSessionTraceState.last) if let eventWithSessionArguments = fixture.transportAdapter.sentEventsWithSessionTraceState.last { @@ -458,7 +464,9 @@ class SentryClientTest: XCTestCase { func testCaptureErrorWithSession_WithBeforeSendReturnsNil() { let eventId = fixture.getSut(configureOptions: { options in options.beforeSend = { _ in return nil } - }).captureError(error, with: fixture.session, with: Scope()) + }).captureError(error, with: Scope()) { _ in + self.fixture.session + } eventId.assertIsEmpty() assertLastSentEnvelopeIsASession() @@ -680,8 +688,10 @@ class SentryClientTest: XCTestCase { } func testCaptureExceptionWithSession() { - let eventId = fixture.getSut().capture(exception, with: fixture.session, with: fixture.scope) - + let eventId = fixture.getSut().capture(exception, with: fixture.scope) { _ in + self.fixture.session + } + eventId.assertIsNotEmpty() XCTAssertNotNil(fixture.transportAdapter.sentEventsWithSessionTraceState.last) if let eventWithSessionArguments = fixture.transportAdapter.sentEventsWithSessionTraceState.last { @@ -694,7 +704,9 @@ class SentryClientTest: XCTestCase { func testCaptureExceptionWithSession_WithBeforeSendReturnsNil() { let eventId = fixture.getSut(configureOptions: { options in options.beforeSend = { _ in return nil } - }).capture(exception, with: fixture.session, with: fixture.scope) + }).capture(exception, with: fixture.scope) { _ in + self.fixture.session + } eventId.assertIsEmpty() assertLastSentEnvelopeIsASession() @@ -731,7 +743,9 @@ class SentryClientTest: XCTestCase { let session = SentrySession(releaseName: "") fixture.getSut().capture(session: session) - fixture.getSut().capture(exception, with: session, with: Scope()) + fixture.getSut().capture(exception, with: Scope()) { _ in + session + } .assertIsNotEmpty() fixture.getSut().captureCrash(fixture.event, with: session, with: Scope()) .assertIsNotEmpty() @@ -850,7 +864,9 @@ class SentryClientTest: XCTestCase { _ = SentryEnvelope(event: Event()) let eventId = fixture.getSut(configureOptions: { options in options.dsn = nil - }).capture(self.exception, with: fixture.session, with: fixture.scope) + }).capture(self.exception, with: fixture.scope) { _ in + self.fixture.session + } eventId.assertIsEmpty() assertNothingSent() @@ -860,7 +876,9 @@ class SentryClientTest: XCTestCase { _ = SentryEnvelope(event: Event()) let eventId = fixture.getSut(configureOptions: { options in options.dsn = nil - }).captureError(self.error, with: fixture.session, with: fixture.scope) + }).captureError(self.error, with: fixture.scope) { _ in + self.fixture.session + } eventId.assertIsEmpty() assertNothingSent() diff --git a/Tests/SentryTests/TestClient.swift b/Tests/SentryTests/TestClient.swift index 70ff760a87e..2836430a90c 100644 --- a/Tests/SentryTests/TestClient.swift +++ b/Tests/SentryTests/TestClient.swift @@ -83,16 +83,16 @@ class TestClient: Client { captureExceptionWithScopeInvocations.record((exception, scope)) return SentryId() } - + var captureErrorWithSessionInvocations = Invocations<(error: Error, session: SentrySession, scope: Scope)>() - override func captureError(_ error: Error, with session: SentrySession, with scope: Scope) -> SentryId { - captureErrorWithSessionInvocations.record((error, session, scope)) + override func captureError(_ error: Error, with scope: Scope, withSession sessionBlock: @escaping (Bool) -> SentrySession) -> SentryId { + captureErrorWithSessionInvocations.record((error, sessionBlock(true), scope)) return SentryId() } var captureExceptionWithSessionInvocations = Invocations<(exception: NSException, session: SentrySession, scope: Scope)>() - override func capture(_ exception: NSException, with session: SentrySession, with scope: Scope) -> SentryId { - captureExceptionWithSessionInvocations.record((exception, session, scope)) + override func capture(_ exception: NSException, with scope: Scope, withSession sessionBlock: @escaping (Bool) -> SentrySession) -> SentryId { + captureExceptionWithSessionInvocations.record((exception, sessionBlock(true), scope)) return SentryId() } From b1249619c46c45f3a97969ea53b23c6994adc739 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Tue, 15 Nov 2022 15:41:10 +0100 Subject: [PATCH 5/9] Added tests --- Tests/SentryTests/SentryClientTests.swift | 10 +++--- Tests/SentryTests/SentryHubTests.swift | 40 +++++++++++++++++++++++ Tests/SentryTests/TestClient.swift | 5 +-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/Tests/SentryTests/SentryClientTests.swift b/Tests/SentryTests/SentryClientTests.swift index b8614802a94..3967e5997d3 100644 --- a/Tests/SentryTests/SentryClientTests.swift +++ b/Tests/SentryTests/SentryClientTests.swift @@ -449,8 +449,9 @@ class SentryClientTest: XCTestCase { } func testCaptureErrorWithSession() { - let eventId = fixture.getSut().captureError(error, with: Scope()) { _ in - self.fixture.session + let eventId = fixture.getSut().captureError(error, with: Scope()) { increaseErrorCount in + XCTAssertTrue(increaseErrorCount) + return self.fixture.session } eventId.assertIsNotEmpty() @@ -464,8 +465,9 @@ class SentryClientTest: XCTestCase { func testCaptureErrorWithSession_WithBeforeSendReturnsNil() { let eventId = fixture.getSut(configureOptions: { options in options.beforeSend = { _ in return nil } - }).captureError(error, with: Scope()) { _ in - self.fixture.session + }).captureError(error, with: Scope()) { increaseErrorCount in + XCTAssertFalse(increaseErrorCount) + return self.fixture.session } eventId.assertIsEmpty() diff --git a/Tests/SentryTests/SentryHubTests.swift b/Tests/SentryTests/SentryHubTests.swift index c06bde20805..19f0b14ae74 100644 --- a/Tests/SentryTests/SentryHubTests.swift +++ b/Tests/SentryTests/SentryHubTests.swift @@ -392,6 +392,26 @@ class SentryHubTests: XCTestCase { // only session init is sent XCTAssertEqual(1, fixture.client.captureSessionInvocations.count) } + + func testCaptureWithoutIncreasingErrorCount() { + let sut = fixture.getSut() + sut.startSession() + fixture.client.sessionIncrementsErrorCount = false + sut.capture(error: fixture.error, scope: fixture.scope).assertIsNotEmpty() + + XCTAssertEqual(1, fixture.client.captureErrorWithSessionInvocations.count) + if let errorArguments = fixture.client.captureErrorWithSessionInvocations.first { + XCTAssertEqual(fixture.error, errorArguments.error as NSError) + + XCTAssertEqual(errorArguments.session.errors, 0) + XCTAssertEqual(SentrySessionStatus.ok, errorArguments.session.status) + + XCTAssertEqual(fixture.scope, errorArguments.scope) + } + + // only session init is sent + XCTAssertEqual(1, fixture.client.captureSessionInvocations.count) + } func testCaptureErrorWithoutScope() { fixture.getSut(fixture.options, fixture.scope).capture(error: fixture.error).assertIsNotEmpty() @@ -441,6 +461,26 @@ class SentryHubTests: XCTestCase { // only session init is sent XCTAssertEqual(1, fixture.client.captureSessionInvocations.count) } + + func testCaptureExceptionWithoutIncreasingErrorCount() { + let sut = fixture.getSut() + sut.startSession() + fixture.client.sessionIncrementsErrorCount = false + sut.capture(exception: fixture.exception, scope: fixture.scope).assertIsNotEmpty() + + XCTAssertEqual(1, fixture.client.captureExceptionWithSessionInvocations.count) + if let exceptionArguments = fixture.client.captureExceptionWithSessionInvocations.first { + XCTAssertEqual(fixture.exception, exceptionArguments.exception) + + XCTAssertEqual(exceptionArguments.session.errors, 0) + XCTAssertEqual(SentrySessionStatus.ok, exceptionArguments.session.status) + + XCTAssertEqual(fixture.scope, exceptionArguments.scope) + } + + // only session init is sent + XCTAssertEqual(1, fixture.client.captureSessionInvocations.count) + } @available(tvOS 10.0, *) @available(OSX 10.12, *) diff --git a/Tests/SentryTests/TestClient.swift b/Tests/SentryTests/TestClient.swift index 2836430a90c..c09ab84c0dc 100644 --- a/Tests/SentryTests/TestClient.swift +++ b/Tests/SentryTests/TestClient.swift @@ -84,15 +84,16 @@ class TestClient: Client { return SentryId() } + var sessionIncrementsErrorCount = true var captureErrorWithSessionInvocations = Invocations<(error: Error, session: SentrySession, scope: Scope)>() override func captureError(_ error: Error, with scope: Scope, withSession sessionBlock: @escaping (Bool) -> SentrySession) -> SentryId { - captureErrorWithSessionInvocations.record((error, sessionBlock(true), scope)) + captureErrorWithSessionInvocations.record((error, sessionBlock(sessionIncrementsErrorCount), scope)) return SentryId() } var captureExceptionWithSessionInvocations = Invocations<(exception: NSException, session: SentrySession, scope: Scope)>() override func capture(_ exception: NSException, with scope: Scope, withSession sessionBlock: @escaping (Bool) -> SentrySession) -> SentryId { - captureExceptionWithSessionInvocations.record((exception, sessionBlock(true), scope)) + captureExceptionWithSessionInvocations.record((exception, sessionBlock(sessionIncrementsErrorCount), scope)) return SentryId() } From 3444baa36b0a464cffc759f5ba3a704c5e399032 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 12:48:21 +0100 Subject: [PATCH 6/9] Succint code --- Sources/Sentry/SentryHub.m | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index c30f4664ccc..d99a7cc2c10 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -445,11 +445,8 @@ - (SentryId *)captureError:(NSError *)error withScope:(SentryScope *)scope return [client captureError:error withScope:scope withSession:^(BOOL withErrorIncremented) { - if (withErrorIncremented) { - return [self incrementSessionErrors]; - } else { - return currentSession; - } + return withErrorIncremented ? [self incrementSessionErrors] + : currentSession; }]; } else { return [client captureError:error withScope:scope]; @@ -472,11 +469,8 @@ - (SentryId *)captureException:(NSException *)exception withScope:(SentryScope * return [client captureException:exception withScope:scope withSession:^(BOOL withErrorIncremented) { - if (withErrorIncremented) { - return [self incrementSessionErrors]; - } else { - return currentSession; - } + return withErrorIncremented ? [self incrementSessionErrors] + : currentSession; }]; } else { return [client captureException:exception withScope:scope]; From be47a8e2135665ad6099d82aa4f3b2f5ee042312 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 14:22:00 +0100 Subject: [PATCH 7/9] Update CHANGELOG.md Co-authored-by: Philipp Hofmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25630c8282b..25ecac75364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- Don't increase session's error count for dropped events (#2374) +- Don't update session for dropped events (#2374) - Set the correct OOM event timestamp (#2394) ## 7.31.0 From 4da4214be3a415d679bfca5da2f9e063db52a983 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 14:22:44 +0100 Subject: [PATCH 8/9] Remove --- Sources/Sentry/include/SentryHub+Private.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/Sentry/include/SentryHub+Private.h b/Sources/Sentry/include/SentryHub+Private.h index 7d4c09dc876..d02295caf82 100644 --- a/Sources/Sentry/include/SentryHub+Private.h +++ b/Sources/Sentry/include/SentryHub+Private.h @@ -53,8 +53,6 @@ SentryHub (Private) withScope:(SentryScope *)scope additionalEnvelopeItems:(NSArray *)additionalEnvelopeItems; -- (nullable SentrySession *)incrementSessionErrors; - @end NS_ASSUME_NONNULL_END From 6d7fab9e59bc6283d397fe97846dbb4391e19bb1 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 14:23:33 +0100 Subject: [PATCH 9/9] Update Tests/SentryTests/SentryClientTests.swift Co-authored-by: Philipp Hofmann --- Tests/SentryTests/SentryClientTests.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/SentryTests/SentryClientTests.swift b/Tests/SentryTests/SentryClientTests.swift index 3967e5997d3..9ef3e3e3cb3 100644 --- a/Tests/SentryTests/SentryClientTests.swift +++ b/Tests/SentryTests/SentryClientTests.swift @@ -449,10 +449,13 @@ class SentryClientTest: XCTestCase { } func testCaptureErrorWithSession() { + let sessionBlockExpectation = expectation(description: "session block gets called") let eventId = fixture.getSut().captureError(error, with: Scope()) { increaseErrorCount in XCTAssertTrue(increaseErrorCount) + sessionBlockExpectation.fulfill() return self.fixture.session } + wait(for: [sessionBlockExpectation], timeout: 0.2) eventId.assertIsNotEmpty() XCTAssertNotNil(fixture.transportAdapter.sentEventsWithSessionTraceState.last)