Skip to content

Commit

Permalink
fix(report): Report release stage at time of crash
Browse files Browse the repository at this point in the history
The previous implementation reported the release stage when the report
is sent, rather than when the report was generated. This change
refactors the app state parser to use the correct stage value, either
current or from a file cache.
  • Loading branch information
kattrali committed Sep 17, 2019
1 parent 59d282d commit c5bfccc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Source/BugsnagCrashReport.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ - (instancetype)initWithKSReport:(NSDictionary *)report
_deviceState = BSGParseDeviceState(report);
_device = BSGParseDevice(report);
_app = BSGParseApp(report);
_appState = BSGParseAppState(report[BSGKeySystem], BSGLoadConfigValue(report, @"appVersion"));
_appState = BSGParseAppState(report[BSGKeySystem],
BSGLoadConfigValue(report, @"appVersion"),
_releaseStage, // Already loaded from config
BSGLoadConfigValue(report, @"codeBundleId"));
_groupingHash = BSGParseGroupingHash(report, _metaData);
_overrides = [report valueForKeyPath:@"user.overrides"];
_customException = BSGParseCustomException(report, [_errorClass copy],
Expand Down
5 changes: 4 additions & 1 deletion Source/BugsnagKSCrashSysInfoParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@

NSDictionary *_Nonnull BSGParseDevice(NSDictionary *_Nonnull report);
NSDictionary *_Nonnull BSGParseApp(NSDictionary *_Nonnull report);
NSDictionary *_Nonnull BSGParseAppState(NSDictionary *_Nonnull report, NSString *_Nullable preferredVersion);
NSDictionary *_Nonnull BSGParseAppState(NSDictionary *_Nonnull report,
NSString *_Nullable preferredVersion,
NSString *_Nullable releaseStage,
NSString *_Nullable codeBundleId);
NSDictionary *_Nonnull BSGParseDeviceState(NSDictionary *_Nonnull report);
6 changes: 3 additions & 3 deletions Source/BugsnagKSCrashSysInfoParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@
return appState;
}

NSDictionary *BSGParseAppState(NSDictionary *report, NSString *preferredVersion) {
NSDictionary *BSGParseAppState(NSDictionary *report, NSString *preferredVersion, NSString *releaseStage, NSString *codeBundleId) {
NSMutableDictionary *app = [NSMutableDictionary dictionary];

NSString *version = preferredVersion ?: report[@"CFBundleShortVersionString"];

BSGDictSetSafeObject(app, report[@"CFBundleVersion"], @"bundleVersion");
BSGDictSetSafeObject(app, [Bugsnag configuration].releaseStage,
BSGDictSetSafeObject(app, releaseStage,
BSGKeyReleaseStage);
BSGDictSetSafeObject(app, version, BSGKeyVersion);

BSGDictSetSafeObject(app, [Bugsnag configuration].codeBundleId, @"codeBundleId");
BSGDictSetSafeObject(app, codeBundleId, @"codeBundleId");

NSString *notifierType;
#if TARGET_OS_TV
Expand Down
5 changes: 4 additions & 1 deletion Source/BugsnagSessionTrackingPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ - (NSMutableDictionary *)toJson {
BSGDictSetSafeObject(dict, [Bugsnag notifier].details, BSGKeyNotifier);

NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo];
BSGDictSetSafeObject(dict, BSGParseAppState(systemInfo, [Bugsnag configuration].appVersion), @"app");
BSGDictSetSafeObject(dict, BSGParseAppState(systemInfo,
[Bugsnag configuration].appVersion,
[Bugsnag configuration].releaseStage,
[Bugsnag configuration].codeBundleId), @"app");
BSGDictSetSafeObject(dict, BSGParseDeviceState(systemInfo), @"device");
return dict;
}
Expand Down

0 comments on commit c5bfccc

Please sign in to comment.