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:
npm uninstall honeybadger-js
npm install @honeybadger-io/js
Next, 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
,projectRoot
instead. - Stack traces are now parsed client-side;
notice.stack
is now read-only inbeforeNotify
handlers, and a newnotice.backtrace
object has been added. - The
max_depth
config option is nowmaxObjectDepth
- The
host
andport
config options are nowendpoint
-
onerror
is nowenableUncaught
- The
onunhandledrejection
config option is nowenableUnhandledRejection
- The
ignorePatterns
config option has been removed. Use abeforeNotify
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:
<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:
npm uninstall honeybadger
npm install @honeybadger-io/js
Next, 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.:js Honeybadger.configure({ apiKey: process.env.HONEYBADGER_API_KEY, environment: process.env.HONEYBADGER_ENVIRONMENT })
-
Honeybadger.logger
is now thelogger
config option. -
Honeybadger.onUncaughtException
is now theafterUncaught
config option. -
Events are no
longer emitted. Use
beforeNotify
andafterNotify
handlers 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.