Using Sentry

Sentry is a crash reporting and aggregation platform that provides you with "real-time insight into production deployments with info to reproduce and fix crashes".

It notifies you of exceptions that your users run into while using your app and organizes for you to triage from their web dashboard. Reported exceptions include sourcemapped stacktraces and other relevant context (device id, platform, Expo verison, etc.) automatically; you can also provide other context that is specific to your application, like the current route and user id.

Why Sentry?

Sentry treats React Native as a first-class citizen and we have collaborated with Sentry to make sure Expo is too.

It's easy to set up and use.

It scales to meet the demands of even the largest projects.

It works on most platforms, so you can use the same service for reporting your server, CLI, or desktop app errors as you use for your Expo app.

Add Sentry to your Expo project

Sign up for a Sentry account and create a project

Once you have signed up, you will be prompted to create a project. Enter the name of your project and continue.

You will now be prompted to configure your application, click the link "Get your DSN" and copy your "Public DSN", you will need it shortly.

Go to the Sentry API section and create an auth token. You can use the default configuration, this token will never be made available to users of your app. Copy your auth token and save it for later.

Go to your project dashboard by going to sentry.io and clicking "Select a project" from the top of the screen, then choosing your project. This is where you will see exceptions reported later. For now, click "Project Settings" in the top right, and copy your project "Short name". Then click on the top left corner icon to expose the organizations in your account. Click on settings gear icon and copy the organization short name. You will need this info for your app.json settings.

Install and configure Sentry

Make sure you're using a new version of Node which supports async/await (Node 7.6+)

Publish your app with sourcemaps

With the postPublish hook in place, now all you need to do is hit publish and the sourcemaps will be uploaded automatically. We automatically assign a unique release version for Sentry each time you hit publish, based on the version you specify in app.json and a release id on our backend -- this means that if you forget to update the version but hit publish, you will still get a unique Sentry release. If you're not familiar with publishing on Expo, you can read more about it here.

Error reporting semantics

In order to ensure that errors are reported reliably, Sentry defers reporting the data to their backend until the next time you load the app after a fatal error rather than trying to report it upon catching the exception. It saves the stacktrace and other metadata to AsyncStorage and sends it immediately when the app starts.

Disabled by default in dev

Unless Sentry.enableInExpoDevelopment = true is set before calling Sentry.config({...}).install(), all your dev/local errors will be ignored and only app releases will report errors to Sentry. You can call methods like Sentry.captureException(new Error('Oops!')) but these methods will be no-op.

Learn more about Sentry

Sentry does more than just catch fatal errors, learn more about how to use Sentry from their JavaScript usage docs.