Skip to content

Capturing events with breadcrumbs

Breadcrumbs are events that happen right before an error occurs. Honeybadger captures many types of breadcrumbs automatically, such as click events, console logs, and Ajax requests. You can enhance your ability to rapidly understand and fix your errors by capturing additional breadcrumbs throughout your application.

To capture a breadcrumb anywhere in your application:

Honeybadger.addBreadcrumb("Sent Email", {
metadata: { user_id: user.id, body: body },
});

The first argument (message) is the only required data. In the UI, message is front and center in your breadcrumbs list, so we prefer a more terse description accompanied by rich metadata.

Here are the supported options when adding breadcrumbs:

Option nameDescription
metadataA (optional) Object that contains any contextual data to help debugging. Must be a single-level object with simple primitives (strings, numbers, booleans) as values.
categoryAn (optional) string key used to group specific types of events. We primarily use this key to display a corresponding icon, however, you can use it for your own categorization if you like.

A Breadcrumb category is a top level property. It’s main purpose is to allow for display differences (icons & styling) in the UI. You may give a breadcrumb any category you wish. Unknown categories will default to the “custom” styling.

Here are the current categories and a brief description of how you might categorize certain activity:

CategoryDescription
customAny other kind of breadcrumb
errorA thrown error
queryAccess or Updates to any data or file store
jobQueueing or Working via a job system
requestOutbound / inbound requests
renderAny output or serialization via templates
logAny messages logged
noticeA Honeybadger Notice

Honeybadger captures the following breadcrumbs automatically by instrumenting browser features:

  • Clicks
  • Console logs
  • Errors
  • History/location changes
  • Network requests (XHR and fetch)

Breadcrumbs are enabled by default. To disable breadcrumbs in your project:

Honeybadger.configure({
// ...
breadcrumbsEnabled: false,
});

You can also enable/disable specific types of breadcrumbs:

Honeybadger.configure({
breadcrumbsEnabled: {
dom: true,
network: true,
navigation: true,
console: true,
},
});

Note: This configuration applies only on the first call to Honeybadger.configure.