-
Notifications
You must be signed in to change notification settings - Fork 15
Upgrade to version 3.x
The Opbeat Node.js agent version 3.0.0 have been released and includes a few breaking changes. This document is a guide on how to upgrade your code if you've been using v1.x or v2.x. If upgrading from versions older than v1.x, please follow the pre-1.0 upgrade guide first.
It's now easier than ever to require the Opbeat agent all over your code-base while only initialising it once in your main app file.
Previously the module would return an init function that when called would return the actual agent. Now a singleton agent is returned when requiring the opbeat module. You instead configure it using the new start
function:
var opbeat = require('opbeat')
opbeat.start({
appId: '...',
organizationId: '...',
secretToken: '...'
})
// now you are ready to capature an custom error like before:
opbeat.captureError(new Error('boom!'))
The start
function is chainable and returns the agent as well, so the above example is equivalent to:
var opbeat = require('opbeat').start({...})
opbeat.captureError(new Error('boom!'))
If you require the opbeat module again in another file, the same agent that you just configured will be returned. So you should not call the start
function more than once - in fact, the agent will throw an error to warn you if you do.
The config option agentLogLevel
have been renamed to logLevel
.
The deprecated trackDeployment
function have now been removed. If you use this, you should now use trackRelease
.