Customizing error reports


Adding a callback


You can configure a beforeSend callback for all reports, and you can supply a beforeSend callback to manual notify() calls.


Modifying report information


var bugsnagClient = bugsnag({
  beforeSend: function (report) {
    // Filter out sensitive information
    report.request.url = '[REDACTED]'

    // Add additional diagnostic information
    report.updateMetaData('account', {
      type: 'paid',
      betaAccess: true

Disabling error reporting


var bugsnagClient = bugsnag({
  beforeSend: function (report) {
    // or

Or you can supply a beforeSend callback for an individual bugsnagClient.notify() call:

bugsnagClient.notify(new Error('Bad things'), {
  beforeSend: function (report) {
    // or

If you’re using an asynchronous callback, to prevent a report from being sent you can either use report.ignore() or asynchronously “return false” with resolve(false)/cb(null, false) depending on the style of function used.

Preventing IP address collection



To prevent IP collection but set user IDs:

var bugsnagClient = bugsnag({
  collectUserIp: false,
  beforeSend: function (report) {
    var userId = getMyUserIdentifier() // a custom user resolver
    report.user = { id: userId }


var bugsnagClient = bugsnag({
  collectUserIp: false,
  user: { id: '1234' }


The report object


metaData set on the report will be combinded with metaData set on the client, with properties on the report taking precedence.

// original metaData
var bugsnagClient = bugsnag({
  apiKey: 'YOUR_API_KEY_HERE',

bugsnagClient.notify(err, {
  beforeSend: function (report) {
    // this metaData will override the original metaData
    report.metaData = {
      overrideTab: { overrideItem: '9.8.7' }


Set or modify the release stage: = 'staging'


Set or modify the app version: = '4.1.1'



report.apiKey = 'YOUR-API-KEY'

Modify the breadcrumbs array:

// filter out breadcrumbs that match a certain name
report.breadcrumbs = report.breadcrumbs.filter(function (breadcrumb) {
  return !== "UI click"



report.context = 'User settings screen'






report.errorClass = 'MyError'


report.errorMessage = 'I have made a huge mistake'


Set the grouping hash of the error report to override the default grouping on the dashboard. All errors with the same grouping hash will be grouped together into one error. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.

report.groupingHash = report.errorClass

By default, errors are grouped by the statement in your code that raised the error. We try to lookup a source map or fetch the JavaScript and use the surrounding code to identify the statement, but if that’s not possible we fall back to using line number and filename as an approximation.


Prevents the report being sent to Bugsnag:

var bugsnagClient = bugsnag({
  beforeSend: function (report) {
    // Example: Disable reporting from internal routes


report.metaData = {
  company: {
    name: 'Acme Co.',
    country: 'UK'


Use this to remove a metaData field or entire metaData tab:

// Remove a metaData field
report.removeMetaData('section', 'property')
// Remove a metaData tab



report.request.url = '[REDACTED]'
report.request.clientIp = '[REDACTED]'



report.severity = 'warning'


An array containing stackframe objects with the following properties:

property type description
file String The location of the executing file. This can be a file path, URL or a value such as 'global code'. If the executing file is an inline script on a web page, this will be the URL of the page it was loaded on.
inProject Boolean In Node, stack frames from outside the project root or inside node_modules will be marked as inProject: false. In the browser and in Expo, this is always set to undefined by default. You can update this property to indicate when stackframes are known to be outside of your project in order to improve grouping and stacktrace readability. See the example below.
code Object When possible (in Node or an inline script in the browser), the notifier will extract the surrounding code and populate this property.
// Sets the `inProject` property to `false` for anything with "vendor" in the path
report.stacktrace.forEach(function (frame) {
  var inProject = !/\/vendor\//.test(frame.file)
  // If you set one stackframe.inProject you should set them all
  frame.inProject = inProject




report.updateMetaData('section', 'property', value)
report.updateMetaData('section', 'property', null)
// Removes `metaData.section` if it exists
report.updateMetaData('section', null)


Modify the information in the user tab:

report.user = {
  id: '3',
  name: 'Bugs Nag',
  email: '',
  roles: [ 'subscriber' ]