Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@airbrake/node

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@airbrake/node

Notify Airbrake on JavaScript exceptions

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-2.69%
Maintainers
2
Weekly downloads
 
Created
Source

Airbrake for Node.js

Build Status

This is the JavaScript notifier for capturing errors in Node.js and reporting them to Airbrake. For web browsers there is a separate package.

Installation

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:

Basic Usage

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

Node.js request and proxy

In order to configure request HTTP client you can pass request option which accepts request wrapper:

const airbrake = new Airbrake.Notifier({
  ...
  request: request.defaults({'proxy':'http://localproxy.com'})
});

Contributing

Install dependencies:

yarn install

Run unit tests:

yarn test

Build project:

yarn build

Credits

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.

License

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.

Keywords

FAQs

Package last updated on 28 Oct 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc