Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Collect version information in device.runtimeVersions #345

Merged
merged 9 commits into from
May 8, 2019

Conversation

fractalwrench
Copy link
Contributor

Goal

We should collect the React Native version in device.runtimeVersions.reactNative for all error reports and sessions.

Note: this PR relies on the following Android and Cocoa PRs. The Cocoa changes have been vendored in; the Android changes require installing an artefact to mavenLocal in the usual way.

Changeset

  • Updated bugsnag-cocoa to runtime-versions-hooks branch
  • Added beforeSendSession callback to both Cocoa/Android which adds the react native version to the session payload
  • Added a beforeSend block/callback which adds the react native version to the error payload
  • Calculated the React Native version by concatenating the values present in the map supplied by the React Native platform

Discussion

There are a couple of important things to note with this approach:

  1. We use a beforeSend callback on React Native rather than a beforeNotify callback because this is the only callback mechanism that is guaranteed to be invoked when a fatal error occurs in the NDK.

  2. Ideally we would specify callbacks in a configuration parameter that is passed into a Bugsnag constructor; however, this is not possible with the current architecture of bugsnag-react-native. Instead we specify callbacks after constructing Bugsnag, which means there is a chance that some sessions could be missing runtime version information. This is a known issue with React Native configuration in general, and is something that we should address as part of a general revamp of the notifier.

Tests

Manually tested that the field was present in the payload for an error/session on both Android/Cocoa.

Mazerunner scenarios will be added in a separate PR to aid review.

@fractalwrench fractalwrench changed the title Collect version information to device.runtimeVersions Collect version information in device.runtimeVersions Apr 25, 2019
[config addBeforeSendBlock:^bool(NSDictionary *_Nonnull rawEventData,
BugsnagCrashReport *_Nonnull report) {
report.device = [self addDeviceRuntimeVersion:report.device];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will append the runtime version of the app when sending the report, which isn't necessarily the same as when capturing the crash.

Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change for perf on iOS, maybe there is also something similar on the Android side?

@fractalwrench fractalwrench dismissed kattrali’s stale review May 7, 2019 14:29

Collect version information in device.runtimeVersions (#345)

@fractalwrench
Copy link
Contributor Author

I've updated bugsnag-android and bugsnag-cocoa to the latest release, and also cached the React Native version on iOS as requested.

@fractalwrench fractalwrench merged commit 412e186 into next May 8, 2019
@fractalwrench fractalwrench deleted the runtime-versions branch May 29, 2019 09:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants