Skip to content

Commit

Permalink
fix: Support adding pre-delivery metadata to OOM reports
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali committed Jul 22, 2019
1 parent b8e8a82 commit 849343c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

* Support adding pre-delivery metadata to out-of-memory reports
[#393](https://github.com/bugsnag/bugsnag-cocoa/pull/393)

## 5.22.3 (2019-07-15)

This release disables reporting out-of-memory events in debug mode, to reduce
Expand Down
1 change: 1 addition & 0 deletions Source/BugsnagCrashReport.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ - (instancetype)initWithKSReport:(NSDictionary *)report
_releaseStage = [report valueForKeyPath:@"user.state.oom.app.releaseStage"];
_handledState = [BugsnagHandledState handledStateWithSeverityReason:LikelyOutOfMemory];
_deviceAppHash = [report valueForKeyPath:@"user.state.oom.device.id"];
_metaData = [NSMutableDictionary new];
NSDictionary *sessionData = [report valueForKeyPath:@"user.state.oom.session"];
if (sessionData) {
_session = [[BugsnagSession alloc] initWithDictionary:sessionData];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ @implementation OOMScenario
- (void)startBugsnag {
self.config.shouldAutoCaptureSessions = NO;
self.config.releaseStage = @"alpha";
[self.config addBeforeSendBlock:^bool(NSDictionary * _Nonnull rawEventData, BugsnagCrashReport * _Nonnull report) {
NSMutableDictionary *metadata = [report.metaData mutableCopy];
metadata[@"extra"] = @{ @"shape": @"line" };
report.metaData = metadata;
return YES;
}];
[super startBugsnag];
}

Expand Down
1 change: 1 addition & 0 deletions features/out_of_memory.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Feature: Reporting out of memory events
And the event "app.releaseStage" equals "beta"
And the event "app.version" equals "1.0.3"
And the event "app.bundleVersion" equals "5"
And the event "metaData.extra.shape" equals "line"
And the event breadcrumbs contain "Crumb left before crash"

Scenario: The OS kills the application in the background
Expand Down

0 comments on commit 849343c

Please sign in to comment.