# Overview # Erised docs Erised shows every person who uses your product and what they did, without a data team. A browser snippet and a server API send page views and actions; Erised stitches an anonymous visitor to a known person at signup and login, and shows each person with their full timeline, plus key events and funnels. Events are never forwarded to third parties. ## How an integration fits together | Where | Key | What it sends | | --- | --- | --- | | Every page of your product | publishable (`pk_live_…`) | Page views (automatic, including single-page-app route changes) and the actions you track with `cdp('track', …)` | | Your server, at signup and at every login | secret (`sk_live_…`) | A verified `identify`: who this browser belongs to | | Your server, when money or an account changes | secret | Conversions such as `order_paid`, with a deterministic `messageId` | | Your logout handler, in the browser | — | `cdp('reset')`, so the next person on the device starts fresh | The secret key stays on your server. The publishable key is meant to be public. ## Start here - [Quickstart](quickstart.md): the four steps above, with code, and how to check that events arrive. - [Using an AI coding assistant](ai-assistants.md): a prompt to paste into Claude Code, Cursor or Copilot, and the rules an integration must follow. ## Reference - [Browser SDK](browser-sdk.md): the snippet, its options, every call, storage and delivery. - [HTTP API](http-api.md): endpoints, keys, the event envelope, limits, responses and error codes. - [Identity](identity.md): when two histories are joined, the rules that protect your data, and undoing a merge. - [Consent](consent.md): the banner, what is collected before and after a choice, and gating your own trackers. - [Server recipes](server-recipes.md): Node, Next.js and Express code for identify and conversions. - [Apps (through your backend)](apps.md): iOS, Android, desktop and game apps, with app, OS and device context. - [Error reporting](errors.md): browser and server errors grouped into issues, with the people each one reached. - [MCP server](mcp.md): connect Claude Code, Cursor or any MCP client with a read key. For tools: [`/llms.txt`](/llms.txt) indexes these pages, and every page is also served as Markdown (add `.md` to its name). --- # Quickstart # Quickstart Most integrations take under an hour. You need an Erised site (sign in at [app.erised.run](https://app.erised.run/login)) and access to your product's pages and server. ## 1. Get your keys - **Publishable key** (`pk_live_…`): on the site's **Install** screen. It goes in the browser. - **Secret key** (`sk_live_…`): **Settings → API keys**, type *Secret*. It goes in your server's environment (for example `ERISED_SECRET_KEY`) and **never** in browser code or a public repository. A key is shown once, when it is created. Erised stores only a hash. ## 2. Add the snippet to every page Put this in the `` of every page, or in your root layout: ```html ``` The snippet sends a page view on load and on every route change of a single-page app, so there is nothing to add for page views. Track the actions that matter: ```js cdp('track', 'signup_started', { plan: 'growth' }); ``` Calls made before the script loads are queued and sent once it does. If your site turned on cookie consent in Erised, add `{ consent: true }` as the third item of the `init` call: the snippet then shows the banner and collects nothing until the visitor agrees. ## 3. Identify people from your server At **signup and at every login**, tell Erised who the browser belongs to. This is what joins the visitor's anonymous history to their account. Send it from your server with the secret key: ```js // Node 18+ (fetch is built in). Runs after your own signup/login succeeds. async function erisedIdentify(user, req) { try { await fetch('https://app.erised.run/v1/identify', { method: 'POST', headers: { Authorization: `Bearer ${process.env.ERISED_SECRET_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ userId: user.id, // your stable id, not the email anonymousId: req.cookies['erised_anonymous_id'], // set by the snippet; may be absent properties: { email: user.email, traits: { plan: user.plan }, }, }), signal: AbortSignal.timeout(3000), }); } catch { // Never fail a signup or a login because analytics is unreachable. } } ``` The snippet keeps the visitor's anonymous id in the `erised_anonymous_id` cookie. That cookie belongs to the page's own host. If your API runs on another host (`api.example.com` for a site on `example.com`), the cookie is not sent to it: read it in the browser and send it with the signup or login request instead: ```js const match = document.cookie.match(/(?:^|; )erised_anonymous_id=([^;]*)/); const anonymousId = match ? decodeURIComponent(match[1]) : undefined; ``` When the cookie is missing (consent not given, or no snippet on that page), send the call without `anonymousId`. ## 4. Track conversions from your server Money and account changes come from the server, where they are true. Give each one a `messageId` built from your own record, so a retried request is stored once: ```js await fetch('https://app.erised.run/v1/track', { method: 'POST', headers: { Authorization: `Bearer ${process.env.ERISED_SECRET_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ userId: user.id, event: 'order_paid', messageId: `order_paid:${order.id}`, properties: { amount: order.total, currency: 'USD' }, }), }); ``` ## 5. Reset at logout In the browser, as part of your logout handler: ```js cdp('reset'); ``` This forgets the identified user and starts a new anonymous id, so the next person on the same device is never merged into the last. ## 6. Check that it works Open your product, click around, sign up and log in. The **Install** screen ticks off the first page view, track event and identify as they arrive, and the **Live feed** shows every event as raw JSON within seconds. A request Erised accepts is answered `202` with `{"received": n, "duplicates": n}`. A `401` (`unauthorized`) means a wrong or revoked key; a `429` means slow down (`rate_limited`, with a `Retry-After` header) or the plan's monthly limit is reached (`quota_exceeded`). --- # Using an AI coding assistant # Using an AI coding assistant Erised is built to be integrated by an AI coding assistant working in your repository. Give it the prompt below; it reads these docs, makes the changes, and you check the result on the Install screen. The **Install** screen in the app has the same prompt with your site's settings filled in, under **Set up with an AI assistant**, with a Copy button. ## The prompt ```text Integrate Erised (customer data platform) into this codebase. Read https://erised.run/llms.txt and the pages it links before writing code, and follow the "Rules" section of https://erised.run/docs/ai-assistants.md exactly. My settings: - API origin: https://app.erised.run (the snippet loads https://app.erised.run/sdk/v0.js) - Publishable key (browser): pk_live_YOUR_PUBLISHABLE_KEY - Secret key (server): read it from the environment variable ERISED_SECRET_KEY. Never write the secret key in code, config files or the browser bundle. - Cookie consent in Erised: off Do this: 1. Add the browser snippet to every page (root layout or the shared ). 2. Track the 3–5 product actions that matter most, in the browser, with snake_case names. Propose the list before adding them. 3. On the server, after a successful signup and after every successful login, send a verified identify (POST /v1/identify) with the user's stable id, email and the erised_anonymous_id cookie. 4. On the server, track money and account changes (for example order_paid, subscription_started) with POST /v1/track and a deterministic messageId. 5. Call cdp('reset') in the browser when the user logs out. Then add error reporting: errors: true and release in the init call, and a server reportError helper (POST /v1/error) wired to the framework's error hook, as https://erised.run/docs/errors.md shows. 6. Add the "Erised rules" block from https://erised.run/docs/ai-assistants.md to this repository's AGENTS.md (or CLAUDE.md), creating the file if needed. 7. Tell me which files you changed and how to check the result on the Install screen of app.erised.run. If the "erised" MCP server is connected, check it yourself with get_install_status and check_identity. ``` ## Rules An integration is correct only if it follows all of these. 1. **The secret key (`sk_live_…`) never reaches a browser.** It lives in a server environment variable. Only the publishable key (`pk_live_…`) appears in page code. 2. **Identify from the server, at signup and at every login**, with `POST /v1/identify`, the secret key, your stable `userId` (your database id, not the email), `properties.email`, and the `anonymousId` from the `erised_anonymous_id` cookie. A browser `identify` is unverified and never merges two people; it does not replace the server call. 3. **The `erised_anonymous_id` cookie belongs to the page's host.** Read it on a server that shares that host, or read it in the browser (`document.cookie`) and send it with the login or signup request. If it is missing, send the identify without `anonymousId`; never invent one. 4. **Conversions come from the server** with `POST /v1/track` and a `messageId` derived from your own record (for example `order_paid:`), so a retry is stored once. 5. **Call `cdp('reset')` on logout**, in the browser. 6. **Event names are `snake_case`, object then past-tense verb**: `signup_completed`, `order_paid`, `invite_sent`. One name per action across browser and server. 7. **No secrets or sensitive data in properties**: no passwords, tokens, card numbers or free-text form fields. The email belongs in `properties.email` of an identify, nowhere else. 8. **Erised must never break your product.** Server calls use a short timeout and swallow errors (log them); a failed analytics call never fails a signup, login or payment. 9. **Respect consent.** If cookie consent is on for the site, pass `{ consent: true }` in `init` and do not set the anonymous id cookie yourself. 10. **Do not add other trackers or forward Erised events** to third parties. 11. **Error reporting is opt-in**: `errors: true` with `release` (the build's git SHA or version) and `environment` in `init`; server errors go through one `reportError` helper with a short timeout. See [Error reporting](errors.md). 12. **An error report never carries request bodies, cookies or auth headers**: the message, the stack, and at most the method, path and user agent. ## The "Erised rules" block for your repository Keep these lines in `AGENTS.md` or `CLAUDE.md`, so later changes made by an assistant keep the integration correct: ```markdown ## Erised (analytics) rules - Docs: https://erised.run/llms.txt. Follow https://erised.run/docs/ai-assistants.md#rules. - ERISED_SECRET_KEY (sk_live_…) is server-only. Only the publishable key (pk_live_…) may appear in browser code. - Server identify (POST https://app.erised.run/v1/identify) after every signup and login, with userId, properties.email and the erised_anonymous_id cookie when present. - Server conversions (POST /v1/track) carry a deterministic messageId, e.g. order_paid:. - cdp('reset') runs on logout. - Event names: snake_case, object_past-tense-verb. No secrets, passwords or free text in properties. - Analytics calls never block or fail a user action: short timeout, errors logged and ignored. - Errors: errors: true + release in init; server errors via one reportError helper (POST /v1/error, secret key). Never bodies, cookies or auth headers. ``` ## Checking the result After the assistant is done, open your product, sign up, log in and log out. On the **Install** screen of [app.erised.run](https://app.erised.run/login), the first page view, track event and identify tick off as they arrive; the **Live feed** shows each event's JSON. --- # Browser SDK # Browser SDK The browser SDK is one script, `https://app.erised.run/sdk/v0.js` (under 5 KB gzipped), loaded by a two-line snippet. It uses a **publishable key** (`pk_live_…`), which is safe to expose. ## The snippet ```html ``` Calls pushed before the script loads are queued and replayed in order. Once it has loaded, `window.cdp` is also a function: `cdp('track', …)` and `window.cdp.push(['track', …])` do the same thing. ### `init` options `cdp('init', key, options)`, once per page; a second `init` is ignored. | Option | Default | Meaning | | --- | --- | --- | | `endpoint` | the origin the script was loaded from | Where events are sent, e.g. `'/erised'` behind a first-party proxy. No trailing slash. | | `consent` | `false` | `true` when the site has cookie consent on: nothing is collected until the visitor grants analytics. See [Consent](consent.md). | | `errors` | `false` | `true` reports uncaught errors and unhandled promise rejections. See [Error reporting](errors.md). | | `release` | — | Your build (e.g. a git SHA), attached to errors | | `environment` | — | e.g. `production`, attached to errors | ## Calls | Call | What it does | | --- | --- | | `cdp('track', name, properties?)` | Records an action. `name` is required, `snake_case` (`signup_started`). | | `cdp('page', properties?)` | Records a page view. Rarely needed: the SDK sends one on load and on every route change. | | `cdp('identify', userId, traits?)` or `cdp('identify', { userId?, email?, traits? })` | An **unverified** identify from the browser. It never merges two people and its `userId` is not attached; use the [server identify](http-api.md#post-v1-identify) for that. | | `cdp('reset')` | At logout: forgets the user and starts a new anonymous id. | | `cdp('captureError', error, { level?, tags?, fingerprint? })` | Reports an error you caught. Works with or without `errors: true`. | | `cdp('consent')` | Returns the visitor's consent choice, or `null`. | | `cdp('onConsent', fn)` | Calls `fn(choice)` at load when a choice exists, and on every change. | | `cdp('showConsent')` | Reopens the consent preferences (your "Cookie settings" link). | | `cdp('grantConsent', categories?)` / `cdp('rejectConsent')` / `cdp('withdrawConsent')` | Record a choice from your own UI instead of the banner. | Unknown calls are ignored: the SDK never throws into your page. ## What each event carries Every event gets an `anonymousId`, a `messageId`, a `timestamp`, and a `context` with the page (`url`, `path`, `referrer`, `search`, `title`), `locale`, `timezone`, `userAgent` and the library version. After an `identify`, the `userId` rides along too. Erised adds country, browser, OS, device class and UTM parameters on the server; the IP address is never stored. Page views are named `page_viewed` and carry `path` and `title` in their properties. The SDK never reads form fields and captures nothing automatically beyond page views, and uncaught errors when `errors: true` is set. ## Storage | Name | Where | Holds | | --- | --- | --- | | `erised_anonymous_id` | cookie (first-party, host-only, `SameSite=Lax`, 1 year) and localStorage | The visitor's anonymous id. Your server reads the cookie to [identify](quickstart.md#3-identify-people-from-your-server). | | `erised_user_id` | localStorage | The id from the last browser `identify`. | | `erised_queue` | localStorage | Events not yet delivered. | | `erised_session_id` | sessionStorage | The browser session. | | `erised_consent` | cookie | The consent choice, when consent is on. | With consent on, none of these except `erised_consent` exist until the visitor grants analytics, and withdrawing deletes them. ## Delivery - Events are sent to `POST /v1/batch` every 2 seconds, or as soon as 10 are waiting. - When the page is hidden or closed, the queue is sent with `sendBeacon`. - Undelivered events wait in localStorage (at most 100, oldest dropped first) and survive a reload. - A `429` keeps the batch and retries after the `Retry-After` delay; a `5xx` or a network error retries with backoff (1 to 30 seconds). Any other `4xx` drops the batch, which could never succeed. ## A first-party proxy To load the script and send events from your own domain, proxy two paths. With Next.js: ```js // next.config.mjs export default { async rewrites() { return [ { source: '/erised/sdk.js', destination: 'https://app.erised.run/sdk/v0.js' }, { source: '/erised/v1/:path*', destination: 'https://app.erised.run/v1/:path*' }, ]; }, }; ``` ```html ``` --- # HTTP API # HTTP API Base URL: `https://app.erised.run`. Every endpoint takes and returns JSON. ## Authentication Send the key as a bearer token: `Authorization: Bearer `. | Key | Use | Allowed | | --- | --- | --- | | Publishable `pk_live_…` | Browsers | `page`, `track`, unverified `identify`. Every event needs an `anonymousId`. Responses carry CORS headers. | | Secret `sk_live_…` | Your servers only | Everything, including verified `identify` and `alias`. No CORS headers: a browser cannot read the response. | A browser that cannot set headers (`sendBeacon`) may put the publishable key in the body as `writeKey`. ## Endpoints | Endpoint | Body | | --- | --- | | `POST /v1/batch` | `{ "batch": [event, …] }` or a JSON array of events, each with its `type` | | `POST /v1/track` | One event; `type` is `track` | | `POST /v1/page` | One event; `type` is `page` | | `POST /v1/identify` | One event; `type` is `identify` | | `POST /v1/alias` | One event; `type` is `alias` (secret key only) | | `POST /v1/error` | One error; `type` is `error`. See [Error reporting](errors.md). | `/v1/consent` and `/v1/consent/config` are used by the browser SDK's consent banner; you do not call them yourself. ## The event | Field | Required | Notes | | --- | --- | --- | | `type` | on `/v1/batch` | `page`, `track`, `identify`, `alias` or `error` | | `name` (or `event`) | for `track` | The event name. Event names are at most 200 characters. | | `anonymousId` | with `pk_` keys | The browser's id, from the `erised_anonymous_id` cookie on the server | | `userId` | at least one of the two ids | Your stable user id | | `messageId` | recommended on servers | Makes a retry safe: a `messageId` already stored for the site is skipped. Without one, Erised generates one, so a retried request is stored twice. | | `timestamp` | no | ISO 8601. Defaults to when Erised received the event; never later than that. | | `sentAt` | no | ISO 8601. When the client sent it; Erised corrects `timestamp` for the client's clock. | | `sessionId` | no | | | `properties` | no | A JSON object; `properties` up to 32 KB per event | | `context` | no | A JSON object; `context` up to 32 KB per event. See below. | Ids (`anonymousId`, `userId`, `messageId`, `sessionId`) are at most 256 characters. ### Context fields Erised reads on server events | Field | Used for | | --- | --- | | `context.ip` | The visitor's country. Used for the lookup only: removed before the event is stored. | | `context.userAgent` | Browser, OS and device class | | `context.os.name`, `context.device.type` | OS and device class when there is no user agent, e.g. [apps](apps.md) | | `context.app.version`, `context.app.build` | App versions on the person's profile | | `context.page.url`, `.path`, `.referrer` | Pages, referrers and UTM parameters | Everything else in `context` is stored as sent and visible in the live feed. ### `POST /v1/identify` From your server, with the secret key, at signup and every login: ```json { "userId": "u_123", "anonymousId": "0b6f…", "properties": { "email": "ada@example.com", "traits": { "plan": "growth", "company": "Acme" } } } ``` `properties.email` becomes the person's verified email; `properties.traits` are merged onto the profile (latest value wins per key). See [Identity](identity.md) for exactly when two histories are joined. ### `POST /v1/alias` Links two anonymous ids of the same browser, for example after a move between two domains. Secret key only. `anonymousId` is the current id and `userId` carries the **previous anonymous id**; neither creates a known user. ## Limits - At most 100 events per request, and 500 KB per request. - Requests are rate-limited per key and per site; a limited request stores nothing. - Each plan has a monthly event limit (with a grace margin); past it, requests are refused with `quota_exceeded`. ## Responses A request Erised accepts is answered `202`: ```json { "received": 2, "duplicates": 1, "rejected": [{ "index": 3, "issues": [{ "path": "name", "code": "missing_name", "message": "…" }] }] } ``` On `/v1/batch` each event is checked on its own: valid events are stored, invalid ones are listed in `rejected` and nothing else is lost. `received + duplicates + rejected.length` equals the number of events sent. On the single-event endpoints an invalid event is a `400` (`validation_failed`) and nothing is stored. ## Errors Errors look like `{ "error": { "code": "…", "message": "…" } }`. | Status | `code` | Meaning | | --- | --- | --- | | 400 | `invalid_json`, `invalid_body`, `invalid_batch`, `empty_batch`, `batch_too_large` | The request is malformed | | 400 | `validation_failed` | A single-event request whose event is invalid (details in `errors`) | | 401 | `unauthorized` | Missing, unknown or revoked key | | 403 | `account_suspended`, `account_deleted` | The organization cannot send events | | 413 | `payload_too_large` | Over 500 KB per request | | 429 | `rate_limited` | Too many requests; wait for `Retry-After` seconds | | 429 | `quota_exceeded` | The plan's monthly limit is reached; retrying will not help (no `Retry-After`) | Per-event issue codes include `missing_anonymous_id` (a `pk_` event without one), `missing_id` (no id at all), `missing_name` (a `track` without a name), `forbidden_for_key` (`alias` with a `pk_` key), `unverified_claim` (a `pk_` identify claiming `verified`) and `type_mismatch` (a `type` that contradicts the endpoint), `missing_error` (an error without message or stack), `invalid_error_field` (an error field of the wrong type), and `rate_limited` on an error event past the site's error burst. --- # Identity # Identity Erised keeps one **profile** per person. A profile holds identities: anonymous ids (one per browser), at most one user id from your system, and emails. Joining two histories is never guessed: it happens only at a confirmed moment, it is recorded, and it can be undone from the app. ## Before signup: anonymous The snippet gives each browser an anonymous id (`erised_anonymous_id`). Browser events land on the profile of that id, and only on it. Even if a browser event claims a `userId`, it is stored as sent but never used to pick the profile, because anyone can send anything from a browser. ## At signup and login: the verified identify A server `identify` with the secret key is the confirmed moment: - The `userId` and `properties.email` attach to the profile as **verified**. - When the request's `anonymousId` belongs to one profile and its `userId` to another (the person used a new device, then logged in), the two profiles are **merged**: one person, one timeline. - A new anonymous id seen for the first time attaches to the person's profile. That is why the identify must be sent at **every** login: each new browser joins the person at that moment. ## Rules that protect your data - **Two known users never share a profile.** If a browser already belongs to a different user (a shared computer), the identify does not merge: the new user's events go to their own profile. - **A verified email beats an unverified one.** An email claimed from the browser stays unverified. A verified identify that claims the same email takes it over; an email already held **verified** by another person is never taken, and never forces a merge. - **The browser cannot merge.** A browser `identify` can attach an email to the current anonymous profile only, when no other profile owns it. It never merges, and it never sets the user id. - **A guard rail on merges.** A profile holds at most 50 anonymous ids; a merge that would go past it is refused and logged. - **Logout starts fresh.** `cdp('reset')` gives the browser a new anonymous id, so the next person on the device is not merged into the last. ## Aliases `POST /v1/alias` (secret key) links two anonymous ids of the same browser, for example across two of your domains. If both ids already have profiles, they merge, under the same guard rail. ## Undoing a merge Every merge is recorded with its reason (`identify` or `alias`). From a person's profile in the app, a merge can be undone; the events go back to the profiles they came from and the timelines are correct after. --- # Consent # Consent Consent is off by default. When you turn it on for a site, the same snippet also shows a cookie banner, and **Erised collects nothing from a browser until the visitor grants the analytics category**. Every choice is recorded, and a known person's choice shows on their profile. Erised is consent tooling, not a compliance guarantee: whether you need consent, and for what, is your decision. ## Turn it on 1. In the app, **Settings → Consent**: enable it, then set the categories, texts, policy link and the look of the banner. The defaults are *Necessary* (always on), *Analytics* and *Marketing*, none pre-ticked; *Reject all* is as easy as *Accept all*. 2. Add `{ consent: true }` to the `init` call: ```html ``` ## What happens - **Before a choice:** no anonymous id, no storage, no events. Only the banner. - **Analytics granted:** collection starts at once, without a reload. - **Rejected:** nothing is collected. The decline is recorded without any id. - **Withdrawn:** the withdrawal is recorded, then every Erised cookie and storage entry is deleted and collection stops. - The choice lives in the `erised_consent` cookie. It expires after 6 months by default (configurable, never more than 13), and changing the policy version asks again. ## A "Cookie settings" link Visitors must be able to change their mind. Reopen the preferences from your footer: ```js document.querySelector('#cookie-settings')?.addEventListener('click', () => { cdp('showConsent'); }); ``` ## Gate your own trackers Erised never starts or blocks other scripts for you. Use the choice: ```js cdp('onConsent', (choice) => { if (choice?.categories.analytics) startMyAnalytics(); else stopMyAnalytics(); }); ``` `cdp('consent')` returns the current choice (or `null`); `onConsent` runs once at load when a choice exists, and on every change. ## The server rule Send an `anonymousId` on a server call only when the visitor granted analytics. Reading it from the `erised_anonymous_id` cookie follows the rule by itself: that cookie does not exist before consent. When it is absent, send the identify without it. --- # Server recipes # Server recipes All server calls use the **secret key** from an environment variable (here `ERISED_SECRET_KEY`), a short timeout, and never fail the user's action. ## A small Node helper ```js // erised.js (server only). Node 18+. const ERISED = 'https://app.erised.run'; export async function erised(path, body) { try { const res = await fetch(`${ERISED}/v1/${path}`, { method: 'POST', headers: { Authorization: `Bearer ${process.env.ERISED_SECRET_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify(body), signal: AbortSignal.timeout(3000), }); if (!res.ok) console.warn('erised', path, res.status, await res.text()); } catch (err) { console.warn('erised', path, err); // never fail the user's action } } export function identify({ user, anonymousId }) { return erised('identify', { userId: String(user.id), ...(anonymousId ? { anonymousId } : {}), properties: { email: user.email, traits: { plan: user.plan } }, }); } export function track({ userId, event, messageId, properties }) { return erised('track', { userId: String(userId), event, messageId, properties }); } ``` ## Next.js (App Router) The snippet, in the root layout: ```tsx // app/layout.tsx import Script from 'next/script'; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( {children} ``` 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 }) { 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. --- # MCP server # MCP server Erised runs a [Model Context Protocol](https://modelcontextprotocol.io) server at `https://app.erised.run/mcp`. Connect your AI coding tool to it and the tool can check its own integration work ("did my identify arrive?") and answer questions about your site's data. It is **read-only**: nothing can be sent, changed or deleted through it (`validate_event` checks a payload without storing it). ## 1. Create a read key In the app, **Settings → API keys → Create key**, type **Read (rk_)**. A read key belongs to one site, is shown once, and can be revoked at any time. It cannot send events. A read key gives the connected tool the same view of the site as the dashboard, including people's emails and event properties. Create one only for tools you trust, and revoke it when you are done. ## 2. Connect your tool Claude Code: ```bash claude mcp add --transport http erised https://app.erised.run/mcp \ --header "Authorization: Bearer rk_live_YOUR_READ_KEY" ``` Cursor (`.cursor/mcp.json`) and other clients that take a JSON config: ```json { "mcpServers": { "erised": { "url": "https://app.erised.run/mcp", "headers": { "Authorization": "Bearer rk_live_YOUR_READ_KEY" } } } } ``` Keep the key out of version control: use your tool's user-level config, or an environment variable where it supports one. ## Tools | Tool | What it answers | | --- | --- | | `get_install_status` | Has the site received its first page view, track event and identify (and an error report, when error reporting is on)? A site whose events all come from a server (an app through its backend, or a backend only) is `kind: "server"` and needs no page view | | `list_recent_events` | The newest events as raw JSON, filtered by type, event name or person (email or user id) | | `get_event_catalog` | Every event name with count, last time and key-event flag, and the page paths seen | | `check_identity` | For a user id, email or anonymous id: does a person hold it, is it verified, which browsers are joined, when was the last identify, and what to fix | | `get_person` | One person's profile: identities, traits, counts, merges, the error issues they hit, and recent events | | `list_funnels` | The saved funnels and their steps | | `run_funnel` | A saved funnel over the last 7, 30 or 90 days: people per step, conversion, drop-off, median time | | `list_issues` | Error issues over 7, 14 or 30 days, by people affected: title, culprit, level, status, events, people | | `get_issue` | One issue: stack frames of the latest occurrence, releases, events per day, people affected, and what the person did in the 10 minutes before | | `validate_event` | A dry run of one event or a batch through the real validation: what would be stored, rejected (with each issue) or dropped as a duplicate, and for an error, the scrubbed properties, the grouping and the issue it would join. Nothing is stored | | `get_docs` | These docs as Markdown: without a topic, the list of pages; with a page slug (`quickstart`, `identity`, `http-api`, `apps`, `errors`, …), that page | A typical error fix: ask your assistant to call `list_issues`, then `get_issue` on the issue that reached the most people. The frames marked `inApp` point at your code; after the fix ships with a new `release`, `get_issue` shows whether that release still produces it. Your assistant does not need this website to write an integration: `get_docs` gives it every page, and the same pages are MCP resources (`erised://docs/`, Markdown) for clients that attach resources. A typical integration check: after adding the server identify, sign up in your product, then ask your assistant to call `check_identity` with the new account's email. It should report `verified: true` and one joined anonymous id; if not, its hints say what to change. ## Details - Transport: Streamable HTTP, JSON responses, no session. Protocol versions 2025-03-26, 2025-06-18 and 2025-11-25. - Every call reads only the site the key belongs to. - Calls are rate-limited per key. A browser page on another origin is refused.