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)
Section titled “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:
npm uninstall honeybadger-jsnpm install @honeybadger-io/jsNext, replace any require/import statements that reference “honeybadger-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. UseapiKey,projectRootinstead. - Stack traces are now parsed client-side;
notice.stackis now read-only inbeforeNotifyhandlers, and a newnotice.backtraceobject has been added. - The
max_depthconfig option is nowmaxObjectDepth - The
hostandportconfig options are nowendpoint onerroris nowenableUncaught- The
onunhandledrejectionconfig option is nowenableUnhandledRejection - The
ignorePatternsconfig option has been removed. Use abeforeNotifyhandler instead:const ignorePatterns = [/NoisyError/i, /unwanted error message/i];Honeybadger.beforeNotify(function (notice) {if (ignorePatterns.some((p) => p.test(notice.message))) {return false;}}); Honeybadger.wraphas been removed. If you used this functionality, you can recreate it like so: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
Section titled “CDN users”If you use the CDN instead of the NPM package, replace your current script tag with the v3.0 script tag:
<script src="//js.honeybadger.io/v3.0/honeybadger.min.js" type="text/javascript"></script>Upgrading from honeybadger 1.x (Node.js)
Section titled “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:
npm uninstall honeybadgernpm install @honeybadger-io/jsNext, replace any require statements that reference “honeybadger-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:
- Environment variables are no longer configured by default; you must explicitly
call
Honeybadger.configure, i.e.:Honeybadger.configure({apiKey: process.env.HONEYBADGER_API_KEY,environment: process.env.HONEYBADGER_ENVIRONMENT,}); Honeybadger.loggeris now theloggerconfig option.Honeybadger.onUncaughtExceptionis now theafterUncaughtconfig option.- Events are no
longer emitted. Use
beforeNotifyandafterNotifyhandlers instead.
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.