Getting Started
Configuration
Every option accepted by init(). Only publicKey is required — sensible defaults are picked for everything else.
A complete example#
typescript
import { init } from '@reliableapp/frontend-core';
init({
publicKey: 'pk_live_rl_xxxxxxxxxxxxxxxx',
endpoint: 'https://reliablebackend.ziloris.com', // optional override
sampleRate: 100, // 0-100
debug: false,
captureErrors: true,
captureVitals: true,
captureNetwork: true,
captureClicks: true,
captureNavigation: true,
captureAllRequests: false,
captureReplay: true,
captureConsole: true,
release: process.env.NEXT_PUBLIC_GIT_SHA, // optional, enables source-map resolution
beforeSend(event) {
if (event.path?.includes('/health-check')) return null;
return event;
},
});Options reference#
| Name | Type | Default | Description |
|---|---|---|---|
| publicKey* | string | — | Your project's public key. Starts with pk_live_rl_ or pk_test_rl_. |
| endpoint | string | auto | Custom ingest endpoint. Leave unset to use the default Reliable cloud endpoint. |
| sampleRate | number | 100 | 0–100. Per-session dice roll. Sessions that lose go fully dark — no events sent for the whole session. Useful for cost control on high-traffic sites. |
| debug | boolean | false | Log SDK internals to the console. Useful during integration; turn off in production. |
| captureErrors | boolean | true | Listen for window 'error' and 'unhandledrejection' events. Manual captureException() works regardless of this flag. |
| captureVitals | boolean | true | Collect LCP, CLS, INP, FID, TTFB via the web-vitals library. |
| captureNetwork | boolean | true | Instrument fetch and XHR. Failures are reported by default; enable captureAllRequests for successful requests too. |
| captureClicks | boolean | true | Record click coordinates and target selectors as breadcrumbs. |
| captureNavigation | boolean | true | Track route changes via history patching and popstate. |
| captureAllRequests | boolean | false | When true, successful network requests are also reported. By default only 4xx/5xx and network errors are sent. |
| captureReplay | boolean | true | Record sessions with rrweb. The last 30 seconds are flushed alongside any error event. |
| captureConsole | boolean | true | Patch console.error and console.warn so soft failures that don't throw still surface as incidents. SDK's own internal logs are excluded. |
| release | string | — | Build identifier (commit SHA, version tag). Required for source-map resolution to work — the upload CLI uses the same value to key sourcemaps. See the Source Maps guide. |
| beforeSend | function | — | Inspect or rewrite every event before it's sent. Return null to drop, or a mutated copy to rewrite. Runs synchronously. |
Environment-specific config#
Use environment variables and the standard pattern of skipping init in test/dev if you don't want noise:
typescript
if (process.env.NODE_ENV === 'production') {
init({
publicKey: process.env.NEXT_PUBLIC_RELIABLE_KEY!,
sampleRate: 25, // 25% of production sessions
});
}Server-side config wins#
Each project has a server-side configuration in the Reliable dashboard. When the SDK boots it pulls that config and merges it with what you passed to init(). The server config is authoritative — if you disable error capture in the dashboard, the SDK will respect that even if your code passes captureErrors: true.
This lets you toggle features without redeploying your frontend. Useful for emergency cost controls (e.g. disabling replay during a traffic spike) or for staged rollouts.
Tip
beforeSend is the most powerful escape hatch — use it for runtime PII scrubbing, dropping noisy URLs, or routing certain events to a different project. See the beforeSend guide for patterns.