From 9ed67dcf9c5465d43dad6fd0ed9145163101de59 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Wed, 29 Sep 2021 10:44:04 +0100 Subject: [PATCH 1/4] Fix missing user info from config in crashing errors PLAT-7374 --- Bugsnag/Client/BugsnagClient.m | 13 ++++++++----- .../shared/scenarios/BareboneTestScenarios.swift | 7 +++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Bugsnag/Client/BugsnagClient.m b/Bugsnag/Client/BugsnagClient.m index 9e101091b..531f659cb 100644 --- a/Bugsnag/Client/BugsnagClient.m +++ b/Bugsnag/Client/BugsnagClient.m @@ -204,10 +204,17 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration { if ((self = [super init])) { // Take a shallow copy of the configuration _configuration = [configuration copy]; + + if (!_configuration.user.id) { // populate with an autogenerated ID if no value set + [_configuration setUser:[BSG_KSSystemInfo deviceAndAppHash] withEmail:_configuration.user.email andName:_configuration.user.name]; + } + _state = [[BugsnagMetadata alloc] initWithDictionary:@{ BSGKeyApp: @{BSGKeyIsLaunching: @YES}, - BSGKeyClient: BSGDictionaryWithKeyAndObject(BSGKeyContext, _configuration.context) + BSGKeyClient: BSGDictionaryWithKeyAndObject(BSGKeyContext, _configuration.context), + BSGKeyUser: [configuration.user toJson] }]; + _notifier = configuration.notifier ?: [[BugsnagNotifier alloc] init]; self.systemState = [[BugsnagSystemState alloc] initWithConfiguration:configuration]; @@ -266,10 +273,6 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration { self.pluginClient = [[BugsnagPluginClient alloc] initWithPlugins:self.configuration.plugins client:self]; - if (self.user.id == nil) { // populate with an autogenerated ID if no value set - [self setUser:[BSG_KSSystemInfo deviceAndAppHash] withEmail:configuration.user.email andName:configuration.user.name]; - } - BSGInternalErrorReporter.sharedInstance = [[BSGInternalErrorReporter alloc] initWithDataSource:self]; } return self; diff --git a/features/fixtures/shared/scenarios/BareboneTestScenarios.swift b/features/fixtures/shared/scenarios/BareboneTestScenarios.swift index e9e28c590..7f6c6b1e0 100644 --- a/features/fixtures/shared/scenarios/BareboneTestScenarios.swift +++ b/features/fixtures/shared/scenarios/BareboneTestScenarios.swift @@ -111,17 +111,16 @@ class BareboneTestUnhandledErrorScenario: Scenario { } } else { // The version of the app at crash time. + config.addMetadata(["group": "users"], section: "user") config.appVersion = "12.3" config.bundleVersion = "12301" + config.context = "Something" + config.setUser("barfoo", withEmail: "barfoo@example.com", andName: "Bar Foo") } super.startBugsnag() } override func run() { - Bugsnag.setContext("Something") - Bugsnag.setUser("barfoo", withEmail: "barfoo@example.com", andName: "Bar Foo") - Bugsnag.addMetadata(["group": "users"], section: "user") - // Triggers "Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: ..." print(payload.name) } From 330ccdef2a80a6326ded51661776035814c1ae7f Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Wed, 20 Oct 2021 15:03:11 +0100 Subject: [PATCH 2/4] Update crash-time session info when resumed --- Bugsnag/BugsnagSessionTracker.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Bugsnag/BugsnagSessionTracker.m b/Bugsnag/BugsnagSessionTracker.m index ed89859a6..07389b4fb 100644 --- a/Bugsnag/BugsnagSessionTracker.m +++ b/Bugsnag/BugsnagSessionTracker.m @@ -147,6 +147,9 @@ - (BOOL)resumeSession { } else { BOOL stopped = session.isStopped; [session resume]; + if (self.callback) { + self.callback(session); + } [self postUpdateNotice]; return stopped; } From 20ce78f9b4eabe268d3b1f7564acbbcbbf921045 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Tue, 21 Sep 2021 10:04:45 +0100 Subject: [PATCH 3/4] Use '#import ' in private headers --- Bugsnag/Bugsnag+Private.h | 2 +- Bugsnag/BugsnagSessionTracker.h | 4 ++-- Bugsnag/BugsnagSystemState.h | 3 ++- Bugsnag/Metadata/BugsnagMetadata+Private.h | 2 +- Bugsnag/Payload/BugsnagApp+Private.h | 2 +- Bugsnag/Payload/BugsnagAppWithState+Private.h | 3 ++- Bugsnag/Payload/BugsnagBreadcrumb+Private.h | 2 +- Bugsnag/Payload/BugsnagDevice+Private.h | 2 +- Bugsnag/Payload/BugsnagDeviceWithState+Private.h | 2 +- Bugsnag/Payload/BugsnagHandledState.h | 3 ++- Bugsnag/Payload/BugsnagSession+Private.h | 2 +- Bugsnag/Payload/BugsnagSessionTrackingPayload.h | 3 ++- Bugsnag/Payload/BugsnagUser+Private.h | 2 +- Bugsnag/Plugins/BugsnagPluginClient.h | 2 +- Bugsnag/Storage/BugsnagSessionFileStore.h | 3 ++- 15 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Bugsnag/Bugsnag+Private.h b/Bugsnag/Bugsnag+Private.h index 3d0329252..70ba5a5e4 100644 --- a/Bugsnag/Bugsnag+Private.h +++ b/Bugsnag/Bugsnag+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "Bugsnag.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/BugsnagSessionTracker.h b/Bugsnag/BugsnagSessionTracker.h index a6e7523a5..1ca1dba35 100644 --- a/Bugsnag/BugsnagSessionTracker.h +++ b/Bugsnag/BugsnagSessionTracker.h @@ -8,8 +8,8 @@ #import -#import "BugsnagSession.h" -#import "BugsnagConfiguration.h" +#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/BugsnagSystemState.h b/Bugsnag/BugsnagSystemState.h index 644963a51..1c474eff6 100644 --- a/Bugsnag/BugsnagSystemState.h +++ b/Bugsnag/BugsnagSystemState.h @@ -8,7 +8,8 @@ #import -#import "BugsnagConfiguration.h" +#import + #import "BugsnagKeys.h" #define SYSTEMSTATE_KEY_APP @"app" diff --git a/Bugsnag/Metadata/BugsnagMetadata+Private.h b/Bugsnag/Metadata/BugsnagMetadata+Private.h index f1eece067..5eeaed774 100644 --- a/Bugsnag/Metadata/BugsnagMetadata+Private.h +++ b/Bugsnag/Metadata/BugsnagMetadata+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagMetadata.h" +#import @class BugsnagStateEvent; diff --git a/Bugsnag/Payload/BugsnagApp+Private.h b/Bugsnag/Payload/BugsnagApp+Private.h index d9aafc599..7f3a9f02a 100644 --- a/Bugsnag/Payload/BugsnagApp+Private.h +++ b/Bugsnag/Payload/BugsnagApp+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagApp.h" +#import @class BugsnagConfiguration; diff --git a/Bugsnag/Payload/BugsnagAppWithState+Private.h b/Bugsnag/Payload/BugsnagAppWithState+Private.h index b53fafd9d..5c376c6fc 100644 --- a/Bugsnag/Payload/BugsnagAppWithState+Private.h +++ b/Bugsnag/Payload/BugsnagAppWithState+Private.h @@ -6,7 +6,8 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagAppWithState.h" +#import + #import "BugsnagApp+Private.h" @class BugsnagConfiguration; diff --git a/Bugsnag/Payload/BugsnagBreadcrumb+Private.h b/Bugsnag/Payload/BugsnagBreadcrumb+Private.h index 1e480dea7..e32d1de2c 100644 --- a/Bugsnag/Payload/BugsnagBreadcrumb+Private.h +++ b/Bugsnag/Payload/BugsnagBreadcrumb+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagBreadcrumb.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/Payload/BugsnagDevice+Private.h b/Bugsnag/Payload/BugsnagDevice+Private.h index dafd27da8..417b266fb 100644 --- a/Bugsnag/Payload/BugsnagDevice+Private.h +++ b/Bugsnag/Payload/BugsnagDevice+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagDevice.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/Payload/BugsnagDeviceWithState+Private.h b/Bugsnag/Payload/BugsnagDeviceWithState+Private.h index a54282188..519f836c4 100644 --- a/Bugsnag/Payload/BugsnagDeviceWithState+Private.h +++ b/Bugsnag/Payload/BugsnagDeviceWithState+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagDeviceWithState.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/Payload/BugsnagHandledState.h b/Bugsnag/Payload/BugsnagHandledState.h index c65e98f1a..e9456895a 100644 --- a/Bugsnag/Payload/BugsnagHandledState.h +++ b/Bugsnag/Payload/BugsnagHandledState.h @@ -6,9 +6,10 @@ // Copyright © 2017 Bugsnag. All rights reserved. // -#import "BugsnagEvent.h" #import +#import + typedef NS_ENUM(NSUInteger, SeverityReasonType) { UnhandledException, Signal, diff --git a/Bugsnag/Payload/BugsnagSession+Private.h b/Bugsnag/Payload/BugsnagSession+Private.h index 028599f4a..7714d4af1 100644 --- a/Bugsnag/Payload/BugsnagSession+Private.h +++ b/Bugsnag/Payload/BugsnagSession+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagSession.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/Payload/BugsnagSessionTrackingPayload.h b/Bugsnag/Payload/BugsnagSessionTrackingPayload.h index b89d26305..7511dfa87 100644 --- a/Bugsnag/Payload/BugsnagSessionTrackingPayload.h +++ b/Bugsnag/Payload/BugsnagSessionTrackingPayload.h @@ -7,7 +7,8 @@ // #import -#import "BugsnagSession.h" + +#import @class BugsnagConfiguration; @class BugsnagNotifier; diff --git a/Bugsnag/Payload/BugsnagUser+Private.h b/Bugsnag/Payload/BugsnagUser+Private.h index c83dcbc7f..17e81ab14 100644 --- a/Bugsnag/Payload/BugsnagUser+Private.h +++ b/Bugsnag/Payload/BugsnagUser+Private.h @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // -#import "BugsnagUser.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/Plugins/BugsnagPluginClient.h b/Bugsnag/Plugins/BugsnagPluginClient.h index 2c1bee9c1..0936bf6f4 100644 --- a/Bugsnag/Plugins/BugsnagPluginClient.h +++ b/Bugsnag/Plugins/BugsnagPluginClient.h @@ -8,7 +8,7 @@ #import -#import "BugsnagPlugin.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Bugsnag/Storage/BugsnagSessionFileStore.h b/Bugsnag/Storage/BugsnagSessionFileStore.h index 3e9b3bcf1..1ca03782b 100644 --- a/Bugsnag/Storage/BugsnagSessionFileStore.h +++ b/Bugsnag/Storage/BugsnagSessionFileStore.h @@ -5,8 +5,9 @@ #import +#import + #import "BugsnagFileStore.h" -#import "BugsnagSession.h" @interface BugsnagSessionFileStore : BugsnagFileStore + (BugsnagSessionFileStore *)storeWithPath:(NSString *)path From 37a3fd835986d453a00b06984674ecff7b8d1bf6 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Wed, 27 Oct 2021 11:23:56 +0100 Subject: [PATCH 4/4] Release v6.14.2 --- .jazzy.yaml | 4 ++-- Bugsnag.podspec.json | 4 ++-- Bugsnag/Payload/BugsnagNotifier.m | 2 +- BugsnagNetworkRequestPlugin.podspec.json | 6 +++--- CHANGELOG.md | 7 +++++++ Framework/Info.plist | 2 +- Tests/Info.plist | 2 +- VERSION | 2 +- 8 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.jazzy.yaml b/.jazzy.yaml index a1626a427..4df94fa55 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -2,11 +2,11 @@ author_url: "https://www.bugsnag.com" author: "Bugsnag Inc" clean: false # avoid deleting docs/.git framework_root: "Bugsnag" -github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.14.1/Bugsnag" +github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.14.2/Bugsnag" github_url: "https://github.com/bugsnag/bugsnag-cocoa" hide_documentation_coverage: true module: "Bugsnag" -module_version: "6.14.1" +module_version: "6.14.2" objc: true output: "docs" readme: "README.md" diff --git a/Bugsnag.podspec.json b/Bugsnag.podspec.json index 5ee43d4d2..0dcdaacc9 100644 --- a/Bugsnag.podspec.json +++ b/Bugsnag.podspec.json @@ -1,6 +1,6 @@ { "name": "Bugsnag", - "version": "6.14.1", + "version": "6.14.2", "summary": "The Bugsnag crash reporting framework for Apple platforms.", "homepage": "https://bugsnag.com", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v6.14.1" + "tag": "v6.14.2" }, "frameworks": [ "Foundation", diff --git a/Bugsnag/Payload/BugsnagNotifier.m b/Bugsnag/Payload/BugsnagNotifier.m index 4014137a2..2f92c600e 100644 --- a/Bugsnag/Payload/BugsnagNotifier.m +++ b/Bugsnag/Payload/BugsnagNotifier.m @@ -23,7 +23,7 @@ - (instancetype)init { #else _name = @"Bugsnag Objective-C"; #endif - _version = @"6.14.1"; + _version = @"6.14.2"; _url = @"https://github.com/bugsnag/bugsnag-cocoa"; _dependencies = @[]; } diff --git a/BugsnagNetworkRequestPlugin.podspec.json b/BugsnagNetworkRequestPlugin.podspec.json index 0e0fcf225..2f90edb62 100644 --- a/BugsnagNetworkRequestPlugin.podspec.json +++ b/BugsnagNetworkRequestPlugin.podspec.json @@ -1,16 +1,16 @@ { "name": "BugsnagNetworkRequestPlugin", - "version": "6.14.1", + "version": "6.14.2", "summary": "Network request monitoring support for Bugsnag.", "homepage": "https://bugsnag.com", "license": "MIT", "authors": { "Bugsnag": "notifiers@bugsnag.com" }, - "readme": "https://raw.githubusercontent.com/bugsnag/bugsnag-cocoa/v6.14.1/BugsnagNetworkRequestPlugin/README.md", + "readme": "https://raw.githubusercontent.com/bugsnag/bugsnag-cocoa/v6.14.2/BugsnagNetworkRequestPlugin/README.md", "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v6.14.1" + "tag": "v6.14.2" }, "dependencies": { "Bugsnag": "~> 6.13" diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b1870d8..65e0265cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +## 6.14.2 (2021-10-27) + +### Bug fixes + +* Fix missing `configuration.user` and manually resumed `session` info in unhandled errors. + [#1215](https://github.com/bugsnag/bugsnag-cocoa/pull/1215) + ## 6.14.1 (2021-10-20) ### Bug fixes diff --git a/Framework/Info.plist b/Framework/Info.plist index 2fa1bac49..cbb323de7 100644 --- a/Framework/Info.plist +++ b/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.14.1 + 6.14.2 CFBundleVersion 1 diff --git a/Tests/Info.plist b/Tests/Info.plist index 1e7a6a313..b7a35149b 100644 --- a/Tests/Info.plist +++ b/Tests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 6.14.1 + 6.14.2 CFBundleVersion 1 diff --git a/VERSION b/VERSION index bbf0c5a54..2876b160f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.14.1 +6.14.2