Error Logging
Set Up BugSnag
Out of the box, errors will be logged to the console. To set up BugSnag, follow these steps:
- Set up a project in BugSnag.
- Run
npx bugsnag-expo-cli init
. - No need to install @bugsnag/expo again, so answer
no
to the first question. - Enter your Api Key (on your Bugsnag Project Dashboard).
- Answer
No
when the CLI asks you to add code toApp.js
(which does not exist in this project). - If you want to upload source maps automatically, answer
yes
, otherwiseno
. You can always upload source maps later manually, or rerun the script if you change your mind. - In your .env file, set EXPO_PUBLIC_ENABLE_ERROR_REPORTING to true:
EXPO_PUBLIC_ENABLE_ERROR_REPORTING=true
. - You can use Bugsnag by importing
import { reportError } from "~/lib/report-error";
and then use reportError like soreportError(someError)
.