diff --git a/.env.example b/.env.example index 3fe9d60..a461aee 100644 --- a/.env.example +++ b/.env.example @@ -9,3 +9,6 @@ CREEM_SPONSOR_DIAMOND_CHECKOUT_URL=https://www.creem.io/payment/prod_1lz1o8e7Htg CREEM_SPONSOR_PLATINUM_CHECKOUT_URL=https://www.creem.io/payment/prod_4kpDvyYwr6XnRuMSysnI3s CREEM_SPONSOR_GOLD_CHECKOUT_URL=https://www.creem.io/payment/prod_2NW3lMTPFHeOey3XhUYlM CREEM_SPONSOR_SILVER_CHECKOUT_URL=https://www.creem.io/payment/prod_3uz4xoRD5vVePnDwRIJxoi + +# Read-only Tracwell MCP key for the traffic section on /stats. +TRACWELL_MCP_KEY= diff --git a/app/(marketing)/stats/page.tsx b/app/(marketing)/stats/page.tsx index 27625ee..7137473 100644 --- a/app/(marketing)/stats/page.tsx +++ b/app/(marketing)/stats/page.tsx @@ -1,112 +1,123 @@ +import Link from "next/link" + import { buildPageMetadata } from "@/lib/seo" +import { getSiteStats } from "@/lib/stats" +import { getTraffic, type Ranked } from "@/lib/tracwell" import { cn } from "@/lib/utils" -import { getSiteStats, type CategoryCount, type WeekCommits } from "@/lib/stats" export const revalidate = 3600 export const metadata = buildPageMetadata({ title: "Stats", description: - "Open numbers for 23rd: components shipped, GitHub stars, forks, contributors, and commits over the past year.", + "Open numbers for 23rd: traffic over the last 30 days, components shipped, GitHub stars, forks, contributors, and commits over the past year.", path: "/stats", - keywords: ["stats", "open source", "open metrics"], + keywords: ["stats", "open source", "open metrics", "analytics"], }) const numberFormat = new Intl.NumberFormat("en") -const weekFormat = new Intl.DateTimeFormat("en", { - month: "short", - day: "numeric", - timeZone: "UTC", +const changeFormat = new Intl.NumberFormat("en", { + maximumFractionDigits: 0, + signDisplay: "exceptZero", }) -const monthFormat = new Intl.DateTimeFormat("en", { +const dayFormat = new Intl.DateTimeFormat("en", { month: "short", + day: "numeric", timeZone: "UTC", }) +const surface = + "rounded-xl bg-sheet p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)] sm:p-5" + function StatTile({ label, value, + change, className, }: { label: string value: number | null + change?: number | null className?: string }) { return ( -
+
{label}
-
- {value === null ? "–" : numberFormat.format(value)} +
+ + {value === null ? "–" : numberFormat.format(value)} + + {change != null ? ( + + {changeFormat.format(change)}% + + ) : null}
) } -function CommitChart({ weeks }: { weeks: WeekCommits[] }) { - const max = Math.max(1, ...weeks.map((week) => week.total)) +type Bar = { key: string; label: string; value: number } + +function BarChart({ + title, + unit, + bars, +}: { + title: string + unit: string + bars: Bar[] +}) { + const max = Math.max(1, ...bars.map((bar) => bar.value)) return ( -
-

- Commits per week -

-
+
+

{title}

+