Yavio

Events

Event types, session semantics, and what gets captured automatically

Everything in Yavio starts with events. An event is a single data point representing something that happened — a tool was called, a widget was rendered, a user converted. All events are stored in a single ClickHouse events table and share a common set of fields.

Common Event Fields

Every event carries these fields:

FieldDescription
event_idUnique identifier (UUID), used for deduplication
event_typeThe type of event (e.g., tool_call, step, widget_render)
trace_idCorrelation key linking server and widget events for the same tool invocation
session_idRepresents a single MCP connection (ses_ prefix)
timestampWhen the event occurred
platformWhich AI platform initiated the action (e.g., chatgpt, claude, cursor)
sourceWhether the event originated from server or widget

Session Semantics

A session_id represents a single MCP connection, derived from the MCP initialize handshake. Both server and widget events share the same session ID — the server propagates it to the widget via the configuration injection. Multiple traces (tool invocations) can share the same session.

Server-Side Auto-Captured Events

These events are captured automatically by the withYavio() proxy without any code changes:

tool_call

Fires on every tool invocation. This is the core event that powers most analytics.

FieldDescription
event_nameTool name
latency_msExecution time in milliseconds
statussuccess or error
error_categoryClassification: auth, validation, timeout, rate_limit, server, unknown
is_retry1 if the preceding event was a tool_call with the same name
input_keysParameter key names (JSON)
input_typesKey-to-type mapping (JSON)
tokens_in / tokens_outEstimated prompt and completion tokens
country_codeISO 3166-1 alpha-2 from CDN headers

connection

Fires on transport connect and disconnect. Captures protocol_version, client_name, client_version, and connection_duration_ms.

resource_access

Fires on resources/read and resources/list interception. Tracks which resources are accessed and how often.

prompt_usage

Fires on prompts/list and prompts/get interception. Records prompt name and argument patterns.

sampling_call

Fires on sampling/createMessage interception (server-to-client). Captures latency and token counts.

elicitation

Fires on elicitation/requestInput interception. Tracks response latency and field schema.

widget_response

Fires when the server-side proxy detects a widget response in a tool call return value. This is the server-side counterpart to the widget's widget_render event.

tool_discovery

Fires on tools/list requests. Tracks how often clients request the tool catalog, which tools are listed, and client capabilities.

Server-Side Explicit Events

These events require developer code using ctx.yavio within a tool handler:

step

Funnel progression point. Called via ctx.yavio.step("step_name"). Each step receives an auto-incrementing step_sequence for deterministic ordering.

track

Generic custom event. Called via ctx.yavio.track("event_name", properties). An escape hatch for anything not auto-captured.

conversion

Revenue attribution event. Called via ctx.yavio.conversion("name", { value, currency }). Powers ROI analytics.

identify

User identification event. Called via ctx.yavio.identify(userId, traits). Ties the session to a known user.

Widget Auto-Captured Events

These events are captured automatically by the useYavio() React hook in ChatGPT widgets:

EventTrigger
widget_renderFirst useYavio() initialization — captures viewport, device info, network type
widget_errorUnhandled JS error or promise rejection
widget_visibilityWidget enters or exits viewport (IntersectionObserver)
widget_clickClick or tap event — captures target element and click count
widget_scrollScroll within widget container — captures max scroll depth
widget_form_fieldFocus and blur of form inputs — captures time spent, not values
widget_form_submitForm submission attempt — captures success/error status
widget_link_clickClick on anchor or external link — captures destination domain
widget_navigationView or route change within multi-step widget
widget_focusWidget iframe gains or loses focus
widget_performancePerformanceObserver data on widget load (time to interactive, first paint)
widget_rage_click3+ clicks within 500ms on the same element

Widget Explicit Events

The widget SDK also exposes step(), track(), conversion(), and identify() via the useYavio() hook. These share the same schema as server-side explicit events but are sent with source: "widget".

On this page