feat(analytics): implement runtime configuration and analytics tracking for GA4 and Baidu

This commit is contained in:
HouYunFei
2026-07-17 11:24:22 +08:00
parent a2586ffe34
commit ca6efdf0c3
15 changed files with 216 additions and 25 deletions
@@ -0,0 +1,15 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
import { trackPageview } from "@/lib/analytics";
// 监听 SPA 路由变化并上报 pageview。无统计配置时 trackPageview 为空操作。
export function AnalyticsTracker() {
const location = useLocation();
useEffect(() => {
trackPageview(`${location.pathname}${location.search}`);
}, [location.pathname, location.search]);
return null;
}