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

pings-js-sdk

v0.1.0

Published

TypeScript analytics client and event-type generator for Desperate event ingestion.

Readme

DesperateAnalytics TypeScript SDK

TypeScript-first event client for Desperate analytics and notification thresholds.

Install

npm install pings-js-sdk

Configure

import { createAnalyticsClient } from "pings-js-sdk";

const analytics = createAnalyticsClient({
  apiKey: "ak_live_xxx",
  maxBatchSize: 25,
  notification: {
    title: "New product activity",
    body: "{project_name} reached {threshold_total} {event_name} events",
    soundName: "checkout_complete",
  },
});

By default the SDK uses the current hosted app URL: https://pings-chi.vercel.app/api/v1/events.

Override it with a base URL:

const analytics = createAnalyticsClient({
  apiKey: "ak_live_xxx",
  baseUrl: "https://your-production-app.com",
});

Or pass the full ingest route:

const analytics = createAnalyticsClient({
  apiKey: "ak_live_xxx",
  endpoint: "https://your-production-app.com/api/v1/events",
});

Track Events

await analytics.track("checkout_completed", {
  userAnonId: "user_123",
  sessionId: "session_abc",
  dedupeKey: "checkout_123",
  notificationTitle: "Checkout is heating up",
  notificationBody: "{project_name} reached {threshold_total} checkout events",
  soundName: "checkout_complete",
  properties: {
    plan: "pro",
    amount: 25,
    is_trial: false,
  },
});

await analytics.flush();

For deterministic tests, use sendBatch() with explicit dedupe keys:

await analytics.sendBatch([
  {
    event_name: "checkout_started",
    dedupe_key: "run-123-checkout-started-1",
    properties: { source: "integration-test" },
  },
]);

Generate Event Type Definitions

Users can create event types in the dashboard. To make TypeScript know those event names, run:

npx pings-js-sdk gen types \
  --api-key ak_live_xxx \
  --out src/desperate-event-types.d.ts

By default the generator reads from https://pings-chi.vercel.app. Override that with your own base URL or the full ingest route:

npx pings-js-sdk gen types \
  --base-url https://your-production-app.com \
  --api-key ak_live_xxx

The generator calls GET /api/v1/event-types with the project API key and writes a declaration file that augments this package:

import "pings-js-sdk";
import type { AnalyticsProperties } from "pings-js-sdk";

declare module "pings-js-sdk" {
  interface AnalyticsEventMap {
    "checkout_completed": AnalyticsProperties;
    "signup_completed": AnalyticsProperties;
  }
}

After that file is included by the user's tsconfig.json, calls like analytics.track("checkout_completed", ...) are typed against dashboard event names.

Options:

  • --include-inactive: include inactive event types
  • --base-url <url> / --app-url <url>: use a different hosted app URL
  • --endpoint <url>: use a full /api/v1/events or /api/v1/event-types URL
  • --module <name>: override the package name to augment
  • --print: print the declaration instead of writing a file

Build Locally

npm run build
npm test