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. Handflush() to your runtime’s lifecycle:
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
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
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.