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

@agentcash/telemetry

v0.3.3

Published

ClickHouse telemetry plugin for @agentcash/router. Logs request lifecycle, payments, settlements, and provider quota to ClickHouse.

Readme

@agentcash/telemetry

npm

ClickHouse telemetry for x402/MPP/SIWX API services. Logs invocations to ClickHouse, extracts verified wallets from x402 payments and SIWX auth.

Telemetry spec | npm | GitHub

Install

pnpm add @agentcash/telemetry @clickhouse/client

Quick start — Router Plugin (recommended)

import { createRouter } from '@agentcash/router';
import { createTelemetryPlugin } from '@agentcash/telemetry/plugin';

const router = createRouter({
  payeeAddress: '0x...',
  plugin: createTelemetryPlugin({
    clickhouse: {
      url: process.env.TELEM_CLICKHOUSE_URL!,
      database: process.env.TELEM_CLICKHOUSE_DATABASE,
      username: process.env.TELEM_CLICKHOUSE_USERNAME,
      password: process.env.TELEM_CLICKHOUSE_PASSWORD,
    },
  }),
});

Quick start — Legacy wrapper

// lib/telemetry.ts (or wherever your route wrappers live)
import { initTelemetry, withTelemetry } from '@agentcash/telemetry';

initTelemetry({
  clickhouse: {
    url: process.env.TELEM_CLICKHOUSE_URL!,
    database: process.env.TELEM_CLICKHOUSE_DATABASE,
    username: process.env.TELEM_CLICKHOUSE_USERNAME,
    password: process.env.TELEM_CLICKHOUSE_PASSWORD,
  },
  verify: true, // optional — pings ClickHouse on startup, logs success/failure
});

export { withTelemetry };
// app/api/example/route.ts
import { withTelemetry } from '@/lib/telemetry';

export const POST = withTelemetry(async (request, ctx) => {
  return NextResponse.json(await doWork(request));
});

Four entrypoints

Router Plugin (@agentcash/telemetry/plugin)

Primary integration path. Hooks into @agentcash/router's orchestrate lifecycle.

Requires: @clickhouse/client

import { createTelemetryPlugin } from '@agentcash/telemetry/plugin';
  • createTelemetryPlugin(config) — returns a RouterPlugin that captures request metadata, payment verification, settlement, response, errors, alerts, and provider quota

Core (@agentcash/telemetry)

Requires: @clickhouse/client, next

import { initTelemetry, withTelemetry } from '@agentcash/telemetry';
  • initTelemetry(config) — synchronous, call once at module level. Pass verify: true to ping ClickHouse on startup (fire-and-forget, never blocks)
  • withTelemetry(handler) — wrap any Next.js route handler
  • extractVerifiedWallet(headers) — extract wallet from x402 payment headers

SIWX (@agentcash/telemetry/siwx)

Requires: @x402/extensions, @x402/core

import { withSiwxTelemetry } from '@agentcash/telemetry/siwx';

export const GET = withSiwxTelemetry(async (request, ctx) => {
  // ctx.verifiedWallet is guaranteed to be set
  return NextResponse.json(await getJobs(ctx.verifiedWallet));
});

Route Builder (@agentcash/telemetry/builder)

Requires: @x402/next, zod (^4), @x402/extensions

import { createRouteBuilder } from '@agentcash/telemetry/builder';

const route = createRouteBuilder({ x402Server });

export const POST = route
  .price('0.05', 'base:8453')
  .body(searchSchema)
  .handler(async ({ body }) => searchPeople(body.query));

Next.js integration footguns

@clickhouse/client must be externalized

The ClickHouse client uses Node.js native APIs that break when bundled by Next.js. Add to your next.config:

const nextConfig: NextConfig = {
  serverExternalPackages: ['@clickhouse/client'],
};

Do NOT call initTelemetry in instrumentation.ts

On Vercel serverless, instrumentation.ts runs in a separate module scope from route handlers. Singletons set there are invisible to your handlers.

Call initTelemetry() in the same module that imports your route wrappers:

// lib/telemetry.ts — CORRECT
import { initTelemetry, withTelemetry } from '@agentcash/telemetry';
initTelemetry({ clickhouse: { ... } });
export { withTelemetry };
// instrumentation.ts — WRONG: singleton won't be shared with handlers
import { initTelemetry } from '@agentcash/telemetry';
export async function register() {
  initTelemetry({ clickhouse: { ... } }); // handlers can't see this
}

Subpath exports isolate heavy deps

The /siwx and /builder entrypoints have additional peer dependencies. If you only use the core withTelemetry or ./plugin, you don't need zod, @x402/next, or @x402/extensions installed.

After updating, commit both package.json and lockfile

pnpm update @agentcash/telemetry bumps the version specifier in both package.json and pnpm-lock.yaml. Vercel's frozen-lockfile mode will reject deploys if only the lockfile is committed. Always:

git add package.json pnpm-lock.yaml