Guides / SaaS

Track B2B Account Health Events

4 min read·SaaS

What Account Health Looks Like

B2B account health is a collection of signals over time: logins, feature usage, support tickets, integration activity. When those signals drop off, churn risk rises.

Health Signals to Log

ts
// lib/account-health.ts
import { logit } from "@/lib/logit";

type HealthSignal = "login" | "feature_used" | "export" | "api_call" | "support_ticket" | "inactive_warning";

export async function logAccountActivity(accountId: string, accountName: string, signal: HealthSignal) {
  const isRisk = signal === "inactive_warning" || signal === "support_ticket";

  await logit.now("account-health", {
    event: `Account signal: ${signal}`,
    description: `${accountName}${signal.replace("_", " ")}`,
    icon: isRisk ? "⚠️" : "✅",
    notify: isRisk,
    tags: { accountId, signal, risk: isRisk ? "true" : "false" },
    metadata: { accountId, accountName, signal, timestamp: new Date().toISOString() },
  });
}

Inactivity Detection via Cron

ts
// jobs/inactive-account-check.ts (runs daily)
export async function checkInactiveAccounts() {
  const cutoff = new Date(Date.now() - 14 * 24 * 3600 * 1000);
  const inactive = await db.account.findMany({
    where: { lastActivityAt: { lt: cutoff }, plan: { not: "free" } },
  });

  for (const account of inactive) {
    await logit.now("account-health", {
      event: "Account inactive",
      description: `${account.name} has been inactive for 14+ days`,
      icon: "😴",
      notify: true,
      tags: { accountId: account.id, plan: account.plan, risk: "true" },
      metadata: { accountId: account.id, accountName: account.name, lastActivityAt: account.lastActivityAt },
    });
  }
}

Support Ticket Cluster Alert

FieldValue
NameSupport ticket cluster
Channelaccount-health
Event nameAccount signal: support_ticket
Threshold3
Window7 days
Cooldown7 days
ActionPush notification

Tips

  • Log the accountId in tags so you can filter the dashboard to a single account's full health timeline.
  • Feed this data to your CRM via Smart Actions webhook when an account crosses a risk threshold.

Try LogIt free

7-day trial. No credit card required.

Start free