Opbeat is joining forces with Elastic – Learn more about Elastic APM

JavaScript agent API

To get started, take a look at our framework specific documentation for either AngularJS or custom stacks.


_opbeat('config', options);

Configure the Opbeat agent.

The available configuration options are listed below. Any configuration option can be set either in the options object or by using hyphen-separated attributes on the opbeat.js script tag.

The only required parameters are appId and orgId.

Example usage configuring appId and orgId:

_opbeat('config', {
    orgId: '<ORGANIZATION-ID>',
    appId: '<APP-ID>'


  • Type: String

Your Opbeat app id. Required unless set via the data-app-id attribute.


  • Type: String

Your Opbeat orgainization id. Required unless set via the data-org-id attribute.


  • Type: Boolean
  • Default: false

Enables logging of debug information to the console. This makes it easier for Opbeat support to troubleshoot issues.


Send an error to Opbeat:

try {
    return multiply(add(a, b), a, b) / c
} catch (error) {
    _opbeat('captureException', error)

The error argument must be an Error object.


To ease debugging it’s possible to send data about the user with each error or transaction you send to Opbeat.

Here is an example:

// Sending some extra details about the user
_opbeat('setUserContext', {
    username: "{{ user_name }}",
    email: "{{ user_email }}",
    id: "{{ user_id }}"

The following fields are allowed:

  • id
  • username
  • email


You can also send extra data with errors or transactions:

// Sending some abitrary extra details using the `extra` field
_opbeat('setExtraContext', {
    user_type: "{{ user.type }}",
    org_name: "{{ organization.name }}",
    org_plan: "{{ organization.billing.plan }}"

AngularJS specific


  • Type: Object
performance: {
    enable: true,
    enableStackFrames: false


  • Type: Boolean
  • Default: true

Option to enable or disable performance monitoring.


  • Type: Boolean
  • Default: false

Option to enable or disable gathering stack traces for performance monitoring.


  • Type: String
  • Default: '(node_modules|bower_components|webpack)'

Set this to paths that should be identified as libraries in stack traces. Libraries are grouped in Opbeat.