fix(telemetry): coalesce session_started/session_ended per daemon boot - #23
Merged
Merged
Conversation
Previously the daemon emitted root.session_started and root.session_ended once per shim→daemon connection. Every MCP client subprocess restart (Cursor MCP reloads, IDE reboots, tool-list refreshes) generated a full event pair, so a single active user could easily produce 20+ pairs a day and drown the signal in PostHog. Now: - root.session_started fires once per daemon lifetime, on the FIRST shim registration, with the first client's name/version. - root.session_ended fires once per daemon lifetime, inside the shutdown path, only if at least one session existed, with duration measured from the first session_started. - Per-shim tab-group broadcasts, session bookkeeping, and rate-limiter wiring stay untouched — only the PostHog event volume is capped. root.daemon_shutdown.total_sessions still records real shim-connection volume, so analytics fidelity is preserved.
whysosaket
added a commit
that referenced
this pull request
Aug 31, 2026
#23) Previously the daemon emitted root.session_started and root.session_ended once per shim→daemon connection. Every MCP client subprocess restart (Cursor MCP reloads, IDE reboots, tool-list refreshes) generated a full event pair, so a single active user could easily produce 20+ pairs a day and drown the signal in PostHog. Now: - root.session_started fires once per daemon lifetime, on the FIRST shim registration, with the first client's name/version. - root.session_ended fires once per daemon lifetime, inside the shutdown path, only if at least one session existed, with duration measured from the first session_started. - Per-shim tab-group broadcasts, session bookkeeping, and rate-limiter wiring stay untouched — only the PostHog event volume is capped. root.daemon_shutdown.total_sessions still records real shim-connection volume, so analytics fidelity is preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
root.session_started/root.session_endedused to fire once per shim→daemon connection; MCP host subprocess churn (Cursor MCP restarts, IDE reloads, tool-list refreshes) meant a single active user could easily generate 20+ event pairs a day, drowning the signal in PostHog.session_startedon the first shim registration,session_endedin the shutdown path, only if a session actually existed.root.daemon_shutdown.total_sessionsstill records the true shim-connection count.Test plan
pnpm --filter @browserops/bridge exec tsc --noEmitcleanpnpm --filter @browserops/bridge exec vitest run src/telemetry/— 36 tests pass (redact allowlist unchanged, schema stable)BROWSEROPS_POSTHOG_HOST=<local-capture> browserops start, launch two MCP clients, restart both a few times,browserops stop— expect exactly oneroot.session_started+ oneroot.session_endedbracketed byroot.daemon_started/root.daemon_shutdown, withtotal_sessions >= 4on shutdown.browserops stop— expect zero session events.