Skip to content

Commit

Permalink
Merge pull request #1215 from bugsnag/nickdowell/crash-info-fixes
Browse files Browse the repository at this point in the history
Crash info fixes
  • Loading branch information
nickdowell authored Oct 22, 2021
2 parents ab997b6 + 330ccde commit c8822be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Bugsnag/BugsnagSessionTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ - (BOOL)resumeSession {
} else {
BOOL stopped = session.isStopped;
[session resume];
if (self.callback) {
self.callback(session);
}
[self postUpdateNotice];
return stopped;
}
Expand Down
13 changes: 8 additions & 5 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]", andName: "Bar Foo")
}
super.startBugsnag()
}

override func run() {
Bugsnag.setContext("Something")
Bugsnag.setUser("barfoo", withEmail: "[email protected]", andName: "Bar Foo")
Bugsnag.addMetadata(["group": "users"], section: "user")

// Triggers "Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: ..."
print(payload.name)
}
Expand Down

0 comments on commit c8822be

Please sign in to comment.