Install and Configure Vercel Web Analytics#1
Draft
vercel[bot] wants to merge 2 commits into
Draft
Conversation
# Vercel Web Analytics Installation Report
## Summary
Successfully installed and configured Vercel Web Analytics for the Firefly Astro blog project following the latest official Vercel documentation.
## Changes Made
### 1. Package Installation
- **Added dependency**: `@astrojs/vercel@^9.0.5` (compatible with Astro 5.x)
- Package installed via pnpm and added to `package.json`
- Updated `pnpm-lock.yaml` with new dependencies
### 2. Configuration
**Modified: `astro.config.mjs`**
- Imported Vercel static adapter: `import vercel from "@astrojs/vercel/static"`
- Added output mode: `output: "static"`
- Configured adapter with Web Analytics enabled:
```javascript
adapter: vercel({
webAnalytics: {
enabled: true,
},
})
```
### 3. Bug Fix (Bonus)
**Modified: `src/config/profileConfig.ts`**
- Fixed pre-existing icon set mismatch that was causing build failures
- Changed `fa6-brands` to `fa7-brands` for Bilibili and PayPal icons
- This was necessary to ensure the build completes successfully
### 4. Code Formatting
**Modified: `src/config/backgroundWallpaper.ts` and `src/config/navBarConfig.ts`**
- Biome linter automatically fixed indentation issues
- No functional changes, only formatting improvements
## Implementation Details
Following the official Vercel documentation for Astro (https://vercel.com/docs/frameworks/frontend/astro), I used the recommended approach of configuring Web Analytics through the Vercel adapter rather than manually adding the Analytics component. This approach:
1. **Automatic injection**: The adapter automatically injects the Web Analytics script (`/_vercel/insights/script.js`) into all pages
2. **Zero configuration**: No manual component imports needed in layouts
3. **Optimized**: Uses Vercel's automatic configuration via build environment variables
4. **Production-ready**: Analytics are automatically enabled when deployed to Vercel
## Verification
✅ **Type checking passed**: `pnpm run check` completed with 0 errors
✅ **Build successful**: `pnpm run build` completed without issues
✅ **Linting passed**: `pnpm run lint` completed and fixed formatting
✅ **Analytics script injected**: Verified `/_vercel/insights/script.js` is present in built HTML files
## How It Works
When deployed to Vercel:
1. The adapter injects the Web Analytics script into all HTML pages
2. Vercel automatically provides configuration via the `VERCEL_OBSERVABILITY_CLIENT_CONFIG` environment variable
3. Analytics start collecting page views and events automatically
4. Data is viewable in the Vercel dashboard under Analytics
## Next Steps
After deploying to Vercel:
1. Visit your Vercel project dashboard
2. Navigate to the "Analytics" tab
3. If not already enabled, click "Enable Web Analytics"
4. Analytics data will start appearing after users visit your site
5. Verify in browser DevTools that requests to `/_vercel/insights/view` are being made
## Notes
- Used `@astrojs/vercel@^9.0.5` for compatibility with Astro 5.17.3 (version 10.x requires Astro 6)
- The adapter uses the `/static` variant as this is a static site build
- Web Analytics are free and don't require any additional Vercel configuration
- The implementation follows Vercel's official best practices for Astro projects
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
701ff52 to
64275be
Compare
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.
Vercel Web Analytics Installation Report
Summary
Successfully installed and configured Vercel Web Analytics for the Firefly Astro blog project following the latest official Vercel documentation.
Changes Made
1. Package Installation
@astrojs/vercel@^9.0.5(compatible with Astro 5.x)package.jsonpnpm-lock.yamlwith new dependencies2. Configuration
Modified:
astro.config.mjsimport vercel from "@astrojs/vercel/static"output: "static"3. Bug Fix (Bonus)
Modified:
src/config/profileConfig.tsfa6-brandstofa7-brandsfor Bilibili and PayPal icons4. Code Formatting
Modified:
src/config/backgroundWallpaper.tsandsrc/config/navBarConfig.tsImplementation Details
Following the official Vercel documentation for Astro (https://vercel.com/docs/frameworks/frontend/astro), I used the recommended approach of configuring Web Analytics through the Vercel adapter rather than manually adding the Analytics component. This approach:
/_vercel/insights/script.js) into all pagesVerification
✅ Type checking passed:
pnpm run checkcompleted with 0 errors✅ Build successful:
pnpm run buildcompleted without issues✅ Linting passed:
pnpm run lintcompleted and fixed formatting✅ Analytics script injected: Verified
/_vercel/insights/script.jsis present in built HTML filesHow It Works
When deployed to Vercel:
VERCEL_OBSERVABILITY_CLIENT_CONFIGenvironment variableNext Steps
After deploying to Vercel:
/_vercel/insights/vieware being madeNotes
@astrojs/vercel@^9.0.5for compatibility with Astro 5.17.3 (version 10.x requires Astro 6)/staticvariant as this is a static site buildView Project · Web Analytics
Created by xlhxzkill-7147 with Vercel Agent