Docs

Trial Tracking

Log trial starts, expirations, and conversions. Know who to nudge before they churn — and celebrate when they upgrade.


Trial started

Log the moment a user begins a free trial — right after you set trialEndsAt on their account.

ts
await logit.now("trials", {
  event: "Trial started",
  description: `${user.email} — 14 days on Pro`,
  icon: "🎁",
  notify: true,
  tags: { plan: "pro", duration: "14d" },
  metadata: {
    userId: user.id,
    email: user.email,
    trialEnds: trialEndsAt.toISOString(),
  },
});

Trial ending soon

Run a daily cron and alert on trials expiring in the next 48 hours.

ts
for (const user of expiringTrials) {
  await logit.now("trials", {
    event: "Trial ending soon",
    description: `${user.email} trial expires in ${user.daysLeft} days`,
    icon: "⏳",
    notify: true,
    tags: { plan: user.plan, daysLeft: String(user.daysLeft) },
    metadata: {
      userId: user.id,
      email: user.email,
      trialEnds: user.trialEndsAt,
    },
  });
}

Trial converted

Log when a trial user becomes a paying customer.

ts
await logit.now("trials", {
  event: "Trial converted",
  description: `${user.email} upgraded to Pro after trial`,
  icon: "🎉",
  notify: true,
  tags: { plan: "pro", converted: "true" },
  metadata: {
    userId: user.id,
    email: user.email,
    trialDaysUsed: daysBetween(user.trialStartedAt, new Date()),
  },
});

Trial expired without converting

ts
await logit.now("trials", {
  event: "Trial expired",
  description: `${user.email} trial ended — no upgrade`,
  icon: "😴",
  tags: { plan: user.plan, converted: "false" },
  metadata: { userId: user.id, email: user.email },
});

Tips

  • Use notify: true on starts and "ending soon" — those are the ones you act on.
  • Tag converted: "true" | "false" so you can filter your inbox later.