Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve minimal report app/device information #239

Merged
merged 6 commits into from
Feb 28, 2018
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
5 changes: 4 additions & 1 deletion Source/BugsnagCrashReport.m
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@ - (NSDictionary *)toJson {

NSMutableDictionary *appObj = [NSMutableDictionary new];
[appObj addEntriesFromDictionary:self.app];
[appObj addEntriesFromDictionary:self.appState];

for (NSString *key in self.appState) {
BSGDictInsertIfNotNil(appObj, self.appState[key], key);
}

if (self.dsymUUID) {
BSGDictInsertIfNotNil(appObj, @[self.dsymUUID], @"dsymUUIDs");
Expand Down
36 changes: 34 additions & 2 deletions Source/BugsnagSink.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "BugsnagCollections.h"
#import "BugsnagNotifier.h"
#import "BugsnagKeys.h"
#import "BSG_KSSystemInfo.h"

// This is private in Bugsnag, but really we want package private so define
// it here.
Expand Down Expand Up @@ -59,9 +60,40 @@ - (void)filterReports:(NSArray *)reports
onCompletion:(BSG_KSCrashReportFilterCompletion)onCompletion {
NSMutableArray *bugsnagReports = [NSMutableArray new];
BugsnagConfiguration *configuration = [Bugsnag configuration];

for (NSDictionary *report in reports) {
BugsnagCrashReport *bugsnagReport =
[[BugsnagCrashReport alloc] initWithKSReport:report];
BugsnagCrashReport *bugsnagReport = [[BugsnagCrashReport alloc] initWithKSReport:report];
BOOL incompleteReport = (![@"standard" isEqualToString:[report valueForKeyPath:@"report.type"]] ||
[[report objectForKey:@"incomplete"] boolValue]);

if (incompleteReport) { // append app/device data as this is unlikely to change between sessions
NSDictionary *sysInfo = [BSG_KSSystemInfo systemInfo];

// reset any existing data as it will be corrupted/nil
bugsnagReport.appState = @{};
bugsnagReport.deviceState = @{};


NSMutableDictionary *appDict = [NSMutableDictionary new];
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_BundleVersion], @"bundleVersion");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_BundleID], @"id");
BSGDictInsertIfNotNil(appDict, configuration.releaseStage, @"releaseStage");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_SystemName], @"type");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_BundleShortVersion], @"version");

NSMutableDictionary *deviceDict = [NSMutableDictionary new];
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_Jailbroken], @"jailbroken");
BSGDictInsertIfNotNil(appDict, [[NSLocale currentLocale] localeIdentifier], @"locale");
BSGDictInsertIfNotNil(appDict, sysInfo[@"Apple"], @"manufacturer");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_Machine], @"model");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_Model], @"modelNumber");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_SystemName], @"osName");
BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_SystemVersion], @"osVersion");

bugsnagReport.app = appDict;
bugsnagReport.device = deviceDict;
}

if (![bugsnagReport shouldBeSent])
continue;
BOOL shouldSend = YES;
Expand Down
6 changes: 3 additions & 3 deletions examples/objective-c-ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Bugsnag (5.15.0)
- Bugsnag (5.15.3)

DEPENDENCIES:
- Bugsnag (from `../..`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: ../..

SPEC CHECKSUMS:
Bugsnag: d7958a4628b967d395a09f650732a234ee7de8c9
Bugsnag: 49464c6c2fb7a2eb5a66064586c64a6e23454c04

PODFILE CHECKSUM: 4c48f26cc704429f747c4af7a40e026b20fdc83e

COCOAPODS: 1.3.1
COCOAPODS: 1.4.0