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 bugfixesConfigure
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=falseThen 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.
Deployment metadata
Optional. When set, each report records where it came from. Nothing is inferred from Git, CI or production flags; only the values you set are sent.
BUGFIXES_COMMIT_SHA=full-git-object-id # deployed commit, 40 or 64 hex characters
BUGFIXES_RELEASE=checkout-api@2.4.0 # release identifier
BUGFIXES_ENVIRONMENT=production # deployment environment
BUGFIXES_SERVICE=checkout-api # service sending the reportReport 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/EdgeSubpaths
bugfixes: logging, config, stack traces, utilitiesbugfixes/logs: logging-only subsetbugfixes/middleware: HTTP middleware fornode:httpservers