ts-bugfixes

Logging, error reporting and HTTP middleware for TypeScript. Works in Node.js 24+, browsers and Edge Runtime with zero runtime dependencies.

Install

npm install bugfixes

Configure

Create an agent in the dashboard and set its key and secret. The library already knows where the BugFixes API is. Server-side, use environment variables:

BUGFIXES_AGENT_KEY=your-key
BUGFIXES_AGENT_SECRET=your-secret
BUGFIXES_LOG_LEVEL=warn
BUGFIXES_LOCAL_ONLY=false

Then load them once at startup, for example in Next.js instrumentation:

// instrumentation.ts
import { loadConfigFromEnv, setDefaultConfig } from "bugfixes";

export function register() {
  setDefaultConfig(loadConfigFromEnv());
}

Or configure directly, which also works in the browser and Edge:

import { setDefaultConfig } from "bugfixes";

setDefaultConfig({ agentKey: "your-key", agentSecret: "your-secret", localOnly: false });

Errors are only sent to BugFixes when localOnly is false and both key and secret are set.

Report errors

import { info, warn, error, fatal } from "bugfixes";

info("listening on port", 3000);
warn("deprecated route");

const err = error("database unavailable"); // returns an Error with a captured stack, and reports it
fatal("unrecoverable"); // reports, then exits in Node or throws in browser/Edge

Subpaths