diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c9bae6276..f1d32d623dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixes - Too long flush duration (#2370) +- Don't increase session's error count for dropped events (#2374) ## 7.30.2 diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index 3da3f62dc2e..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]; } @@ -220,6 +225,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..96b49b0f2c3 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) { @@ -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) { 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