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

@tracewayapp/backend

v1.0.1

Published

Traceway SDK for Node.js backends

Readme

@tracewayapp/backend

Traceway SDK for Node.js backends. Provides error tracking, distributed tracing, span management, and metrics collection.

Installation

npm install @tracewayapp/backend

Quick Start

import {
  init,
  captureException,
  withTraceContext,
  startSpan,
  endSpan,
  captureCurrentTrace,
  shutdown,
} from "@tracewayapp/backend";

// Initialize once at startup
init("your-token@https://traceway.example.com/api/report");

// Use trace context for HTTP requests
async function handleRequest(req, res) {
  await withTraceContext(
    {
      endpoint: `${req.method} ${req.path}`,
      clientIP: req.ip,
    },
    async () => {
      try {
        const dbSpan = startSpan("database-query");
        const users = await db.query("SELECT * FROM users");
        endSpan(dbSpan);

        res.json(users);
      } catch (error) {
        captureException(error);
        res.status(500).json({ error: "Internal error" });
      } finally {
        captureCurrentTrace();
      }
    }
  );
}

// Graceful shutdown
process.on("SIGTERM", async () => {
  await shutdown();
  process.exit(0);
});

API

Core Functions

| Function | Description | |----------|-------------| | init(connectionString, options?) | Initialize the SDK | | shutdown() | Stop timers, flush remaining data, and await final upload |

Capture Functions

| Function | Description | |----------|-------------| | captureException(error) | Capture error (auto-detects trace context) | | captureExceptionWithAttributes(error, attrs?, traceId?) | Capture with explicit context | | captureMessage(msg, attrs?) | Capture message (auto-detects trace context) | | captureMetric(name, value) | Capture a custom metric | | captureMetricWithTags(name, value, tags) | Capture a metric with key-value tags | | captureTrace(...) | Capture HTTP trace (manual mode) | | captureTask(...) | Capture background task (manual mode) | | captureCurrentTrace() | Capture trace from current context |

Span Functions

| Function | Description | |----------|-------------| | startSpan(name) | Start a span (returns SpanHandle) | | endSpan(span, addToContext?) | End span (auto-adds to context by default) |

Context API

| Function | Description | |----------|-------------| | withTraceContext(options, fn) | Run function within a new trace context | | runWithTraceContext(options, fn) | Run function within a new trace context (alternative) | | getTraceContext() | Get current context (or undefined) | | getTraceId() | Get current trace ID (or undefined) | | hasTraceContext() | Check if inside a trace context | | setTraceAttribute(key, value) | Set attribute on current trace | | setTraceAttributes(attrs) | Set multiple attributes | | setTraceResponseInfo(status, size?) | Set HTTP response info | | addSpanToContext(span) | Manually add a span | | getTraceSpans() | Get all spans in current trace | | getTraceDuration() | Get elapsed time in ms | | forkTraceContext(fn) | Fork context for parallel ops |

Utility Functions

| Function | Description | |----------|-------------| | shouldSample(isError) | Check if trace should be recorded | | measureTask(title, fn) | Execute function as auto-captured task |

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | debug | boolean | false | Enable debug logging to console | | maxCollectionFrames | number | 12 | Ring buffer capacity for pending frames | | collectionInterval | number | 5000 | Frame rotation interval (ms) | | uploadThrottle | number | 2000 | Minimum gap between uploads (ms) | | metricsInterval | number | 30000 | System metrics collection interval (ms) | | version | string | "" | Application version sent with reports | | serverName | string | hostname | Server identifier sent with reports | | sampleRate | number | 1.0 | Normal trace sampling rate (0.0-1.0) | | errorSampleRate | number | 1.0 | Error trace sampling rate (0.0-1.0) |

Requirements

  • Node.js >= 18