Skip to content

feat(revenue): Revenue page with RapidAPI subscriptions and Stripe metrics - #32

Merged
mlava merged 2 commits into
mainfrom
feat/revenue-rapidapi-stripe
Aug 3, 2026
Merged

feat(revenue): Revenue page with RapidAPI subscriptions and Stripe metrics#32
mlava merged 2 commits into
mainfrom
feat/revenue-rapidapi-stripe

Conversation

@mlava

@mlava mlava commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a per-project Revenue page (/p/$projectId/revenue) with two independent panels, following the Vercel Web Analytics integration pattern (design record in specs/0013-revenue-rapidapi-stripe.md):

RapidAPI panel

  • Enter your listing's api_… id (verified against the GraphQL Platform API on save — there is no usable "list my APIs" query).
  • Shows active subscribers, paying subscribers, and 30-day new/churn vs the prior 30 days, plus recent subscription events.
  • The Platform API endpoint is per-hub, so it's config: RAPIDAPI_GRAPHQL_URL + RAPIDAPI_KEY. The plan-aware query (billingPlanVersion { name price }) falls back to the documented basic shape if the hub's schema rejects it; "paying" shows as unknown rather than guessed.

Stripe panel

  • Pick which Stripe products count as the project's subscription and one-off offerings (either optional) from /v1/products.
  • Subscription product: active subscribers (active|trialing|past_due), estimated MRR (normalized across day/week/month/year intervals), 30-day new/churn vs prior 30.
  • One-off product: purchase count and revenue from paid mode=payment Checkout Sessions (last 30 vs prior 30).
  • Auth via STRIPE_SECRET_KEY (restricted read key recommended: Products, Subscriptions, Checkout Sessions).

No PII, by construction

The RapidAPI GraphQL query never requests entity.name/entity.email — subscribers are opaque entity ids only. The Stripe client parses no customer fields (no customer, customer_details).

Plumbing

  • New tables rapidapi_connections / stripe_connections (identifier mappings only; secrets stay env-level) with SQLite + Postgres migrations and schema-parity coverage.
  • Server functions + connection cards + settings sections + "My Site" nav entry.
  • Two MCP tools: get_rapidapi_subscriptions, get_stripe_revenue (read-only, no credits).
  • Env docs in .env.example, typing in src/env.d.ts, Alchemy dataEnv wiring.

Testing

  • 11 new unit tests over the pure metric functions (windowing, product scoping, MRR normalization, plan-info fallback).
  • Full suite: 1181 tests pass; tsc --noEmit, oxlint, and Prettier clean.
  • Live API calls not exercised (needs real STRIPE_SECRET_KEY / RAPIDAPI_* secrets) — please verify against your accounts after setting the env vars.

🤖 Generated with Claude Code

mlava and others added 2 commits August 3, 2026 17:53
…e metrics

A per-project Revenue page with two independent panels, mirroring the
Vercel Web Analytics integration pattern (specs/0013):

- RapidAPI: subscriber counts for a provided API listing id via the
  GraphQL Platform API (per-hub endpoint), with active/paying counts and
  30-day new/churn vs the prior 30 days. Plan-aware query falls back to
  the documented basic shape when the hub's schema lacks
  billingPlanVersion.
- Stripe: active subscribers, estimated MRR, and 30-day new/churn for a
  mapped subscription product, plus purchase count and revenue for a
  mapped one-off product (paid Checkout Sessions).
- Credentials are instance-level env secrets (STRIPE_SECRET_KEY,
  RAPIDAPI_KEY, RAPIDAPI_GRAPHQL_URL); the DB stores identifier
  mappings only.
- No PII by construction: the RapidAPI query never requests subscriber
  names or emails (opaque entity ids only), and the Stripe client
  parses no customer fields.
- MCP tools: get_rapidapi_subscriptions, get_stripe_revenue.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mlava
mlava merged commit 2410088 into main Aug 3, 2026
@mlava
mlava deleted the feat/revenue-rapidapi-stripe branch August 3, 2026 08:01
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