From 67055f20d38b61cb69cfc9de0c4fafbdc7ffe874 Mon Sep 17 00:00:00 2001 From: Delisa Mason Date: Tue, 21 May 2019 11:29:22 +0100 Subject: [PATCH 1/2] fix(oom): Report short version as app.version Add bundleVersion as separate field --- CHANGELOG.md | 5 +++++ Source/BSGOutOfMemoryWatchdog.m | 10 ++++++++-- Tests/BugsnagCrashReportTests.m | 1 + features/oom.feature | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4b0e6d25..8b931bbab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Changelog ## 5.22.1 (2019-05-20) * Fix handled stacktrace generation +* Report correct app version in out-of-memory reports. Previously the bundle + version was reported as the version number rather than the short version + string. + [#349](https://github.com/bugsnag/bugsnag-cocoa/pull/349) + [#348](https://github.com/bugsnag/bugsnag-cocoa/pull/348) ## 5.22.0 (2019-05-09) diff --git a/Source/BSGOutOfMemoryWatchdog.m b/Source/BSGOutOfMemoryWatchdog.m index dafc034de..b80a7f50b 100644 --- a/Source/BSGOutOfMemoryWatchdog.m +++ b/Source/BSGOutOfMemoryWatchdog.m @@ -146,6 +146,8 @@ - (BOOL)computeDidOOMLastLaunchWithConfig:(BugsnagConfiguration *)config { NSDictionary *lastBootInfo = [self readSentinelFile]; if (lastBootInfo != nil) { self.lastBootCachedFileInfo = lastBootInfo; + NSString *lastBootBundleVersion = + [lastBootInfo valueForKeyPath:@"app.bundleVersion"]; NSString *lastBootAppVersion = [lastBootInfo valueForKeyPath:@"app.version"]; NSString *lastBootOSVersion = @@ -154,9 +156,12 @@ - (BOOL)computeDidOOMLastLaunchWithConfig:(BugsnagConfiguration *)config { [[lastBootInfo valueForKeyPath:@"app.inForeground"] boolValue]; NSString *osVersion = [BSG_KSSystemInfo osBuildVersion]; NSDictionary *appInfo = [[NSBundle mainBundle] infoDictionary]; + NSString *bundleVersion = + [appInfo valueForKey:@BSG_KSSystemField_BundleVersion]; NSString *appVersion = - [appInfo valueForKey:(__bridge NSString *)kCFBundleVersionKey]; + [appInfo valueForKey:@BSG_KSSystemField_BundleShortVersion]; BOOL sameVersions = [lastBootOSVersion isEqualToString:osVersion] && + [lastBootBundleVersion isEqualToString:bundleVersion] && [lastBootAppVersion isEqualToString:appVersion]; BOOL shouldReport = config.reportOOMs && (config.reportBackgroundOOMs || lastBootInForeground); [self deleteSentinelFile]; @@ -214,7 +219,8 @@ - (NSMutableDictionary *)generateCacheInfoWithConfig:(BugsnagConfiguration *)con app[@"id"] = systemInfo[@BSG_KSSystemField_BundleID] ?: @""; app[@"name"] = systemInfo[@BSG_KSSystemField_BundleName] ?: @""; app[@"releaseStage"] = config.releaseStage; - app[@"version"] = systemInfo[@BSG_KSSystemField_BundleVersion] ?: @""; + app[@"version"] = systemInfo[@BSG_KSSystemField_BundleShortVersion] ?: @""; + app[@"bundleVersion"] = systemInfo[@BSG_KSSystemField_BundleVersion] ?: @""; app[@"inForeground"] = @YES; #if TARGET_OS_TV app[@"type"] = @"tvOS"; diff --git a/Tests/BugsnagCrashReportTests.m b/Tests/BugsnagCrashReportTests.m index b69fb9bd4..7b5f8068e 100644 --- a/Tests/BugsnagCrashReportTests.m +++ b/Tests/BugsnagCrashReportTests.m @@ -556,6 +556,7 @@ - (void)testNoReportMetaData { - (void)testAppVersion { NSDictionary *dictionary = [self.report toJson]; XCTAssertEqualObjects(@"1.0", dictionary[@"app"][@"version"]); + XCTAssertEqualObjects(@"1", dictionary[@"app"][@"bundleVersion"]); } - (void)testAppVersionOverride { diff --git a/features/oom.feature b/features/oom.feature index 49d251e7c..f5e5389dc 100644 --- a/features/oom.feature +++ b/features/oom.feature @@ -16,6 +16,8 @@ Feature: Reporting out of memory events And the event "severity" equals "error" And the event "severityReason.type" equals "outOfMemory" 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 breadcrumbs contain "Crumb left before crash" Scenario: The OS kills the application in the background @@ -39,6 +41,8 @@ Feature: Reporting out of memory events And the event "severity" equals "error" And the event "severityReason.type" equals "outOfMemory" 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 breadcrumbs contain "Crumb left before crash" Scenario: The OS kills the application after a session is sent From cfeb982fa98295ea661b10fcfe49dccde9d411ae Mon Sep 17 00:00:00 2001 From: Delisa Mason Date: Tue, 21 May 2019 13:16:45 +0100 Subject: [PATCH 2/2] build: Unset release version/date --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b931bbab..973c40d0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,14 @@ Changelog ========= -## 5.22.1 (2019-05-20) +## TBD -* Fix handled stacktrace generation * Report correct app version in out-of-memory reports. Previously the bundle version was reported as the version number rather than the short version string. [#349](https://github.com/bugsnag/bugsnag-cocoa/pull/349) +* Fix missing stacktraces in reports generated from `notify()` [#348](https://github.com/bugsnag/bugsnag-cocoa/pull/348) ## 5.22.0 (2019-05-09)