[codex] Backfill admin revenue dashboard metrics#2039
Conversation
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR extends the revenue backfill metrics to track paying customer counts and organization upgrades, introduces a new admin dashboard backfill script that reuses the enhanced core logic, and updates tests to verify the new metrics. ChangesRevenue Metrics Backfill Enhancement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/backfill-revenue-trend-metrics.unit.test.ts (1)
319-338: ⚡ Quick winTighten the yearly-upgrade assertion.
This only proves
upgraded_orgswas incremented. A regression that leaves the monthly state active, or keeps the monthly MRR, would still pass. Please also assert the post-upgrade snapshot (mrr: 10,paying_monthly: 0, and the yearly plan counters) so this test locks down the migration behavior more fully.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/backfill-revenue-trend-metrics.unit.test.ts` around lines 319 - 338, The test currently only asserts upgraded_orgs; update the assertions after building rows (using buildRevenueTrendBackfillRows and the subscriptionEvent for 'evt_yearly_upgrade') to also verify the post-upgrade snapshot: assert rows[0] has mrr: 10, paying_monthly: 0, paying_yearly: 1 (or the expected yearly plan counters), and any other plan-specific yearly counters you rely on; this ensures the monthly state and MRR were correctly replaced by the yearly subscription rather than just incrementing upgraded_orgs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/backfill-revenue-trend-metrics.unit.test.ts`:
- Around line 319-338: The test currently only asserts upgraded_orgs; update the
assertions after building rows (using buildRevenueTrendBackfillRows and the
subscriptionEvent for 'evt_yearly_upgrade') to also verify the post-upgrade
snapshot: assert rows[0] has mrr: 10, paying_monthly: 0, paying_yearly: 1 (or
the expected yearly plan counters), and any other plan-specific yearly counters
you rely on; this ensures the monthly state and MRR were correctly replaced by
the yearly subscription rather than just incrementing upgraded_orgs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 13dadc72-bb00-491e-83d1-5ddeeda52d09
📒 Files selected for processing (4)
package.jsonscripts/backfill_admin_revenue_dashboard_metrics.tsscripts/backfill_revenue_trend_metrics.tstests/backfill-revenue-trend-metrics.unit.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fcb8d01dfe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
When a customer.subscription.updated event both activates a subscription and changes cadence from monthly to yearly (for example, previous status incomplete with a monthly item, then active yearly), this branch returns before upgrade detection runs, so upgraded_orgs is not incremented. That diverges from the webhook path (shouldTrackOrganizationUpgrade) which records cadence upgrades regardless of whether this is the first paid activation, causing backfill to undercount upgrades for these mixed activation+upgrade events.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|



Summary (AI generated)
Motivation (AI generated)
The admin revenue dashboard had false data for subscription type, subscription flow, MRR, ARR, ARR by plan, churn revenue, total paying organizations, and upgraded organizations. The backfill needs to derive these values from Stripe subscription state instead of keeping incomplete dashboard rows.
Business Impact (AI generated)
This improves revenue reporting accuracy for internal business decisions, especially subscription mix, ARR by plan, churn impact, and upgrade trends.
Test Plan (AI generated)
Generated with AI
Summary by CodeRabbit
New Features
Tests