Public: anyone can read this; the crew can change it.

Settings → Billing shows the selling funnel for the last 7 days: visits to ho… #11263

opened this in answer to

Merged 22d 21h ago, live in production

Settings → Billing now opens with one funnel line for the last 7 days, and GET /api/v1/admin/billing/funnel?days=7 returns the same numbers. The new test/funnel.test.ts covers the visitor path and the row, and passes. tsc, gate.ts, design-lint and hollow are clean, and so are the related suites I ran.

Notes

opened this

Settings → Billing now opens with one funnel line for the last 7 days, and GET /api/v1/admin/billing/funnel?days=7 returns the same numbers. The new test/funnel.test.ts covers the visitor path and the row, and passes. tsc, gate.ts, design-lint and hollow are clean, and so are the related suites I ran. The row's one-line fit at 1280 px is not verified: I never rendered the page, and the test only checks the row is a single line of text. I did not run the full suite or the check's skipped socket suites.

The line reads "N visits → N saw plans % → N clicked % (by plan) → N forges % → N paid %". Each percentage is a share of the step before. Under it, the top 5 referrers of visits that pressed a plan, with "(direct)" when there is none.

  • Counting: steps 1–4 are stored as a funnel scope in traffic_view. That gives them the traffic view's visitor hash, scraper flag, daily caps and 90-day retention, with no new table. Visits, plans seen and clicks count a visitor once a day, forges count forges, and scrapers are never counted.
  • Paid: read from entitlement_change, counting changes to active on a forge whose provider isn't none. Nothing in the repo writes a provider entitlement yet, so it reads 0 until the Stripe webhook lands.
  • Capture:
    • The home records a visit server-side for an anonymous GET of /.
    • A small script on the home posts "plans in view" and plan clicks to POST /_funnel. It is same-origin and rate-limited, stores nothing under Do-Not-Track, and refuses any plan the forge doesn't offer.
    • Pay links carry data-plan; the "Get a forge" button counts as the free plan.
    • The new-forge form records a forge made.
  • Probe: GET /api/v1/admin/traffic/probe?scope=funnel adds a recomputed-in-SQL figure for each step.
  • Tests: a visitor moves home, plans, click and forge by one each, and a scraper moves none. A provider activation counts as paid and a hand grant doesn't. Referrers, the Billing row, the API, the probe and bad input are covered too.
  • Housekeeping: docs/features/selling-funnel.md has the how-to, and the new OpenAPI route entry and index are in.

Not done: forges made through the API or MCP aren't counted, only the form. Plan clicks made with scripts off aren't seen. I added no terminal screen, because there's no new page.

Try: open /settings/billing as an admin, or GET /api/v1/admin/billing/funnel?days=7.

Closes #11259

3 earlier comments
commented

Settings → Billing now opens with one funnel line for the last 7 days, and GET /api/v1/admin/billing/funnel?days=7 returns the same numbers. The new test/funnel.test.ts covers the visitor path and the row, and passes. tsc, gate.ts, design-lint and hollow are clean, and so are the related suites I ran. The row's one-line fit at 1280 px is not verified: I never rendered the page, and the test only checks the row is a single line of text. I did not run the full suite or the check's skipped socket suites.

The line reads "N visits → N saw plans % → N clicked % (by plan) → N forges % → N paid %". Each percentage is a share of the step before. Under it, the top 5 referrers of visits that pressed a plan, with "(direct)" when there is none.

  • Counting: steps 1–4 are stored as a funnel scope in traffic_view. That gives them the traffic view's visitor hash, scraper flag, daily caps and 90-day retention, with no new table. Visits, plans seen and clicks count a visitor once a day, forges count forges, and scrapers are never counted.
  • Paid: read from entitlement_change, counting changes to active on a forge whose provider isn't none. Nothing in the repo writes a provider entitlement yet, so it reads 0 until the Stripe webhook lands.
  • Capture:
    • The home records a visit server-side for an anonymous GET of /.
    • A small script on the home posts "plans in view" and plan clicks to POST /_funnel. It is same-origin and rate-limited, stores nothing under Do-Not-Track, and refuses any plan the forge doesn't offer.
    • Pay links carry data-plan; the "Get a forge" button counts as the free plan.
    • The new-forge form records a forge made.
  • Probe: GET /api/v1/admin/traffic/probe?scope=funnel adds a recomputed-in-SQL figure for each step.
  • Tests: a visitor moves home, plans, click and forge by one each, and a scraper moves none. A provider activation counts as paid and a hand grant doesn't. Referrers, the Billing row, the API, the probe and bad input are covered too.
  • Housekeeping: docs/features/selling-funnel.md has the how-to, and the new OpenAPI route entry and index are in.

Not done: forges made through the API or MCP aren't counted, only the form. Plan clicks made with scripts off aren't seen. I added no terminal screen, because there's no new page.

Try: open /settings/billing as an admin, or GET /api/v1/admin/billing/funnel?days=7.

commented

Settings → Billing now shows the selling funnel for 7 days, and the failing check is fixed. I ran test/forge-looks.test.ts and bun x tsc --noEmit, both clean, then pushed. I did not re-run the full suite or the gate; the forge's check does that on this push.

What failed: the check failed because POST /_funnel, the home page's beacon route, was not on the not-a-page list in test/forge-looks.test.ts. That test requires every top-level route to be either a picture or listed there with a reason. I added /_funnel to the list as a POST-only mutation, covered by test/funnel.test.ts. The test was out of date, so I changed the test and not the code.

What the pull does

  • Billing: Settings → Billing shows home visits, plans seen, plan clicks by plan, forges made and paid.
  • API and probe: GET /api/v1/admin/billing/funnel and the traffic probe (scope=funnel) return the same numbers.

To try it: open /settings/billing as an admin, or GET /api/v1/admin/billing/funnel?days=7.

commented

Settings → Billing now shows the funnel as rows, and there is a terminal screen for it. I ran tsc, the gate, the design lint and 83 tests across the funnel, billing, palette and both-doors suites, all passing. I have not looked at the preview, so the 1280px render is not checked, and the full suite was not run here (the changed files reach 1,875 test files, too many to run locally); the forge's check runs it on this push.

  • Terminal door: the palette entry "From visit to paid" (src/tui/screens/funnel.ts) is offered to a forge admin who is a person, the same people who see the page. It shows the same rows, and w flips 7 and 30 days. It is added to ENTRIES and named in docs/features/selling-funnel.md. test/tui-funnel.test.ts checks that an admin reads every step and a member is offered nothing.
  • Design: the heading is now "Last 7 days: from visit to paid", and the block sits below Provider and Plans. Each step is a dl row with its count and "N% of the step before". Clicks by plan and plan-click referrers are rows under it. The arrow sentence is gone, so there is no one-line fit to break at 1280px or on a phone. I updated test/funnel.test.ts for the new markup and the position.
  • Direction: I can't name a pipeline item (#6534, #6611, #5276, #3316, #6217, #6428, #1242, #1073) this serves. It serves the owner's own request in #11259, which asked for the selling-funnel numbers because the home now sells and its traffic was unmeasured. The latest commit on the branch (767200b16) records that the pipeline items do not block it. It is a feature ahead of the pipeline, and whether to hold it behind them is the owner's call.
commented

The check failed because the admin palette roster test didn't list the new "From visit to paid" screen, and I've fixed that and pushed.

I added the missing entry to the expected admin roster in test/palette-roster.test.ts, just before "Who can do what". The test was out of date, so the code is unchanged. The new entry is the terminal screen added earlier on this pull, and it is shown to admins only.

test/palette-roster.test.ts now passes (15 tests) and bun x tsc --noEmit is clean. I did not re-run the full suite or bun scripts/gate.ts here, so the forge's check on this push is the full run.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs