Skip to content

feat(web): add Vercel Web Analytics - #230

Merged
amanthanvi merged 11 commits into
mainfrom
vercel/install-and-configure-vercel-w-f8nm24
Sep 23, 2026
Merged

amanthanvi merged 11 commits into
mainfrom
vercel/install-and-configure-vercel-w-f8nm24

Conversation

@vercel

@vercel vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

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

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:

  • Add production Vercel Web Analytics to collect aggregate page-view and referral statistics alongside existing performance measurements.

Enhancements:

  • Update the privacy policy to document Web Analytics data collection, retention, usage, provider details, and Global Privacy Control behavior.
  • Clarify changelog disclosures for Web Analytics and Speed Insights privacy behavior.

Build:

  • Add the Vercel Analytics package and update the lockfile.

# 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>
@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
synac-web Ready Ready Preview Sep 23, 2026 3:23pm UTC

Request Review

@sourcery-ai

sourcery-ai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The 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 reporting

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Add Vercel Web Analytics alongside existing Speed Insights, sharing production gating and privacy-related request filtering.
  • Add the Analytics package dependency and lockfile resolution.
  • Render Analytics and Speed Insights together through the shared insights component, using the existing before-send hook.
  • Document aggregate page-view collection, data fields, retention, referral data, and Global Privacy Control behavior.
apps/web/package.json
apps/web/src/components/VercelInsights.tsx
pnpm-lock.yaml
CHANGELOG.md
apps/web/src/app/legal/privacy/page.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: a4734c0f-1168-4586-a411-d7d9fa80dcdd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

vercel Bot and others added 10 commits September 13, 2026 02:23
## 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.
@amanthanvi
amanthanvi marked this pull request as ready for review September 23, 2026 15:22
@amanthanvi
amanthanvi self-requested a review as a code owner September 23, 2026 15:22
@amanthanvi amanthanvi changed the title Install and configure Vercel Web Analytics feat(web): add Vercel Web Analytics Sep 23, 2026
@amanthanvi

Copy link
Copy Markdown
Owner

Updated for merge on top of #231 (now on main):

  • Merged current main; the lockfile diff is purely additive (@vercel/analytics@2.0.1, same integrity hash as the original).
  • Web Analytics renders from the existing VercelInsights wrapper (production builds only) with the same beforeSend as Speed Insights: nothing is sent when the browser sends Global Privacy Control, and the reported page address loses its query string otherwise. Verified against Vercel's hosted script: every pageview goes through beforeSend, and the script sets no cookies or storage for SynAc.
  • /legal/privacy describes what Web Analytics sends per Vercel's docs and drains schema (including the device identifier and the external referrer as the browser reports it); CHANGELOG.md Unreleased entry added.
  • Local lint, typecheck, tests, content check, and build pass; wording independently reviewed.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the analytics integration is mounted once in production and preserves the existing privacy filtering.

Summary

This PR adds Vercel Web Analytics alongside the existing Speed Insights integration and applies the same query-string removal and Global Privacy Control filtering to both measurement paths.

  • Adds and locks @vercel/analytics for the web workspace.
  • Mounts Web Analytics through the existing production-only VercelInsights component.
  • Updates the privacy policy and changelog to disclose aggregate page-view measurement and related data handling.

Reviews (1) · Last reviewed commit: "docs(web): tighten the Web Analytics dis..."

@amanthanvi
amanthanvi merged commit 542f746 into main Sep 23, 2026
15 checks passed

This branch was successfully deployed

1 active deployment
Preview 49ce11b3 Deployed Sep 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant