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

untracker

v0.0.1

Published

Framework-agnostic error handling core: CustomError, error catalog builder, pluggable transports

Readme

untracker

Error-handling mechanics without project knowledge: CustomError, a typed error-catalog builder, and a pluggable transport interface. The module provides the machinery; the project provides the data — the error catalog, translations and toast UI stay in the consuming app.

Zero runtime dependencies. Rollbar, Hawk and React are optional peers.

Install

npm i untracker

Composition root

The transport is created by the project and passed in — the module never reads process.env, so it works outside Next.js too.

// app/lib/error-handler.ts
import { createErrorHandler, setGlobalErrorHandler } from "untracker";
import { rollbarTransport } from "untracker/rollbar";

export const errorHandler = createErrorHandler({
  transport: rollbarTransport({
    accessToken: process.env.NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN!,
  }),
  environment: process.env.NODE_ENV,
  release: process.env.NEXT_PUBLIC_APP_RELEASE,
  beforeSend: (event) => {
    delete event.context.password;
    return event;
  },
});

setGlobalErrorHandler(errorHandler);

After setGlobalErrorHandler, the free functions work anywhere without threading the instance through:

import { captureException } from "untracker";

captureException(err, { action: "checkout" });

Before it, calls fall back to consoleTransport — they log rather than throw, so no try/catch boilerplate is needed at call sites.

Error catalog

The builder lives here, the table lives in the project:

// app/lib/errors.ts
import { defineErrors } from "untracker";
import { errorHandler } from "./error-handler";

export const { Errors, ErrorCodes, createError, isErrorCode } = defineErrors({
  INVALID_CREDENTIALS: { status: 401, kind: "auth",       message: "Invalid email or password" },
  QUERY_FAILED:        { status: 500, kind: "database",   message: "Database query failed" },
  VALIDATION_ERROR:    { status: 400, kind: "validation", message: "Validation failed" },
}, {
  onCreate: (err) => errorHandler.captureException(err),
});

export type AppErrorCode = keyof typeof Errors;

createError is typed to the project's codes — createError("QUERY_FILED") is a compile error.

throw createError("VALIDATION_ERROR", { field: "email", message: "Email is required" });
createError("QUERY_FAILED", { report: false });   // skip onCreate for this call

Domain is expressed as kind, not subclasses — it survives serialization across a server-action boundary, where instanceof does not:

if (err.kind === "validation") { /* … */ }
CustomError.is(err, "QUERY_FAILED");   // reliable even if the package is duplicated in the bundle

Handler API

interface ErrorHandler {
  captureException(error: unknown, context?: Context): void;
  captureMessage(message: string, level?: Level, context?: Context): void;
  setUser(user: UserInfo | null): void;
  setContext(key: string, value: unknown): void;
  addBreadcrumb(breadcrumb: Breadcrumb): void;
  child(context: Context): ErrorHandler;
  flush(timeoutMs?: number): Promise<boolean>;
}

child() scopes context per request instead of repeating it at each call:

const log = errorHandler.child({ requestId, userId });
log.captureException(err);

flush() matters on Vercel/Lambda, where the process freezes right after the response:

await errorHandler.flush(2000);

Transports

| Import | Transport | |---|---| | untracker/rollbar | rollbarTransport({ accessToken }) | | untracker/hawk | hawkTransport({ token }) — resolves to the browser or node SDK automatically | | untracker | consoleTransport(), noopTransport() |

A custom transport is a small object:

import type { ErrorTransport } from "untracker";

export const httpTransport = (url: string): ErrorTransport => ({
  name: "http",
  captureException: (error, event) => {
    void fetch(url, { method: "POST", body: JSON.stringify({ ...event, stack: error.stack }) });
  },
  captureMessage: (message, event) => {
    void fetch(url, { method: "POST", body: JSON.stringify(event) });
  },
});

The core assembles the ErrorEvent — merging scope context, user, breadcrumbs and running beforeSend — so transports stay thin.

React

import { ErrorHandlerProvider } from "untracker/react";
import { addToast } from "@heroui/react";
import { useTranslations } from "next-intl";

const tErrors = useTranslations("Errors");

<ErrorHandlerProvider
  handler={errorHandler}
  notify={({ title }) => addToast({ title, color: "danger" })}
  translate={(code) => tErrors(code)}
>
  {children}
</ErrorHandlerProvider>

The provider takes a ready instance — the transport is live from module import, not from the first effect, so errors thrown during the initial render are not lost. The toast library and i18n stay in the project.

const handler = useErrorHandler();
const { notifyError } = useErrorNotification();

notifyError(err);                              // resolves the code through `translate`
notifyError(err, { code: "UNKNOWN_ERROR" });   // fallback when the error carries none

<ErrorBoundary fallback={(error, reset) => <Failed error={error} onRetry={reset} />}>
  {children}
</ErrorBoundary>

Testing

noopTransport() records instead of sending:

const transport = noopTransport();
const handler = createErrorHandler({ transport });

handler.captureException(new Error("boom"), { action: "save" });
expect(transport.events[0].context).toMatchObject({ action: "save" });

Development

npm install
npm test
npm run typecheck
npm run build