Configuration options

apiKey

Set your Bugsnag API key. You can find your API key on your dashboard.

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
      data-apikey="YOUR-API-KEY-HERE"></script>

In situations where Bugsnag is not in its own script tag, you can set this with:

Bugsnag.apiKey = "YOUR-API-KEY-HERE";

appVersion

Setting the appVersion lets you see at a glance when errors first and last happened in your code.

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
      data-apikey="YOUR-API-KEY-HERE"
      data-appversion="2.0.14"></script>

In situations where Bugsnag is not in its own script tag, you can set this with:

Bugsnag.appVersion = "2.0.14";

autoNotify

By default, we will automatically notify Bugsnag of any JavaScript errors that get sent to window.onerror. If you want to stop this from happening, you can set autoNotify to false:

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
      data-apikey="YOUR-API-KEY-HERE"
      data-autonotify="false"></script>

In situations where Bugsnag is not in its own script tag, you can set this with:

Bugsnag.autoNotify = false;

autoBreadcrumbs

By default, Bugsnag will automatically create breadcrumbs for several types of common events, as listed in the integration guide. To disable this behavior entirely, you can set data-autobreadcrumbs="false":

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
        data-apikey="YOUR-API-KEY-HERE"
        data-autobreadcrumbs="false"></script>

In situations where Bugsnag is not in its own script tag, you can toggle this with:

// Enable all automatic breadcrumbs
Bugsnag.enableAutoBreadcrumbs();
// Disable all automatic breadcrumbs
Bugsnag.disableAutoBreadcrumbs();

You can also disable automatic breadcrumb types individually:

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
        data-apikey="YOUR-API-KEY-HERE"
        data-autobreadcrumbsclicks="false"
        data-autobreadcrumbserrors="false"
        data-autobreadcrumbsconsole="false"
        data-autobreadcrumbsnavigation="false"></script>

In situations where Bugsnag is not in its own script tag, you can toggle these with:

// Breadcrumbs from click events
Bugsnag.enableAutoBreadcrumbsClicks();
Bugsnag.disableAutoBreadcrumbsClicks();
// Breadcrumbs from exceptions
Bugsnag.enableAutoBreadcrumbsErrors();
Bugsnag.disableAutoBreadcrumbsErrors();
// Breadcrumbs from console.log, console.warn, console.error
Bugsnag.enableAutoBreadcrumbsConsole();
Bugsnag.disableAutoBreadcrumbsConsole();
// Breadcrumbs from browser navigation events,
// (hash change, pushState, replaceState etc...)
Bugsnag.enableAutoBreadcrumbsNavigation();
Bugsnag.disableAutoBreadcrumbsNavigation();

To enable a single type of automatic breadcrumb you can disable all of them and then enable the individual group:

// disable all automatic breadcrumbs except click events
Bugsnag.disableAutoBreadcrumbs();
Bugsnag.enableAutoBreadcrumbsClicks();

beforeNotify

To have more fine grained control over what errors are sent to Bugsnag, you can implement a beforeNotify function. If you want to halt the notification completely, return false from this function.

Bugsnag.beforeNotify = function(payload) {
 // modify the payload here
}

For more information, see Customizing error reports

context

By default, Bugsnag sets the context to the current page’s pathname, otherwise referred to as location.pathname. Note: location.pathname does not include any search parameters or the page’s fragment identifier.

Bugsnag.context = "/path/to/my/page.php";

endpoint

The endpoint option causes the Bugsnag notifier to send errors to a different web address. By default the address is set to https://notify.bugsnag.com/js, but you can change it to point to an On-premise installation of Bugsnag:

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
      data-apikey="YOUR-API-KEY-HERE"
      data-endpoint="https://bugsnag.local:49000/js"></script>

In situations where Bugsnag is not in its own script tag, you can set this with:

Bugsnag.endpoint = "https://bugsnag.local:49000/js";

groupingHash

If the metaData hash has a key groupingHash it will be used to override the default grouping on Bugsnag.com. Exceptions with the same grouping hash will be grouped together into one error. You should not normally need to change this.

Bugsnag.notifyException(e, {groupingHash: e.message});

By default errors will be grouped by the statement in your code that raised the error. We try to fetch the javascript and use the surrounding code to identify the statement, but if that’s not possible we fall back to using line number and filename as an approximation.

metaData

Set additional meta-data to send to Bugsnag with every error. You can use this to add custom tabs of data to each error on your Bugsnag dashboard to help you debug.

This should be an object of objects, the outer object should represent the “tabs” to display on your Bugsnag dashboard, and the inner objects should be the values to display on each tab, for example:

Bugsnag.metaData = {
account: {
  name: "Bugsnag",
  plan: "premium",
  beta_access: true
}
};

notifyHandler

By default, the notify request will be made via temporary javascript image object. This does not work in Chrome apps and extensions where XHR needs to be used. If you want to use Bugsnag with XHR, just set notifyHandler to xhr:

<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
      data-apikey="YOUR-API-KEY-HERE"
      data-notifyhandler="xhr"></script>

In situations where Bugsnag is not in its own script tag, you can set this with:

Bugsnag.notifyHandler = "xhr";

notifyReleaseStages

By default, we will notify Bugsnag of exceptions that happen in any releaseStage. If you would like to change which release stages notify Bugsnag of errors you can set notifyReleaseStages:

  Bugsnag.notifyReleaseStages = ["development", "production"];

notifyUnhandledRejections

Bugsnag allows you to notify on unhandled promise rejections in browsers that support the unhandledrejection event. Because browser support for this event is inconsistent, this option is off by default to reduce confusion.

// Enable notifying on unhandledrejection in browsers that support it:
Bugsnag.enableNotifyUnhandledRejections();

// Disable notifying on unhandledrejection:
Bugsnag.disableNotifyUnhandledRejections();

For more information on reporting unhandled Promise and Deferred rejections, see Reporting promise rejections.

projectRoot

By default, Bugsnag sets the projectRoot to the current host address (protocol & the domain). For example, https://example.com is the projectRoot for all errors that occur within the example.com domain.

  Bugsnag.projectRoot = "http://example.com";

refresh

By default we report a maximum of 10 errors per page load. This is to prevent wasting a user’s browser resources and bandwidth by sending thousands of duplicate exceptions to Bugsnag. If you have a long-running single page app, you may want to reset this rate-limit from your router when users navigate from one view to another:

Bugsnag.refresh()

releaseStage

If you would like to distinguish between errors that happen in different stages of the application release process (development, production, etc) you can set the releaseStage that is reported to Bugsnag.

  <script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-3.min.js"
        data-apikey="YOUR-API-KEY-HERE"
        data-releasestage="development"></script>

In situations where Bugsnag is not in its own script tag, you can set this with:

  Bugsnag.releaseStage = "development";

By default this is set to be “production”.

user

Information about the current user. This data will be sent to Bugsnag with exception reports so that you can see who was affected by a particular error and search for problems seen by a given user.

Bugsnag.user = {
id: 7,
name: "Example User",
email: "user@example.com"
};