Skip to content

feat(admin): chart registration sources - #2963

Merged
WcaleNieWolny merged 9 commits into
mainfrom
wolny/admin-registration-source-trend
Aug 9, 2026
Merged

feat(admin): chart registration sources#2963
WcaleNieWolny merged 9 commits into
mainfrom
wolny/admin-registration-source-trend

Conversation

@WcaleNieWolny

@WcaleNieWolny WcaleNieWolny commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • add an auth.users-based daily registration-source trend to admin onboarding statistics
  • classify accounts as normal registration, organization invite, or without profile
  • render the three mutually exclusive categories as a stacked vertical bar chart with daily counts and percentages

Test plan

  • bun lint
  • bun lint:backend
  • bun run lint:deadcode
  • bun typecheck
  • bun test:unit
  • bunx vitest run tests/admin-stats.test.ts -t "returns every auth registration in exactly one daily profile bucket"
  • CHOKIDAR_USEPOLLING=true bun run build

Summary by CodeRabbit

  • New Features

    • Added a “Registrations by source” chart to the admin dashboard.
    • View daily registration trends grouped by standard registrations, organization invitations, and accounts without profiles.
    • Chart supports stacked visualization, loading and empty states, localized labels, responsive layout, and dark mode.
    • Added English translations for the new chart and registration categories.
  • Tests

    • Added coverage for chart rendering, tooltips, localization, and registration-source analytics.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 49254c56-4dc4-484b-bfd0-fec2c2890653

📥 Commits

Reviewing files that changed from the base of the PR and between 18ec354 and 96449f9.

📒 Files selected for processing (5)
  • docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md
  • src/components/admin/AdminStackedBarChart.vue
  • src/pages/admin/dashboard/users.vue
  • tests/admin-stacked-bar-chart.unit.test.ts
  • tests/admin-stats.test.ts
📝 Walkthrough

Walkthrough

Adds daily registration-source analytics to the admin onboarding response and users dashboard. The change classifies accounts into three sources, zero-fills dates, adds a reusable stacked-bar chart, translations, integration fixtures, and frontend/backend tests.

Changes

Registration source trend

Layer / File(s) Summary
Backend trend aggregation
supabase/functions/_backend/utils/pg.ts, tests/admin-stats.test.ts, docs/superpowers/specs/..., docs/superpowers/plans/...
The onboarding response now includes daily normal, invite, and profile-less registration counts. Queries classify auth.users records and apply date boundaries. Tests cover classification, date grouping, exclusive end dates, and cleanup.
Stacked chart component
src/components/admin/AdminStackedBarChart.vue, src/components/admin/adminStackedBarChart.ts, tests/admin-stacked-bar-chart.unit.test.ts, docs/superpowers/specs/..., docs/superpowers/plans/...
Reusable helpers and a Vue component build themed stacked bar charts with localized dates, counts, percentages, loading states, and empty-series handling.
Dashboard registration-source chart
src/pages/admin/dashboard/users.vue, messages/en.json, tests/admin-registration-source-dashboard.unit.test.ts, docs/superpowers/plans/...
The dashboard maps the three trend categories into chart series and renders a translated chart card. Source wiring and English labels have unit coverage.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AdminDashboard
  participant getAdminOnboardingFunnel
  participant auth_users
  participant public_users
  participant AdminStackedBarChart
  AdminDashboard->>getAdminOnboardingFunnel: request onboarding metrics
  getAdminOnboardingFunnel->>auth_users: read account creation dates
  getAdminOnboardingFunnel->>public_users: match profiles and invite status
  getAdminOnboardingFunnel-->>AdminDashboard: return registration_source_trend
  AdminDashboard->>AdminStackedBarChart: provide three chart series
  AdminStackedBarChart-->>AdminDashboard: render stacked daily chart
Loading

Possibly related PRs

  • Cap-go/capgo.app#2690: Modifies the same admin onboarding funnel response and users dashboard.
  • Cap-go/capgo.app#2883: Modifies the onboarding funnel, registration trend data, users dashboard, and admin statistics tests.

Suggested labels: codex

Suggested reviewers: riderx

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding an admin chart for registration sources.
Description check ✅ Passed The description includes a clear summary and detailed test plan, but omits the Screenshots and Checklist sections.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

@cursor
cursor Bot requested a review from riderx August 9, 2026 16:33

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Risk: medium. Left a non-blocking comment rather than approving: Cursor Bugbot was not present, and this admin registration-source trend (auth.users SQL + dashboard UI) is above the low-risk auto-approve threshold. Assigned a reviewer for human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@coderabbitai coderabbitai Bot added the codex label Aug 9, 2026
@codspeed-hq

codspeed-hq Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing wolny/admin-registration-source-trend (96449f9) with main (ecfb160)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@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: 5

🤖 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 `@docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md`:
- Line 13: Update the task headings in the document from level-three headings
(`###`) to level-two headings (`##`), including the headings at all referenced
locations, so they follow the level-one title without skipping a hierarchy
level.
- Around line 168-173: Update the commit steps for backend and frontend changes
to run the required lint command immediately before each commit: use bun
lint:backend for the backend commit and bun lint:fix for each frontend commit.
Apply this to the referenced steps as well, without relying on the later
validation step.

In `@src/components/admin/AdminStackedBarChart.vue`:
- Around line 2-16: Update the local imports in the AdminStackedBarChart
component to use the frontend ~ alias, replacing both relative references to
adminStackedBarChart with ~/components/admin/adminStackedBarChart while
preserving the imported symbols.

In `@supabase/functions/_backend/utils/pg.ts`:
- Around line 3444-3450: Update the registration bucket filters in the query
around normal_registrations and invite_registrations so profiles with a null
created_via_invite value are counted as non-invite profiles. Use
u.created_via_invite IS DISTINCT FROM TRUE for normal_registrations while
keeping invite_registrations limited to TRUE, ensuring every matching profile is
included in a bucket.

In `@tests/admin-stats.test.ts`:
- Around line 1203-1228: Extend the test around getOnboardingFunnelDirect to
issue a request ending at 2026-02-02T00:00:00.000Z, then assert the user created
exactly at that timestamp is absent from the returned registration_source_trend.
Preserve the existing full-range assertions while explicitly verifying the end
boundary is exclusive.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8a1450af-ea6a-4444-bf5c-82be8ab02774

📥 Commits

Reviewing files that changed from the base of the PR and between ecfb160 and 0722917.

📒 Files selected for processing (10)
  • docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md
  • docs/superpowers/specs/2026-08-09-admin-registration-source-trend-design.md
  • messages/en.json
  • src/components/admin/AdminStackedBarChart.vue
  • src/components/admin/adminStackedBarChart.ts
  • src/pages/admin/dashboard/users.vue
  • supabase/functions/_backend/utils/pg.ts
  • tests/admin-registration-source-dashboard.unit.test.ts
  • tests/admin-stacked-bar-chart.unit.test.ts
  • tests/admin-stats.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

Comment thread docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md Outdated
Comment thread src/components/admin/AdminStackedBarChart.vue Outdated
Comment thread supabase/functions/_backend/utils/pg.ts
Comment thread tests/admin-stats.test.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 10 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tests/admin-stats.test.ts
Comment thread src/components/admin/AdminStackedBarChart.vue Outdated
Comment thread tests/admin-stats.test.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium. Left a non-blocking comment rather than approving: Cursor Bugbot was not present after the first poll, and this admin registration-source trend (auth.users SQL + dashboard UI) is above the low-risk auto-approve threshold. Human review is needed; a reviewer is already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md (1)

95-103: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Reset the database before the integration test commands.

These commands run tests/admin-stats.test.ts, which inserts rows into auth.users and public.users. Without a reset, stale rows from an earlier run can change the expected daily counts and make the regression test order-dependent. Add bun run supabase:db:reset immediately before each database-backed test run, or make the test command perform that reset.

As per coding guidelines, database-backed test runs must reset the database before execution.

Proposed command change
- bunx vitest run tests/admin-stats.test.ts -t "returns subscribed as the last onboarding funnel step without exceeding the bundle cohort|returns every auth registration in exactly one daily profile bucket"
+ bun run supabase:db:reset
+ bunx vitest run tests/admin-stats.test.ts -t "returns subscribed as the last onboarding funnel step without exceeding the bundle cohort|returns every auth registration in exactly one daily profile bucket"

Also applies to: 450-458

🤖 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 `@docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md` around
lines 95 - 103, Update each documented database-backed test command in this plan
to run bun run supabase:db:reset immediately beforehand, including the focused
integration test command in Step 2 and the corresponding command at the other
referenced section. Preserve the existing Vitest arguments and expected results.

Source: Coding guidelines

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

Outside diff comments:
In `@docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md`:
- Around line 95-103: Update each documented database-backed test command in
this plan to run bun run supabase:db:reset immediately beforehand, including the
focused integration test command in Step 2 and the corresponding command at the
other referenced section. Preserve the existing Vitest arguments and expected
results.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9eeebb08-50aa-4f3d-82f2-388dddec8bf2

📥 Commits

Reviewing files that changed from the base of the PR and between 0722917 and 18ec354.

📒 Files selected for processing (3)
  • docs/superpowers/plans/2026-08-09-admin-registration-source-trend.md
  • src/components/admin/AdminStackedBarChart.vue
  • tests/admin-stats.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

@WcaleNieWolny
WcaleNieWolny merged commit 9973370 into main Aug 9, 2026
112 of 113 checks passed
@WcaleNieWolny
WcaleNieWolny deleted the wolny/admin-registration-source-trend branch August 9, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant