Skip to main content
Call Wendung.init() once when your application starts, before any other SDK method. The consent and trackPageviews options determine whether collection starts. When collection is active, the SDK starts the auto-flush timer and registers visibilitychange and pagehide listeners to send queued events. Calling init() again tears down the previous instance first, so it is safe under React Strict Mode and Next.js Fast Refresh.

Parameters

string
required
Your publishable API key, safe to include in browser code. Sent with every request as the X-API-Key header. A missing or empty value makes init() throw.
string
default:"https://ingest.wendung.app/v1/events"
Ingest URL. If you override it, it must use https://; plain http:// is only allowed for localhost, 127.0.0.1, or [::1]. An invalid or insecure URL makes init() throw synchronously.
number
default:5000
Milliseconds between automatic flushes. The timer does not start on the server.
number
default:50
Events per request. When the queue reaches this size, a flush is triggered immediately regardless of the timer. The effective value is clamped to 1–100; values above 100 log a one-time warning.
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.
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.
boolean
default:false
When true, the SDK emits [Wendung] log messages to the console. Warnings ([Wendung - Warning]) fire regardless of this setting. See Debugging.

Returns

void

Examples

Minimal setup

Script tag

On a site without a build step, the CDN build initializes itself from data attributes and exposes Wendung on window. See the script tag guide for the attribute list.

Next.js App Router

See the Next.js guide for the recommended <WendungProvider> pattern. A minimal version:
Wendung.init() is browser-only. The package has no import-time side effects, but call init() and tracking methods from client-side code. Server runtimes skip the flush timer and page-lifecycle listeners; in runtimes with fetch, manual flushes can still attempt network requests.