Wendung.flush() when you want a send attempt to settle before a specific action, such as navigating to an external URL or asserting in a test. Each call sends at most one batch (up to the effective batch size); events beyond that stay queued for later flushes. Normally you never need this: the SDK flushes automatically on a timer, on batch fill, and on page hide or unload.
Throws if called before init().
Parameters
None.Returns
Promise<void>
Resolves when the HTTP request has settled; it never rejects. Resolves immediately without a network request if the queue is empty or
fetch is unavailable.Error handling
- 4xx responses: the batch is dropped permanently and a
[Wendung - Warning]is logged. These typically indicate a malformed payload or invalid API key. - 5xx responses and network errors: the batch is re-queued at the front with the same
batchIdand retried on the next flush. There is no backoff and no retry cap.
Examples
Flush before external navigation
Flush in a test
flush() sends one batch per call. To drain the entire queue in one call, use sendBeacon(), which is also the better choice in unload handlers because it sends with keepalive.