vTilt
Why vTiltHow It WorksFeaturesFAQDocs
Docs / Context & shutdown
Quick startEvent forwarding
MCP server
Guides
OverviewAuthenticationOAuthAgent skills (prompts)AI intelligenceGoogle Ads
Client setup
CursorClaude DesktopVS CodeCodex
Realtime
Debug ViewRealtime Dashboard
Integration guides
Frontend frameworks
Next.jsNuxt.jsVue.jsReactReact RouterRemixGatsbySvelte / SvelteKitAstroAngularTanStack StartDocusaurus
Backend frameworks
NestJSHonoCloudflare WorkersDjangoFlaskLaravelPhoenixRuby on Rails
Backend languages
PythonPHPRubyElixirGoJava.NET / C#Rust
Stack guides
Vue + PHP
SDK
Browser SDK
InstallScript bundlesEvent trackingAutocaptureIdentify & aliasWeb VitalsSession recordingChat widgetFeature readinessRemote configurationReverse proxyDebug logging
Node SDK
Install & setupCapture, identify & aliasContext & shutdown

Documentation

vTilt
Quick startEvent forwarding

MCP server

Realtime

Debug ViewRealtime Dashboard

Integration guides

SDK

Install & setupCapture, identify & aliasContext & shutdown
DocsNode SDKContext & shutdown

Context & shutdown

Set per-request identity once with setContext() so capture() calls stay clean. Always shutdown() before the process exits.

Set per-request identity with setContext() so you don't repeat distinctId/anonymousId on every capture(). Always call shutdown() before process exit to flush queued events.

#setContext / clearContext

Set distinctId and optional anonymousId from session or cookie at the start of a request; clear at the end.

vtilt.setContext({
  distinctId: req.user?.id,
  anonymousId: req.cookies?.vt_anon,
})
vtilt.capture({ event: 'page_view', properties: { path: req.path } })
vtilt.clearContext()
typescript

In Express / Fastify, wrap this in middleware so every handler downstream inherits the identity. In Next.js route handlers, set context at the top of the handler, run your logic, and call clearContext() in a finally block.

#flush & shutdown

flush() sends the queue immediately. shutdown() flushes and stops the timer (use before process exit).

await vtilt.flush() // optional: send now
await vtilt.shutdown(30_000) // flush + stop, 30s timeout
typescript
MethodWhen to callNotes
flush()Right before a known boundary (e.g. webhook response, lambda return) where queued events would otherwise be lost.Idempotent. Safe to call multiple times.
shutdown(timeoutMs)Process termination — SIGINT, SIGTERM, lambda extension shutdown, container stop.Stops the internal flush timer. Subsequent calls are no-ops.

Important

Important: Forgetting shutdown() in serverless / edge runtimes is the #1 reason events go missing. The default flush interval is generous; without shutdown, the last interval's worth of events disappear with the runtime.

PreviousCapture, identify & aliasNode SDK

On this page

  • setContext / clearContext
  • flush & shutdown