File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,8 +78,11 @@ DENO_ENV=development
7878# Redis 连接字符串(如需缓存)
7979# REDIS_URL=
8080
81- # 分析/统计 ID(如 Google Analytics)
82- # GA_ID=
81+ # Google Analytics ID
82+ GA_ID =
83+
84+ # 51.la 统计 ID
85+ LA_ID = L1NaKSoU1jvMh9mE
8386
8487# Sentry DSN(错误追踪)
8588# SENTRY_DSN=
Original file line number Diff line number Diff line change @@ -71,7 +71,12 @@ export const env = {
7171 // 可选配置
7272 databaseUrl : getEnv ( "DATABASE_URL" , "" ) ,
7373 redisUrl : getEnv ( "REDIS_URL" , "" ) ,
74+
75+ // 统计分析
7476 gaId : getEnv ( "GA_ID" , "" ) ,
77+ laId : getEnv ( "LA_ID" , "" ) ,
78+
79+ // 错误追踪
7580 sentryDsn : getEnv ( "SENTRY_DSN" , "" ) ,
7681} as const ;
7782
Original file line number Diff line number Diff line change 1+ // deno-lint-ignore-file react-no-danger
12import { type PageProps } from "$fresh/server.ts" ;
3+ import { env } from "../config/env.ts" ;
4+
25export default function App ( { Component } : PageProps ) {
6+ const gaId = env . gaId ;
7+ const laId = env . laId ;
8+
39 return (
410 < html >
511 < head >
612 < meta charset = "utf-8" />
713 < meta name = "viewport" content = "width=device-width, initial-scale=1.0" />
814 < title > HaloLight</ title >
915 < link rel = "stylesheet" href = "/styles.css" />
16+
17+ { /* 51.la 统计 */ }
18+ { laId && (
19+ < script
20+ id = "LA_COLLECT"
21+ src = { `https://web.51.la/go?id=${ laId } ` }
22+ defer
23+ />
24+ ) }
25+
26+ { /* Google Analytics */ }
27+ { gaId && (
28+ < >
29+ < script
30+ async
31+ src = { `https://www.googletagmanager.com/gtag/js?id=${ gaId } ` }
32+ />
33+ { /* deno-lint-ignore react-no-danger */ }
34+ < script
35+ dangerouslySetInnerHTML = { {
36+ __html : `
37+ window.dataLayer = window.dataLayer || [];
38+ function gtag(){dataLayer.push(arguments);}
39+ gtag('js', new Date());
40+ gtag('config', '${ gaId } ');
41+ ` ,
42+ } }
43+ />
44+ </ >
45+ ) }
1046 </ head >
1147 < body >
1248 < Component />
You can’t perform that action at this time.
0 commit comments