# Introducing browser error capture

Until now, Tailcove saw everything your servers logged and nothing your users' browsers did. Today that changes: `@tailcove/browser` ships logs and uncaught errors straight from the frontend, and they land in the same sources, search and issues as the rest of your stack.

## Why a separate client

Server-side clients authenticate with an ingest token, and an ingest token is a secret. Anything you bundle into frontend JavaScript is public by definition, so the browser client uses a different credential: a **browser key**.

A browser key is meant to be visible. Access is controlled by the **allowed origins** you configure for it, not by keeping it secret. A request from an origin you have not listed is rejected before it ever reaches your source's data.

## Two minutes to set up

Generate a browser key and its allowed origins from a source's **Settings** tab, then install the client:

```bash
npm install @tailcove/browser
```

```ts
import { init } from '@tailcove/browser';

const tailcove = init({
    key: '<your browser key>',
    captureWindowErrors: true,
    captureUnhandledRejections: true,
});

tailcove.info('checkout started', { cartTotal: 42.5 });
```

No build step? A single `<script>` tag from unpkg works too.

## Errors that group with your backend

Captured errors use the same structured shape every Tailcove client uses (`class`, `message`, `location`, `trace`). That means a frontend error is fingerprinted like any other exception and grouped into an **issue**, with occurrence counts and first and last seen.

Automatic capture is off by default, so you choose exactly what is collected:

| Option                       | What it captures                                           |
| ---------------------------- | ---------------------------------------------------------- |
| `captureWindowErrors`        | Uncaught errors via `window.onerror`                       |
| `captureUnhandledRejections` | Unhandled promise rejections                               |
| `captureConsoleErrors`       | `console.error(...)` calls, sampled by `consoleSampleRate` |

## Delivery that survives page unloads

Like every Tailcove client, the browser client never sends one request per line. It buffers in memory and flushes every 20 lines or 2 seconds, whichever comes first.

The tricky part on the web is the moment a user closes the tab. A pending timer or an in-flight `fetch()` is not guaranteed to finish once a page starts unloading, so when the tab is hidden or navigating away the client switches to `navigator.sendBeacon`, falling back to `fetch` with `keepalive`.

## Framework integrations

The package ships thin adapters for the frameworks most teams use:

- **React**: a `TailcoveProvider` and an `ErrorBoundary`
- **Vue**: a plugin that chains onto `app.config.errorHandler`
- **SvelteKit**: a `handleError` hook factory

## What's next

Source map resolution is the next step, so that minified stack traces point at your original code. Until then, `location` is best-effort and most useful against unminified builds.

Browser capture is available on every plan, including Free. Read the [browser docs](https://tailcove.dev/docs/sending-logs/browser) to get started.
