They never arrive: the function returned first
The server SDK batches events and sends them in the background. A serverless platform — Vercel, Netlify, AWS Lambda, Cloudflare Workers — may freeze the function as soon as the response is sent, with the batch still in memory. Nothing is logged, because nothing failed.
Fix: await analytics.flush() before every return.
analytics.track('checkout_completed', { plan: 'pro' }, { userId });
await analytics.flush();
return Response.json({ ok: true });
In a long-running server, call await analytics.shutdown() on SIGTERM so a deploy does not cut
off the last batch (Node.js and serverless).
They never arrive: no person on the call
An event with neither userId nor anonymousId is dropped, with an error in your log. Check the
log for a [togo] line, and pass the person on every call
(Send events from your server for the right person).
They arrive as somebody else
Server events credited to a different person than the browser’s — or each user counted twice —
mean the two sides use different ids. Pass the same userId on the server as the browser
passes to identify(): your database’s user id, not an email on one side and an id on the other.
They arrive outside the visit
A server event without sessionId belongs to the right person but no session. Forward the
browser’s getSessionId() if you want it in the visit.