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(function (notification, originalError) {

    var metaData =[0].metaData;

    // modify metadata = {version: '0.3'}

    // Don't log error reports from admins or missing records
    if (metaData.user.is_admin || == "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};