Open
Conversation
Implemented Vercel Web Analytics for Next.js App Router ## Summary Successfully installed and configured Vercel Web Analytics in the GitBook Next.js application. ## Changes Made ### 1. Installed Dependencies - Added `@vercel/analytics@1.6.1` package using Bun package manager - Updated `bun.lock` lockfile to reflect the new dependency ### 2. Modified Files #### packages/gitbook/package.json - Added `@vercel/analytics` as a dependency #### packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx - Imported `Analytics` component from `@vercel/analytics/next` - Added `<Analytics />` component inside the `<body>` tag after the `<IconsProvider>` wrapper - Maintained proper import sorting according to project's Biome linter rules ## Implementation Details This project uses Next.js App Router with a custom architecture where `CustomizationRootLayout` serves as the shared root layout component across different routes. The Analytics component was placed in this central location to ensure it's included across all pages in the application. The component is placed right before the closing `</body>` tag to ensure: - It loads after the main content - It doesn't block rendering - It tracks all page views across the entire application ## Testing & Verification ✅ **Build**: Successfully compiled with `bun run build` from the monorepo root ✅ **Linter**: Passed Biome linter checks (pre-existing linter errors in other files remain unchanged) ✅ **Unit Tests**: All 174 tests passed ✅ **TypeScript**: Type checking successful ## Notes - The project uses a monorepo structure with Bun as the package manager - The Analytics component is placed in the shared `CustomizationRootLayout` component, which is used by all routes in the app - This ensures analytics tracking is enabled across the entire application without needing to modify individual layout files Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented Vercel Web Analytics for Next.js App Router
Summary
Successfully installed and configured Vercel Web Analytics in the GitBook Next.js application.
Changes Made
1. Installed Dependencies
@vercel/analytics@1.6.1package using Bun package managerbun.locklockfile to reflect the new dependency2. Modified Files
packages/gitbook/package.json
@vercel/analyticsas a dependencypackages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx
Analyticscomponent from@vercel/analytics/next<Analytics />component inside the<body>tag after the<IconsProvider>wrapperImplementation Details
This project uses Next.js App Router with a custom architecture where
CustomizationRootLayoutserves as the shared root layout component across different routes. The Analytics component was placed in this central location to ensure it's included across all pages in the application.The component is placed right before the closing
</body>tag to ensure:Testing & Verification
✅ Build: Successfully compiled with
bun run buildfrom the monorepo root✅ Linter: Passed Biome linter checks (pre-existing linter errors in other files remain unchanged)
✅ Unit Tests: All 174 tests passed
✅ TypeScript: Type checking successful
Notes
CustomizationRootLayoutcomponent, which is used by all routes in the appView Project · Web Analytics
Created by MOVE (cshein45) with Vercel Agent