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

@rustrak/client

v0.2.1

Published

Type-safe TypeScript client for the Rustrak self-hosted error tracking API

Downloads

903

Readme


@rustrak/client is the official TypeScript client for Rustrak — an ultra-lightweight, self-hosted error tracking system compatible with any Sentry SDK. This package wraps the Rustrak REST API with full type safety, runtime validation via Zod, built-in retry logic, and structured error handling. Total bundle size: ~28 KB.

Installation

npm install @rustrak/client
# or
pnpm add @rustrak/client
# or
yarn add @rustrak/client

Requirements: Node.js ≥ 18, TypeScript ≥ 5

Quick Start

import { RustrakClient } from '@rustrak/client';

const client = new RustrakClient({
  baseUrl: 'https://your-rustrak-instance.example.com',
  token: process.env.RUSTRAK_API_TOKEN!,
});

// List all projects
const projects = await client.projects.list();

// Paginate through open issues
const { items, next_cursor, has_more } = await client.issues.list(1, {
  sort: 'last_seen',
  order: 'desc',
});

// Resolve an issue
await client.issues.updateState(1, 'issue-id', { is_resolved: true });

Full documentation →

Features

  • Type-safe — All API responses validated at runtime with Zod; types are inferred from schemas
  • Lightweight — ~28 KB total (ky 3 KB + zod 10 KB + client 15 KB)
  • Automatic retry — Exponential backoff on transient failures (408, 429, 5xx)
  • Structured errors — Typed error classes for every HTTP status and failure mode
  • Cursor pagination — First-class support for paginated responses across all list endpoints
  • 97% test coverage — 133 tests (unit + integration with MSW)

API Reference

Configuration

const client = new RustrakClient({
  baseUrl: 'https://rustrak.example.com', // required
  token: 'your-bearer-token',             // required
  timeout: 30000,                         // optional, ms (default: 30000)
  maxRetries: 2,                          // optional (default: 2)
  headers: {},                            // optional custom headers
});

Projects

const projects = await client.projects.list();
const project  = await client.projects.get(1);
const created  = await client.projects.create({ name: 'My App', slug: 'my-app' });
const updated  = await client.projects.update(1, { name: 'New Name' });
await client.projects.delete(1);

Issues

// List with filters and cursor pagination
const { items, next_cursor, has_more } = await client.issues.list(projectId, {
  sort: 'last_seen',        // 'digest_order' | 'last_seen'
  order: 'desc',            // 'asc' | 'desc'
  include_resolved: false,
  cursor: 'eyJzb3J0...',    // from previous response
});

const issue = await client.issues.get(projectId, issueId);
await client.issues.updateState(projectId, issueId, { is_resolved: true });
await client.issues.delete(projectId, issueId);

Events

const { items } = await client.events.list(projectId, issueId, { order: 'desc' });
const event     = await client.events.get(projectId, issueId, eventId);
console.log(event.data); // Full Sentry event payload

Auth Tokens

const tokens  = await client.tokens.list();
const created = await client.tokens.create({ description: 'CI token' });
console.log(created.token); // Save this — shown only once
await client.tokens.delete(1);

Error Handling

import {
  AuthenticationError,
  AuthorizationError,
  NotFoundError,
  RateLimitError,
  NetworkError,
  ServerError,
  ValidationError,
} from '@rustrak/client';

try {
  await client.projects.list();
} catch (error) {
  if (error instanceof RateLimitError)       console.log(`Retry after ${error.retryAfter}s`);
  else if (error instanceof AuthenticationError) redirect('/login');
  else if (error instanceof NotFoundError)   console.log('Not found');
  else if (error instanceof NetworkError)    console.log('Will retry automatically');
  else if (error instanceof ValidationError) console.log(error.getValidationDetails());
}

| Error Class | HTTP | Retryable | |---|---|---| | NetworkError | — | ✅ | | AuthenticationError | 401 | ❌ | | AuthorizationError | 403 | ❌ | | NotFoundError | 404 | ❌ | | BadRequestError | 400 | ❌ | | RateLimitError | 429 | ✅ | | ServerError | 500+ | ✅ | | ValidationError | — | ❌ |

Next.js Integration

Server Component

import { RustrakClient } from '@rustrak/client';

export default async function ProjectsPage() {
  const client = new RustrakClient({
    baseUrl: process.env.RUSTRAK_API_URL!,
    token: process.env.RUSTRAK_API_TOKEN!,
  });
  const projects = await client.projects.list();
  return <ProjectsList projects={projects} />;
}

Server Action

'use server';
import { RustrakClient } from '@rustrak/client';

export async function resolveIssue(projectId: number, issueId: string) {
  const client = new RustrakClient({
    baseUrl: process.env.RUSTRAK_API_URL!,
    token: process.env.RUSTRAK_API_TOKEN!,
  });
  return client.issues.updateState(projectId, issueId, { is_resolved: true });
}

TypeScript

All types are exported and inferred from Zod schemas — single source of truth:

import type {
  Project,
  Issue,
  Event,
  EventDetail,
  AuthToken,
  PaginatedResponse,
  CreateProject,
  UpdateIssueState,
} from '@rustrak/client';

Related Packages

| Package | Description | |---|---| | @rustrak/mcp | MCP server — gives Claude Desktop, Cursor, and Continue direct access to your Rustrak instance via 18 tools |

What is Rustrak?

Rustrak is a self-hosted error tracking server written in Rust that is fully compatible with any Sentry SDK. Drop-in replacement for Sentry — no code changes needed. Runs on ~50 MB of memory as a single binary or Docker image.

License

GPL-3.0