Guides / SaaS

Get Notified When Users Delete Their Accounts

3 min read·SaaS

Why Log Deletions

Account deletions are the clearest churn signal you have. Unlike subscription cancellations (which might be pauses), a deletion is deliberate. Logging it gives you:

  • A real-time feed of departing users
  • A Smart Actions alert when deletions cluster after a release
  • Exit reason data if you ask before deleting

Step 1: Log the Deletion

ts
export async function logAccountDeletion(userId: string, email: string, plan: string, reason?: string) {
  await logit.now("deletions", {
    event: "Account deleted",
    description: `${email} deleted their account${reason ? ` — "${reason}"` : ""}`,
    icon: "🗑️",
    notify: true,
    tags: {
      plan,
      reason: reason ?? "not_provided",
      hadPaidPlan: plan !== "free" ? "true" : "false",
    },
    metadata: {
      userId,
      email,
      plan,
      reason: reason ?? null,
      deletedAt: new Date().toISOString(),
    },
  });
}

Step 2: Call It Before Deleting

ts
// app/api/account/delete/route.ts
export async function DELETE(req: Request) {
  const { reason } = await req.json() as { reason?: string };
  const user = await getAuthUser(req);

  // Log before deleting — you need the user data
  await logAccountDeletion(user.id, user.email, user.plan, reason);

  await db.user.delete({ where: { id: user.id } });
  return new Response(null, { status: 204 });
}

Step 3: Smart Action for Deletion Spike

FieldValue
NameDeletion spike
Channeldeletions
Event nameAccount deleted
Threshold3
Window2 hours
Cooldown6 hours
ActionPush notification

Tips

  • Set notify: true on every deletion — paid plan deletions especially deserve immediate attention.
  • Log before removing the user record so you still have access to email, plan, and other data.
  • Track hadPaidPlan: "true" as a tag to quickly filter for high-value departures in the dashboard.

Try LogIt free

7-day trial. No credit card required.

Start free