Customizing error reports

The OnBeforeNotify configuration option allows for modifying reported information by editing fields on bugsnag.Event.

Modifying report information

Any value on an event can be overridden prior to delivery:

    func(event *bugsnag.Event, config *bugsnag.Configuration) error {

    // Change the context of an event
    event.Context = "GET /api/cart@handler"
    return nil

Or removed altogether:

    func(event *bugsnag.Event, config *bugsnag.Configuration) error {

    // Remove a potentially sensitive parameter from the raw payload data
    delete(event.MetaData["params"], "credit_card_param")
    return nil

Skipping lines in a stacktrace

If you have your own logging wrapper all of your errors will appear to originate from inside it. You can avoid this problem by constructing an error with a stacktrace manually, and then passing that to Bugsnag.notify:

import (

func LogError(e error) {
    // 1 removes one line of stacktrace, so the caller of LogError
    // will be at the top.
    e = errors.New(e, 1)

The bugsnag.Event object


A short description of the error location, such as the URL path or top filename from the stack trace.


The original error which caused the event.


The name or title of the report sent to Bugsnag


A hint for how a report should be grouped with other events in a project. All reports with the same grouping hash will be grouped together.


The description or summary of the report sent to Bugsnag


Additional information appended to the report, organized as key/value pairs in named sections.


The raw information available about the event. This structure is not appended to the report directly but is available to cache request information or additional context.


An array of stack frames leading to the original error.


Information about the user who encountered the event