errorping
v0.1.0
Published
Modular, multi-channel error notification package with built-in storage for AI agent triage
Readme
errorping
Lightweight error capture library for the browser and Node.js. Catches errors and sends them to your backend via webhook. No opinions about storage, delivery, or notification — your backend decides what to do.
Install
npm install errorpingQuick start
import { init, Severity } from "errorping";
init({
channels: [
{ type: "webhook", url: "https://your-backend.com/errorping" },
],
appName: "my-app",
minSeverity: Severity.ERROR,
});Errors are now captured and POSTed to your webhook as JSON.
React
import { ErrorPingProvider } from "errorping/react";
function App() {
return (
<ErrorPingProvider
config={{
channels: [{ type: "webhook", url: "/api/errorping" }],
captureConsoleErrors: true,
captureUnhandledRejections: true,
}}
fallback={({ error, reset }) => (
<div>
<p>Something went wrong: {error.message}</p>
<button onClick={reset}>Try again</button>
</div>
)}
>
{children}
</ErrorPingProvider>
);
}The provider wraps your app with an error boundary and global listeners (window.onerror, unhandledrejection).
What it captures
Each error event includes:
id— unique UUIDseverity— INFO (0), WARNING (1), ERROR (2), CRITICAL (3)name,message,stack— from the Error objectfingerprint— djb2 hash for deduplicationcontext— runtime, URL, method, environment, release, etc.timestamp,occurrences,firstSeen
Built-in pipeline
- Deduplication — groups identical errors within a sliding window (default 60s)
- Rate limiting — token bucket, default 30 events/minute
- Console patching — optionally capture
console.error()calls - Global listeners —
window.onerror,unhandledrejection,uncaughtException - beforeSend hook — filter or modify events before dispatch
Configuration
init({
channels: [{ type: "webhook", url: "..." }],
appName: "my-app",
environment: "production",
release: "1.2.3",
minSeverity: Severity.ERROR,
captureConsoleErrors: true,
captureUnhandledRejections: true,
captureUncaughtExceptions: true,
dedupWindowMs: 60_000,
maxEventsPerMinute: 30,
beforeSend: (event) => event, // return null to drop
onAfterSend: (event, results) => {}, // callback after dispatch
classifySeverity: (error, ctx) => Severity.ERROR,
fingerprint: (error, ctx) => "custom-fp",
silent: false,
debug: false,
});Backend
errorping doesn't include a backend — it just sends events to a webhook URL. Use backend-template to get a ready-made backend that stores errors in Postgres and forwards to Telegram.
API
import { captureError, captureMessage } from "errorping";
// Capture an error
captureError(new Error("something broke"), { severity: Severity.CRITICAL });
// Capture a message
captureMessage("User signed up", { severity: Severity.INFO });From React:
import { useErrorPing } from "errorping/react";
function MyComponent() {
const { captureError, captureMessage } = useErrorPing();
// ...
}License
MIT
