Customizing error reports

In order to quickly reproduce and fix errors, it is often helpful to send additional application-specific diagnostic data to Bugsnag.

Adding callbacks

An error notification can be modified to add or remove fields, or cancelled altogether by returning false, using the onBeforeNotify function. The original error object is also passed to the callback in case it provides additional context for modifying or cancelling the report.

bugsnag.onBeforeNotify((notification) ->

    metaData = notification.events[0].metaData

    # modify metadata
    metaData.app = {version: '0.3'}

    # Don't log error reports from admins
    if metaData.user.is_admin || originalError.name == "MissingRecordError"
        return false
)

You can add multiple onBeforeNotify callbacks, they’ll be called in the order you add them.

Per-request metaData

If you are using our express middleware, or otherwise using domains, you can set per-request metaData using the requestData property. This metaData will be sent with any crashes occurring during the current request.

bugsnag.requestData.user = {id: 5}