npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@infrasity/agent-tracker

v0.1.1

Published

Track AI coding agent and LLM crawler traffic to your docs site.

Downloads

282

Readme

@infrasity/agent-tracker

Track AI coding agent traffic (Claude Code, Codex, Cursor, Aider…) and LLM crawlers (GPTBot, PerplexityBot, ClaudeBot…) hitting your docs site.

Drop-in middleware. Fire-and-forget beacon. Won't slow down your site.


Install

npm install @infrasity/agent-tracker
# or
pnpm add @infrasity/agent-tracker

Get an API key from Dev Intelligence → Agent Traffic in your Infrasity dashboard.

Next.js (App Router, 13+)

Create or edit middleware.ts at the root of your project:

import { withAgentTracking } from '@infrasity/agent-tracker/next';

export default withAgentTracking({
  apiKey: process.env.INFRASITY_API_KEY!,
});

export const config = {
  // Skip API routes, static assets, and admin paths
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico|admin).*)'],
};

Add the env var:

# .env.local
INFRASITY_API_KEY=infra_live_xxxxxxxxxxxxx

Express

import express from 'express';
import { agentTracker } from '@infrasity/agent-tracker/express';

const app = express();
app.use(agentTracker({ apiKey: process.env.INFRASITY_API_KEY! }));

Generic

If you're on another framework, call track() directly from anywhere that has access to request headers:

import { track, shouldTrack } from '@infrasity/agent-tracker';

if (shouldTrack(request.headers.get('accept'))) {
  track({ apiKey: process.env.INFRASITY_API_KEY! }, {
    host: request.headers.get('host')!,
    path: new URL(request.url).pathname,
    userAgent: request.headers.get('user-agent') ?? '',
    accept: request.headers.get('accept') ?? '',
  });
}

Configuration

| Option | Type | Default | Description | | --- | --- | --- | --- | | apiKey | string | required | API key from your Infrasity dashboard | | endpoint | string | https://app.infrasity.com/api/dev-intelligence/track | Override for self-hosted setups | | timeoutMs | number | 2500 | Hard timeout for the beacon | | debug | boolean | false | Log warnings to console |

What gets tracked

Only requests that look like AI agents or crawlers. Specifically:

  • Requests with Accept: text/html or text/markdown (filters out asset, JSON-API, and XHR traffic)
  • Server-side classified by User-Agent — anything matching a known coding agent (Claude Code, Codex, Cursor, Aider, Devin, Copilot CLI, etc.) or LLM crawler (GPTBot, PerplexityBot, ClaudeBot, etc.)
  • Browser User-Agents are dropped server-side — never stored

What's sent

Only request metadata. Never page contents, query params (unless you opt in), or cookies.

{
  "host": "docs.acme.com",
  "path": "/sdk/python/quickstart",
  "user_agent": "claude-code/0.5.2",
  "accept": "text/html,application/xhtml+xml",
  "country": "US",
  "referer": null
}

Local development

Don't set INFRASITY_API_KEY in your dev environment, or use a separate dev key. The middleware no-ops when the API key is empty.

License

MIT