No items found.
March 8, 2017

Bugsnag now supports Code Push for React Native

What you CANNOT use CodePush for:

  • Code that touches the native side of React Native. These changes will require an App Store update.
  • Updates that impact the overall purpose of your app (via Apple’s Developer agreement), so keep it within reason.

What you CAN use CodePush for:

  • Code updates related to your JavaScript bundle and any associated assets (ex. images).

This last one makes Code Push a perfect tool for hot bug fixes, and combined with Bugsnag, you’ll be able to easily identify the bugs that need fixing. Bugsnag gives you visibility into when your apps crash in production. We will point you to the line of code that caused the crash even for minified and obfuscated JavaScript, so you can easily fix the error, and push out a new release with CodePush. To complete this cycle of identifying and fixing bugs, you’ll also want visibility into your newly Code Pushed release. This is just what we’ve added. Thanks to Code Push’s latest release, you can integrate Bugsnag into your development process in just a few lines.

How does Code Push integrate with Bugsnag?

To get full visibility of an error, Bugsnag uses source maps to de-obfuscate JavaScript stack traces. Bugsnag has a Source Map Upload API to help with this. When you release your app with Code Push, you’ll define a [CODE]codeBundleId[/CODE] (like a version for Code Push), and send us the source maps associated with that [CODE]codeBundleId[/CODE]. Bugsnag will link the errors you send, with the associated source maps, so it’s easy to see what line of code caused the error.

The Details

Before you deploy, the [CODE]codeBundleId[/CODE] gets defined in your Bugsnag configuration.

-- CODE language-plaintext --
const config = new Configuration('YOUR_API_KEY_HERE');
config.codeBundleId = '1.0-123'
const bugsnag = new Client(config);

When you release your app, specify the [CODE]--sourcemapOutput[/CODE] or [CODE]--outputDir[/CODE] in order to capture the source map and asset bundle files for upload.

-- CODE language-plaintext --
code-push release-react <appName> <platform> --outputDir <outputDir> <other options>

And finally, send Bugsnag your source maps, making sure to include the [CODE]codeBundleId[/CODE] and source map path.

-- CODE language-plaintext --
$ curl \
 -F codeBundleId=1.0-123 \
 -F minifiedUrl="main.jsbundle" \
 -F sourceMap=@path/to/ \
 -F minifiedFile=@path/to/main.jsbundle \
 -F overwrite=true
 -F */index.ios.js=@/workspace/app/index.ios.js

For a full rundown of each of these steps, make sure to check out the Bugsnag docs. We hope this new support is useful as more and more of you continue to roll out React Native apps.A few months back, we announced support for React Native crash reporting, and since then, React Native has quickly become one of our most popular platforms. This is no surprise, given its range of benefits, from speed of deployment across iOS and Android, to the skills transfer for JavaScript developers and, as its name indicates, the ability to render hybrid apps natively. But easily one of our favorite features is React Native’s integration with Microsoft Code Push: the magical ability to push updates without having to go through the App Store update process. Code Push comes with some caveats of course.

Bugsnag helps you prioritize and fix software bugs while improving your application stability
Request a demo