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

@stdiolabs/provenance-sdk

v2.5.0

Published

Node.js SDK for the Provenance platform — queue ingestion and full REST API client

Downloads

186

Readme


Installation

npm install @stdiolabs/provenance-sdk

Quick Start

const { create } = require("@stdiolabs/provenance-sdk");

const provenance = await create({
  apiKey: "your-api-key",
  origin: "my-service",
});

// Queue-based ingestion (high throughput, async delivery)
await provenance.log({
  resourceType: "user",
  resourceId: "user-123",
  action: "login",
  uowId: "550e8400-e29b-41d4-a716-446655440000",
  interaction: { email: "[email protected]" },
});

// REST API client (read data, manage config, analytics)
const api = await provenance.api();
const actions = await api.actions.list();
const trace = await api.traces.get("user-123");

The SDK resolves queue credentials and API URL automatically from the platform using your API key. Both are cached for 5 minutes and auto-refresh on token rotation.

Queue Ingestion

The log() method pushes interactions through a managed queue for reliable async delivery with automatic retries. This is the recommended path for recording interactions in production.

await provenance.log({
  resourceType: "user",
  resourceId: "user-123",
  action: "create",
  uowId: "550e8400-e29b-41d4-a716-446655440000",
  interaction: { email: "[email protected]" },
});

REST API Client

The api() method returns a client covering all Provenance API endpoints. The API URL is resolved from the platform automatically (or can be set explicitly).

const api = await provenance.api();

// CRUD
const action = await api.actions.create({
  title: "Deploy",
  mnemonic: "DEPLOY",
});
await api.actions.update(action.id, { title: "Deploy v2" });
await api.actions.delete(action.id);

// Search
const results = await api.activity.search({
  filters: { action: "CREATE", resourceType: "USER" },
});

// Analytics
const data = await api.analytics.query({
  metrics: ["count"],
  dimensions: ["action"],
  timeRange: { type: "relative", value: "7d" },
});

// Traces
const trace = await api.traces.get("user-123");

Auto-Pagination

CRUD resources include a listAll() async generator that handles pagination automatically:

for await (const action of api.actions.listAll()) {
  console.log(action.title);
}

Available Resources

| Namespace | Methods | | ------------------------ | ---------------------------------------------------------------------------------------- | | api.actions | list, get, create, update, delete, listAll | | api.origins | list, get, create, update, delete, listAll | | api.resourceTypes | list, get, create, update, delete, listAll | | api.interactions | list, get, delete | | api.activity | search | | api.traces | get, timeline, summary | | api.analytics | query, discover | | api.dashboards | list, get, create, update, delete, listAll | | api.widgets | list, get, create, update, delete, listAll, getData, previewData | | api.subscribers | list, get, create, update, delete, listAll, stats | | api.subscriptions | list, get, create, update, delete, listAll, pause, resume | | api.alerts | list, get, create, update, delete, listAll, states, evaluate | | api.interactionMetrics | list, get, create, update, delete, listAll, types, discover, calculate | | api.queue | stats, process | | api.secrets | list, get, create, update, delete, listAll, test | | api.secretProviders | list, get, create, update, delete, listAll, types | | api.inboundSources | list, get, create, update, delete, listAll | | api.inboundMappings | list, get, create, update, delete, listAll, test | | api.home | dashboard | | api.health() | Health check |

Context Layering

Set shared context once, override per call:

const scoped = provenance.addContext({
  resourceType: "order",
  userId: "user-456",
});

await scoped.log({
  resourceId: "order-789",
  action: "create",
  uowId: "...",
  interaction: { total: 99.99 },
});

addContext() is synchronous — no extra network calls.

Span Hierarchy

log() returns the generated spanId — a UUID that identifies the interaction in a span tree. Pass it as parentSpanId to link child interactions:

const parentSpanId = await provenance.log({
  resourceType: "order",
  resourceId: "order-789",
  action: "create",
  uowId,
  interaction: { total: 99.99 },
});

await provenance.log({
  resourceType: "payment",
  resourceId: "payment-456",
  action: "process",
  uowId,
  parentSpanId,
  interaction: { method: "card" },
});

You can also propagate parentSpanId via context:

const child = provenance.addContext({ parentSpanId });
await child.log({
  resourceId: "item-1",
  action: "reserve",
  uowId,
  interaction: {},
});

See the full docs for more details.

Winston Transport

const winston = require("winston");
const { ProvenanceTransport } = require("@stdiolabs/provenance-sdk");

const logger = winston.createLogger({
  transports: [
    new ProvenanceTransport({
      level: "info",
      apiKey: "your-api-key",
      config: { origin: "my-service" },
    }),
  ],
});

logger.info({
  resourceType: "user",
  resourceId: "user-123",
  action: "login",
  uowId: "550e8400-e29b-41d4-a716-446655440000",
  interaction: { email: "[email protected]" },
});

Auto-Instrumentation

Zero-code provenance tracking for Express, Fastify, Prisma, and Sequelize:

const { instrument } = require("@stdiolabs/provenance-sdk/auto");

instrument({
  apiKey: process.env.PROVENANCE_API_KEY,
  origin: "order-service",
});

Every inbound HTTP request, database mutation, and outbound HTTP call is tracked automatically — with UOW propagation across async boundaries and service calls.

Fastify

const {
  instrument,
  instrumentFastify,
} = require("@stdiolabs/provenance-sdk/auto");
instrument({ apiKey: "...", origin: "my-service" });
instrumentFastify(fastify);

Prisma

const {
  instrument,
  instrumentPrisma,
} = require("@stdiolabs/provenance-sdk/auto");
instrument({ apiKey: "...", origin: "my-service" });
instrumentPrisma(prisma);

Sequelize

const {
  instrument,
  instrumentSequelize,
} = require("@stdiolabs/provenance-sdk/auto");
instrument({ apiKey: "...", origin: "my-service" });
instrumentSequelize(sequelize);

Configuration

| Option | Required | Description | | ------------- | -------- | --------------------------------------------------------- | | apiKey | Yes | Your Provenance API key | | origin | Yes | Name of the source system | | platformUrl | No | Platform URL (default: https://platform.provenance.dev) | | apiUrl | No | Override API URL (resolved from platform by default) |

Self-Hosted

const provenance = await create(
  { origin: "my-service", apiUrl: "https://your-api.com/api" },
  "https://your-queue-url",
  "your-queue-token",
  "your-api-key",
);

Resilience

  • Lazy resolution — Config fetched on first use, not at create() time
  • Retry with backoff — 429/5xx retried up to 3× with exponential backoff
  • Auto-refresh — On 401/403, credentials force-refreshed and retried
  • 5-minute cache — Platform config cached per API key
  • Shared instances — API client shared across addContext() children

Licenses

Proprietary — STDIO Labs