# Error tracking

Pagebee groups the errors on your site and server into issues, counts them, and hands them to your agent to fix. It works like Sentry, with one difference: nothing in a report says who hit the error.

## What it keeps, and what it never does

- **Kept:** the error's type, message and stack, the page or route without its query string, the release, and the browser and OS from the user agent.
- **Never:** user ids, IP addresses, cookies, headers, request bodies, local variables, or a trail of what the person clicked or typed.
- **Scrubbed:** before anything is stored, emails, tokens, passwords, card numbers, phone numbers, IPs, UUIDs and query strings are taken out of messages, stacks and props.
- **Visitors affected** is counted per local day with the same daily hash as visits, deleted when the day closes. Someone who hits an error on two days counts twice.
- Do Not Track and Global Privacy Control switch reporting off, like everything else.

## Websites

Add `errors.js` before your other scripts. It's separate from the counting script and under 1 KB.

```html
<script src="https://api.pagebee.ai/errors.js" data-site="pb_pk_your_site_key" data-release="1.4.2"></script>
```

Uncaught errors and unhandled promise rejections are reported on their own. Report errors your code catches with:

```js
window.pagebeeError && window.pagebeeError(error, { props: { step: "checkout" } });
```

With the npm package, `captureError(error)` does the same.

| Attribute | Meaning |
| --- | --- |
| `data-site` | The site's public key |
| `data-release` | Your build's version or commit. Set it so fixes can be resolved in a release |
| `data-env` | `production`, `staging` or `preview`. Omit to let hostname rules decide |
| `data-local` | Report from localhost too |

It sends at most 10 reports a page load and each distinct error once. Scripts loaded from another origin need `crossorigin="anonymous"` on their tag, or the browser hides their errors as "Script error.", which is dropped.

## Servers

With the Node SDK and a secret key:

```ts
import { Pagebee } from "@pagebee/node";

const pagebee = new Pagebee({ secretKey: process.env.PAGEBEE_SECRET_KEY!, release: process.env.GIT_SHA });
pagebee.captureUnhandled();        // uncaught exceptions and unhandled rejections
app.use(pagebee.errorHandler());   // Express: errors with a status of 500 or more

try {
  await charge(order);
} catch (err) {
  await pagebee.captureException(err, { path: "/api/checkout", props: { provider: "stripe" } });
}
```

Or post to `/v1/errors` from any language, up to 50 a request:

```bash
curl https://api.pagebee.ai/v1/errors \
  -H "Authorization: Bearer pb_sk_your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{"type":"Error","message":"Charge failed","stack":"Error: Charge failed\n    at charge (/app/src/billing.ts:22:11)","path":"/api/checkout","release":"a1b2c3d"}'
```

| Field | Meaning |
| --- | --- |
| `type`, `message` | Required. The error's name and message |
| `stack` | The stack as a string, as `Error.stack` gives it |
| `release` | Your deploy's version or commit |
| `path` | The route or page; the query string is dropped |
| `handled` | True when your code caught it |
| `fingerprint` | Up to 10 strings, to group reports yourself |
| `props` | Up to 30 keys, scrubbed like messages |
| `context` | `method`, `status` and `runtime`, never headers or bodies |

## Issues

Reports with the same error type and the same top frames of your own code are one issue. Library, runtime and browser extension frames don't count, and build hashes in file names are ignored, so a redeploy keeps the issue. Minified code without readable function names is grouped by message as well. Source maps aren't supported yet.

Each issue is open, resolved or ignored:

- **Resolve** when the fix is live. Any new report reopens it as regressed.
- **Resolve in a release** when the fix ships later. It reopens only if seen in that release or a newer one, so older versions still running don't reopen it.
- **Ignore** to stop alerts. It is still counted.

## Alerts

New and regressed issues post to an `errors` channel on the [live feed](/docs/live-feed). In production the channel pushes to the [iPhone app](/docs/iphone-app); switch it off on the Live page. Staging and preview never push. A site sends at most 20 error alerts an hour.

## Your agent

With the [MCP](/docs/mcp), `list_issues` finds what is breaking, `get_issue` gives the stack, releases and impact, and with a dev key `update_issue` resolves it in the release that ships the fix:

```text
Fix the error in production that hit the most visitors today. Resolve it in the next release when you've shipped the fix.
```

## Limits

Every report is counted, on every plan, and errors never count toward your monthly events. The stored samples behind the stack and breakdowns are kept 90 days and at most 100 per issue: the first 10 reports of each issue, then one in ten, up to 10,000 a month on Free and 250,000 on Grow. Past that, counting carries on and new samples wait for the next month.
