init() accepts a single configuration object. Call it once at application startup, before any other SDK method. Calling init() a second time is safe: it tears down the previous instance and starts a fresh one, which makes the SDK compatible with React Strict Mode and Next.js Fast Refresh.
Options
string
required
Your publishable API key. It is safe to include in browser code and is sent as the
X-API-Key header on every ingest request. Find or create keys under Settings → API Keys in the dashboard.string
default:"https://ingest.wendung.app/v1/events"
The ingest URL. Set it only if you route through your own CDN or run a self-hosted ingest service.Must use
https://. http:// is allowed only when the hostname is localhost, 127.0.0.1, or [::1].boolean
default:"false"
Enable SDK lifecycle logging in the browser console, prefixed with
[Wendung]. Intended for development; disable in production. See Debugging for the full list of messages. Warnings are emitted regardless of this setting.number
default:"5000"
Milliseconds between automatic event flushes. While collection is active, the SDK sends queued events each time the timer fires. The value is used as-is, without validation or clamping. Flushing also happens when
maxBatchSize is reached and on page hide, regardless of this interval.number
default:"50"
Maximum number of events in a single HTTP request. If the queue reaches this threshold before the flush timer fires, the SDK flushes immediately.Effective range is
1 to 100: fractional values are floored, values below 1 are treated as 1, and values above 100 (the ingest endpoint’s per-request limit) are capped with a one-time warning. Your configured value is not mutated.boolean | 'auto'
default:false
Automatic pageviews are off by default.
true records full pageviews only with granted consent. 'auto' records aggregate pageviews while consent is pending, then full pageviews after consent is granted. denied stops collection in either mode.When enabled, the SDK records the initial load and navigation through pushState, replaceState, and popstate. Aggregate collection ignores changes to only the query string or fragment. Pageviews count against your plan’s pageview allowance and appear in reports for registered sites. See page() for manual capture.'pending' | 'granted' | 'denied'
default:"granted"
The visitor’s analytics choice at startup.
pending allows only aggregate pageviews when trackPageviews is 'auto'; otherwise it stops collection. granted enables full analytics. denied stops all collection, discards queued events, and removes stored SDK identifiers.Pass the saved choice on every load. The SDK does not store it. Use setConsent() when the choice changes. See the consent guide for the setup and data limits.Errors
init() throws synchronously if the configuration is invalid:
Complete example
The snippet below shows every option. OnlyapiKey is required.
See also
- Quickstart: the minimal setup, in context.
- Debugging: what
debug: truelogs and how to interpret warnings. step()andidentify(): the methods you’ll call afterinit().