Skip to content

feat: track API usage in Vercel Web Analytics - #222

Open
brunobuddy wants to merge 2 commits into
mainfrom
feat/api-usage-tracking
Open

feat: track API usage in Vercel Web Analytics#222
brunobuddy wants to merge 2 commits into
mainfrom
feat/api-usage-tracking

Conversation

@brunobuddy

Copy link
Copy Markdown
Member

💭 Why

The analytics script only runs on HTML pages. The JSON API is static files fetched by curl and SDKs, so we had no visibility into which endpoints and models get used.

✨ What changed

  • Edge middleware posts an api_request custom event per /api/* and llms.txt request.
  • Events carry endpoint, provider, model, auth mode, and client type (curl, python, node, browser).
  • Wire format copied from @vercel/analytics/server 2.0.1: the package itself can't install here (its optional SvelteKit peer wants vite 8, we're on vite 5).
  • No-op outside Vercel. README and CONTRIBUTING document the new module.

🔧 For operators

  • Custom events need a Vercel Pro plan; they show up under Analytics → Events.
  • Every API hit counts as one metered Web Analytics event.

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
modelparams.dev Ready Ready Preview Aug 13, 2026 3:20pm

Request Review

@github-actions github-actions Bot added site Website code or tooling meta Repo docs, CI, and config labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Repo docs, CI, and config site Website code or tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant