Skip to content

Latest commit

 

History

History
73 lines (51 loc) · 1.73 KB

README.md

File metadata and controls

73 lines (51 loc) · 1.73 KB

bugnet

Capture Javascript errors. Minimal version of rollbar, bugsnag, etc.

build status coverage license version downloads

Usage

Simply pass the function you wish to use for being notified of errors. As soon as you include bugnet in your application errors will start to be captured and buffered until they're ready to be consumed later. It is recommended you include bugnet as soon as possible in your application.

Importantly bugnet will NOT squelch your application errors (i.e. not a silent catch-all) - it simply monitors them.

npm install --save bugnet
import capture from 'bugnet';

capture((error) => {
	// ...
});

Examples

Browser

Send browser errors to an off-site logger:

import capture from 'bugnet';

// Add event handler.
capture((error) => {
	const request = new XMLHttpRequest();
	request.open('http://errors.myapp.com/', 'POST', true);
	request.send(JSON.stringify(event));
});

Node

Send node.js errors to the console:

// example.js
import capture from 'bugnet';

// Add event handler.
capture((error) => {
	console.log('Got error', error);
});

To start capturing errors at the earliest possible point, load bugnet from node itself.

#!/bin/sh
node -r bugnet ./example.js

TODO:

  • Testing
  • Fix incompatibilities using Object.* methods