Skip to content

feat: add Vercel Web Analytics#2

Merged
marklearst merged 1 commit intomainfrom
feat/vercel-analytics
Jan 26, 2026
Merged

feat: add Vercel Web Analytics#2
marklearst merged 1 commit intomainfrom
feat/vercel-analytics

Conversation

@marklearst
Copy link
Copy Markdown
Owner

Add analytics tracking to all documentation pages using docmd's
customJs configuration. The script dynamically loads Vercel's
analytics from /_vercel/insights/script.js.

  • Create assets/js/vercel-analytics.js initialization script
  • Add customJs config to docmd.config.js

Add analytics tracking to all documentation pages using docmd's
customJs configuration. The script dynamically loads Vercel's
analytics from /_vercel/insights/script.js.

- Create assets/js/vercel-analytics.js initialization script
- Add customJs config to docmd.config.js
Copilot AI review requested due to automatic review settings January 26, 2026 03:09
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 26, 2026

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

Project Deployment Review Updated (UTC)
variables-contract Ready Ready Preview, Comment Jan 26, 2026 3:09am

@marklearst marklearst merged commit 4dc275e into main Jan 26, 2026
6 checks passed
@marklearst marklearst deleted the feat/vercel-analytics branch January 26, 2026 03:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Vercel Web Analytics to the documentation site by injecting a custom initialization script via docmd configuration.

Changes:

  • Configure docmd to load a custom JavaScript file on all pages.
  • Add a client-side script that defines window.va and dynamically loads Vercel’s Insights script.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
docmd.config.js Adds customJs entry to include the Vercel analytics initializer on all doc pages.
assets/js/vercel-analytics.js Initializes window.va and injects /_vercel/insights/script.js at runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docmd.config.js
},
autoTitleFromH1: true,
copyCode: true,
customJs: ["/assets/js/vercel-analytics.js"],
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customJs is configured with an absolute /assets/... URL, but this repo’s basePath is /variables-contract for GitHub Pages. If docmd doesn’t automatically prefix customJs entries with basePath, this will 404 on GitHub Pages. Prefer constructing the path with basePath (or using a relative path that docmd resolves against basePath) to ensure it works across both GH Pages and Vercel deployments.

Suggested change
customJs: ["/assets/js/vercel-analytics.js"],
customJs: [`${basePath}/assets/js/vercel-analytics.js`],

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +15
(function () {
var script = document.createElement('script');
script.defer = true;
script.src = '/_vercel/insights/script.js';
document.head.appendChild(script);
})();
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script always injects /_vercel/insights/script.js. On the GitHub Pages deployment (see docmd.config.js’s siteUrl/basePath), that endpoint won’t exist, causing a 404 request on every page load. Consider gating the injection to known Vercel hosts (e.g., variables-contract.vercel.app / *.vercel.app) or adding a lightweight guard/feature-detect so non‑Vercel environments don’t attempt to load it; also consider preventing duplicate injection by checking for an existing script tag before appending.

Copilot uses AI. Check for mistakes.
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.

2 participants