Repository navigation
Conversation
|
@VG31OP is attempting to deploy a commit to the Curated Tests - Permanent E2E Team on Vercel. A member of the Team first needs to authorize it. |
Khanos
pushed a commit
to Khanos/khanos.frontend
that referenced
this pull request
Oct 29, 2026
# Vercel Web Analytics Installation Report
## Summary
Successfully installed and configured Vercel Web Analytics for this Astro project following the latest official documentation.
## Changes Made
### 1. Installed @vercel/analytics package
- Added `@vercel/analytics@^2.0.1` to dependencies
- Updated `pnpm-lock.yaml` to reflect the new dependency
### 2. Configured Vercel adapter (astro.config.mjs)
- Enabled Web Analytics in the Vercel adapter configuration
- Added `webAnalytics: { enabled: true }` to the adapter options
- This configuration helps with proper deployment and integration with Vercel's platform
### 3. Added Analytics component (src/layouts/Layout.astro)
- Imported Analytics component from `@vercel/analytics/astro`
- Added `<Analytics />` component to the head section of the main layout
- The component is placed after the ClientRouter to ensure proper initialization
- Analytics will now track page views across all pages that use this layout
### 4. Added TypeScript declarations (src/env.d.ts)
- Added module declarations for `@vercel/analytics/astro` to resolve TypeScript errors
- This allows the TypeScript compiler to recognize the Astro component import
- Workaround for missing type exports in the current version of @vercel/analytics
## Implementation Details
The implementation follows the official Vercel Analytics documentation for Astro:
- For @vercel/analytics v2.0.1 (installed), manual component integration is required
- The adapter's `webAnalytics.enabled` configuration provides additional integration with Vercel's platform
- The Analytics component is imported and rendered in the base layout to track all pages
## Testing
- ✅ Build successful: `pnpm build` completes without errors
- ✅ TypeScript check passed: No type errors in Astro files
- ✅ All tests passing: 86 tests across 7 test files
- ✅ No linting errors introduced
## Deployment Notes
Once deployed to Vercel:
1. Enable Web Analytics in your Vercel dashboard under the project's Analytics tab
2. Analytics will automatically start tracking page views
3. Check browser's Network tab for `/<unique-path>/view` requests to confirm tracking is active
## Files Modified
- `astro.config.mjs` - Added webAnalytics configuration to Vercel adapter
- `package.json` - Added @vercel/analytics dependency
- `pnpm-lock.yaml` - Updated with new dependency
- `src/layouts/Layout.astro` - Imported and added Analytics component
- `src/env.d.ts` - Added TypeScript module declarations
## Notes
The TypeScript module declarations in `env.d.ts` are a temporary workaround for the current version of @vercel/analytics which doesn't properly expose types for the Astro subpath export. This is a known issue (vercel/analytics#219) and should be resolved in a future version of the package.
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
This branch has not been deployed
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.
Summary
Fixes #169.
When importing
@vercel/analytics/astro, TypeScript fails to resolve module declarations under TypeScript 4.7+ / 5.x resolution modes (moduleResolution: "bundler","node16", or"nodenext"):Root Cause
packages/web/package.json#exports["./astro"], only"import": "./dist/astro/component.ts"was provided, omitting the"types"export condition. TypeScript requires the"types"condition to be listed first for subpath imports.packages/web/package.json#typesVersions["*"], entries existed fornext,nuxt,react,remix,server,sveltekit, andvue, but"astro"was missing../next,./react,./nuxt,./remix,./vue) were also missing explicit"types"conditions inexports, relying solely on fallbacktypesVersions.Changes
"types": "./dist/astro/component.ts"toexports["./astro"]."astro": ["dist/astro/component.ts"]totypesVersions["*"]."types"conditions across all subpath export targets inpackages/web/package.json.Verification
pnpm --filter astro buildandastro checkinapps/astro:@vercel/analytics/astroimports and resolves cleanly without type errors.packages/webpass (10/10 test files, 107/107 tests passing).