Menu

#505 fix(tray): match PostHog daily_usage to dashboard stats, make sends retry-safe

closed
nobody
None
2026-07-20
2026-07-20
Anonymous
No

Originally created by: adityaharishch

Summary

  • daily_usage now sends focus_hours, coding_hours, logged_hours, and drafts_count computed identically to the dashboard's Today card (OverviewPanel.tsx) — previously focus_hours read a different field than the UI shows, and there was no coding_hours at all.
  • capture() now reports success/failure; the app_installed/daily_usage "sent" bookkeeping only advances on a confirmed PostHog 2xx, so a network error, timeout, or rejected request retries the same pending event (never a fabricated or skipped one) instead of losing it — retry survives a tray restart since the bookkeeping is persisted to ~/.meridian/analytics_state.json.
  • Added a single-flight guard (TICK_IN_FLIGHT) around maybe_send_daily_tick — the poll loop spawns this call every ~60s tick without awaiting the previous one, so without the guard a slow request could theoretically let two calls overlap and double-send the same day's event.
  • Removed the person_identified event and identify_signed_in_email — redundant, since the signed-in email already rides along on every app_installed/daily_usage capture via base_properties's $set.email. Dropped the now-unused app: AppHandle param from the save_account_email command.

Every daily_usage event carries a date property naming the exact day it reports on (the day that just closed), so a retry is always correctly labeled.

Test plan

  • [x] cargo fmt --check
  • [x] cargo clippy --all-targets -- -D warnings
  • [x] cargo test (125 passed, including day_rollover_tests)
  • [x] Manually sent one real daily_usage event to the PostHog project (via a temporary, since-removed test) and confirmed in PostHog: event landed with correct focus_hours/coding_hours/logged_hours/drafts_count matching the dashboard, and the person profile resolved to the signed-in email via $set

Related

Tickets: #506
Tickets: #508

Discussion

  • Anonymous

    Anonymous - 2026-07-20

    Originally posted by: coderabbitai[bot]

    [!IMPORTANT]

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.


    ⚙️ Run configuration

    Configuration used: Organization UI

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: e4e10e91-379a-4a87-a6ae-150ab985d3be

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:
    - [ ] 🔍 Trigger review

    ✨ Finishing Touches
    🧪 Generate unit tests (beta) - [ ] Create PR with unit tests - [ ] Commit unit tests in branch `feat/posthog-daily-usage-dashboard-match`

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

    Comment @coderabbitai help to get the list of available commands.

     
  • Anonymous

    Anonymous - 2026-07-20

    Ticket changed by: adityaharishch

    • status: open --> closed
     

Log in to post a comment.