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";

autoCaptureSessions

By default, Bugsnag will automatically capture and report session information from your application.

If the notify endpoint is changed and the sessions endpoint is not, this option will be set to false and session tracking will be disabled.

To disable automatic session capturing:

configuration.autoCaptureSessions = false;

If you want control over what is deemed a session, you can switch off automatic session tracking with the autoCaptureSessions option, and call startSession() when appropriate for your application.

bugsnag.startSession();

automaticallyCollectBreadcrumbs

By default we will automatically add breadcrumbs for common application events at the native layer, such as entering the background and system events. To disable this behavior, set this property to false:

configuration.automaticallyCollectBreadcrumbs = false;

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.registerBeforeSendCallback(function(report, error) {
  if (report.errorClass === 'UnimportantDeviceError')
    return false;
});

Callbacks can also be removed individually:

configuration.unregisterBeforeSendCallback(callback_to_remove);

or all at once:

configuration.clearBeforeSendCallbacks();

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 App Center CodePush to update your app. See the showing full stacktraces guide for more information.

configuration.codeBundleId = "1.0-15"

consoleBreadcrumbsEnabled

Leaves a breadcrumb when any console log method is called. This wraps .log(…), .debug(…), .info(…), .warn(…) and .error(…), creating a breadcrumb with the supplied arguments and severity level. The supplied arguments are passed on to the original log function.

Warning: this has an unfortunate side-effect in that all log messages will appear to originate from the Bugsnag source rather than original location of the log call. As such the default for this option is false.

configuration.consoleBreadcrumbsEnabled = true

delivery

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

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

configuration.delivery = new StandardDelivery("https://notify.example.com",
                                              "https://sessions.example.com");

You should also alter how the Android/iOS components are initialised, by passing a config parameter:

Configuration config = new Configuration("your-api-key-here");
config.setEndpoints("https://notify.example.com", "https://sessions.example.com");
BugsnagReactNative.start(this, config);
BugsnagConfiguration *config = [BugsnagConfiguration new];
[config setEndpointsForNotify:@"http://notify.example.com"
                     sessions:@"http://sessions.example.com"];
[BugsnagReactNative startWithConfiguration:config];

This ensures that all requests are sent to the correct endpoint immediately after initialisation. Further documentation can be found in the Android and iOS guides.

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.