Install Vercel Web Analytics - #1
Draft
vercel[bot] wants to merge 1 commit into
Draft
Conversation
Implemented Vercel Web Analytics for the Astro project
## What was implemented:
### 1. Package Installation
- Installed `@vercel/analytics` package (version ^2.0.1)
- Updated package.json to include the new dependency
- Updated package-lock.json with the new package and its dependencies
### 2. Configuration Changes
- Modified `astro.config.mjs` to enable Vercel Web Analytics
- Added `webAnalytics: { enabled: true }` configuration to the Vercel adapter
- This follows the official Astro-specific integration method documented at https://vercel.com/docs/analytics/quickstart
## Files Modified:
- `astro.config.mjs` - Added webAnalytics configuration to the Vercel adapter
- `package.json` - Added @vercel/analytics dependency
- `package-lock.json` - Updated with @vercel/analytics and its dependencies
## Implementation Details:
For Astro projects using the Vercel adapter, the recommended approach is to configure Web Analytics directly in the adapter configuration rather than manually adding script tags or components. The configuration added enables Vercel Web Analytics by setting `webAnalytics.enabled` to `true` in the `vercel()` adapter options.
This approach:
- Follows Vercel's official documentation for Astro projects
- Integrates seamlessly with the existing Vercel adapter already in use
- Automatically injects the necessary analytics scripts during build
- Requires no changes to individual page or layout files
## Verification:
1. ✅ Build completed successfully with `npm run build`
2. ✅ All 20 tests passed with `npm test`
3. ✅ No linting errors or build warnings
4. ✅ Lock files properly updated with new dependency
The analytics will be active once the project is deployed to Vercel and Web Analytics is enabled in the Vercel dashboard for this project.
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 the Astro project
What was implemented:
1. Package Installation
@vercel/analyticspackage (version ^2.0.1)2. Configuration Changes
astro.config.mjsto enable Vercel Web AnalyticswebAnalytics: { enabled: true }configuration to the Vercel adapterFiles Modified:
astro.config.mjs- Added webAnalytics configuration to the Vercel adapterpackage.json- Added @vercel/analytics dependencypackage-lock.json- Updated with @vercel/analytics and its dependenciesImplementation Details:
For Astro projects using the Vercel adapter, the recommended approach is to configure Web Analytics directly in the adapter configuration rather than manually adding script tags or components. The configuration added enables Vercel Web Analytics by setting
webAnalytics.enabledtotruein thevercel()adapter options.This approach:
Verification:
npm run buildnpm testThe analytics will be active once the project is deployed to Vercel and Web Analytics is enabled in the Vercel dashboard for this project.
View Project · Web Analytics
Created by sankalp1519-1430 with Vercel Agent