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

@punchline-analytics/next

v0.6.1

Published

See which visitors are AI agents: Next.js middleware/proxy for Punchline Analytics. Forwards a minimal, privacy-reduced event per page request.

Readme

@punchline-analytics/next

Shows how much of your site's traffic is AI agents, and which ones. This package runs in your Next.js proxy (or middleware), and for each page request it sends a small event to your Punchline Analytics collector, after the response has gone out.

  • No cookies, no browser script, nothing added to your pages.
  • Doesn't slow pages down. The event is sent after the response; our code adds about 1 ms.
  • Never breaks your site. If Punchline is misconfigured or unreachable, requests continue normally.

Install

npm install @punchline-analytics/next

Set one environment variable (your Punchline Analytics dashboard gives you the value):

PUNCHLINE_DSN=https://<site-id>:<secret>@<your-collector>/api/collect

Next.js 16: create proxy.ts at the project root, or in src/ if you use one:

import { punchline } from "@punchline-analytics/next";

export const proxy = punchline();

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

Next.js 15, or to run on the edge runtime: use middleware.ts with export const middleware = punchline(); and the same config.

Next.js reads matcher at build time, so it has to be written out in your file as shown.

Already have a proxy or middleware?

Call the tracker inside it:

import { createTracker } from "@punchline-analytics/next";
import { NextResponse, type NextFetchEvent, type NextRequest } from "next/server";

const tracker = createTracker();

export function proxy(request: NextRequest, event: NextFetchEvent) {
  tracker.track(request, event);
  // …your existing logic…
  return NextResponse.next();
}

What gets sent

For each page view (GET/HEAD for pages, plus .txt, .md and .xml files such as robots.txt and llms.txt), the package sends one event, server to server:

  • The host, the path and utm_* values. Every other query parameter, and the #fragment, are removed before sending.
  • The referrer's host only.
  • The Accept header, cut to 200 characters.
  • Whether the browser sent Sec-GPC: 1.
  • The country code your host provides (x-vercel-ip-country on Vercel).
  • Web Bot Auth signature headers, when an agent sends them.
  • The visitor's IP address and user agent. The collector uses these in memory to classify the request and to compute a daily visitor hash, then discards them; they're never stored or logged.

Not tracked: images, scripts, styles, other assets, or Next.js link prefetches.

Options

punchline({
  dsn: "...",            // default: process.env.PUNCHLINE_DSN
  timeoutMs: 3000,       // give up sending after this long
  serverTiming: true,    // add `Server-Timing: punchline;dur=…` (default: PUNCHLINE_SERVER_TIMING=1)
  onError: (err) => {},  // configuration or network errors (default: ignored)
});

Troubleshooting

  • No events arriving. Check PUNCHLINE_DSN is set for the environment you deployed. Pass onError: console.error once to see why sends are failing.
  • Measuring the overhead. Set PUNCHLINE_SERVER_TIMING=1 and look at the Server-Timing response header.