Skip to main content

Track

track() returns at once. It mints an id of the form sdk-js:<uuid> when you do not supply one, queues the event, and keeps the id across every retry, so a flaky network never double-counts. It validates userId, name, value and timestamp synchronously and throws invalid_input on a bad argument. When the queue holds eventQueueLimit events (1,000 by default), it returns { queued: false } and reports queue_full through onError; nothing earlier is evicted.

Flush

The queue is in memory and not durable. Hand flush() to your runtime’s lifecycle:
A flush also happens on its own every eventFlushIntervalMs (5 seconds) and whenever eventFlushSize (100) events are queued. flush() sends batches, retries transient failures with backoff under the same ids up to eventMaxAttempts (5), honours Retry-After, drops items the API rejects (reported as event_rejected), and resolves with a summary rather than throwing:
trackNow(event) sends one event immediately and returns its item result, for the rare case that must not wait.

Identify

Identify is an ordered mutation: it is sent at once, never queued behind events, retried only on transient failures, and awaited. Call it from your server when a user logs in, and await it before the next decide that should see the merged profile. It throws a CuriousError: identity_conflict on a 409, authentication_error on a bad key. See Identify users.

Declare

The same camelCase declaration as decide()’s declaration, without a user. It throws a CuriousError on failure, so a deploy step that declares fails loudly. See Declare ahead of traffic.