|
29 | 29 | #import "BugsnagCollections.h" |
30 | 30 | #import "BugsnagNotifier.h" |
31 | 31 | #import "BugsnagKeys.h" |
| 32 | +#import "BSG_KSSystemInfo.h" |
32 | 33 |
|
33 | 34 | // This is private in Bugsnag, but really we want package private so define |
34 | 35 | // it here. |
@@ -59,9 +60,40 @@ - (void)filterReports:(NSArray *)reports |
59 | 60 | onCompletion:(BSG_KSCrashReportFilterCompletion)onCompletion { |
60 | 61 | NSMutableArray *bugsnagReports = [NSMutableArray new]; |
61 | 62 | BugsnagConfiguration *configuration = [Bugsnag configuration]; |
| 63 | + |
62 | 64 | for (NSDictionary *report in reports) { |
63 | | - BugsnagCrashReport *bugsnagReport = |
64 | | - [[BugsnagCrashReport alloc] initWithKSReport:report]; |
| 65 | + BugsnagCrashReport *bugsnagReport = [[BugsnagCrashReport alloc] initWithKSReport:report]; |
| 66 | + BOOL incompleteReport = (![@"standard" isEqualToString:[report valueForKeyPath:@"report.type"]] || |
| 67 | + [[report objectForKey:@"incomplete"] boolValue]); |
| 68 | + |
| 69 | + if (incompleteReport) { // append app/device data as this is unlikely to change between sessions |
| 70 | + NSDictionary *sysInfo = [BSG_KSSystemInfo systemInfo]; |
| 71 | + |
| 72 | + // reset any existing data as it will be corrupted/nil |
| 73 | + bugsnagReport.appState = @{}; |
| 74 | + bugsnagReport.deviceState = @{}; |
| 75 | + |
| 76 | + |
| 77 | + NSMutableDictionary *appDict = [NSMutableDictionary new]; |
| 78 | + BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_BundleVersion], @"bundleVersion"); |
| 79 | + BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_BundleID], @"id"); |
| 80 | + BSGDictInsertIfNotNil(appDict, configuration.releaseStage, @"releaseStage"); |
| 81 | + BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_SystemName], @"type"); |
| 82 | + BSGDictInsertIfNotNil(appDict, sysInfo[@BSG_KSSystemField_BundleShortVersion], @"version"); |
| 83 | + |
| 84 | + NSMutableDictionary *deviceDict = [NSMutableDictionary new]; |
| 85 | + BSGDictInsertIfNotNil(deviceDict, sysInfo[@BSG_KSSystemField_Jailbroken], @"jailbroken"); |
| 86 | + BSGDictInsertIfNotNil(deviceDict, [[NSLocale currentLocale] localeIdentifier], @"locale"); |
| 87 | + BSGDictInsertIfNotNil(deviceDict, sysInfo[@"Apple"], @"manufacturer"); |
| 88 | + BSGDictInsertIfNotNil(deviceDict, sysInfo[@BSG_KSSystemField_Machine], @"model"); |
| 89 | + BSGDictInsertIfNotNil(deviceDict, sysInfo[@BSG_KSSystemField_Model], @"modelNumber"); |
| 90 | + BSGDictInsertIfNotNil(deviceDict, sysInfo[@BSG_KSSystemField_SystemName], @"osName"); |
| 91 | + BSGDictInsertIfNotNil(deviceDict, sysInfo[@BSG_KSSystemField_SystemVersion], @"osVersion"); |
| 92 | + |
| 93 | + bugsnagReport.app = appDict; |
| 94 | + bugsnagReport.device = deviceDict; |
| 95 | + } |
| 96 | + |
65 | 97 | if (![bugsnagReport shouldBeSent]) |
66 | 98 | continue; |
67 | 99 | BOOL shouldSend = YES; |
@@ -115,6 +147,7 @@ - (NSDictionary *)getBodyFromReports:(NSArray *)reports { |
115 | 147 | NSMutableDictionary *data = [[NSMutableDictionary alloc] init]; |
116 | 148 | BSGDictSetSafeObject(data, [Bugsnag notifier].details, BSGKeyNotifier); |
117 | 149 | BSGDictSetSafeObject(data, [Bugsnag notifier].configuration.apiKey, BSGKeyApiKey); |
| 150 | + BSGDictSetSafeObject(data, @"4.0", @"payloadVersion"); |
118 | 151 |
|
119 | 152 | NSMutableArray *formatted = |
120 | 153 | [[NSMutableArray alloc] initWithCapacity:[reports count]]; |
|
0 commit comments