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

waterline-sdk

v0.2.1

Published

Waterline TypeScript ingestion SDK — asynchronous, fire-and-forget. Metadata only.

Readme

waterline-sdk

TypeScript ingestion SDK for Waterline — connect your AI spend to your revenue, customer by customer.

The SDK is asynchronous and fire-and-forget: it never blocks your app and never throws. If Waterline is unreachable, your product keeps running. It reports metadata only — never prompts or responses.

Install

npm install waterline-sdk

ESM-only, Node 18+. Using an AI coding agent to integrate this? Point it at AGENTS.md — it has the exact wiring, rules, and pitfalls.

Usage

import { init, track, identify, withCustomer, shutdown } from "waterline-sdk";

// Once, at startup.
init({
  endpoint: "https://ingest.waterline.dev",
  apiKey: process.env.WATERLINE_API_KEY,
  env: "prod",
});

// Attribute events to a customer via context propagation — no threaded parameter.
// A middleware typically wraps each request in withCustomer(...).
withCustomer("cus_acme", () => {
  // Tell Waterline who this customer is, so the dashboard shows a real name and
  // unit economics instead of an opaque id. Metadata only — call it again on change.
  // Passing email and/or stripeCustomerId lets Waterline join cost to revenue
  // automatically — no manual reconciliation. See "Linking to Stripe" below.
  identify({
    name: "Acme Corp",
    seats: 25,
    model: "Pro",
    email: "[email protected]",
    stripeCustomerId: "cus_123", // if your app already created the Stripe customer
  });

  track({
    kind: "llm",
    model: "gpt-4o",
    runId: "run_123",
    success: true,
    usage: { inputTokens: 1200, outputTokens: 340 },
  });
});

// You can also attribute a single call explicitly, without the context.
identify({ name: "Beta LLC", seats: 3 }, "cus_beta");
track({ kind: "embedding", model: "text-embedding-3-small", customerId: "cus_beta" });

// On graceful shutdown, flush what's left.
await shutdown();

API

  • init(config) — create the client and start the background flush loop.
  • track(event) — enqueue an event. Never throws, never blocks.
  • identify(traits, customerId?) — attach name / seats / model to a customer. Never throws, never blocks.
  • withCustomer(customerId, fn) — run fn within an ambient customer context.
  • flush() — send all queued events now. Never rejects.
  • shutdown() — stop the timer and flush. Safe to call when not initialized.

Cost is computed server-side from the reported usage — the SDK never sends cost.

Linking to Stripe (no manual reconciliation)

Waterline joins each customer's AI cost to their Stripe revenue. You link them once, in code — never by hand, and never per end-user. Best to worst:

  1. identify({ stripeCustomerId }) — when your app created the Stripe customer and has its id. Exact, instant, scales to millions. The Stripe id belongs here and only here — never on a track event.
  2. identify({ email }) — Waterline auto-matches to the Stripe customer with the same email. Great when you don't hold the Stripe id.
  3. Stripe metadata — stamp your internal id on the Stripe customer (metadata.waterline_id = <your customer id>); Waterline finds it automatically.

Anything left unmatched shows up in the dashboard's reconciliation screen for a one-off manual link. Matching is only ever done on a unique correspondence — an ambiguous email is left for you to resolve, never guessed.

Event kinds

llm · embedding · vectordb · sandbox · search · stt · tts · image