---
title: Error reporting
description: Catch browser and server errors, grouped into issues, with the people each one reached and what they did just before.
order: 10
---
# Error reporting

Erised catches errors from your product and groups them into **issues**. Each issue shows how many **people** it reached, which ones (linked to their profiles), and what each person did in the minutes before it happened: their timeline is the breadcrumb trail. Errors count toward your plan's events like any other event.

## In the browser

Add `errors: true` to the `init` call, with the build you are running:

```html
<script>
  window.cdp = window.cdp || [];
  window.cdp.push(['init', 'pk_live_YOUR_PUBLISHABLE_KEY', {
    errors: true,                 // uncaught errors and unhandled rejections
    release: 'web@1.4.2',         // your build, e.g. a git SHA
    environment: 'production',
  }]);
</script>
<script async src="https://app.erised.run/sdk/v0.js"></script>
```

Report an error you caught yourself, with optional `level` (`fatal`, `error`, `warning`), `tags` and `fingerprint`:

```js
try {
  await submitOrder(cart);
} catch (error) {
  cdp('captureError', error, { level: 'error', tags: { feature: 'checkout' } });
  throw error;
}
```

`captureError` works without `errors: true`. The snippet sends the same error at most once every 10 seconds and at most 25 errors per page view, skips opaque cross-origin `Script error.` events, and with cookie consent on, sends nothing before the visitor agrees.

## On the server

There is no package to install: a short helper posts to `POST /v1/error` with the secret key.

```js
// report-error.js (server only). Node 18+.
export async function reportError(error, { userId, anonymousId, path, userAgent } = {}) {
  try {
    await fetch('https://app.erised.run/v1/error', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.ERISED_SECRET_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        name: error?.name ?? 'Error',
        ...(userId ? { userId: String(userId) } : {}),
        ...(anonymousId ? { anonymousId } : {}),
        properties: {
          message: String(error?.message ?? error),
          stack: error?.stack,
          release: process.env.RELEASE,
          environment: process.env.NODE_ENV,
        },
        context: { page: path ? { path } : undefined, userAgent },
      }),
      signal: AbortSignal.timeout(3000),
    });
  } catch {
    // Reporting must never fail the request.
  }
}

process.on('unhandledRejection', (reason) => reportError(reason));
```

Send the request's method, path and user agent at most: **never** request bodies, cookies or auth headers. Pass the signed-in user's id, and the `erised_anonymous_id` cookie when you have it, so the error joins the person.

### Next.js (App Router)

```ts
// instrumentation.ts
import { reportError } from './lib/report-error';

export async function onRequestError(error: unknown, request: { path: string; headers: Record<string, string> }) {
  await reportError(error, { path: request.path, userAgent: request.headers['user-agent'] });
}
```

### Express

```js
import { reportError } from './report-error.js';

// After your routes: the error middleware.
app.use(async (err, req, res, next) => {
  await reportError(err, { userId: req.user?.id, path: req.path, userAgent: req.get('user-agent') });
  next(err);
});
```

### Apps

Apps report through your backend, like their events: the app sends the error to your API, which forwards it to `POST /v1/error` or in a `POST /v1/batch` with `type: "error"`. [Errors from apps](apps.md#errors-from-apps) has the payload, release names for app builds, and grouping in React Native release builds.

## The error event

| Field | Notes |
| --- | --- |
| `name` | The error's type, e.g. `TypeError`. Default `Error`. |
| `properties.message` | Required unless `stack` is set. Kept up to 1 KB. |
| `properties.stack` | The raw stack. Kept up to 16 KB. Erised parses it on its side (Chrome, Node, Firefox, Safari, React Native's Hermes). |
| `properties.level` | `fatal`, `error` (default) or `warning` |
| `properties.handled` | `false` for an uncaught error |
| `properties.release`, `properties.environment` | Strings. `release` drives "resolve as of release". |
| `properties.tags` | Flat strings, at most 20 keys |
| `properties.fingerprint` | Your own grouping key; errors with the same one form one issue |

An error without a message or a stack is refused (`missing_error`), as is a field of the wrong type (`invalid_error_field`).

## What is removed before storage

Before an error is stored, Erised removes email addresses, Erised keys, bearer and basic credentials, JWTs, card numbers, and the values of names like `password`, `token`, `secret`, `key`, `session` or `code`, from the message, the stack, the tags and the page URL. Add your own names (for example `ssn` or `iban`) in **Settings → Errors**, where you can also turn on **Location data** (latitude, longitude pairs and H3 cell ids) and hide environments such as `development` from the Errors list. Erised does not take patterns of your own: mask anything else before you send it.

## Issues

- Errors with the same type and the same top three frames of your own code form one issue, across builds and deploys; line numbers and build hashes are ignored. Without your own frames, or when they are all one React Native bundle with minified names, the normalised message decides.
- **Resolve as of a release**: errors from that release are expected until people update; the same error from another release reopens the issue as a **regression**. Resolved without a release, it reopens if it happens more than 24 hours later.
- **Ignore** keeps counting but hides the issue from the default list.
- Counts are refreshed every few minutes; the live feed shows each error at once.

## Checking an integration

- Check the payload first, without sending it: the MCP tool `validate_event` runs an error through the real validation, scrubbing and grouping and shows the issue it would form. Nothing is stored. See [MCP server](mcp.md).
- To check end to end, send one error with `environment: "integration-test"`. It is stored and shown in the live feed, but the Errors list and the Overview leave the `integration-test` environment out unless you pick it, so a test never sits among real issues.

## Limits

Errors count toward the monthly events of your plan. Each site also has an error burst limit: past it, error events are refused with `rate_limited` while the other events of the same batch are stored, so a crash loop cannot use up your month.
