@solenai/monitor
v0.1.0
Published
Lightweight incident reporter for Solen MetaShift webhooks (Sentry-compatible payload)
Maintainers
Readme
@solen/monitor
Report runtime errors to Solen MetaShift incident webhooks. Payloads use a Sentry-compatible shape so MetaShift normalizes them automatically. No runtime dependencies—Node 18+ built-in fetch only.
Install
npm install @solen/monitorQuick setup
import { monitor } from '@solen/monitor';
const { captureError } = monitor({
webhookUrl: process.env.SOLEN_WEBHOOK_URL!,
secret: process.env.SOLEN_WEBHOOK_SECRET!,
environment: 'production',
});Calling monitor() registers uncaughtException and unhandledRejection handlers and returns manual capture helpers.
Express middleware
import express from 'express';
import { monitor } from '@solen/monitor';
import { solenErrorHandler } from '@solen/monitor/express';
const { captureError } = monitor({
webhookUrl: process.env.SOLEN_WEBHOOK_URL!,
secret: process.env.SOLEN_WEBHOOK_SECRET!,
});
const app = express();
app.use(solenErrorHandler({ captureError }));solenErrorHandler captures the error with route, method, and status, then calls next(err) so your existing error handlers still run.
Manual capture
import { monitor } from '@solen/monitor';
const { captureError, captureMessage } = monitor({
webhookUrl: process.env.SOLEN_WEBHOOK_URL!,
secret: process.env.SOLEN_WEBHOOK_SECRET!,
});
try {
await chargeCustomer(orderId);
} catch (err) {
await captureError(err, {
extra: { orderId },
tags: { service: 'billing' },
});
throw err;
}
await captureMessage('Stripe webhook replay detected', { level: 'warning' });Webhook URL and secret
Create an incident webhook endpoint in the Solen dashboard:
https://solenai.ca/integrations/webhooks
Each endpoint provides:
- Webhook URL — MetaShift ingest URL (
/api/webhooks/incident/{endpointId}) - Secret — sent as the
X-Solen-Secretheader on every request
Store both in environment variables (for example SOLEN_WEBHOOK_URL and SOLEN_WEBHOOK_SECRET) and pass them to monitor().
Fastify
import Fastify from 'fastify';
import { monitor } from '@solen/monitor';
import { solenFastifyPlugin } from '@solen/monitor/fastify';
const { captureError } = monitor({ webhookUrl, secret });
const app = Fastify();
await app.register(solenFastifyPlugin, { captureError });Requirements
- Node.js 18+
- Optional peers:
express(for@solen/monitor/express),fastify(for@solen/monitor/fastify)
