feat: lead summary dashboard at /admin/leads#1
Open
brooksRoley wants to merge 1 commit into
Open
Conversation
Read-only dashboard for consulting attribution signal. Reuses the tracker_session cookie via the existing /login flow; middleware now also gates /admin/* and /api/admin/* (the API path returns JSON 401 instead of redirecting to the HTML login page so fetches surface the error). Summary covers total leads, last 7d vs. prior 7d delta, budget-set vs. unset, and top 5 source breakdown. Column is `source` (set by the leads form); UTM-style attribution lives in that column today.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Read-only dashboard for consulting attribution signal at
/admin/leads. Reuses the existingtracker_sessioncookie //loginflow — no new auth surface.src/middleware.tsmatcher extended to/admin/:path*and/api/admin/:path*. The API path returns JSON 401 instead of redirecting to the HTML login page so client fetches see the error.src/pages/api/admin/leads.ts— single roundtrip: total, last_7d vs. prior_7d, budget_set vs. unset, top 5 source breakdown.src/pages/admin/leads.tsx— three stat cards + horizontal bar of top sources, forest palette.Livelihood stream: Consulting (instrumentation — measure whether the source/UTM attribution shipped this week is producing signal).
Notes / context
The original prompt referenced a
utm_sourcecolumn. The actual leads table has a singlesourcecolumn (set by/api/consulting/leads). The dashboard groups by that. If we later split into proper UTM fields (utm_source,utm_medium,utm_campaign), the API can be updated without touching the page layout.This PR does not touch the three Stripe / monetization prompts (consulting pricing grid, /funding Payment Links, Model Arena email gate). Those were either blocked by the LLC status, contradicted the "no monetization UI yet" preference, or required external setup (Stripe Dashboard product creation). Flagged separately in chat.
Test plan
/admin/leadswhile logged out — middleware redirects to/login?from=/admin/leads/admin/leadsrenders and shows totals + 7d delta + top source barGET /api/admin/leadswhile logged out returns{"error":"Unauthorized"}with status 401 (not an HTML redirect)GET /api/admin/leadswhile logged in returns the summary JSON/trackerstill works (unchanged behavior — same cookie)Verification before push
npx eslint src/middleware.ts src/pages/api/admin/leads.ts src/pages/admin/leads.tsx --max-warnings 0— exit 0npx tsc --noEmit— exit 0npm test— 281/281 passingnpm run build—/admin/leads(○ static),/api/admin/leads(ƒ function) both present, no warnings