Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 772 Bytes

File metadata and controls

30 lines (20 loc) · 772 Bytes

@upstash/agent-analytics

Track Claude, ChatGPT, Perplexity and other citations to your website.

AI Analytics Screenshot

Setup

Track a request in your Next.js middleware (now named proxy.ts):

// proxy.ts
import { NextResponse, type NextRequest } from "next/server"
import { AgentAnalytics } from "@upstash/agent-analytics"
import { redis } from "./redis"

const analytics = new AgentAnalytics({ redis })

export const proxy = async (request: NextRequest) => {
  await analytics.track(request)

  return NextResponse.next()
}

export const config = {
  matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
}

You can now see AI traffic in your Upstash dashboard under AI Tracking (three dot menu in the top).