Skip to content

fix(admin): devpass timeseries 404 + legacy sub history - #2223

Merged
smakosh merged 3 commits into
mainfrom
fix/admin-devpass-timeseries-and-legacy-subs
May 9, 2026
Merged

smakosh merged 3 commits into
mainfrom
fix/admin-devpass-timeseries-and-legacy-subs

Conversation

@smakosh

@smakosh smakosh commented May 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Two bugs in the admin DevPass page:

  • Timeseries chart 404'd with Subscriber not found. Hono matches routes in registration order, so /devpass/{orgId} (registered first) was capturing /devpass/timeseries as orgId="timeseries" and the org lookup returned 404. Moved the timeseries handler registration above the {orgId} handler.
  • Subscribers from before the subscription_* → dev_plan_* rename showed Subscription history (0) even when active (e.g. subscription_start row with $29 / Pro subscription started). The detail and listing queries only matched dev_plan_* types. Now also include legacy subscription_start/cancel/end rows so the history populates and subscribedSince anchors to the correct first start.

Test plan

  • Open /devpass in admin — chart loads (no Failed to load DevPass timeseries banner).
  • Click into a subscriber whose only DB row is subscription_start (e.g. hxJxePnwiH0kXHoVZMKb) — Subscription history shows that row, "Subscribed" date populated.
  • Click into a modern subscriber with dev_plan_* rows — history still shows them; no regressions.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed DevPass timeseries routing to prevent request conflicts.
    • Admin DevPass metrics now recognize legacy and current subscription transactions for accurate subscriber counts.
    • Subscriber history queries expanded to include legacy transaction types for complete activity visibility.
    • Timeseries revenue/cost/margin calculations updated to avoid counting legacy org Pro records as DevPass revenue.

Review Change Stack

The DevPass timeseries chart 404'd because Hono matches routes in
registration order: `/devpass/{orgId}` was declared before
`/devpass/timeseries`, so the literal path was captured as
`orgId="timeseries"` and the org lookup returned 404.

Subscribers from before the `subscription_*` → `dev_plan_*` rename
also showed an empty Subscription history because the detail and
listing queries only matched `dev_plan_*` types. Include the legacy
`subscription_start/cancel/end` rows for the same orgs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1dbf5b81-a58e-40c9-a1d8-df25aae4e760

📥 Commits

Reviewing files that changed from the base of the PR and between 021465d and 8819c8e.

⛔ Files ignored due to path filters (3)
  • apps/code/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • apps/playground/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • apps/ui/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
📒 Files selected for processing (1)
  • apps/api/src/routes/admin.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/routes/admin.ts

Walkthrough

The PR updates DevPass admin metrics endpoints to include legacy subscription_* transaction types alongside dev_plan_* types. The /devpass/timeseries route is declared earlier with new tx-type constants; subscriber-list KPI, subscriber detail first-start lookup, and transaction-history filters are broadened to include legacy rows, with legacy rows counted in timeseries only for personal orgs.

Changes

DevPass Admin Metrics Legacy Support

Layer / File(s) Summary
Data Types and Timeseries Route Setup
apps/api/src/routes/admin.ts
Timeseries route moved earlier; DEV_PLAN_TX_TYPES and LEGACY_DEV_PLAN_TX_TYPES constants added; range resolution considers legacy subscription_start for personal orgs and daily revenue/cost/margin aggregation includes legacy rows under the personal-org guard.
Subscriber KPI Start Date Anchor
apps/api/src/routes/admin.ts
Subscriber-list subscribedSince / firstStart aggregation now finds earliest createdAt across dev_plan_start and legacy subscription_start.
Subscriber Detail firstStartRow
apps/api/src/routes/admin.ts
Subscriber detail firstStartRow lookup changed to use type IN [dev_plan_start, subscription_start].
Subscriber Detail Transaction Lookups
apps/api/src/routes/admin.ts
Subscriber transaction-history allowed type list expanded to include subscription_start, subscription_cancel, and subscription_end in addition to existing dev_plan_* types.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the two main fixes: resolving the devpass timeseries 404 error and adding legacy subscription history support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/admin-devpass-timeseries-and-legacy-subs

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@apps/api/src/routes/admin.ts`:
- Around line 8087-8181: The timeseries handler (getDevpassTimeseries) only
considers dev_plan_* transactions (DEV_PLAN_TX_TYPES, the initial MIN(...) query
that anchors startDate, the revenuePerDay filter, and the EXISTS check in
costPerDay) so legacy subscription_* rows are omitted; update the logic to treat
pre-rename subscription rows as equivalent by expanding DEV_PLAN_TX_TYPES (or
adding a new set) to include 'subscription_start' (and any related subscription
types used elsewhere), use that set in the initial MIN(...) query that computes
oldest startDate, use it in the revenuePerDay where clause (inArray(...)), and
update the EXISTS subquery in the costPerDay where clause to check for either
dev_plan_start OR subscription_start (or to use the same set) so legacy-only
subscribers are included in the default range, revenue, and "ever had DevPass"
org check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e8de9434-58b6-4d3a-8972-4f8da53febc3

📥 Commits

Reviewing files that changed from the base of the PR and between d77790f and 021465d.

⛔ Files ignored due to path filters (1)
  • ee/admin/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
📒 Files selected for processing (1)
  • apps/api/src/routes/admin.ts

Comment thread apps/api/src/routes/admin.ts
@smakosh smakosh self-assigned this May 9, 2026
Anchor the default startDate, the revenuePerDay filter, and the cost
EXISTS check on `dev_plan_*` OR (`subscription_*` AND personal org).
Without this, pre-rename DevPass subscribers were missing from the
chart's range, revenue total, and "ever had DevPass" cost cohort.

Scoped to personal orgs because `subscription_*` types are still
written today by non-personal org Pro subs in stripe.ts; including
them unconditionally would over-count org Pro revenue.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@smakosh
smakosh added this pull request to the merge queue May 9, 2026
Merged via the queue into main with commit 9639ba6 May 9, 2026
13 checks passed
@smakosh
smakosh deleted the fix/admin-devpass-timeseries-and-legacy-subs branch May 9, 2026 12:38
@coderabbitai coderabbitai Bot mentioned this pull request Jul 10, 2026
2 of 3 tasks
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