-
Notifications
You must be signed in to change notification settings - Fork 15
Upgrade to version 1.0
The Opbeat Node.js client version 1.0 have been is soon to be released and includes a lot of breaking changes. This document is a guide on how to upgrade your code if you've been using a previous version.
The createClient()
have been removed and replaced with a primary initialisation function. Previously you'd setup the Opbeat like so:
// old
var opbeat = require('opbeat');
var client = opbeat.createClient(options);
Now the Opbeat module just exposes the createClient()
function directly, so you should update your code to the following:
// new
var opbeat = require('opbeat');
var client = opbeat(options);
Or you could do this as a one-liner, which you'll also see used in our documentation from now on:
// new
var opbeat = require('opbeat')(options);
Alternatively you can completely drop parsing in an options
object and instead configure the client using environment variables, which is now supported for all options.
The following options have been renamed or changed:
Old name | New name |
---|---|
app_id |
appId |
organization_id |
organizationId |
secret_token |
secretToken |
env |
removed, see active |
logger |
removed |
handleExceptions |
captureExceptions |
silent |
removed, see clientLogLevel |
exceptionsAreCritical |
removed, see exceptionLogLevel |
To access the already initialised client, you'd previously access the opbeat.client
property. This was considered too magic so from now on this should now be handled in user-land.
At Opbeat we like to create an opbeat.js file somewhere in our project, initialize Opbeat in there and export it:
// opbeat.js
module.exports = require('opbeat')({
appId: '...',
organizationId: '...',
secretToken: '...'
});
The two functions captureRequestError
and captureMessage
have been removed. Their functionality have been merged into captureError
which now support all use cases. This also means that you can log request information along with a "message", which wasn't possible before.
Previously you'd log HTTP request info like so:
// old
opbeat.captureRequestError(err, req);
Now you just parse in the HTTP request object as an option to the 2nd argument of captureError()
:
// new
opbeat.captureError(err, { request: req });
The captureError()
function now also takes a regular string as the error argument. This removes the need for a separate captureMessage()
function:
// new
opbeat.captureError("Something is wrong");
Just as with the old captureMessage()
function you can use it for parameterized messages as well:
// new
opbeat.captureError({
message: 'Timeout exeeded by %d seconds',
params: [seconds]
});
The connectionError
event is now just called error
.
The opbeat.version
property have been removed. If you need access to this information, load the package.json
file or open an issue.