Guides / Platforms & Tools
npm install logit
# or
pnpm add logit
# or
yarn add logit
// lib/logit.ts
import { init } from "logit";
export const logit = init({
token: process.env.LOGIT_API_KEY!,
});
Create one instance at startup. The client is stateless and safe to share across requests.
// 1. User signup
await logit.now("signups", {
event: "New user",
description: user.email,
icon: "👤",
notify: true,
tags: { plan: user.plan },
metadata: { userId: user.id, email: user.email },
});
// 2. Payment
await logit.now("payments", {
event: "Payment received",
description: `${user.email} — $${amount}`,
icon: "💰",
notify: true,
tags: { plan: user.plan },
metadata: { amount, userId: user.id },
});
// 3. Error (revenue-critical)
await logit.now("errors", {
event: "Checkout failed",
description: error.message,
icon: "❌",
notify: true,
tags: { component: "checkout" },
metadata: { stack: error.stack },
});
// 4. Custom milestone
await logit.now("milestones", {
event: "100 users 🎉",
description: "Total signup count crossed 100",
icon: "🎉",
notify: true,
});
import { LogitError } from "logit";
try {
await logit.now("signups", { event: "New user", description: email });
} catch (err) {
if (err instanceof LogitError) {
console.error("LogIt error:", err.message, err.statusCode);
}
// LogIt errors should never crash your app — log and continue
}
# .env
LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx
Try LogIt free
7-day trial. No credit card required.