bridge
bridge
¶
Bridge between the internal event bus and the analytics client.
The internal bus (:mod:openjarvis.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:
SessionAggregatorso 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_usedfires 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.)
Classes¶
EventBridge
¶
EventBridge(bus: 'EventBus', client: 'AnalyticsClient', aggregator: SessionAggregator | None = None)
Subscribes to the internal bus and routes to the analytics client.
Source code in src/openjarvis/analytics/bridge.py
Functions¶
start
¶
Attach subscribers to the bus. Idempotent.
Source code in src/openjarvis/analytics/bridge.py
stop
¶
Detach subscribers and flush buffered sessions.