Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@airbrake/node
Advanced tools
This is the JavaScript notifier for capturing errors in Node.js and reporting them to Airbrake. For web browsers there is a separate package.
airbrake can be installed using yarn:
yarn add @airbrake/node
or using npm:
npm install @airbrake/node
Example configurations can be found in examples, including:
First you need to initialize the notifier with the project id and API key taken from Airbrake.io:
import { Notifier } from '@airbrake/browser';
const airbrake = new Notifier({
projectId: 1,
projectKey: 'REPLACE_ME',
environment: 'production',
});
Then you can send a textual message to Airbrake:
let promise = airbrake.notify(`user id=${user_id} not found`);
promise.then(function(notice) {
if (notice.id) {
console.log('notice id', notice.id);
} else {
console.log('notify failed', notice.error);
}
});
Or report catched errors directly:
try {
// This will throw if the document has no head tag
document.head.insertBefore(document.createElement('style'));
} catch(err) {
airbrake.notify(err);
throw err;
}
Alternatively, you can wrap any code which may throw errors using the client's wrap
method:
let startApp = function() {
// This will throw if the document has no head tag.
document.head.insertBefore(document.createElement('style'));
}
startApp = airbrake.wrap(startApp);
// Any exceptions thrown in startApp will be reported to Airbrake.
startApp();
or use call
shortcut:
let startApp = function() {
// This will throw if the document has no head tag.
document.head.insertBefore(document.createElement('style'));
}
airbrake.call(startApp);
In order to use request HTTP client you can pass request
option which accepts request wrapper:
const airbrake = new Notifier({
...
request: request.defaults({'proxy':'http://localproxy.com'})
});
Install dependencies:
yarn install
Run unit tests:
yarn test
Build project:
yarn build
Airbrake is maintained and funded by airbrake.io
Thank you to all the contributors.
The names and logos for Airbrake are trademarks of Airbrake Technologies Inc.
Airbrake is Copyright © 2008-2017 Airbrake Technologies Inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
FAQs
Official Airbrake notifier for Node.js
The npm package @airbrake/node receives a total of 13,052 weekly downloads. As such, @airbrake/node popularity was classified as popular.
We found that @airbrake/node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.