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
Originally posted by: coderabbitai[bot]
✨ 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 helpto get the list of available commands.Ticket changed by: adityaharishch