Upgrading to @honeybadger-io/js v3.0

The new @honeybadger-io/js package is a universal/isomorphic JavaScript package combining the deprecated honeybadger-js for browsers and the honeybadger for Node.js NPM packages.

Moving forward, development for both platforms will happen on @honeybadger-io/js (source code on GitHub).

The new API is mostly the same as the old packages, with a few small changes.

Upgrading from honeybadger-js v2.x (Client-side)

If you currently use the honeybadger-js package, this section is for you.

The changes between honeybadger-js and @honeybadger-io/js are minimal. First, replace the old package with the new one:

sh
npm uninstall honeybadger-js npm install @honeybadger-io/js

Next, replace any require/import statements that reference "honeybadger-js":

js
const Honeybadger = require('@honeybadger-io/js'); // Or: // import Honeybadger from '@honeybadger-io/js'; Honeybadger.configure({ apiKey: 'project api key', environment: 'production', revision: 'git SHA/project version' });

Finally, review this list of changes:

  • Previously deprecated snake case config options such as api_key, project_root, etc. are no longer supported. Use apiKey, projectRoot instead.
  • Stack traces are now parsed client-side; notice.stack is now read-only in beforeNotify handlers, and a new notice.backtrace object has been added.
  • The max_depth config option is now maxObjectDepth
  • The host and port config options are now endpoint
  • onerror is now enableUncaught
  • The onunhandledrejection config option is now enableUnhandledRejection
  • The ignorePatterns config option has been removed. Use a beforeNotify handler instead: js const ignorePatterns = [/NoisyError/i, /unwanted error message/i] Honeybadger.beforeNotify(function(notice) { if (ignorePatterns.some((p) => p.test(notice.message))) { return false; } });
  • Honeybadger.wrap has been removed. If you used this functionality, you can recreate it like so: js Honeybadger.wrap = function(func) { try { func.apply(this, arguments); } catch(error) { Honeybadger.notify(error); throw(error); } };

See configuration for an up-to-date list of available config options. Feel free to email support if you run into issues not mentioned here.

CDN users

If you use the CDN instead of the NPM package, replace your current script tag with the v3.0 script tag:

html
<script src="//js.honeybadger.io/v3.0/honeybadger.min.js" type="text/javascript"></script>

Upgrading from honeybadger 1.x (Node.js)

If you currently use the honeybadger package, this section is for you.

First, replace the old package with the new one:

sh
npm uninstall honeybadger npm install @honeybadger-io/js

Next, replace any require statements that reference "honeybadger-js":

js
const Honeybadger = require('@honeybadger-io/js'); Honeybadger.configure({ apiKey: 'project api key', environment: 'production', revision: 'git SHA/project version' });

Finally, review this list of changes:

See configuration for an up-to-date list of available config options. Feel free to email support if you run into issues not mentioned here.