---
title: "Server events are missing"
description: "Events sent from a serverless function or API route never arrive, or arrive as a different person. The usual two causes."
canonical: "https://www.togohq.ai/docs/troubleshooting/server-events"
applies_to: "@togohq/sdk-node 1.x"
updated: "2026-11-03T00:00:00Z"
---

# Server events are missing

Events sent from a serverless function or API route never arrive, or arrive as a different person. The usual two causes.

## 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.

```ts
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](/docs/node)).

## 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](/docs/guides/server-events)).

## 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.
