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

@churndown/sdk

v0.0.7

Published

Official Churndown SDK — identify users and track key actions

Downloads

51

Readme

@churndown/sdk

Official SDK for Churndown — predict which users are about to churn so you can intervene.

Install

npm install @churndown/sdk

Quick start

import Churndown from "@churndown/sdk"

const churndown = new Churndown("cd_YOUR_API_KEY")

// Identify a user (call on sign up and every login)
await churndown.identify({
  userId: "user_123",
  email: "[email protected]",
  name: "Sam Shore",
})

// Track a key action
await churndown.track("user_123", "send-message")

That's it — two calls and you're done.

API

new Churndown(apiKey, config?)

Create a new client instance.

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | apiKey | string | Yes | Your API key (starts with cd_) | | config.baseUrl | string | No | Override the API URL. Defaults to https://churndown.sh/api |

churndown.identify(params)

Identify a user. Call this when a user signs up or logs in. Safe to call multiple times — it creates the user on the first call and updates on subsequent calls.

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | userId | string | Yes | Your internal user ID | | email | string | Yes | User's email address | | name | string | No | User's display name | | image | string | No | URL to user's avatar | | properties | Record<string, unknown> | No | Any additional user data | | timestamp | string | No | ISO 8601 signup timestamp (defaults to now) |

await churndown.identify({
  userId: "user_123",
  email: "[email protected]",
  name: "Sam Shore",
  image: "https://example.com/avatar.jpg",
  properties: {
    plan: "pro",
    company: "Acme Inc",
  },
})

churndown.track(userId, event, options?)

Track a key action. Call this each time a user performs the action that signals they're active.

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | userId | string | Yes | The user's ID (same as in identify) | | event | string | Yes | Event name | | options.properties | Record<string, unknown> | No | Any additional event data | | options.timestamp | string | No | ISO 8601 timestamp (defaults to now) |

await churndown.track("user_123", "send-message", {
  properties: { channel: "general", messageLength: 142 },
})

// With a historical timestamp
await churndown.track("user_123", "send-message", {
  timestamp: "2026-01-15T10:30:00Z",
})

churndown.importEvents(events)

Import historical events to backfill data. Each event must include a timestamp.

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | events[].userId | string | Yes | The user's ID | | events[].event | string | Yes | Event name | | events[].timestamp | string | Yes | ISO 8601 timestamp | | events[].properties | Record<string, unknown> | No | Any additional event data |

await churndown.importEvents([
  { userId: "user_123", event: "send-message", timestamp: "2026-01-15T10:30:00Z" },
  { userId: "user_123", event: "send-message", timestamp: "2026-02-01T14:22:00Z" },
  { userId: "user_456", event: "send-message", timestamp: "2026-02-10T09:15:00Z" },
])

Frameworks

Works everywhere — server-side, client-side, edge functions, serverless. The SDK is just a thin fetch wrapper with no dependencies.

Next.js (App Router)

// app/api/auth/callback/route.ts
import Churndown from "@churndown/sdk"

const churndown = new Churndown(process.env.CHURNDOWN_API_KEY!)

export async function GET(request: Request) {
  const user = await getUser(request)

  await churndown.identify({
    userId: user.id,
    email: user.email,
    name: user.name,
  })

  // ...
}

Express

import Churndown from "@churndown/sdk"

const churndown = new Churndown(process.env.CHURNDOWN_API_KEY!)

app.post("/api/messages", async (req, res) => {
  // ... create message ...

  await churndown.track(req.user.id, "send-message")

  res.json({ ok: true })
})

License

MIT