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

promptry-js

v1.1.0

Published

Lightweight JS/TS client for promptry telemetry — drop-in OpenAI tracking, cost-attributed call trees, and prompt/invocation/feedback events for your self-hosted promptry

Readme

promptry-js

Lightweight JS/TS client for promptry telemetry. Ships prompt, invocation, and feedback events to your own self-hosted promptry ingest endpoint — the same server your Python apps write to via the RemoteStorage backend. Everything lands in the same SQLite store and shows up in the same dashboard (prompts, cost, latency, feedback).

There is no hosted or cloud default endpoint. You always point endpoint at a server you run.

Zero runtime dependencies. Works in browsers and Node 18+.

What it is (and isn't)

Node/Next.js apps use this to report production telemetry so it shows up next to your Python telemetry:

  • trackPrompt — record the prompt/system text a request used.
  • trackInvocation — record one LLM call's cost, latency, tokens, and model.
  • trackFeedback — record an end-user rating/comment, correlated back to an invocation.

It is not an eval runner. It does not assert, score, or gate — it only ships telemetry. Run evals with the Python library/CLI; use this to capture what actually happened in production.

Install

npm install promptry-js

Usage

Class API

import { Promptry } from 'promptry-js';

const p = new Promptry({
  endpoint: 'https://your-server.com/ingest', // your self-hosted promptry
  apiKey: 'pk_...',        // optional
  projectId: 'my-app',     // optional, added to every event's metadata
  batchSize: 10,            // default 10
  flushInterval: 5000,      // default 5000ms
  sampleRate: 1.0,          // default 1.0
});

// Prompt text — returns content unchanged, ships in the background
const prompt = p.trackPrompt('You are a helpful assistant...', 'rag-qa');

// Retrieval context chunks — returns chunks unchanged, name gets ":context"
const chunks = p.trackContext(retrievedChunks, 'rag-qa');

// One LLM call: cost / latency / tokens
p.trackInvocation({
  name: 'rag-qa',
  model: 'claude-opus-4-8',
  tokensIn: 1200,
  tokensOut: 240,
  cost: 0.018,          // optional — compute it however you like
  latencyMs: 842,
  requestId: 'req-abc', // so feedback can link back to this call
});

// End-user feedback for a prior invocation
p.trackFeedback({
  requestId: 'req-abc',
  rating: 1,            // e.g. thumbs up / down, or 1–5
  comment: 'nailed it',
  source: 'thumbs',
});

await p.flush();    // manual flush
await p.destroy();  // flush + teardown

Singleton API

import {
  init, trackPrompt, trackInvocation, trackFeedback, flush,
} from 'promptry-js';

init({ endpoint: 'https://your-server.com/ingest' });

trackPrompt(systemPrompt, 'rag-qa');
trackInvocation({ name: 'rag-qa', tokensIn: 1200, tokensOut: 240, requestId: 'req-abc' });
trackFeedback({ requestId: 'req-abc', rating: 1 });

await flush();

Wire contract

Every batch this client POSTs conforms to the shared JSON Schema at docs/wire-schema/events.schema.json — the single source of truth for the envelope and event types, shared with the Python RemoteStorage._ship_batch backend. Both the Python test (tests/test_wire_contract.py) and the JS test (__tests__/wire-contract.test.ts) validate their payloads against that file.

{
  "events": [
    {
      "type": "invocation",
      "data": {
        "name": "rag-qa",
        "model": "claude-opus-4-8",
        "tokens_in": 1200,
        "tokens_out": 240,
        "cost": 0.018,
        "latency_ms": 842,
        "request_id": "req-abc",
        "metadata": { "project_id": "my-app" },
        "created_at": "2026-07-07T14:23:45.123Z"
      },
      "timestamp": "2026-07-07T14:23:45.123Z"
    }
  ]
}

Batching, retry, and offline fallback mirror the Python client: events are queued, flushed on batchSize/flushInterval, retried with exponential backoff, and (in the browser) persisted to localStorage if the network is down.

Development

npm install
npm run build
npm test