Skip to content

Add Vercel Speed Insights integration - #6

Draft
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/vercel-speed-insights-integrat-epo75p
Draft

Add Vercel Speed Insights integration#6
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/vercel-speed-insights-integrat-epo75p

Conversation

@vercel

@vercel vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

Implemented Vercel Speed Insights for the wechat-workflow project.

Summary

Successfully installed and configured Vercel Speed Insights following the latest official documentation from https://vercel.com/docs/speed-insights/quickstart.

Changes Made

1. Package Installation

  • Installed @vercel/speed-insights version 2.0.0
  • Added dependency to package.json
  • Updated package-lock.json with new package and its 87 dependencies

2. Server Configuration (server.js)

  • Added a new route to serve the Speed Insights script from node_modules
  • Route: GET /_vercel/speed-insights/script.js
  • This serves the browser-compatible ES module from @vercel/speed-insights/dist/index.mjs
  • Positioned before the static file middleware to ensure proper handling

3. Client Integration (public/index.html)

  • Added a module script tag at the end of the HTML body
  • Imported and initialized Speed Insights using injectSpeedInsights() function
  • Used ES6 module syntax with type="module" for browser compatibility

Implementation Details

Since this is an Express application serving a vanilla JavaScript single-page application (SPA), I implemented the framework-agnostic approach:

  1. The Speed Insights library is served directly from node_modules via an Express route
  2. The HTML file loads it as an ES module
  3. The injectSpeedInsights() function is called immediately to initialize tracking

This approach:

  • Does not require a build step or bundler
  • Preserves the existing code structure
  • Works seamlessly with the Express server setup
  • Automatically tracks web vitals and performance metrics when deployed to Vercel

Testing Performed

npm test: All smoke tests passed (template conversions working correctly)
Server startup: Server starts without errors on port 3000
Script endpoint: Speed Insights script is accessible at /_vercel/speed-insights/script.js
HTML validation: HTML file is valid and properly formatted

Notes

  • Speed Insights will only track data in production mode (not in development)
  • The analytics data will be visible in the Vercel dashboard once the app is deployed
  • No additional configuration is required; Speed Insights works out of the box with default settings
  • The implementation uses the official Vercel Speed Insights package (v2.0.0) as of June 2026

View Project · Speed Insights

Created by Dong Ke (baiheinet) with Vercel Agent

Implemented Vercel Speed Insights for the wechat-workflow project.

## Summary
Successfully installed and configured Vercel Speed Insights following the latest official documentation from https://vercel.com/docs/speed-insights/quickstart.

## Changes Made

### 1. Package Installation
- Installed `@vercel/speed-insights` version 2.0.0
- Added dependency to package.json
- Updated package-lock.json with new package and its 87 dependencies

### 2. Server Configuration (server.js)
- Added a new route to serve the Speed Insights script from node_modules
- Route: `GET /_vercel/speed-insights/script.js`
- This serves the browser-compatible ES module from `@vercel/speed-insights/dist/index.mjs`
- Positioned before the static file middleware to ensure proper handling

### 3. Client Integration (public/index.html)
- Added a module script tag at the end of the HTML body
- Imported and initialized Speed Insights using `injectSpeedInsights()` function
- Used ES6 module syntax with type="module" for browser compatibility

## Implementation Details

Since this is an Express application serving a vanilla JavaScript single-page application (SPA), I implemented the framework-agnostic approach:

1. The Speed Insights library is served directly from node_modules via an Express route
2. The HTML file loads it as an ES module
3. The `injectSpeedInsights()` function is called immediately to initialize tracking

This approach:
- Does not require a build step or bundler
- Preserves the existing code structure
- Works seamlessly with the Express server setup
- Automatically tracks web vitals and performance metrics when deployed to Vercel

## Testing Performed

✅ **npm test**: All smoke tests passed (template conversions working correctly)
✅ **Server startup**: Server starts without errors on port 3000
✅ **Script endpoint**: Speed Insights script is accessible at /_vercel/speed-insights/script.js
✅ **HTML validation**: HTML file is valid and properly formatted

## Notes

- Speed Insights will only track data in production mode (not in development)
- The analytics data will be visible in the Vercel dashboard once the app is deployed
- No additional configuration is required; Speed Insights works out of the box with default settings
- The implementation uses the official Vercel Speed Insights package (v2.0.0) as of June 2026

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown
Author

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
wechat-workflow Ready Ready Preview, Comment Jun 10, 2026 1:37pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants