Skip to main content

Node — Capture

Track events from the server with signal.capture(options). Pass sessionId and windowId from request headers to correlate with the client session.

capture(options)

OptionTypeRequiredDescription
distinctIdstringyesUser identifier
eventstringyesEvent name
propertiesRecord<string, JsonType>noEvent properties
timestampDatenoWhen the event occurred (default: now)
groupsRecord<string, string>noGroups the user belongs to (e.g. { company: 'acme' })
sessionIdstringnoFrom x-signal-session-id header for client correlation
windowIdstringnoFrom x-signal-window-id header for client correlation

Example

const { sessionId, windowId, distinctId } = getSessionInfo(req);

signal.capture({
  distinctId: distinctId || userId,
  event: 'order_created',
  properties: { orderId, amount },
  sessionId,
  windowId,
});
Events are queued and sent in batches. All methods are synchronous except flush and shutdown.

See also