From fcdc9d6f033346a7e1ba593487c46f03e14a3ecd Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 11:54:39 +0100 Subject: [PATCH 1/3] Use the last breadcrumb's timestamp as the OOM event timestamp Fixes #2383 --- Sources/Sentry/SentryOutOfMemoryTracker.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/Sentry/SentryOutOfMemoryTracker.m b/Sources/Sentry/SentryOutOfMemoryTracker.m index 5aa953956d9..3d309d0f38a 100644 --- a/Sources/Sentry/SentryOutOfMemoryTracker.m +++ b/Sources/Sentry/SentryOutOfMemoryTracker.m @@ -1,3 +1,4 @@ +#import "NSDate+SentryExtras.h" #import "SentryEvent+Private.h" #import "SentryFileManager.h" #import @@ -68,6 +69,12 @@ - (void)start self.options.maxBreadcrumbs)]; } + NSDictionary *lastBreadcrumb = event.serializedBreadcrumbs.lastObject; + if (lastBreadcrumb && [lastBreadcrumb objectForKey:@"timestamp"]) { + NSString *timestampIso8601String = [lastBreadcrumb objectForKey:@"timestamp"]; + event.timestamp = [NSDate sentry_fromIso8601String:timestampIso8601String]; + } + SentryException *exception = [[SentryException alloc] initWithValue:SentryOutOfMemoryExceptionValue type:SentryOutOfMemoryExceptionType]; From aa9fe51e12ae120e927bf977a0b52af5ea9bc994 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 11:57:42 +0100 Subject: [PATCH 2/3] Add a test --- .../OutOfMemory/SentryOutOfMemoryTrackerTests.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift b/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift index 686ae66da3a..fd6ad00ebd2 100644 --- a/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift +++ b/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift @@ -225,6 +225,9 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { fixture.fileManager.moveBreadcrumbsToPreviousBreadcrumbs() sut.start() assertOOMEventSent(expectedBreadcrumbs: 2) + + let crashEvent = fixture.client.captureCrashEventInvocations.first?.event + XCTAssertEqual(crashEvent?.timestamp, breadcrumb.timestamp) } func testAppOOM_WithOnlyHybridSdkDidBecomeActive() { From 553fdca66e1e167f3eb5185254a401b9fd56d6a5 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 16 Nov 2022 11:59:29 +0100 Subject: [PATCH 3/3] Changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8457a3e15c..c23af9be8ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Set the correct OOM event timestamp (#2394) + ## 7.31.0 ### Features