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#

NameTypeDefaultDescription
publicKey*stringYour project's public key. Starts with pk_live_rl_ or pk_test_rl_.
endpointstringautoCustom ingest endpoint. Leave unset to use the default Reliable cloud endpoint.
sampleRatenumber1000–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.
debugbooleanfalseLog SDK internals to the console. Useful during integration; turn off in production.
captureErrorsbooleantrueListen for window 'error' and 'unhandledrejection' events. Manual captureException() works regardless of this flag.
captureVitalsbooleantrueCollect LCP, CLS, INP, FID, TTFB via the web-vitals library.
captureNetworkbooleantrueInstrument fetch and XHR. Failures are reported by default; enable captureAllRequests for successful requests too.
captureClicksbooleantrueRecord click coordinates and target selectors as breadcrumbs.
captureNavigationbooleantrueTrack route changes via history patching and popstate.
captureAllRequestsbooleanfalseWhen true, successful network requests are also reported. By default only 4xx/5xx and network errors are sent.
captureReplaybooleantrueRecord sessions with rrweb. The last 30 seconds are flushed alongside any error event.
captureConsolebooleantruePatch console.error and console.warn so soft failures that don't throw still surface as incidents. SDK's own internal logs are excluded.
releasestringBuild 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.
beforeSendfunctionInspect 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.