Sentry Adapter
Send captured errors, messages, breadcrumbs, and user context to Sentry.
Install
yarn add @sentry/browser
Activate
import { initialize, useAdapter } from 'unified-error-handling';
initialize();
await useAdapter('sentry', {
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
environment: 'production',
release: '1.4.2',
});
Config
Pass the options your Sentry project expects. The most common:
| Field | Purpose |
|---|---|
dsn | Your Sentry project DSN (required). |
environment | Environment label (e.g. production). |
release | Release identifier for grouping. |
The adapter forwards your config to the Sentry SDK on initialize, then maps each NormalizedError, message, breadcrumb, and context update onto the corresponding Sentry call.
Notes
- The
@sentry/browserSDK is loaded with a dynamicimport()only when you activate this adapter — it never reaches a bundle that does not use Sentry. - If
@sentry/browseris not installed, activation throwsFailed to load Sentry SDK…with the original import error preserved ascause. - Use the store's
beforeSendhook (ininitialize()) to scrub PII before it reaches Sentry.
See the adapters guide for switching and the core API for setUser / addBreadcrumb, which the adapter forwards.