diff --git a/app/(marketing)/stats/page.tsx b/app/(marketing)/stats/page.tsx
index 67815c0..efd67fb 100644
--- a/app/(marketing)/stats/page.tsx
+++ b/app/(marketing)/stats/page.tsx
@@ -10,16 +10,12 @@ export const revalidate = 3600
export const metadata = buildPageMetadata({
title: "Stats",
description:
- "Open numbers for 23rd: traffic over the last 30 days, components shipped, GitHub stars, forks, contributors, and commits over the past year.",
+ "Open numbers for 23rd: lifetime traffic, components shipped, GitHub stars, forks, contributors, and commits over the past year.",
path: "/stats",
keywords: ["stats", "open source", "open metrics", "analytics"],
})
const numberFormat = new Intl.NumberFormat("en")
-const changeFormat = new Intl.NumberFormat("en", {
- maximumFractionDigits: 0,
- signDisplay: "exceptZero",
-})
const dayFormat = new Intl.DateTimeFormat("en", {
month: "short",
day: "numeric",
@@ -32,26 +28,17 @@ const surface =
function StatTile({
label,
value,
- change,
className,
}: {
label: string
value: number | null
- change?: number | null
className?: string
}) {
return (
{label}
-
-
- {value === null ? "–" : numberFormat.format(value)}
-
- {change != null ? (
-
- {changeFormat.format(change)}%
-
- ) : null}
+
+ {value === null ? "–" : numberFormat.format(value)}
)
@@ -197,21 +184,12 @@ export default async function StatsPage() {
id="traffic-heading"
className="text-xl font-semibold tracking-tight"
>
- Last 30 days
+ Traffic
-
-
+
+
-
diff --git a/lib/tracwell.ts b/lib/tracwell.ts
index 21dae2d..5c645e3 100644
--- a/lib/tracwell.ts
+++ b/lib/tracwell.ts
@@ -1,33 +1,25 @@
const MCP_URL = "https://tracwell.app/mcp"
const PROJECT_ID = "fa269223-7fa6-4ff7-a44a-3752aec9d15e"
-const RANGE_DAYS = 30
+// First day of history (imported from Umami). Tracwell caps a report at 732
+// days, so lifetime is clamped to the most recent 731.
+const FIRST_DAY = Date.UTC(2026, 7, 16)
+const MAX_RANGE_DAYS = 731
const DAY_MS = 24 * 60 * 60 * 1000
-type Metric = { value: number; previous: number; changePercent: number | null }
-type Breakdown = { value: string; count: number; views: number }
+type Breakdown = { value: string; count: number }
type Overview = {
- metrics: { views: Metric; visitors: Metric }
- trend: { date: string; views: number; visitors: number }[]
- breakdowns: {
- pages: Breakdown[]
- sources: Breakdown[]
- countries: Breakdown[]
- deviceTypes: Breakdown[]
- }
+ metrics: { views: { value: number }; visitors: { value: number } }
+ breakdowns: { sources: Breakdown[]; countries: Breakdown[] }
}
export type Ranked = { label: string; value: number }
-export type Day = { date: string; visitors: number; views: number }
export type Traffic = {
- views: Metric
- visitors: Metric
- days: Day[]
- pages: Ranked[]
+ views: number
+ visitors: number
sources: Ranked[]
countries: Ranked[]
- devices: Ranked[]
}
const regionNames = new Intl.DisplayNames(["en"], { type: "region" })
@@ -55,19 +47,20 @@ function top(
}
/**
- * The last 30 full days of traffic from Tracwell's read-only MCP endpoint.
- * One stateless tools/call; the answer comes back as a single SSE message.
- * Today is left out so the chart doesn't end on a half day.
+ * Lifetime traffic from Tracwell's read-only MCP endpoint. One stateless
+ * tools/call; the answer comes back as a single SSE message.
*/
export async function getTraffic(): Promise {
const key = process.env.TRACWELL_MCP_KEY
if (!key) return null
+ const now = new Date()
const today = Date.UTC(
- new Date().getUTCFullYear(),
- new Date().getUTCMonth(),
- new Date().getUTCDate()
+ now.getUTCFullYear(),
+ now.getUTCMonth(),
+ now.getUTCDate()
)
+ const from = Math.max(FIRST_DAY, today - MAX_RANGE_DAYS * DAY_MS)
try {
const res = await fetch(MCP_URL, {
@@ -85,8 +78,8 @@ export async function getTraffic(): Promise {
name: "analytics_overview",
arguments: {
projectId: PROJECT_ID,
- from: isoDate(today - RANGE_DAYS * DAY_MS),
- to: isoDate(today - DAY_MS),
+ from: isoDate(from),
+ to: isoDate(today),
},
},
}),
@@ -113,23 +106,12 @@ export async function getTraffic(): Promise {
return null
}
- const { metrics, trend, breakdowns } = overview
+ const { metrics, breakdowns } = overview
return {
- views: metrics.views,
- visitors: metrics.visitors,
- days: trend.map(({ date, views, visitors }) => ({
- date,
- views,
- visitors,
- })),
- pages: top(breakdowns.pages, 8),
+ views: metrics.views.value,
+ visitors: metrics.visitors.value,
sources: top(breakdowns.sources, 6),
countries: top(breakdowns.countries, 6, countryName),
- devices: top(
- breakdowns.deviceTypes.filter((row) => row.value !== "unknown"),
- 3,
- (value) => value.charAt(0).toUpperCase() + value.slice(1)
- ),
}
} catch (error) {
console.warn("Tracwell: request failed", error)