Configuration
Client options for createClient()
createClient
import { createClient } from '@realanalytics/sdk'
const analytics = createClient({
publicKey: 'pk_live_xxx',
endpoint: 'https://ingest.realanalytics.dev',
autocapture: true,
retry: {
maxRetries: 3,
baseDelay: 1000,
maxDelay: 30000,
},
onError: (error, events) => {
console.error(error.message, events.length)
},
onSuccess: (events) => {
console.log('sent', events.length)
},
})Option reference
| Option | Type | Default | Notes |
|---|---|---|---|
publicKey | string | Required | Your project public key |
endpoint | string | https://ingest.realanalytics.dev | Custom ingest URL |
autocapture | boolean | AutocaptureOptions | true | Enable all or selected built-in tracking |
retry | Partial<RetryConfig> | 3 / 1000 / 30000 | Retries 429/5xx/network failures |
onError | (error, events) => void | None | Called after final retry fails |
onSuccess | (events) => void | None | Called when a batch is accepted |
Autocapture options
const analytics = createClient({
publicKey: 'pk_live_xxx',
autocapture: {
pageviews: true,
pageleave: true,
clicks: true,
scrollDepth: true,
forms: true,
errors: true,
webVitals: true,
outboundLinks: true,
fileDownloads: true,
rageClicks: true,
},
})Retry behavior
- 429: uses
Retry-Afterheader when present - 5xx/network errors: exponential backoff with jitter
- 4xx (except 429): no retry