feat(admin): add paid product activity chart#2094
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis pull request adds 60-day active paying client metrics for both Builder and Live Updates products to the admin dashboard. It includes database schema migration, type definitions, backend calculation logic in the insights function, admin query utilities, dashboard visualization, and a CLI backfill script to populate historical data. ChangesPaid Product Activity Metrics
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 SQLFluff (4.1.0)supabase/migrations/20260510191550_add_paid_product_activity_to_global_stats.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/backfill_paid_product_activity.ts (1)
126-133: 💤 Low valueConsider adding query timeout for long-running backfills.
The database client doesn't set a
statement_timeoutorquery_timeout. For large datasets, a query could potentially run indefinitely if there are database issues.♻️ Optional: Add query timeout
function createPgClient(databaseUrl: string, env: Record<string, string | undefined>) { const host = new URL(databaseUrl).hostname const usesLocalDatabase = host === 'localhost' || host === '127.0.0.1' || host === '::1' return new PgClient({ connectionString: databaseUrl, ssl: usesLocalDatabase ? false : { rejectUnauthorized: !shouldAllowSelfSignedPgCertificate(env, databaseUrl) }, + statement_timeout: 300000, // 5 minutes per query }) }🤖 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 `@scripts/backfill_paid_product_activity.ts` around lines 126 - 133, The createPgClient factory currently returns a PgClient without any query timeout; add a configurable query timeout to prevent runaway backfill queries by having createPgClient accept a timeout (or read from env) and, after creating and connecting the PgClient, execute a SET statement to apply a default statement_timeout (e.g., await client.query(`SET statement_timeout = ${timeoutMs}`)) before running backfill queries; update callers to pass a sensible timeout and keep shouldAllowSelfSignedPgCertificate and existing ssl behavior unchanged (refer to createPgClient, PgClient, and shouldAllowSelfSignedPgCertificate to locate the change).
🤖 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 `@scripts/backfill_paid_product_activity.ts`:
- Around line 126-133: The createPgClient factory currently returns a PgClient
without any query timeout; add a configurable query timeout to prevent runaway
backfill queries by having createPgClient accept a timeout (or read from env)
and, after creating and connecting the PgClient, execute a SET statement to
apply a default statement_timeout (e.g., await client.query(`SET
statement_timeout = ${timeoutMs}`)) before running backfill queries; update
callers to pass a sensible timeout and keep shouldAllowSelfSignedPgCertificate
and existing ssl behavior unchanged (refer to createPgClient, PgClient, and
shouldAllowSelfSignedPgCertificate to locate the change).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ba0adf37-bf2a-4474-81aa-67126f18c228
📒 Files selected for processing (9)
messages/en.jsonpackage.jsonscripts/backfill_paid_product_activity.tssrc/pages/admin/dashboard/index.vuesrc/types/supabase.types.tssupabase/functions/_backend/triggers/logsnag_insights.tssupabase/functions/_backend/utils/pg.tssupabase/functions/_backend/utils/supabase.types.tssupabase/migrations/20260510171606_add_paid_product_activity_to_global_stats.sql
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
|



Summary (AI generated)
bun run admin:backfill-paid-product-activityto backfill historical global_stats rows once.$/%toggle to the churn chart so admins can switch between lost MRR and churn rate.Motivation (AI generated)
Business Impact (AI generated)
Test Plan (AI generated)
bun test tests/admin-stats.unit.test.ts tests/logsnag-insights-revenue.unit.test.tsbun run admin:backfill-paid-product-activity --helpbunx eslint --no-ignore scripts/backfill_paid_product_activity.tsbunx eslint --no-ignore src/pages/admin/dashboard/revenue.vue supabase/functions/_backend/utils/pg.tsbun lintbun lint:backendbun typecheckbun run lint:deadcodetypos package.json scripts/backfill_paid_product_activity.tsgit diff --checkbun run build/admin/dashboardSummary by CodeRabbit
Release Notes
New Features
Chores