diff --git a/Source/BugsnagCrashReport.m b/Source/BugsnagCrashReport.m index 42e313aa7..090cd6691 100644 --- a/Source/BugsnagCrashReport.m +++ b/Source/BugsnagCrashReport.m @@ -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"); diff --git a/Source/BugsnagSink.m b/Source/BugsnagSink.m index 19dbb4365..8d271acbf 100644 --- a/Source/BugsnagSink.m +++ b/Source/BugsnagSink.m @@ -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. @@ -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; diff --git a/examples/objective-c-ios/Podfile.lock b/examples/objective-c-ios/Podfile.lock index 8e05f7088..c36191120 100644 --- a/examples/objective-c-ios/Podfile.lock +++ b/examples/objective-c-ios/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Bugsnag (5.15.0) + - Bugsnag (5.15.3) DEPENDENCIES: - Bugsnag (from `../..`) @@ -9,8 +9,8 @@ EXTERNAL SOURCES: :path: ../.. SPEC CHECKSUMS: - Bugsnag: d7958a4628b967d395a09f650732a234ee7de8c9 + Bugsnag: 49464c6c2fb7a2eb5a66064586c64a6e23454c04 PODFILE CHECKSUM: 4c48f26cc704429f747c4af7a40e026b20fdc83e -COCOAPODS: 1.3.1 +COCOAPODS: 1.4.0