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.

bugsnag.onBeforeNotify(function (notification) {

    var metaData = notification.events[0].metaData;

    // modify meta-data
    metaData.app = {version: '0.3'}

    // Don't log error reports from admins
    if (metaData.user.is_admin) {
        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};