Johnny's fork of Node.js client for airbrake.io
npm install airbrake
The common use case for this module is to catch all
events on the
process object and send them to airbrake:
var airbrake = ;airbrake;throw 'I am an uncaught exception';
Please note that the above will re-throw the exception after it has been successfully delivered to airbrake, caushing your process to exit with status 1.
If you want more control over the delivery of your errors, you can also manually submit errors to airbrake.
var airbrake = ;var err = 'Something went terribly wrong';airbrake;
A custom error handler will need to be set for Express:
var airbrake = ;app
This has been verified with Express 2.X
This screenshot shows an airbrake error send from this module:
process.envas well as other information when sending notifications
notify() method automatically adds the following context information to
each delivered error:
err.typestring if set, or
err.stackas parsed by stack-trace)
err.componentstring if set);
err.actionstring if set);
process.env, merged all other properties of
err.paramsobject if set)
err.sessionobject if set)
airbrake.projectRootstring if set)
airbrake.hostnamestring if set)
You can add additional context information by modifying the error properties listed above:
var airbrake = ;var http = ;http;
uncaughtException events cannot be traced back to particular
requests, so you should still try to handle errors where they occur.
In some scenarios you might want to filter some context to never show up in Airbrake. For example you might have a private key loaded in your environment memory, or your user has some critical data in his session, and you want to hide that.
This can be done by hooking into the
'vars' event like so:
This client supports airbrake's deployment tracking:
var airbrake = ;var deployment =rev: '98103a8fa850d5eaf3666e419d8a0a93e535b1b2'repo: 'email@example.com:felixge/node-airbrake.git';airbrake;
Check out the
airbrake.trackDeployment() API docs below for a list of all
Returns a new Airbrake instance.
The API key to use.
The name of the server environment this is running in.
The base url for errors. If
err.url is not set,
airbrake.host is used
err.url is a relative url starting with
'/', it is appended
err.url is an absolute url,
airbrake.host is ignored.
The root directory of this project.
The version of this app. Set to a semantic version number, or leave unset.
The protocol to use.
Do not post to Airbrake when running in these environments.
The timeout after which to give up trying to notify airbrake in ms.
process.on('uncaughtException') listener. When an uncaught
exception occurs, the error is send to airbrake, and then re-thrown to
kill the process.
Sends the given
err to airbrake.
The callback parameter receives two arguments,
err is set if
the delivery to airbrake failed.
cb is given, and the delivery fails, an
error event is emitted. If
there is no listener for this event, node will kill the process as well. This
is done to avoid silent error delivery failure.
Notifies airbrake about a deployment.
params is an object with the following
env:The environment being deployed, defaults to
user:The user doing the deployment, defaults to
repo:The github url of this repository. Defaults to
rev:The revision of this deployment. Defaults to
Besides bug fixes, I'd be happy to accept patches for:
revfrom the local git repository when calling
airbrake.trackDeployment(). This can be done via
exec(), but must not be done when specifying
revby hand, or if they are set to
If you have other feature ideas, please open an issue first, so we can discuss it.
airbrake is licensed under the MIT license.