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

vident-sdk

v0.18.0

Published

TypeScript SDK for Vident - monitoring, tracing, and error tracking

Readme

vident-sdk

TypeScript SDK for Vident - monitoring, tracing, and error tracking.

Installation

npm install vident-sdk

Quick Start

import { Vident } from "vident-sdk"

const vident = new Vident({
  apiKey: "sw_...",
  serviceName: "my-api",
})

// Trace an operation
await vident.trace("process-order", async (span) => {
  span.setAttributes({ orderId: "123" })
  await processOrder()
})

Auto-Instrumentation

The SDK can automatically trace database queries, HTTP requests, and more.

Setup with --import (Recommended)

For reliable auto-instrumentation, load the SDK before any other modules using Node's --import flag:

1. Create instrumentation.ts:

import { Vident, autoInstrumentations } from "vident-sdk"

new Vident({
  apiKey: process.env.VIDENT_API_KEY,
  serviceName: process.env.VIDENT_SERVICE_NAME ?? "my-api",
  instrumentations: autoInstrumentations(),
})

2. Update your start command:

{
  "scripts": {
    "start": "node --import ./dist/instrumentation.js dist/index.js",
    "dev": "tsx --import ./src/instrumentation.ts src/index.ts"
  }
}

This ensures pg, fetch, etc. are patched before any modules use them.

What gets auto-instrumented

autoInstrumentations() detects and instruments:

| Library | Spans Created | |---------|---------------| | pg (PostgreSQL) | pg:SELECT users, pg:INSERT orders | | fetch | GET api.stripe.com, POST internal-api.com | | @prisma/client | prisma:user.findMany, prisma:order.create | | @aws-sdk/* | aws:S3.PutObject, aws:SQS.SendMessage |

Disabling specific instrumentations

autoInstrumentations({
  prisma: false,  // Disable if using Prisma extension instead
  pg: false,      // Disable PostgreSQL
  fetch: false,   // Disable fetch
  awsSdk: false,  // Disable AWS SDK
})

HTTP Framework Middleware

Add server-side tracing for incoming requests:

Hono

import { Vident, createHonoMiddleware } from "vident-sdk"

const vident = new Vident({ apiKey: "sw_...", serviceName: "my-api" })
app.use(createHonoMiddleware(vident))

Express

import { Vident, createExpressMiddleware } from "vident-sdk"

const vident = new Vident({ apiKey: "sw_...", serviceName: "my-api" })
app.use(createExpressMiddleware(vident))

Fastify

import { Vident, createFastifyPlugin } from "vident-sdk"

const vident = new Vident({ apiKey: "sw_...", serviceName: "my-api" })
fastify.register(createFastifyPlugin(vident))

Prisma Extension

For more control over Prisma tracing, use the extension instead of auto-instrumentation:

import { Vident } from "vident-sdk"
import { createPrismaExtension } from "vident-sdk/instrument"

const vident = new Vident({
  apiKey: "sw_...",
  serviceName: "my-api",
  instrumentations: autoInstrumentations({ prisma: false }), // Disable auto
})

const prisma = new PrismaClient().$extends(createPrismaExtension(vident))

Fetch Instrumentation Options

By default, spans are created for all fetch requests but trace headers are not propagated (to avoid breaking third-party SDKs).

To enable distributed tracing with your own services:

import { FetchInstrumentation } from "vident-sdk/instrument"

new Vident({
  apiKey: "sw_...",
  serviceName: "my-api",
  instrumentations: [
    new FetchInstrumentation({
      propagateToUrls: [
        /\.mycompany\.com$/,    // Regex: any subdomain
        "api.internal.com",      // String: URLs containing this
      ],
    }),
  ],
})

Manual Tracing

trace() - Automatic span lifecycle

const result = await vident.trace("process-order", async (span) => {
  span.setAttributes({ orderId: "123" })
  const order = await db.getOrder("123")
  return order
})
// Span automatically ends, errors recorded if thrown

startSpan() - Manual control

const span = vident.startSpan("custom-operation", { kind: "internal" })
try {
  await doWork()
  span.setAttributes({ result: "success" })
} catch (error) {
  span.end({ error })
  throw error
}
span.end()

Metrics

vident.counter("orders.processed", 1)
vident.gauge("queue.depth", 42)
vident.histogram("request.duration", 150, { unit: "ms" })

Events

vident.info("user.signup", "New user registered", { userId: "123" })
vident.warn("rate.limit", "Rate limit approaching", { current: 95 })
vident.errorEvent("payment.failed", "Payment declined", { reason: "insufficient_funds" })

Cron Job Monitoring

// Automatic start/success/fail tracking
await vident.wrap("daily-backup", async () => {
  await runBackup()
})

// Manual pinging
await vident.ping("check-id")
await vident.ping("check-id", { type: "start" })
await vident.ping("check-id", { type: "fail", body: "Error details" })

Configuration

const vident = new Vident({
  apiKey: "sw_...",           // Required
  serviceName: "my-api",      // Required for tracing
  baseUrl: "https://...",     // Optional, custom API endpoint
  timeout: 30000,             // Optional, default 30s
  retries: 2,                 // Optional, default 2
  sampler: traceIdRatioSampler(0.1), // Optional, sample 10% of traces
})

Development Mode

When apiKey is undefined, all methods silently no-op:

const vident = new Vident({ apiKey: process.env.VIDENT_API_KEY })
// Works in dev (no-op) and prod (sends data)

Error Handling

import { VidentError, NotFoundError, UnauthorizedError } from "vident-sdk"

try {
  await vident.projects.get("invalid-id")
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log("Not found")
  } else if (error instanceof UnauthorizedError) {
    console.log("Invalid API key")
  }
}

License

MIT