Skip to content

fix(analytics): send session_start once per process per day - #291

Merged
mountainowl merged 3 commits into
mainfrom
bugfix/session-start-once
Oct 22, 2026
Merged

mountainowl merged 3 commits into
mainfrom
bugfix/session-start-once

Conversation

@mountainowl

Copy link
Copy Markdown
Owner

Requested by Ajay Singh · project thread

What changed

  • Before: bubo service calls poll() in one process every service_poll_interval_seconds, which defaults to 900. Each poll sent session_start, so an idle install sent about 96 liveness events a day, and the event name suggested a human session that wasn't there.
  • After: session_start is sent once per process per UTC day. A long-running idle service still checks in daily, so it keeps showing as alive. run-once, the Action and CLI polls are separate processes, so each of them still sends one.
  • How:
    • record_session_start remembers the UTC day it last sent under a lock.
    • It only marks the day once analytics consent is on, so turning consent on later in the same process still sends that day's event.

Verification

  • tests/test_session_start.py drives the real poll() with an idle config and counts the queued PostHog events.
  • On main, 3 polls sent 3 events and 4 polls across 2 days sent 4. With this change they send 1 and 2. The third test checks that a poll with consent off doesn't use up the day; it passes on both.
  • The full suite on Python 3.14 gives 1930 passed. The only failures are the 2 container-only test_ui_export failures, which also fail on main.
  • ruff check and cz check pass.

Generated by Claude Code

The service calls poll() in one process every few minutes, and each poll
sent session_start, so an idle install produced about 96 liveness events
a day. It is now sent once per process per UTC day, which still shows a
long-running idle service as alive. A day is not spent while analytics
consent is off.
@mountainowl mountainowl self-assigned this Oct 20, 2026
Comment thread src/bubo/analytics.py Fixed
CodeQL reported the module-level day as an unused global because it was
only reassigned through a global statement.
@mountainowl
mountainowl merged commit e2de7f3 into main Oct 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants