Skip to content

Commit

Permalink
Persist default version information in BugsnagConfiguration so that i…
Browse files Browse the repository at this point in the history
…t gets put into events when users don't manually set version info.
  • Loading branch information
kstenerud committed Oct 27, 2020
1 parent b5120c5 commit c27d464
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Bugsnag/Configuration/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey

_metadata = [[BugsnagMetadata alloc] init];
_config = [[BugsnagMetadata alloc] init];
_bundleVersion = NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"];
_endpoints = [BugsnagEndpointConfiguration new];
_sessionURL = [NSURL URLWithString:@"https://sessions.bugsnag.com"];
_autoDetectErrors = YES;
Expand Down Expand Up @@ -203,19 +202,30 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
sessionWithConfiguration:[NSURLSessionConfiguration
defaultSessionConfiguration]];
}

NSString *releaseStage = nil;
#if DEBUG
_releaseStage = BSGKeyDevelopment;
releaseStage = BSGKeyDevelopment;
#else
_releaseStage = BSGKeyProduction;
releaseStage = BSGKeyProduction;
#endif

NSString *appType = nil;
#if BSG_PLATFORM_TVOS
_appType = @"tvOS";
appType = @"tvOS";
#elif BSG_PLATFORM_IOS
_appType = @"iOS";
appType = @"iOS";
#elif BSG_PLATFORM_OSX
_appType = @"macOS";
appType = @"macOS";
#else
appType = @"unknown";
#endif

[self setAppType:appType];
[self setReleaseStage:releaseStage];
[self setAppVersion:NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]];
[self setBundleVersion:NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]];

return self;
}

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Changelog

### Bug fixes

* Fix for incorrect version info during edge case where version info is not
manually set, and app version is changed between crashing and reporting the error.
[862](https://github.com/bugsnag/bugsnag-cocoa/pull/862)

* Catch and report unexpected exceptions when (de)serializing JSON data rather
than crashing.
[856](https://github.com/bugsnag/bugsnag-cocoa/pull/856)
Expand Down

0 comments on commit c27d464

Please sign in to comment.