Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Set the correct OOM event timestamp (#2394)

## 7.31.0

### Features
Expand Down
7 changes: 7 additions & 0 deletions Sources/Sentry/SentryOutOfMemoryTracker.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import "NSDate+SentryExtras.h"
#import "SentryEvent+Private.h"
#import "SentryFileManager.h"
#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down