Skip to content

Commit 6542ebd

Browse files
committed
Install Vercel Web Analytics integration
# Vercel Web Analytics Installation Report ## Summary Successfully installed and configured Vercel Web Analytics for both Next.js applications in this monorepo following the official Vercel documentation. ## Changes Made ### 1. Package Installation - Installed `@vercel/analytics@^2.0.1` in both Next.js applications: - `extras/docs` - `extras/web` ### 2. Configuration Updates #### extras/docs/app/layout.tsx - Added import: `import { Analytics } from '@vercel/analytics/next'` - Added `<Analytics />` component inside the `<body>` tag (after children) - This enables automatic tracking of page views and user interactions #### extras/docs/package.json - Added `"@vercel/analytics": "^2.0.1"` to dependencies #### extras/web/package.json - Added `"@vercel/analytics": "^2.0.1"` to dependencies - Note: The layout.tsx file already had Analytics configured #### pnpm-lock.yaml - Updated lockfile with new dependency resolutions ## Implementation Details ### Framework Detection This is a pnpm monorepo with two Next.js 15 applications using the App Router architecture. ### Installation Approach Following the official Vercel documentation (https://vercel.com/docs/analytics/quickstart): 1. Fetched latest installation instructions from Vercel docs 2. Identified Next.js App Router as the framework 3. Installed package using pnpm (the project's package manager) 4. Added Analytics component to root layout files as per Next.js App Router best practices ### Configuration Pattern The Analytics component is placed at the end of the `<body>` tag (after `{children}`) as recommended by Vercel. This ensures: - Analytics loads after main content - Minimal impact on page load performance - Proper tracking of all page interactions ## Testing Notes The packages were successfully installed and configuration is correct. The project has pre-existing build errors in the `@repo/ui` package (unrelated to Analytics installation): - Missing react type declarations in the shared UI package - These errors existed before our changes The Analytics integration itself is correctly implemented and will work once the project's pre-existing issues are resolved or when deployed to Vercel (where Analytics routes are automatically enabled). ## Next Steps (for project owner) 1. Deploy the application to Vercel 2. Enable Web Analytics in the Vercel dashboard (Analytics section of your project) 3. After deployment, verify tracking by checking for requests to `/_vercel/insights/*` in browser DevTools 4. Analytics data will start appearing in the Vercel dashboard ## Files Modified - `extras/docs/app/layout.tsx` - Added Analytics component - `extras/docs/package.json` - Added dependency - `extras/web/package.json` - Added dependency - `pnpm-lock.yaml` - Updated lockfile Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
1 parent b4ff445 commit 6542ebd

4 files changed

Lines changed: 15157 additions & 2619 deletions

File tree

extras/docs/app/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from 'next'
22
import localFont from 'next/font/local'
3+
import { Analytics } from '@vercel/analytics/next'
34
import './globals.css'
45

56
const geistSans = localFont({
@@ -23,7 +24,10 @@ export default function RootLayout({
2324
}>) {
2425
return (
2526
<html lang="en">
26-
<body className={`${geistSans.variable} ${geistMono.variable}`}>{children}</body>
27+
<body className={`${geistSans.variable} ${geistMono.variable}`}>
28+
{children}
29+
<Analytics />
30+
</body>
2731
</html>
2832
)
2933
}

extras/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@repo/ui": "workspace:^",
16+
"@vercel/analytics": "^2.0.1",
1617
"next": "^15.5.16",
1718
"react": "^19.2.3",
1819
"react-dom": "^19.2.3"

extras/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@repo/ui": "workspace:^",
16+
"@vercel/analytics": "^2.0.1",
1617
"next": "^15.5.16",
1718
"react": "^19.2.3",
1819
"react-dom": "^19.2.3"

0 commit comments

Comments
 (0)