Find paying customers who stopped logging in

Stripe knows who pays you. Supabase knows who still shows up. Here is the SQL that compares the two.

The short answer

Put your active Stripe subscriptions next to Supabase's auth.users and auth.sessions tables, match them by email, and keep the customers with no activity for 10 days. You can do it in the Supabase SQL editor, without changing your app.

Don't use last_sign_in_at on its own. It can flag customers who use your app every day.

Why last_sign_in_at is misleading

last_sign_in_at changes when someone signs in. Supabase sessions last indefinitely by default, so a customer can sign in once in March, stay signed in, and still show a March date in June.

Their session tells you more. While someone uses your app, the Supabase client keeps renewing their access token, which lasts an hour by default, and the row in auth.sessions is updated each time. Signing out deletes that row, so you need both: the latest session activity or the last sign-in, whichever is newer.

Get your subscriptions out of Stripe

  1. In the Stripe Dashboard, open Subscriptions and export the list as a CSV.
  2. In a spreadsheet, keep three columns and name them email, status and mrr. For yearly plans, divide the price by 12. Leave out currency signs.
  3. In the Supabase SQL editor, create a table for it:
create schema if not exists churn_check;

create table churn_check.subscriptions (
  email  text,
  status text,
  mrr    numeric
);

The separate schema matters. Supabase's API exposes the public schema by default, and a list of who pays you shouldn't be there.

Then open the Table Editor, switch the schema to churn_check, open subscriptions and choose Insert, then Import data from CSV.

Find who has gone quiet

This only reads your data. The customers who pay the most come first.

with paying as (
  select lower(trim(email)) as email, sum(mrr) as mrr
  from churn_check.subscriptions
  where lower(status) in ('active', 'past_due')
  group by 1
),
logins as (
  select lower(u.email) as email,
    greatest(
      u.last_sign_in_at,
      max(greatest(s.updated_at, s.refreshed_at at time zone 'utc'))
    ) as last_active
  from auth.users u
  left join auth.sessions s on s.user_id = u.id
  where u.email is not null
  group by u.id
)
select p.email, p.mrr,
  l.last_active::date as last_active,
  current_date - l.last_active::date as days_quiet
from paying p
join logins l on l.email = p.email
where l.last_active is null
   or l.last_active < now() - interval '10 days'
order by p.mrr desc nulls last;

An empty last_active means they have an account but have never signed in. past_due is included because those customers haven't cancelled. Trials are left out because they don't pay yet.

Ten days suits a product people open every week. If yours is used once a month, try 45.

Check the emails that don't match

Some people pay with a company address and log in with their own. The query above skips them, so list them separately:

select distinct c.email, c.mrr
from churn_check.subscriptions c
left join auth.users u on lower(u.email) = lower(trim(c.email))
where u.id is null
  and lower(c.status) in ('active', 'past_due')
order by c.mrr desc nulls last;

Look these up by name or company. To avoid the problem for new customers, save the Stripe customer ID on your user when they check out, and match on that instead of the email.

If you use the Stripe Sync Engine

Supabase can copy your Stripe data into your database for you. If you have it installed, skip the CSV and replace the paying part of the main query with this:

with paying as (
  select lower(trim(c.email)) as email, round(sum(p.unit_amount) / 100.0, 2) as mrr
  from stripe.subscriptions s
  join stripe.customers c on c.id = s.customer
  left join stripe.prices p on p.id = s.plan::json ->> 'id'
  where s.status::text in ('active', 'past_due')
  group by 1
),

Here mrr is the plan's full price, so a yearly plan shows the yearly amount. It also ignores quantities and discounts. That's fine for sorting a list, not for reporting revenue.

What this list gets wrong

  • Teams. The person who pays may never log in while their colleagues do. Check the whole account before you write.
  • API users. Someone who only calls your API has no session to update, so they look inactive.
  • Open tabs. A forgotten tab can keep renewing its session, which makes someone look active when they aren't.
  • Holidays. Ten quiet days in August may mean nothing.

Logins are also just one sign. The guide to customer churn prediction covers the other six.

What to send them

Write to the top few yourself, one at a time. Something this short is enough:

Quick check on your account

Hi Sam,

It's been a little while since you last logged in, so I wanted to check in personally.

If you reply with what you're trying to get done, I'll point you to the fastest way to do it.

Best,

When you're done, delete the copy of your customer list:

drop schema churn_check cascade;

Or have it done every week

The CSV is out of date as soon as someone subscribes or cancels. KeptMRR connects to Stripe and Supabase, keeps both up to date, and compares each customer with how often they normally log in. You get the list by email every Monday, with the reason next to each name. Free up to $2k MRR.

Get your first list free