feat(web): add Vercel Web Analytics - #230
Conversation
# Vercel Web Analytics Installation ## Summary Successfully installed and configured Vercel Web Analytics for the synac-web project following the latest official documentation from https://vercel.com/docs/analytics/quickstart. ## Changes Made ### 1. Package Installation - Installed `@vercel/analytics@^2.0.1` using pnpm - Updated `apps/web/package.json` to include the new dependency - Updated `pnpm-lock.yaml` with dependency resolution ### 2. Analytics Integration (apps/web/src/app/layout.tsx) - Added import: `import { Analytics } from '@vercel/analytics/next';` - Added `<Analytics />` component before the closing `</body>` tag in the RootLayout component - Follows Next.js App Router best practices as specified in the official documentation ## Implementation Details **Framework Detected:** Next.js 16.3.4 with App Router (using `src/app/layout.tsx`) **Package Manager:** pnpm (version 10.34.4 as specified in package.json) **Implementation Approach:** - Followed the Next.js App Router installation pattern from official Vercel documentation - Placed Analytics component at the end of the body tag to ensure it loads after all content - Preserved all existing code structure, imports, and functionality ## Verification Steps Completed 1. ✅ **Type Check:** `pnpm typecheck` passed with no errors 2. ✅ **Linter:** `pnpm lint` passed with no errors 3. ✅ **Build:** `pnpm build` completed successfully (all 24 routes generated) 4. ✅ **Tests:** `pnpm test` passed (38 tests across 8 test files) ## Files Modified 1. `apps/web/package.json` - Added @vercel/analytics dependency 2. `apps/web/src/app/layout.tsx` - Added Analytics import and component 3. `pnpm-lock.yaml` - Updated with new dependencies (485 packages added for the full dependency tree) ## Next Steps To complete the setup: 1. Deploy the changes to Vercel 2. Enable Web Analytics in the Vercel dashboard (Navigate to Analytics → Enable) 3. After deployment, verify analytics is working by checking browser Network tab for analytics requests ## Notes - The Analytics component is automatically configured to work in both development and production environments - No additional configuration is required unless custom options are needed - The component will only collect anonymous analytics data when deployed on Vercel Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideThe PR integrates Vercel Web Analytics into the existing production-only Vercel insights component, applies the shared privacy filtering hook, and updates the privacy policy and changelog to describe the new aggregate page-view tracking and opt-out behavior. Sequence diagram for production Vercel analytics reportingsequenceDiagram
participant Browser
participant VercelInsights
participant Analytics
participant SpeedInsights
participant Vercel
Browser->>VercelInsights: render()
alt production
VercelInsights->>Analytics: Analytics(beforeSend=beforeInsightsSend)
VercelInsights->>SpeedInsights: SpeedInsights(beforeSend=beforeInsightsSend)
Analytics->>Analytics: beforeInsightsSend(...)
Analytics->>Vercel: send page-view measurement
SpeedInsights->>SpeedInsights: beforeInsightsSend(...)
SpeedInsights->>Vercel: send performance measurement
else non-production
VercelInsights-->>Browser: null
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## Vercel Speed Insights Installation - Implementation Report
### Summary
Successfully installed and configured Vercel Speed Insights for the SynAc web application following the latest official documentation from Vercel.
### Changes Made
#### 1. Package Installation
- **Added dependency**: `@vercel/speed-insights@^2.0.0` to `apps/web/package.json`
- **Package manager**: Used pnpm (project's package manager)
- **Updated**: `pnpm-lock.yaml` to reflect new dependency
#### 2. Code Configuration
- **Modified file**: `apps/web/src/app/layout.tsx`
- **Added import**: `import { SpeedInsights } from '@vercel/speed-insights/next';`
- **Added component**: `<SpeedInsights />` component placed at the end of the `<body>` tag in the root layout
### Implementation Details
The implementation follows the official Vercel Speed Insights quickstart guide for Next.js App Router:
1. **Framework Detection**: Identified Next.js 16.3.4 with App Router structure
2. **Documentation Source**: Fetched latest installation instructions from https://vercel.com/docs/speed-insights/quickstart
3. **Placement Strategy**: Added SpeedInsights component at the end of the body tag (after SiteFooter) in the root layout, following Vercel's recommendation
4. **Integration**: The component will automatically track Core Web Vitals and performance metrics when deployed to Vercel
### Verification Steps Completed
✓ **TypeScript Check**: `pnpm run typecheck` - Passed with no errors
✓ **Linting**: `pnpm run lint` - Passed with no errors
✓ **Build**: `pnpm run build` - Successfully completed production build
✓ **Tests**: `pnpm run test` - All 38 tests passed (8 test files)
### Files Changed
1. `apps/web/package.json` - Added @vercel/speed-insights dependency
2. `apps/web/src/app/layout.tsx` - Added SpeedInsights import and component
3. `pnpm-lock.yaml` - Updated with new dependency resolution
### Notes
- The SpeedInsights component is a zero-config solution that automatically tracks performance metrics
- Data collection will begin automatically once the application is deployed to Vercel
- The component adds tracking routes at `/_vercel/speed-insights/*` for data collection
- No additional configuration is required; metrics will appear in the Vercel dashboard after deployment
- The implementation preserves all existing code structure and functionality
- The component is placed at the end of the body to ensure it doesn't interfere with the page's critical rendering path
### Next Steps
The Speed Insights component is now ready to collect performance data when deployed to Vercel. After deployment:
1. Visit your site to generate initial metrics
2. View Speed Insights data in the Vercel dashboard
3. Monitor Core Web Vitals (LCP, FID, CLS) and other performance metrics
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
# Conflicts: # apps/web/package.json # pnpm-lock.yaml
Route Speed Insights through a client wrapper so beforeSend can drop the query string from every report, keeping search terms (/search?q=...) out of Vercel's data. Update the privacy policy and changelog to describe what Speed Insights sends.
# Conflicts: # apps/web/package.json # apps/web/src/app/layout.tsx # pnpm-lock.yaml
Render Vercel Web Analytics from the VercelInsights client wrapper with the same beforeSend that drops query strings, so search terms never reach Vercel. Describe what Web Analytics sends in the privacy policy and the changelog.
… disclosure - beforeSend drops every report when the browser sends Global Privacy Control; other reports still lose their query string. - Render Speed Insights only in production builds; the development CSP blocks the debug script it loads from va.vercel-scripts.com. - The policy now lists the fields Vercel documents (route, element attribution, region and city, device brand, a device identifier), attributes anonymity claims to Vercel, and scopes query-string removal to the reported page address.
# Conflicts: # CHANGELOG.md # apps/web/src/app/legal/privacy/page.tsx # apps/web/src/components/VercelInsights.tsx
Render Vercel Web Analytics beside Speed Insights with the same beforeSend: no reports when the browser sends Global Privacy Control, and no query string otherwise. The privacy policy lists what Web Analytics sends, and the changelog records it.
# Conflicts: # CHANGELOG.md # apps/web/package.json # apps/web/src/app/legal/privacy/page.tsx # apps/web/src/components/VercelInsights.tsx # pnpm-lock.yaml
Per review: the 24-hour discard applies to the visitor session, Vercel's records include a device identifier, the referrer is sent as the browser reports it for arrivals from other sites, and GPC browsers send nothing rather than going unmeasured.
|
Updated for merge on top of #231 (now on
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the analytics behavior or its privacy assumptions are wrong, every production visitor who does not send GPC may have page-view metadata, referrers, device details, and approximate location sent to Vercel. Reverting stops future collection but cannot retract data already received, so this is an immediate, site-wide privacy and third-party trust-boundary decision.
|
Vercel Web Analytics Installation
Summary
Successfully installed and configured Vercel Web Analytics for the synac-web project following the latest official documentation from https://vercel.com/docs/analytics/quickstart.
Changes Made
1. Package Installation
@vercel/analytics@^2.0.1using pnpmapps/web/package.jsonto include the new dependencypnpm-lock.yamlwith dependency resolution2. Analytics Integration (apps/web/src/app/layout.tsx)
import { Analytics } from '@vercel/analytics/next';<Analytics />component before the closing</body>tag in the RootLayout componentImplementation Details
Framework Detected: Next.js 16.3.4 with App Router (using
src/app/layout.tsx)Package Manager: pnpm (version 10.34.4 as specified in package.json)
Implementation Approach:
Verification Steps Completed
pnpm typecheckpassed with no errorspnpm lintpassed with no errorspnpm buildcompleted successfully (all 24 routes generated)pnpm testpassed (38 tests across 8 test files)Files Modified
apps/web/package.json- Added @vercel/analytics dependencyapps/web/src/app/layout.tsx- Added Analytics import and componentpnpm-lock.yaml- Updated with new dependencies (485 packages added for the full dependency tree)Next Steps
To complete the setup:
Notes
View Project · Web Analytics
Created by amanthanvi with Vercel Agent
Summary by Sourcery
Enable production page-view analytics and document its privacy implications.
New Features:
Enhancements:
Build: