Skip to content

fix: classify non-mcp /api/* requests as 'other', not 'docs'#695

Open
MattewGraham wants to merge 2 commits into
tempoxyz:mainfrom
MattewGraham:classify-api-routes-as-other
Open

fix: classify non-mcp /api/* requests as 'other', not 'docs'#695
MattewGraham wants to merge 2 commits into
tempoxyz:mainfrom
MattewGraham:classify-api-routes-as-other

Conversation

@MattewGraham

Copy link
Copy Markdown

Stop counting non-MCP /api/* requests as documentation traffic

classifyDocsRequest powers the server-side analytics that tell us which AI
agents and crawlers hit the docs. Right now it quietly files a chunk of
plain application traffic under the docs surface, which skews every report
built on top of it.

Where it goes wrong

classifySurface special-cases /api/mcp, then falls through to
isDocsPage:

function isDocsPage(pathname: string) {
  const lastSegment = pathname.split('/').pop() ?? ''
  return !lastSegment.includes('.')   // "no file extension" == a docs page
}

/api/og, /api/feedback, /api/faucet, /api/index-supply all have an
extensionless last segment, so they’re labelled surface: 'docs'. From there:

  • an OG-image unfurl from Slackbot/facebookexternalhit (UA without
    mozilla/5.0) trips the unknown_ua branch and is recorded as an
    unknown_ai docs view;
  • a scripted POST /api/faucet is recorded as a developer_tool docs
    request.

The DocsRequestSurface docblock already says unrelated APIs belong in
other — the classifier just never enforced it.

Change

One guard, right after the existing /api/mcp check:

if (pathname === '/api' || pathname.startsWith('/api/')) return 'other'

MCP keeps its dedicated surface; everything else under /api/ becomes
other, which is excluded from agent-surface tracking. Added a regression
case (/api/ogsurface: 'other', shouldTrack: false) to the
table-driven classifier tests.

Checks

pnpm check:types passes. New case added to
e2e/docs-request-classifier.test.ts.

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@MattewGraham is attempting to deploy a commit to the Tempo Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant