Guides / Monitoring
Error bursts rarely announce themselves. You ship a release, the error rate quietly spikes, and you find out from a support ticket 40 minutes later.
Smart Actions evaluates a condition every time an event is ingested:
"If event X in channel Y occurs N times in Z minutes → trigger action"
No cron job, no polling. The evaluation runs inline, fired by your own events.
First, make sure your error events flow into a dedicated channel:
// lib/logit.ts
import { init } from "logit";
export const logit = init({ token: process.env.LOGIT_API_KEY! });
// In your global error handler
import { logit } from "@/lib/logit";
export async function logError(err: Error, context?: Record<string, unknown>) {
await logit.now("errors", {
event: "Application error",
description: err.message,
icon: "🚨",
notify: false, // don't ping on every error — Smart Action handles the threshold
tags: { type: err.name },
metadata: { stack: err.stack, ...context },
});
}
In your LogIt dashboard, go to Smart Actions for your project and click New Rule.
Configure it like this:
| Field | Value |
|---|---|
| Name | Error spike alert |
| Channel | errors |
| Event name | Application error |
| Threshold | 5 |
| Window | 5 minutes |
| Cooldown | 15 minutes |
| Action | Push notification |
| Push title | 🚨 Error spike detected |
| Push body | 5+ errors in the last 5 minutes |
Trigger 5+ errors quickly (or lower the threshold temporarily). You'll receive a push notification within seconds of the threshold being crossed.
The cooldown period prevents alert storms. After the rule fires, it won't fire again for 15 minutes — even if errors keep coming. Adjust based on how quickly your team can act.
notify: false on individual events — let Smart Actions handle the signal, not the noise.Try LogIt free
7-day trial. No credit card required.