From 1de318be5e48c8516c712bc400dfe689973ff9c2 Mon Sep 17 00:00:00 2001 From: Vercel Date: Sun, 21 Jun 2026 16:04:02 +0000 Subject: [PATCH] Install and configure Vercel Web Analytics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented Vercel Web Analytics for PetroBrain Web ## What was implemented Successfully installed and configured Vercel Web Analytics following the latest official documentation from https://vercel.com/docs/analytics/quickstart. ### Changes made: 1. **Installed @vercel/analytics package** - Added `@vercel/analytics` version 2.0.1 to project dependencies - Used npm (the project's package manager) to install the package - Updated package.json and package-lock.json accordingly 2. **Configured Analytics in root layout** - Modified `app/layout.tsx` to import the Analytics component from `@vercel/analytics/next` - Added the `` component to the root layout body, alongside the existing Plausible analytics component - Followed Next.js App Router best practices by placing it in the root layout for app-wide analytics tracking ### Implementation details: - **Framework**: Next.js with App Router (identified from project structure) - **Installation method**: Framework-specific integration for Next.js as specified in Vercel documentation - **Placement**: Added to `app/layout.tsx` root layout to ensure analytics tracks all pages - **Compatibility**: Preserved existing analytics setup (Plausible) - both analytics solutions now run in parallel ### Verification: ✅ Package installed successfully via npm ✅ Linter passes with no errors ✅ Code follows existing project patterns and conventions ✅ Lock file updated correctly ### Notes: - The Analytics component will automatically collect page view data once the app is deployed to Vercel - Analytics must be enabled in the Vercel dashboard for the project to start collecting data - The component gracefully handles development vs production environments - Build verification showed a pre-existing configuration issue (missing NEON_AUTH_COOKIE_SECRET) unrelated to these changes - All changes follow the official Vercel documentation retrieved on June 21, 2026 ### Files modified: - `app/layout.tsx` - Added Analytics import and component - `package.json` - Added @vercel/analytics dependency - `package-lock.json` - Updated with new package resolution Co-authored-by: Vercel --- app/layout.tsx | 2 ++ package-lock.json | 43 +++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 46 insertions(+) diff --git a/app/layout.tsx b/app/layout.tsx index ee5cd9d..3b2c9d6 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,6 +3,7 @@ import "./globals.css"; import { fontMono, fontSans } from "@/lib/fonts"; import { site } from "@/lib/site"; import { Plausible } from "@/components/analytics/Plausible"; +import { Analytics } from "@vercel/analytics/next"; export const metadata: Metadata = { metadataBase: new URL(site.url), @@ -40,6 +41,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) app/(marketing)/layout.tsx and app/app/layout.tsx. */} {children} + ); diff --git a/package-lock.json b/package-lock.json index f13fe29..c0ab118 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@neondatabase/auth": "^0.4.1-beta", "@tanstack/react-query": "^5.100.14", + "@vercel/analytics": "^2.0.1", "contentlayer2": "^0.5.8", "date-fns": "^3.6.0", "maplibre-gl": "^4.7.1", @@ -6948,6 +6949,48 @@ "win32" ] }, + "node_modules/@vercel/analytics": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@vercel/analytics/-/analytics-2.0.1.tgz", + "integrity": "sha512-MTQG6V9qQrt1tsDeF+2Uoo5aPjqbVPys1xvnIftXSJYG2SrwXRHnqEvVoYID7BTruDz4lCd2Z7rM1BdkUehk2g==", + "license": "MIT", + "peerDependencies": { + "@remix-run/react": "^2", + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "nuxt": ">= 3", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@remix-run/react": { + "optional": true + }, + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "nuxt": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + } + }, "node_modules/@vis.gl/react-mapbox": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/@vis.gl/react-mapbox/-/react-mapbox-8.1.1.tgz", diff --git a/package.json b/package.json index 928be73..d2555b4 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "dependencies": { "@neondatabase/auth": "^0.4.1-beta", "@tanstack/react-query": "^5.100.14", + "@vercel/analytics": "^2.0.1", "contentlayer2": "^0.5.8", "date-fns": "^3.6.0", "maplibre-gl": "^4.7.1",