Skip to content

fix(dashboard): center revenue empty state - #627

Open
izadoesdev wants to merge 2 commits into
mainfrom
staging
Open

fix(dashboard): center revenue empty state#627
izadoesdev wants to merge 2 commits into
mainfrom
staging

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Aug 18, 2026

Copy link
Copy Markdown
Member

Summary

  • keep the revenue empty state below the analytics toolbar
  • give the state a consistent centered content area

Validation

  • bun run lint
  • bun run check-types
  • bun run test
  • Dashboard Playwright CI

Summary by cubic

Aligns revenue page empty and error states under the analytics toolbar and adds retry for failed loads. Previously empty views could be off-center and errors were silent; now RevenueContent, the chart, and attribution tables render a centered EmptyState with a minimum height and optional retry.

  • Adds error handling with Retry in revenue content, attribution tables, and settings sheet; disables Save when loading/error.
  • Replaces ad‑hoc chart empty view with EmptyState; improves X-axis ticks (min gap, dayjs formatting) and wraps legend.
  • Uses Button instead of raw buttons; adds aria labels for copy/toggle controls; keeps copy, routing, and state logic unchanged.
  • Verify on narrow and wide screens: invalid currency, configured/waiting, not configured, and error states. Ensure Retry calls refetch and the settings sheet still opens from actions.

Written for commit 37e03ab. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard (staging) Ready Ready Preview Aug 18, 2026 3:18pm
databuddy-status Ready Ready Preview Aug 18, 2026 3:18pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
documentation (staging) Skipped Skipped Aug 18, 2026 3:18pm

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a46b8b0b-0f85-442a-8172-97e2aacc8170

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@unkey-deploy

unkey-deploy Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Aug 18, 2026 3:16pm

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR centers the dashboard revenue empty state and substantially replaces Stripe revenue ingestion and query reconciliation with canonical provider identities.

  • Centers the revenue empty state in a responsive content area below the analytics toolbar.
  • Reworks Stripe normalization around PaymentIntent, InvoicePayment, refund, and out-of-band provider IDs.
  • Simplifies ClickHouse revenue reads to canonical rows selected with FINAL and updates AI revenue/profile queries.
  • Adds Stripe end-to-end and integration coverage and updates payment-integration documentation.

Confidence Score: 3/5

The PR should not merge until legacy endpoint ingestion and persisted pre-cutover Stripe revenue remain protected from duplicate counting.

Successful invoice-associated PaymentIntents can now be counted alongside unlinked invoice rows, and removing historical reconciliation allows distinct legacy invoice and PaymentIntent records for one payment to contribute simultaneously.

Files Needing Attention: apps/basket/src/routes/webhooks/stripe-normalization.ts, packages/ai/src/query/builders/revenue.ts, packages/db/src/clickhouse/revenue.ts

Important Files Changed

Filename Overview
apps/basket/src/routes/webhooks/stripe-normalization.ts Replaces version-aware invoice reconciliation with canonical records, but can double-count endpoints that do not provide an invoice-payment relationship.
packages/ai/src/query/builders/revenue.ts Simplifies revenue and attribution SQL but drops compatibility reconciliation for persisted pre-cutover Stripe rows.
packages/db/src/clickhouse/revenue.ts Replaces deterministic application-level lifecycle collapsing with ClickHouse FINAL reads over canonical transaction keys.
apps/dashboard/app/(main)/websites/[id]/revenue/_components/revenue-content.tsx Safely wraps the empty state in a responsive centered area beneath the existing toolbar.
packages/ai/src/query/builders/profiles.ts Aligns profile revenue attribution with the new PaymentIntent-based canonical context.
apps/docs/content/docs/Integrations/payments.mdx Documents the newer Stripe API-version and invoice_payment.paid expectations.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  S[Stripe webhooks] --> B[Basket normalization]
  B --> C[(ClickHouse analytics.revenue)]
  C --> Q[Canonical revenue CTE]
  Q --> R[Revenue and profile builders]
  R --> D[Dashboard and AI analytics]
  PI[payment_intent.succeeded] --> B
  IP[invoice_payment.paid] --> B
  INV[invoice.paid] --> B
Loading

Comments Outside Diff (2)

  1. apps/basket/src/routes/webhooks/stripe-normalization.ts, line 397-424 (link)

    P1 Invoice PaymentIntent double counting

    If a Stripe endpoint uses a pre-Basil invoice payload or has not enabled invoice_payment.paid, a subscription's successful PaymentIntent is recorded as a standalone sale while invoice.paid can record an out-of-band subscription without the PaymentIntent ID, causing the same payment to inflate revenue and transaction totals.

    Knowledge Base Used: Basket Ingestion Flow

  2. packages/ai/src/query/builders/revenue.ts, line 346-380 (link)

    P1 Historical Stripe reconciliation removed

    If existing revenue history contains legacy invoice and PaymentIntent rows for the same payment under different transaction IDs, both rows survive FINAL and now enter revenue_base without the removed legacy duplicate exclusion, inflating historical revenue and transaction totals.

    Knowledge Base Used: Shared database package (packages/db)

Reviews (1): Last reviewed commit: d619ed7 | Re-trigger Greptile

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.

1 participant