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, Azure Functions — may freeze the function as soon as the response is sent,
with the batch still in memory. Nothing fails, so no error is logged. It works when you run it
locally, because your machine never freezes the process and the SDK’s timer sends the batch. Where
the platform’s environment variable is set, the SDK logs one warning once its timer has sent events
twice with no flush() between: [togo] events were sent twice by the 10-second timer …. That
warning means this problem.
Fix: wrap the handler in analytics.withFlush(), which sends before it returns, also when it
throws:
export const POST = analytics.withFlush(async (request: Request) => {
analytics.track('checkout_completed', { plan: 'pro' }, { userId });
return Response.json({ ok: true });
});
Or await analytics.flush() before every return. On Azure Functions with the .NET SDK, call
builder.UseTogo() (.NET and Azure Functions).
Check the fix after you deploy, not locally: trigger the handler and watch Events → Live View → Production in the dashboard.
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.