Installing Airbrake in a JavaScript application



Visit our official GitHub repository for full installation instructions and configuration options.

The notifier is built using a standalone browserify build and can be used with:

We include the full source code with the package, so you can use Browserify too.

If you prefer not to host the library yourself, airbrake-js is available on the excellent cdnjs CDN.

Basic Usage

First you need to initialize notifier with project id and API key taken from

var airbrake = new airbrakeJs.Client({projectId: 1, projectKey: 'abc'});

Or if you are using browserify/webpack/etc:

var airbrakeJs = require('airbrake-js');
var airbrake = new airbrakeJs({projectId: 1, projectKey: 'abc'});

The simplest method is to report errors directly:

try {
  // This will throw if the document has no head tag
} catch(err) {
  throw err;

Alternatively you can wrap any code which may throw errors using the client’s wrap method:

var startApp = function() {
  // This will throw if the document has no head tag.
startApp = airbrake.wrap(startApp);

// Any exceptions thrown in startApp will be reported to Airbrake.

Visit our official GitHub repository for more information.