Skip to content

bridge

diapason.analytics.bridge

Bridge between the internal event bus and the analytics client.

The internal bus (:mod:diapason.core.events) carries dozens of event types — most are too granular or too internal to ship as analytics. The bridge:

  • Subscribes to a focused subset of EventTypes.
  • Aggregates high-frequency events (INFERENCE_END, TOOL_CALL_END) via :class:SessionAggregator so we only ship one event per chat session, not one per inference.
  • Forwards user-meaningful low-frequency events directly (FEEDBACK_RECEIVED, SECURITY_ALERT).
  • Tracks first-uses in-process so tool_first_used fires once per (anon_id, tool) per process. (First-use across processes is not promised — that would require disk state and isn't worth the complexity for v1.)

EventBridge

Subscribes to the internal bus and routes to the analytics client.

start()

Attach subscribers to the bus. Idempotent.

stop()

Detach subscribers and flush buffered sessions.