---
title: Customizing error reports
description: Customize JavaScript error reports with additional context, filters, and callbacks before sending them to Honeybadger.
url: https://docs.honeybadger.io/lib/javascript/errors/customizing-error-reports/
---

Honeybadger has several ways to customize the data reported with each error to add custom metadata, request information, and more.

## Adding context

Honeybadger can display additional custom key/value metadata — or “context” — with each error report. Context data can be anything, but a few keys have a special meaning in Honeybadger.

Use `Honeybadger.setContext` to add context to error reports. You can call `setContext` as many times as you like, and it will be reset on each page load. New context data is merged with existing data:

```javascript
// On load
Honeybadger.setContext({
  user_id: 123,
});


// Later
Honeybadger.setContext({
  backbone_view: "tracks",
});


// The context now contains { user_id: 123, backbone_view: 'tracks' }
```

If you’ve used `Honeybadger.setContext` to store context data, you can clear it with `Honeybadger.clear()`:

```javascript
// Set the context to {}
Honeybadger.clear();
```

While you can add any key/value data to context, a few keys have special meaning in Honeybadger:

| Option       | Description                                                                                              |
| ------------ | -------------------------------------------------------------------------------------------------------- |
| `user_id`    | The `String` user ID used by Honeybadger to aggregate user data across occurrences on the error page.    |
| `user_email` | Same as `user_id`, but for email addresses                                                               |
| `tags`       | A `String` comma-separated list of tags. When present, tags will be applied to errors with this context. |

## Capturing 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. To learn more about breadcrumbs, check out [Capturing Events with Breadcrumbs](https://docs.honeybadger.io/lib/javascript/errors/breadcrumbs/).

To use Breadcrumbs, you must first enable them in your `honeybadger.js` config:

```js
Honeybadger.configure({
  // ...
  breadcrumbsEnabled: true,
});
```

To capture a breadcrumb anywhere in your application:

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

See [the guide](https://docs.honeybadger.io/lib/javascript/errors/breadcrumbs/) for additional options and a list of breadcrumbs that are automatically captured.

## Modifying data

If you need full control over the data that is reported, you can inspect and modify all the data on the notice using a `Honeybadger.beforeNotify` handler:

```javascript
Honeybadger.beforeNotify(function (notice) {
  notice.params = myParams;
});
```

The following notice properties are available in `notice` objects:

* `notice.stack` - The stack trace (read only)
* `notice.backtrace` - The parsed backtrace object
* `notice.name` - The exception class name
* `notice.message` - The error message
* `notice.url` - The current url
* `notice.projectRoot` - The root url
* `notice.environment` - Name of the environment. example: “production”
* `notice.component` - Similar to a rails controller name. example: “users”
* `notice.action` - Similar to a rails action name. example: “create”
* `notice.fingerprint` - A unique fingerprint, used to customize grouping of errors in Honeybadger
* `notice.context` - The context object
* `notice.tags` - A string comma-separated list of tags
* `notice.params` - An object of request parameters
* `notice.session` - An object of request session key/values
* `notice.headers` - An object of request headers
* `notice.cookies` - An object of cookie key/values. May also be sent as a string in the document.cookie “foo=bar;bar=baz” format.

The following additional notice properties are available in `afterNotify` handlers:

* `notice.id` - The UUID of the error in Honeybadger

## Sending cookies

To automatically send cookies with all error reports, use the following `beforeNotify` handler:

```javascript
Honeybadger.beforeNotify(function (notice) {
  notice.cookies = document.cookie;
});
```

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
