Configuration options

In addition to configuring a Bugsnag client with an API key, it can also be configured with additional options using a Configuration object.

import { Client, Configuration } from "bugsnag-react-native";

const configuration = new Configuration(),
      bugsnag = new Client(configuration);

Configuration can be instantiated with an API key and has the following options.

apiKey

Your Integration API Key, available on your Bugsnag dashboard under “Settings”. If not set, it will be loaded from your AndroidManifest.xml or Info.plist if available on Android and iOS respectively.

configuration.apiKey = "YOUR-API-KEY";

appVersion

The version of the application. By default, this information is populated from the underlying native app.

configuration.appVersion = "1.4.5";

autoNotify

By default, we will automatically notify Bugsnag of any fatal exceptions in your application. If you want to stop this from happening, you can set autoNotify to false:

configuration.autoNotify = false;

beforeSendCallbacks

Before a report is sent to Bugsnag, a callback can be registered to modify or reject any error report. By default, no callbacks are registered. To prevent a report from being sent, return false from the callback.

configuration.beforeSendCallbacks.push(function(report) {
  if (report.errorClass === 'UnimportantDeviceError')
    return false;
});

clearUser

Removes customized user information from an error report which was set with setUser.

bugsnag.clearUser();

codeBundleId

A user-defined unique identifier for a JavaScript code deployment. There can be multiple deployments for a given appVersion. This is most useful when using a tool like CodePush to update your app. See the showing full stacktraces guide for more information.

configuration.codeBundleId = "1.0-15"

delivery

Delivery contains the configuration for how reports are sent to Bugsnag. To change the endpoint used to send error reports, change the delivery endpoint:

import { StandardDelivery } from "bugsnag-react-native";

configuration.delivery = new StandardDelivery("https://example.com/errors");

handlePromiseRejections

By default, unhandled promise rejections are sent to Bugsnag when not in dev mode. To change whether rejections are sent, set handlePromiseRejections:

configuration.handlePromiseRejections = false;

Promises can also be captured on an individual basis by using notify as the catch block:

new Promise(function(resolve, reject) {
  /* potentially failing code */
})
.then(function() { /* the promise resolved */ })
.catch(bugsnag.notify);

notifyReleaseStages

By default, we notify Bugsnag of all exceptions that happen in your app. If you would like to change which release stages notify Bugsnag of exceptions you can set the notifyReleaseStages property:

configuration.notifyReleaseStages = ['beta', 'production'];

releaseStage

In order to distinguish between errors that occur in different stages of the application release process a release stage is sent to Bugsnag when an error occurs. This is automatically configured by the notifier to be “production”, unless a development environment is detected. In this case it will be set to “development”. If you wish to override this, you can do so by setting the releaseStage property manually:

configuration.releaseStage = 'beta';

setUser

In order to correlate errors with customer reports, or to see a list of users who experienced each error, it is helpful to capture and display user information on your Bugsnag dashboard. To set an identifier for a user, use the setUser function:

bugsnag.setUser('1234', 'Jessica Jones', 'jess@example.com');

The user ID, email, and name are searchable on the Bugsnag dashboard.

By default, if no user information is provided, Bugsnag sends a device- and vendor-specific identifier assigned as the user id for each device.

To remove customized user information, use clearUser.