canter-error-reporter
v0.1.0
Published
Tiny zero-dependency client for the Canter Error Reporter API. Fire-and-forget reportError() with env-var configuration.
Readme
canter-error-reporter
Tiny, zero-dependency client for the Canter Error Reporter API.
Fire-and-forget reportError() that:
- Never awaits the network — won't block your request handlers.
- Never throws — telemetry failures don't take down your app.
- No-ops silently when env vars aren't set, so local dev keeps working.
Install
npm install canter-error-reporterRequires Node 18+ (uses global fetch).
Usage
import { reportError } from "canter-error-reporter";
try {
await doSomethingRisky();
} catch (err) {
reportError({
project: "my-project", // your project's slug
category: "database_error", // e.g. provider_failure, rate_limit, parse_error
message: "Failed to load user", // short description
rawError: err, // optional: full error/stack
context: { userId: "123" }, // optional: structured context
});
throw err;
}Configuration
Set these on your deployed environment (e.g. Railway):
| Env var | Description |
|---|---|
| ERROR_API_URL | Full URL of the API endpoint, e.g. https://error-reporter-production.up.railway.app/errors |
| ERROR_API_KEY | Shared secret matching the server's API_KEY |
Both are optional — if either is missing, reportError() is a no-op. That makes local dev a non-event.
API
reportError(params: {
project: string;
category: string;
message: string;
provider?: string;
rawError?: unknown;
context?: Record<string, unknown>;
}, options?: {
apiUrl?: string; // override ERROR_API_URL
apiKey?: string; // override ERROR_API_KEY
}): voidReturns void — the function is intentionally synchronous; the network POST happens in the background.
