Sessions

A session is a time-bounded grouping of events from a single user visit. Every event, error, and page view tied to the same sessionId appears together in the dashboard's session timeline.

How sessions work

You supply the sessionId at init() time. The SDK attaches it to every subsequent event automatically.

import { init } from "@emit-vision/sdk-js";
 
init({
  apiKey: process.env.NEXT_PUBLIC_EMIT_VISION_API_KEY,
  sessionId: crypto.randomUUID(), // one ID per browser tab/visit
});

Generate a fresh ID when:

  • The user opens a new tab
  • A long period of inactivity ends (e.g., after 30 minutes idle)
  • The user logs out and back in

A good rule of thumb: generate sessionId once when your app mounts and store it in sessionStorage (not localStorage). sessionStorage is scoped to the tab and cleared when the tab closes, which naturally gives you one session per visit.

What you see in the dashboard

The Sessions tab shows:

  • Session timeline — events in chronological order with timestamps
  • Duration — total time from first to last event
  • Error count — how many errors occurred in the session
  • User — the identified user if identify() was called
  • Entry point — the first page view event

Sessions in the React and Next.js SDKs

When using EmitVisionProvider, pass sessionId as a prop:

<EmitVisionProvider
  apiKey={process.env.NEXT_PUBLIC_EMIT_VISION_API_KEY}
  sessionId={
    sessionStorage.getItem("emit-session-id") ??
    (() => {
      const id = crypto.randomUUID();
      sessionStorage.setItem("emit-session-id", id);
      return id;
    })()
  }
>
  <App />
</EmitVisionProvider>

Node.js

The Node SDK does not auto-generate session IDs. Only set one if your server process has a real session concept (e.g., a long-running WebSocket connection):

import { init } from "@emit-vision/sdk-node";
 
init({
  apiKey: process.env.EMIT_VISION_API_KEY,
  // sessionId omitted for stateless HTTP servers
});

For HTTP request context (IP, URL, user agent), use emitVisionRequestContext() middleware instead.