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

@opstrails/sdk

v0.1.0

Published

Official TypeScript SDK for OpsTrails event ingestion

Readme

@opstrails/sdk

Official TypeScript SDK for OpsTrails event ingestion.

Features

  • Zero runtime dependencies — uses native fetch (Node 18+, Deno, Bun, edge runtimes)
  • ESM + CJS dual output
  • Strict TypeScript types
  • Automatic retry with exponential backoff + jitter
  • Respects Retry-After header
  • Typed error classes mapping 1:1 to API error codes

Installation

npm install @opstrails/sdk

Quick Start

import { OpsTrailsClient } from '@opstrails/sdk'

const client = new OpsTrailsClient({
  apiKey: 'ot_your_api_key',
})

await client.trackEvent({
  type: 'deployment',
  source: '//github.com/your-org/your-repo',
  subject: 'production',
  version: 'v1.2.3',
  severity: 'LOW',
  data: {
    description: 'Deployed v1.2.3 to production',
  },
})

API Reference

new OpsTrailsClient(options)

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | required | OpsTrails API key (ot_ or otr_ prefix) | | baseUrl | string | https://api.opstrails.dev | API base URL | | timeout | number | 30000 | Request timeout in milliseconds | | retry | Partial<RetryOptions> | See below | Retry configuration |

Retry Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | maxRetries | number | 3 | Maximum retry attempts | | initialDelayMs | number | 1000 | Initial delay between retries | | backoffMultiplier | number | 2 | Exponential backoff multiplier | | maxJitter | number | 0.25 | Max jitter fraction (0-1) |

Only 429 (rate limit) and 5xx (server error) responses are retried. Client errors (4xx) are never retried.

client.trackEvent(options): Promise<TrackEventResponse>

Track an infrastructure event. Automatically sets specversion: "1.0" and defaults time to "NOW" (server-side timestamp).

| Option | Type | Required | Description | |--------|------|----------|-------------| | type | string | Yes | Event type (e.g. "deployment", "rollback"). 1-100 chars | | source | string | Yes | Event source URI (e.g. "//github.com/org/repo"). 1-500 chars | | id | string | No | Event ID. Max 200 chars. Auto-generated if omitted | | time | string \| Date | No | Event time. ISO 8601, RFC 2822, Date object, or "NOW" | | subject | string | No | Event subject (e.g. environment). Max 50 chars | | severity | Severity | No | "LOW", "MINOR", "MAJOR", or "CRITICAL" | | version | string | No | Version string. Max 50 chars | | data | EventData | No | Additional event data |

client.sendRawEvent(event): Promise<TrackEventResponse>

Send a raw CloudEvents 1.0 JSON payload. Use this when you need full control over the event fields.

Error Handling

All errors extend OpsTrailsError with status, code, and message properties.

import { OpsTrailsClient, AuthenticationError, QuotaExceededError } from '@opstrails/sdk'

try {
  await client.trackEvent({ type: 'deployment', source: '//test' })
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key')
  } else if (error instanceof QuotaExceededError) {
    console.error('Monthly quota exceeded')
  }
}

| Error Class | API Code | HTTP Status | |-------------|----------|-------------| | AuthenticationError | UNAUTHORIZED | 401 | | ForbiddenError | FORBIDDEN | 403 | | ValidationError | VALIDATION_ERROR | 400 | | QuotaExceededError | QUOTA_EXCEEDED | 429 | | NotFoundError | NOT_FOUND | 404 | | NetworkError | NETWORK_ERROR | 0 | | TimeoutError | TIMEOUT | 0 |

Edge Runtime Support

The SDK uses only standard Web APIs (fetch, AbortController) and works in any runtime that supports them — Node.js 18+, Deno, Bun, Cloudflare Workers, Vercel Edge Functions, etc.

License

MIT