Server SDKv1.0.0MIT License
Node.js SDK
acai-node is the server-side Node.js SDK. It runs only in Node environments — if loaded in a browser it logs a warning and exits.
Server-only. Do not bundle acai-node into browser builds. Use acai-js or @acai/analytics-browser for client-side tracking.
Installation
Initialise
Track events
Always call client.flush() before your process exits to ensure all buffered events are sent.
Identify users
Middleware
Config reference
| Option | Type | Default | Description |
|---|---|---|---|
serverUrl | string | — | Your collector endpoint. |
logLevel | number | 0 | 0=None · 1=Error · 2=Warn · 3=Verbose |
debug | boolean | false | Shorthand for verbose logging. |
maxCachedEvents | number | 16000 | Max buffered events before forced flush. |
uploadIntervalInSec | number | 0 | Auto-flush interval (0 = next tick). |
retryTimeouts | number[] | [100, 100, 200…] | Retry delay schedule in ms. |
requestTimeoutMillis | number | 10000 | Per-request HTTP timeout. |
optOut | boolean | false | Disable all event sending. |
minIdLength | number | null | Minimum length for user/device IDs. |
