0.5.0 • Published 10 years ago

node-honeybadger v0.5.0

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

node-honeybadger

Build Status

node-honeybadger is a node.js module for sending errors and related metadata to honeybadger.io.

It is small, lightweight, and uses the stack-trace module to give honeybadger the stack trace format it expects, allowing node.js stack traces to show up properly in the honeybadger UI.

Usage is simple:

var Badger = require('node-honeybadger');

var hb = new Badger({
  apiKey: 'your api key goes here',
  server: { hostname: 'steve', otherMetadata: 'goes here' },
  // Any object with info, warn, and error methods can be used as the logger.
  // If nothing is provided, nothing will be logged.
  logger: console
});

var err = new Error('FLAGRANT ERROR!');

err.name = 'FlagrantError'

// The second argument is error tracking metadata, like user/session id
hb.send(err, {
  context: {
    user: 'jane',
    email: 'a@b.net'
  },
  session: {},
  cookies: {},
  params: {},
  cgi_data: req.headers
});

The cgi_data metadata field is important - this is what populates the "Environment" section of the Honeybadger error UI. It usually contains HTTP headers and other server info, in the Ruby frameworks that Honeybadger mainly supports - since there is no sensible default in node for this, populating this field effectively is left as an exercise to the user.

Instances of node-honeybadger can also emit the following events:

  • sent: This is emitted when honeybadger.io returns a 201 successfully. The response body, containing metadata about the submitted error, is emitted as data.
  • error: Emitted in the case of local node errors while trying to connect to honeybadger.io. Will not be emitted unless a listener is present.
  • remoteError: Emitted when a non-201 status code is returned by honeybadger.io. Emits the response body, if one is present.

Prior to version 0.4.0, node-honeybadger was a Writable Stream. This interface has been removed, since it was only wishful thinking in the first place, and did not make a lot of sense in practice.

0.5.0

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago