Web Analytics

historic-country-borders-app

⭐ 166 stars Simplified Chinese by nrgapple

历史边界

可视化不同时期的国家边界(公元前2000年-1994年)

见于 r/dataisbeautiful

截图

screen-shot-of-app

功能

信息来源

该应用通过两种来源提供国家信息:

您可以通过页脚的切换按钮在这两种来源之间切换。

AI响应缓存

该应用使用 Redis 缓存AI响应以提升性能:

详细设置说明见 REDIS_SETUP.md

AI功能分析

该应用包含全面的谷歌分析跟踪AI功能,以了解用户参与度和性能:

#### 跟踪事件

提供者使用情况:

AI请求: 缓存性能: 内容展示: 性能指标: #### 分析类别

所有AI相关事件均使用类别 "AI Feature",方便在Google Analytics中筛选。

#### 数据隐私

分析跟踪是匿名的,侧重于功能使用模式而非个人信息。不会跟踪 API 密钥或敏感数据。

设置

前提条件

安装

git clone https://github.com/nrgapple/historic-country-borders-app.git
cd historic-country-borders-app
yarn install

环境变量

创建一个 .env.local 文件:

# Optional for analytics
NEXT_PUBLIC_GA_FOUR=your_google_analytics_id

Optional for map features

NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_mapbox_token

Redis for AI response caching (required for caching)

REDIS_URL=your_redis_connection_string

Required for AI features (server-side only)

GEMINI_API_KEY=your_gemini_api_key_here

获取 API 密钥

#### Google Gemini API(免费)

优点: #### Vercel Redis 缓存(可选但推荐)

优点: #### Google Analytics 4(可选)

开发

yarn dev

打开 http://localhost:3000 查看应用。

测试

# Run all tests
yarn test

Run tests in watch mode

yarn test:watch

Run specific test files

yarn test hooks/__tests__/useAI.test.tsx

AI 功能故障排除

常见问题

“AI 信息需要设置 Gemini API 密钥”

AI 响应缓慢 空响应或错误响应

分析仪表盘

在 Google Analytics 查看 AI 功能分析:

性能监控

应用追踪多个性能指标:

贡献指南

许可证

MIT 许可证 - 详情请见 LICENSE

致谢

--- Tranlated By Open Ai Tx | Last indexed: 2026-03-07 ---