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

If you’d like to add diagnostic data to every error report, or adjust error reports conditionally, you can add callbacks which will be invoked each time a report will be sent:

Bugsnag.before_notify_callbacks << lambda {|notification|
  # Add customer information to every report
  notification.add_tab(:account, {
    paying_customer: current_user.organization.paying?

  # Add user information to every report
  notification.user = {

# Your app code here

See the notification object for methods available inside the callback.

The notification object


Call add_tab on a notification object to add a tab to the error report so that it would appear on your dashboard.

notification.add_tab(:user_info, { name: })

The first parameter is the tab name that will appear in the error report and the second is the key, value list that will be displayed in the tab.


Set the project API key for the error report. The API key is normally set in the configuration, but it can be overridden to report to a different API key in some situations.

notification.api_key = 'your-api-key-here'


Set the context of the error report. This is notionally the location of the error and should be populated automatically. Context is displayed in the dashboard prominently.

notification.context = 'billing'


Allows you to read the exceptions that will be combined into the report.

puts notification.exceptions.first.message + ' found!'


Sets the grouping hash of the error report. All errors with the same grouping hash are grouped together. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.

notification.grouping_hash = exception.message + exception.class.to_s


Calling ignore! on a notification object will cause the notification to not be sent to Bugsnag. This means that you can choose dynamically not to send an error depending on application state or the error itself.

notification.ignore! if foo == 'bar'


Provides access to the meta_data in the error report.

notification.ignore! if notification.meta_data[:sidekiq][:retry_count] < 2


Removes a tab completely from the error report



Set the severity of the error. Severity can be error, warning or info.

notification.severity = 'error'


You can set or read the user with the user property of the notification.

notification.user = {