Add Microsoft Clarity as a fourth analytics provider option alongside
Umami, Google Analytics, and Custom. Clarity provides free heatmaps,
session recordings, and user analytics.
- admin.types.ts: Add 'clarity' to AnalyticsProvider union type
- api/admin/site/route.ts: Add 'clarity' to validation
- admin/page.tsx: Add Clarity option to dropdown + Project ID input UI
- layout.tsx: Inject Clarity tracking script with project ID
Add traffic analytics support to the admin panel with three provider
options:
- Umami (open-source, self-hosted) — script URL + website ID
- Google Analytics 4 — Measurement ID (G-XXXXXXXXXX)
- Custom — any third-party analytics script (百度统计, Plausible, 51la, etc.)
Changes:
- admin.types.ts: Add AnalyticsEnabled, AnalyticsProvider,
AnalyticsScriptUrl, AnalyticsWebsiteId, AnalyticsCustomScript to
SiteConfig interface
- config.ts: Add default values in getInitConfig() and configSelfCheck()
- api/admin/site/route.ts: Add analytics fields to destructuring, type
validation, and SiteConfig update
- admin/page.tsx: Add SiteConfig interface fields, state initialization,
config sync, and analytics configuration UI with provider-specific
input fields
- layout.tsx: Inject analytics scripts into <head> based on provider
type (Umami: async script with data-website-id; GA: gtag.js + config;
Custom: dangerouslySetInnerHTML)