Phase 4 part 2: MRR, its movements, NRR and cohorts

Each customer's MRR at each month's end, from the recurring lines of paid
and open invoices: the amount after discounts over the billing interval,
prorations over their part-period. Moves are new, expansion, contraction,
churn and reactivation (sub-dollar noise ignored); NRR monthly and over
12 months; cohorts by first paid month. A start month, suggested when
most of the business appears at once (billing moved to Stripe), makes
those customers the base. Metrics page with a chart, the month table,
cohorts, and each month's customer moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 12:17:53 -07:00
co-authored by Claude Opus 5.5
parent 2c242d8c94
commit 5e799c7541
11 changed files with 860 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
{{define "content"}}{{with .Data}}{{$m := .M}}
<div class="heading">
<h1>MRR in {{$m.Month}}</h1>
<div class="buttons"><a class="button secondary" href="/metrics">Metrics</a></div>
</div>
<p class="lede">{{usd $m.MRR}} from {{num $m.Customers}} customers{{if $m.Partial}}, so far this month{{end}}. Net change {{usd $m.NetNew}}: new {{usd $m.New}}, expansion {{usd $m.Expansion}}, reactivation {{usd $m.Reactivation}}, contraction −{{usd $m.Contraction}}, churn −{{usd $m.Churn}}.</p>
{{if .Changes}}
<table class="list">
<thead><tr><th>Customer</th><th>Movement</th><th class="num">MRR before</th><th class="num">After</th><th class="num">Change</th></tr></thead>
<tbody>{{range .Changes}}<tr>
<td>{{or .Customer.Name .Customer.Email .Customer.ID}}{{if and .Customer.Name .Customer.Email}} <span class="muted small">{{.Customer.Email}}</span>{{end}}</td>
<td><span class="badge {{if or (eq .Kind "churn") (eq .Kind "contraction")}}failed{{else}}published{{end}}">{{.Kind}}</span></td>
<td class="num">{{usd .Before}}</td><td class="num">{{usd .After}}</td><td class="num">{{usd (sub .After .Before)}}</td>
</tr>{{end}}</tbody>
</table>
{{else}}<p class="help">No customer moved this month.</p>{{end}}
{{end}}{{end}}
+59
View File
@@ -7,6 +7,65 @@
</div>
<p class="lede">MRR and its movements, NRR, CAC and CLV, computed from your Stripe data: every customer, invoice, credit note and refund. MRR comes from the invoice lines (what each customer was billed, for which period), so past months are exact. Supermarket only reads Stripe.</p>
{{with .Now}}{{$d := $.Data}}
{{with $d.Model.Suggest}}
<section class="card">
<p class="warn-text">In {{.Month}}, {{.Customers}} customers ({{usd .MRR}} of MRR) appear in Stripe at once. That usually means billing moved to Stripe then, not that they all signed up that month. Counting from {{.Month}} makes them the starting base instead of new customers.</p>
<div class="row">
<form method="post" action="/metrics/start"><input type="hidden" name="month" value="{{.Month}}"><button type="submit" class="small">Count from {{.Month}}</button></form>
<form method="post" action="/metrics/start"><input type="hidden" name="month" value="all"><button type="submit" class="secondary small">Keep counting everything</button></form>
</div>
</section>
{{end}}
<section class="card">
<h2>MRR {{if .Partial}}<span class="muted small">today</span>{{else}}<span class="muted small">at the end of {{.Month}}</span>{{end}}</h2>
<div class="funnel">
<div class="step"><span class="label">MRR</span><strong>{{usd .MRR}}</strong><span class="rate">ARR {{usd (mul12 .MRR)}}</span></div>
<div class="step"><span class="label">Paying customers</span><strong>{{num .Customers}}</strong></div>
<div class="step"><span class="label">Average per customer</span><strong>{{usd .ARPA}}</strong></div>
<div class="step"><span class="label">NRR, this month</span><strong>{{pct .NRR}}</strong><span class="rate">of last month's MRR kept</span></div>
<div class="step"><span class="label">NRR, 12 months</span><strong>{{pct .NRR12}}</strong><span class="rate">what customers of a year ago pay now</span></div>
</div>
{{with $d.Bars}}
<svg class="chart" viewBox="0 0 600 170" role="img" aria-label="MRR by month">
{{range .}}<rect x="{{.X}}" y="{{.Y}}" width="{{.W}}" height="{{.H}}"><title>{{.Month}}: {{usd .MRR}}</title></rect>{{if .Label}}<text x="{{.X}}" y="166">{{.Month}}</text>{{end}}{{end}}
</svg>
{{end}}
<p class="small muted">From the invoice lines of paid and open invoices, in {{$d.Model.Currency}}: each recurring line's amount after discounts, spread over its billing period. Trials ($0), one-off charges, void and uncollectible invoices don't count.{{with $d.Model.Start}}{{if ne . "all"}} Counted from {{.}}.{{end}}{{end}}</p>
</section>
<h2>Month by month</h2>
<div class="table-wrap"><table class="list compact">
<thead><tr><th>Month</th><th class="num">MRR</th><th class="num">Customers</th><th class="num">Net change</th><th class="num">NRR</th><th class="num">New</th><th class="num">Expansion</th><th class="num">Contraction</th><th class="num">Churn</th><th class="num">Reactivation</th></tr></thead>
<tbody>{{range $d.Recent}}<tr>
<td><a href="/metrics/month/{{.Month}}">{{.Month}}</a>{{if .Partial}} <span class="muted small">so far</span>{{end}}</td>
<td class="num">{{usd .MRR}}</td><td class="num">{{num .Customers}}</td>
<td class="num"><strong>{{usd .NetNew}}</strong></td>
<td class="num">{{pct .NRR}}</td>
<td class="num">{{if .New}}{{usd .New}} <span class="muted small">({{.NewCount}})</span>{{else}}<span class="muted">·</span>{{end}}</td>
<td class="num">{{if .Expansion}}{{usd .Expansion}}{{else}}<span class="muted">·</span>{{end}}</td>
<td class="num">{{if .Contraction}}−{{usd .Contraction}}{{else}}<span class="muted">·</span>{{end}}</td>
<td class="num">{{if .Churn}}−{{usd .Churn}} <span class="muted small">({{.ChurnCount}})</span>{{else}}<span class="muted">·</span>{{end}}</td>
<td class="num">{{if .Reactivation}}{{usd .Reactivation}}{{else}}<span class="muted">·</span>{{end}}</td>
</tr>{{end}}</tbody>
</table></div>
{{if $d.Cohorts}}
<h2>Cohorts</h2>
<p class="help">Customers by the month they first paid, and the share of their first month's MRR they pay each month after: above 100% means they grew.</p>
<div class="table-wrap"><table class="list compact cohorts">
<thead><tr><th>First paid</th><th class="num">Customers</th><th class="num">Starting MRR</th>{{range $i, $_ := $d.Span}}<th class="num">{{$i}}</th>{{end}}</tr></thead>
<tbody>{{range $d.Cohorts}}<tr><td>{{.Month}}</td><td class="num">{{.Customers}}</td><td class="num">{{usd .Start}}</td>{{range .Retained}}<td class="num">{{if ge . 0.0}}{{pct .}}{{end}}</td>{{end}}</tr>{{end}}</tbody>
</table></div>
{{end}}
<form method="post" action="/metrics/start" class="row small">
<label class="small">Count from <input name="month" value="{{with $d.Model.Start}}{{if ne . "all"}}{{.}}{{end}}{{end}}" placeholder="YYYY-MM, empty for everything" size="12"></label>
<button type="submit" class="secondary small">Save</button>
</form>
{{end}}
<section class="card">
<h2>Stripe</h2>
{{if not .Stripe}}