You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

backtrace-js

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backtrace-js

Backtrace.io error reporting tool for client-side applications

0.0.7
npm
Version published
Weekly downloads
12
-29.41%
Maintainers
7
Weekly downloads
 
Created
Source

backtrace-js

Backtrace error reporting tool for client-side JavaScript.

Usage

// Import backtrace-js with your favorite package manager.
import * as bt from 'backtrace-js';

bt.initialize({
  endpoint: `https://console.backtrace.io:${BACKTRACE_PORT}`,
  token: '51cc8e69c5b62fa8c72dc963e730f1e8eacbd243aeafc35d08d05ded9a024121',
});

// Later, when you have an error:
bt.report(new Error('something broke'));

Documentation

See backtrace-node's documentation.

bt.initialize([options])

This is intended to be one of the first things your application does during initialization. It registers a handler for uncaughtException which will spawn a detached child process to perform the error report and then crash in the same way that your application would have crashed without the handler.

Options

See backtrace-node's documentation for the complete options list.

In addition to all backtrace-node's options, Backtrace-JS includes sampling and filter.

sampling

Optional. Sets a percentage of reports which should be sent. For example, sampling: 0.25 would send 25/100 reports.

filter

Optional. Set a pre-send function which allows custom filtering of reports. This function accepts the backtrace report object and should return true if the report SHOULD be sent or return false if the report should NOT be sent.

Example:

filter: function(report) {
  if (report.attributes["error.message"] == "Script Error.") {
    return  Math.random() >= 0.5;  // Sample half of this kind of report
  }
  return true;  // Otherwise, always send the report
}

Testing

npm install
./node_modules/.bin/browserify test/app.js --outfile test/out.js
node test/server.js

Making a release

  • Update package.json with version number
  • Update var myVersion = "x.y.z"; to match package.json
  • Create a git tag
  • npm publish

FAQs

Package last updated on 12 Jun 2018

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