@aisightline/ai-traffic-vercel
v0.3.0
Published
AI Sightline AI Traffic — Vercel / Next.js middleware. One-line install for AI bot + AI referral analytics.
Maintainers
Readme
@aisightline/ai-traffic-vercel
AI Sightline AI Traffic — one-line install for Vercel / Next.js middleware. Tracks AI bot crawls and AI-platform referrals (ChatGPT, Perplexity, Claude, Gemini, Copilot, Google AIO) server-side, with no cookies and no client-side script.
Install
npm install @aisightline/ai-traffic-vercelSet the website key in your Vercel project's environment:
AISIGHTLINE_WEBSITE_KEY=your-key-hereUsage
Drop-in (most common)
// src/middleware.ts
import { withAiTraffic } from '@aisightline/ai-traffic-vercel';
export default withAiTraffic();
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};Wrap an existing middleware
// src/middleware.ts
import { withAiTraffic } from '@aisightline/ai-traffic-vercel';
import { NextResponse, type NextRequest } from 'next/server';
export default withAiTraffic(async (req: NextRequest) => {
// your existing middleware logic here
return NextResponse.next();
});
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};Express / Fastify
If you're not on Next.js, import sendIntake and call it from your request handler:
import { sendIntake, shouldSkipPath } from '@aisightline/ai-traffic-vercel';
app.use((req, res, next) => {
if (!shouldSkipPath(req.path)) {
const xff = (req.headers['x-forwarded-for'] ?? '').toString();
sendIntake({
websiteKey: process.env.AISIGHTLINE_WEBSITE_KEY!,
url: `${req.protocol}://${req.get('host')}${req.originalUrl}`,
userAgent: req.headers['user-agent'] ?? '',
referer: req.headers.referer ?? '',
ip: xff.split(',')[0].trim(),
});
}
next();
});What it captures
For every HTML pageview, AI Traffic identifies AI bot crawls (verified via reverse-DNS) and AI-platform referrals. It skips static assets (images, CSS, JS, fonts), /api/* routes, and Next.js internals automatically. It explicitly tracks discovery paths even though they look static (/robots.txt, /llms.txt, /sitemap.xml, /ai.txt, /.well-known/*) because AI crawlers fingerprint themselves on those paths.
Privacy
We hash IP addresses (SHA-256) before persistence and never store the raw IP. No cookies, no client JavaScript, no third-party trackers. You don't need a cookie banner or a privacy policy update for AI Traffic specifically.
Verifying the install
After deploying, run the verify probe at:
https://aisightline.com/portal/ai-traffic/install
The probe fetches your site with the AISightlineBot-Test/1.0 user agent and confirms an intake landed within 5 seconds. Active probe = installed-and-confident in 60 seconds.
License
MIT.
