Guides / Monitoring
When you send webhooks to your customers' endpoints and they fail (5xx, timeout, network error), you might not know for hours — until a customer emails support. Logging delivery failures to LogIt gives you real-time visibility.
// lib/webhook-dispatcher.ts
import { logit } from "@/lib/logit";
export async function dispatchWebhook(customerId: string, endpointUrl: string, eventType: string, payload: object) {
let statusCode: number | null = null;
try {
const res = await fetch(endpointUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
signal: AbortSignal.timeout(10_000),
});
statusCode = res.status;
if (!res.ok) throw new Error(`HTTP ${res.status}`);
} catch (err) {
const error = err instanceof Error ? err.message : String(err);
await logit.now("webhook-failures", {
event: "Webhook delivery failed",
description: `${eventType} to ${new URL(endpointUrl).hostname} — ${error}`,
icon: "📡",
notify: false,
tags: {
customerId,
eventType,
statusCode: statusCode?.toString() ?? "timeout",
},
metadata: { customerId, endpointUrl, eventType, statusCode, error },
});
throw err; // re-throw so your retry queue picks it up
}
}
| Field | Value |
|---|---|
| Name | Webhook failure spike |
| Channel | webhook-failures |
| Event name | Webhook delivery failed |
| Threshold | 10 |
| Window | 15 minutes |
| Cooldown | 30 minutes |
| Action | Push notification |
Filter by customerId tag in the LogIt dashboard to see which customer's endpoint is failing — before they contact you.
statusCode in tags so you can filter by HTTP 500 vs. timeout vs. DNS failure.webhooks channel (with notify: false) for a complete delivery timeline.Try LogIt free
7-day trial. No credit card required.