Commit Graph
6 Commits
Author SHA1 Message Date
mtvpls-turso 392211264f feat: add Microsoft Clarity analytics provider
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
2026-07-11 19:01:16 +00:00
mtvpls-turso d98f5082a5 feat: add traffic analytics configuration (Umami/GA/Custom)
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)
2026-07-11 18:47:11 +00:00
mtvpls-turso e624ffb087 fix: add turso storage type to data migration import/export
The data migration import/export API was missing 'turso' as a storage
type check. Without this, Turso storage fell into the Redis 'else'
branch, which tries to use hSet/withRetry methods that don't exist
on the D1Storage adapter (used by Turso), causing user data import
to fail silently.

- Import route: added 'turso' alongside 'd1' to use
  createUserWithHashedPassword method
- Export route: added 'turso' alongside 'd1' to use
  getUserPasswordHash method
2026-07-11 18:15:46 +00:00
mtvpls-turso aab6db64cc fix: use @libsql/client/http subpath to avoid native module deps
The main @libsql/client entry point pulls in the native libsql module
and isomorphic-ws/isomorphic-fetch, which webpack cannot parse in
EdgeOne builds. Using the http subpath provides a pure HTTP client
that works in edge/serverless environments without native dependencies.

Also add libsql, @libsql/isomorphic-fetch, @libsql/isomorphic-ws to
the edge build alias list in next.config.js as a safety net.
2026-07-11 17:28:55 +00:00
mtvpls-turso d094e379d9 fix: use require() for @libsql/client to fix EdgeOne webpack ESM resolution
The @libsql/client package uses conditional exports (edge-light, workerd)
that cause webpack to resolve to the web.js entry point during EdgeOne
builds, resulting in 'TypeError: e is not a constructor'.

Switching from static import to dynamic require() bypasses webpack's
ESM conditional export resolution and uses the CommonJS entry point
consistently.
2026-07-11 17:23:56 +00:00
mtvpls-turso 8e464c463b feat: add Turso (libSQL) storage support for EdgeOne deployment
- Add TursoAdapter implementing DatabaseAdapter interface using @libsql/client
- Add 'turso' storage type to db.ts storage selector (reuses D1Storage)
- Add init-turso.js script for database migration and admin initialization
- Add @libsql/client dependency to package.json
- Update next.config.js to exclude @libsql/client from client-side bundle
- Update edgeone-deploy.yml workflow with TURSO_URL and TURSO_TOKEN secrets
- Update edgeone-build.mjs runtime env keys to include Turso variables
- Update .env.edgeone.example with Turso deployment instructions
- Update README.md with Turso as recommended storage for EdgeOne

Turso provides free SQLite-compatible cloud database (libSQL) with:
- 500 databases, 9GB storage, 1B row reads/month on free tier
- HTTP API compatible with edge/serverless environments
- Full SQLite syntax compatibility, reuses existing migrations
2026-07-11 17:04:27 +00:00