Guides / SaaS
One cancellation is expected. Three cancellations in an hour after a deploy is a sign your new release broke something — or your pricing page just updated with a bug. Smart Actions detects the cluster, not the individual event.
// Stripe webhook: customer.subscription.deleted
if (event.type === "customer.subscription.deleted") {
const sub = event.data.object;
await logit.now("churn", {
event: "Subscription cancelled",
description: `Customer ${sub.customer} cancelled ${sub.items.data[0]?.price.nickname ?? "plan"}`,
icon: "😢",
notify: true, // notify on every cancellation AND watch the threshold
tags: {
plan: sub.items.data[0]?.price.nickname ?? "unknown",
reason: sub.cancellation_details?.reason ?? "none",
},
metadata: {
subscriptionId: sub.id,
customerId: sub.customer,
mrr: sub.items.data[0]?.price.unit_amount,
},
});
}
| Field | Value |
|---|---|
| Name | Churn cluster |
| Channel | churn |
| Event name | Subscription cancelled |
| Threshold | 3 |
| Window | 1 hour |
| Cooldown | 6 hours |
| Action | Push notification |
| Push title | 🚨 Churn cluster detected |
| Push body | 3+ cancellations in 1 hour — investigate |
Create a second action using the Webhook type to post into your #churn Slack channel so the whole team sees it, not just the person with the app.
notify: true on individual events so you still see each cancellation, but use Smart Actions for the pattern.downgrades channel and add its own rule — they're often a leading indicator of full churn.Try LogIt free
7-day trial. No credit card required.