feat: add middleware to track AI coding agent traffic#2496
Draft
caffeinum wants to merge 1 commit intolangfuse:mainfrom
Draft
feat: add middleware to track AI coding agent traffic#2496caffeinum wants to merge 1 commit intolangfuse:mainfrom
caffeinum wants to merge 1 commit intolangfuse:mainfrom
Conversation
|
@caffeinum is attempting to deploy a commit to the langfuse Team on Vercel. A member of the Team first needs to authorize it. |
|
|
d0c9172 to
0de00a8
Compare
- sends raw headers to API for server-side detection - uses waitUntil to not block response - tracks all visits (AI + human) for ratio analytics
0de00a8 to
112a102
Compare
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
Adds Next.js middleware to detect and track AI coding agents (Claude Code, Cursor, Windsurf, etc.) visiting the docs.
How it works
AI coding agents send
Accept: text/markdownheader when fetching documentation - browsers never do this. The middleware detects this signal and sends anonymized events to an external analytics API.Detection signals:
Accept: text/markdown(primary - browsers never send this)Accept: text/plainprioritized overtext/htmlDetected agents:
claude,anthropicin UA)cursorin UA)windsurf,codeiumin UA)opencodein UA)aiderin UA)continuein UA)copilot,githubin UA)Configuration
No configuration needed. The middleware sends events to an external tracking API - no env vars or secrets required in this repo.
Data collected
No PII or sensitive data is collected.
Testing