Implemented Vercel Web Analytics Integration
SUMMARY:
Successfully integrated Vercel Web Analytics into the Docusaurus 2 project following the user's specifications.
CHANGES MADE:
1. Installed @vercel/analytics package
- Executed: npm install @vercel/analytics
- Added @vercel/analytics to package.json dependencies
- Updated package-lock.json with dependency resolution
2. Modified src/pages/index.js (Home page component)
- Added import for useEffect from React: `import { useEffect } from 'react';`
- Added import for inject from @vercel/analytics: `import { inject } from '@vercel/analytics';`
- Added useEffect hook in the Home component to initialize Vercel Analytics on component mount
- The inject() function runs on the client side as required, with empty dependency array to ensure it runs once
IMPLEMENTATION DETAILS:
The Vercel Web Analytics configuration was added to the main homepage component since this is a Docusaurus 2 site. The inject() function is called within a useEffect hook with an empty dependency array [], ensuring it runs once when the component mounts on the client side.
The implementation follows React best practices:
- Uses useEffect for client-side initialization
- Empty dependency array ensures the analytics initializer runs once
- No route-specific configuration needed (as per user requirements)
- Minimal and non-intrusive changes to existing code
TESTING:
✓ Build completed successfully with no errors
✓ All webpack compilation warnings are pre-existing (LaTeX and Docusaurus-related)
✓ Static files generated without issues
✓ No linter errors introduced (no linter configured in project)
FILES MODIFIED:
- package.json - Added @vercel/analytics dependency
- package-lock.json - Updated with dependency resolution
- src/pages/index.js - Added Vercel Analytics initialization
VERIFICATION:
- Build: npm run build ✓ PASSED
- Package installation: npm install @vercel/analytics ✓ PASSED
- All changes preserve existing code structure and functionality
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
|
||
|---|---|---|
| .github | ||
| blog | ||
| docs | ||
| src | ||
| static | ||
| .gitattributes | ||
| .gitignore | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| README.md | ||
| docusaurus.config.js | ||
| package-lock.json | ||
| package.json | ||
| sidebars.js | ||
README.md
ECNU·课栈
本项目起源于 タクヤマ 的 ECNU_Crypt_Student_Manual
由 Eagle233 提出整合想法, 并建立第一版仓库 ECNU-SharedCourses
经由 KirisameVanilla 重构, 最终呈现为本仓库.
项目简介
本项目旨在为华东师范大学学生提供统一, 开放的课程资料共享平台, 集中整理, 公开共享各类课程资源, 欢迎所有人参与贡献.
快速开始
- 访问 courses.myecnu.org 或 courses.vanillaaaa.org 浏览和下载资料
- 贡献资料: Fork 本仓库, 按命名规范添加资料, 提交 PR, 等待审核合并
贡献指南
贡献者
项目结构
docs/
├── undergraduate/ # 本科生课程资料目录
├── postgraduate/ # 研究生课程资料目录
└── README.md # docs 路由中的置顶文档
研究生资料来源于 tianyilt/ecnu-PGCourseShare, BetterECNU 团队仅是收录并且更改了索引文档以适用于 docusaurus 框架
联系我们
如有问题或建议, 欢迎通过 Issue(推荐) 或 邮件 联系我们.