feat: add agent-analytics-starter example#1461
Open
Gdewilde wants to merge 4 commits intovercel:mainfrom
Open
Conversation
Next.js 15 starter that tracks AI agent traffic (ClaudeBot, GPTBot, PerplexityBot, Google-Extended, and 20+ more) in PostHog via middleware. Drop in a PostHog key, deploy, and agent fetches show up as doc_view events with is_ai_bot, source, and user_agent properties. Demonstrates the full agent-readiness pattern: - /docs/[slug] serves HTML to browsers, clean Markdown to agents - Three triggers: .md suffix, Accept: text/markdown, known AI-bot UA - Content-Signal, x-markdown-tokens, and Vary headers on every Markdown response - Synthesized pointer document for routes without a pre-built mirror - public/llms.txt for agent discovery Wires in the @apideck/agent-analytics npm package (MIT, zero deps). Live demo: https://agent-analytics-nextjs-starter.vercel.app Source repo: https://github.com/apideck-libraries/agent-analytics-nextjs-starter Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@Gdewilde is attempting to deploy a commit to the Vercel Examples Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
- turbo.json: standard monorepo build-pipeline config (build outputs under .next/**, excluding the cache) so Turbo can cache and parallelize this example alongside the others - .npmrc: legacy-peer-deps=true to match the peer-dep tolerance other examples use (avoids conflicts with next@canary across the monorepo) - package.json: bump @apideck/agent-analytics ^0.1.0 → ^0.1.1 so Socket's dep scan reports the current minor (0.1.1 adds bot_name as a captured property; semver range auto-upgraded but the explicit bump is tidier for supply-chain reports) The mintlify-docs-rewrite deployment failure flagged by the Vercel bot is a pre-existing issue in cdn/mintlify-docs-rewrite/vercel.ts on main and is unrelated to this PR — we touch only edge-middleware/ files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
| <h2>What's in this template</h2> | ||
| <ul> | ||
| <li> | ||
| <code>middleware.ts</code> — fires <code>trackDocView</code> on every |
Contributor
There was a problem hiding this comment.
Suggested change
| <code>middleware.ts</code> — fires <code>trackDocView</code> on every | |
| <code>middleware.ts</code> — fires <code>trackVisit</code> on every |
UI text in app/page.tsx references the old function name trackDocView while middleware.ts uses the renamed trackVisit from @apideck/agent-analytics ^0.3.0.
| <!-- code --> | ||
| <g font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="14" font-weight="400"> | ||
| <text x="24" y="72"><tspan fill="#c084fc">import</tspan><tspan fill="#9ca3af"> {</tspan></text> | ||
| <text x="24" y="94"><tspan fill="#e5e7eb"> trackDocView, posthogAnalytics</tspan></text> |
Contributor
| **Swap analytics backends** — replace the PostHog adapter with a webhook, Mixpanel, or your own callback: | ||
|
|
||
| ```ts | ||
| import { trackDocView, webhookAnalytics } from '@apideck/agent-analytics' |
Contributor
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.
Next.js 15 starter that tracks AI agent traffic (ClaudeBot, GPTBot, PerplexityBot, Google-Extended, and 20+ more) in PostHog via middleware. Drop in a PostHog key, deploy, and agent
fetches show up as doc_view events with is_ai_bot, source, and user_agent properties.
Demonstrates the full agent-readiness pattern:
Wires in the @apideck/agent-analytics npm package (MIT, zero deps).
Live demo: https://agent-analytics-nextjs-starter.vercel.app
Source repo: https://github.com/apideck-libraries/agent-analytics-nextjs-starter