whatisgithub

What is agent-analytics?

upstash/agent-analytics — explained in plain English

Analysis updated 2026-06-24

16TypeScriptAudience · pm founderComplexity · 1/5Setup · easy

In one sentence

A small TypeScript library for Next.js that detects and logs visits from AI tools like Claude, ChatGPT, and Perplexity, so you can see how much of your site traffic comes from AI crawlers versus real humans.

Mindmap

mindmap
  root((agent-analytics))
    Setup
      Next.js middleware
      Redis connection
      Single tracking call
    AI Detection
      Request headers
      Claude visits
      ChatGPT visits
      Perplexity visits
    Dashboard
      Upstash UI
      AI Tracking section
      Visit frequency
    Audience
      Website owners
      Traffic analysts
      Content publishers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Find out how often AI tools like ChatGPT or Claude are fetching content from your website.

USE CASE 2

Separate AI crawler traffic from real human visitors in your analytics.

USE CASE 3

Track which specific AI systems are referencing or indexing your site's pages.

What is it built with?

TypeScriptNext.jsUpstash RedisNext.js Middleware

How does it compare?

upstash/agent-analyticsdabao-yi/model-fluxdenjino/horizon-view
Stars161616
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity1/53/52/5
Audiencepm founderdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Requires a Next.js app and an Upstash Redis database. Initialize once in middleware with your Redis credentials, then call the tracking function on each request. About ten lines of code total.

License not mentioned in the explanation.

So what is it?

agent-analytics is a small TypeScript library for Next.js websites that detects and records visits from AI tools. When AI systems like Claude, ChatGPT, or Perplexity reference your website or fetch its content, they identify themselves through request headers. This library reads those identifiers and logs the traffic so you can see how often AI tools are visiting your pages. The library is designed to slot into Next.js middleware, which is a layer that runs on every incoming request before your pages load. You initialize it once with a Redis connection from Upstash, then call a single tracking function on each request. The setup shown in the README takes about ten lines of code. Once connected, the traffic data appears in the Upstash dashboard under an AI Tracking section. This lets you see which AI tools are visiting your site and how frequently, without needing to build or host any separate analytics infrastructure. The README is minimal and only shows the code required to get started. It does not explain what signals the library uses to identify AI traffic, what data fields are recorded, or what level of detail the dashboard provides beyond showing which AI tools have visited. This library would be useful for website owners who want to understand how much of their traffic comes from AI crawlers and citation-fetching systems rather than human visitors. As AI assistants increasingly surface web content in their answers, knowing which tools are pulling from your site becomes useful context for understanding your audience.

Copy-paste prompts

Prompt 1
I want to add agent-analytics to my Next.js site. Show me how to set up the middleware with an Upstash Redis connection and start tracking AI traffic in under 15 lines of code.
Prompt 2
Using the upstash/agent-analytics library, how do I detect when ChatGPT or Claude visits my Next.js pages? Show me the exact middleware file I need to create.
Prompt 3
I've installed agent-analytics on my Next.js site. How do I view the AI traffic data in the Upstash dashboard, and what metrics can I see about which AI tools are visiting?
Prompt 4
What AI crawlers and bots does upstash/agent-analytics detect by default? How does it identify them from request headers?

Frequently asked questions

What is agent-analytics?

A small TypeScript library for Next.js that detects and logs visits from AI tools like Claude, ChatGPT, and Perplexity, so you can see how much of your site traffic comes from AI crawlers versus real humans.

What language is agent-analytics written in?

Mainly TypeScript. The stack also includes TypeScript, Next.js, Upstash Redis.

What license does agent-analytics use?

License not mentioned in the explanation.

How hard is agent-analytics to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is agent-analytics for?

Mainly pm founder.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.