aggregator
diapason.analytics.aggregator
¶
Per-session aggregator — turns many internal events into one analytics event.
Without this, a single chat (50 inferences, 10 tool calls) would
produce ~60 PostHog events. With it, the same chat produces one
chat_session_ended event with summary properties — a ~60× reduction
that keeps per-DAU event volume in the target zone (~40 events/day).
The aggregator buffers per-session counts in memory, emits on explicit session end, and also emits stale sessions on a background flusher thread (so abandoned sessions don't accumulate forever).