Skip to main content
Call Wendung.sendBeacon() to send everything in the queue at once. It splits the queue into batches and sends them all in parallel as fetch requests with keepalive: true, which lets the browser finish the requests even while the page is unloading. Despite the name, it does not use navigator.sendBeacon; requests carry the same JSON body and headers (including X-API-Key) as flush(). The SDK already calls this automatically on visibilitychange (when the page becomes hidden) and pagehide. Call it manually only in a custom unload flow, or when you want to drain the whole queue rather than the single batch flush() sends. Throws if called before init().

Parameters

None.

Returns

Promise<void>
Resolves after all batch requests have settled; it never rejects. Failed batches follow the normal retry rules. Resolves immediately if the queue is empty, or if fetch is unavailable (events are retained). During a real unload the page may terminate before the promise resolves; keepalive lets the requests themselves complete regardless.

Examples

Draining the queue before teardown