From 39330880e4e734c9e40023c71c259b9650493992 Mon Sep 17 00:00:00 2001 From: Alex Zhu Date: Thu, 30 Apr 2026 19:18:52 +0800 Subject: [PATCH] feat: add Google Analytics (GA4) configuration (#11739) * fix: resolve CF Worker Date.now() returning 0 at module level In Cloudflare Workers, module-level Date.now() evaluates to 0 during initialization, causing all time-dependent data (visitData dates, offlineChartData times, activities updatedAt) to render as epoch-zero values (1970-01-01, 0:00). This broke the analysis dashboard charts on the preview site. Convert static module-level data exports to functions that generate data at request time, ensuring Date.now() returns the current time. Co-Authored-By: Claude Opus 4.7 * feat: add Google Analytics (GA4) configuration Add ga_v2 tracking ID G-59NF1VHHPF via Umi Max analytics plugin. Co-Authored-By: Claude Opus 4.7 --------- Co-authored-by: Claude Opus 4.7 --- config/config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/config.ts b/config/config.ts index 2a6e4bac..cf00ac8d 100644 --- a/config/config.ts +++ b/config/config.ts @@ -173,6 +173,14 @@ export default defineConfig({ * @doc https://umijs.org/docs/max/access */ access: {}, + /** + * @name Google Analytics + * @description 使用 GA4 (gtag.js) 进行站点分析 + * @doc https://umijs.org/docs/max/analytics + */ + analytics: { + ga_v2: 'G-59NF1VHHPF', + }, /** * @name 中额外的 script * @description 配置 中额外的 script