feat/mrr-tables
needs attentionviewing older commit870badc · fullpre-PRreviewed 2026-08-07 23:15 UTC1H · 3M · 3L · 4I- Purpose
- Clean up obsolete PostHog MRR analytics insights that used a plan-floor event (revenue.mrr_snapshot) excluded overage/subs and were superseded by a better interactive pivot
- Goal
- Reduce dashboard noise by removing 7 dead/superseded insights and restructuring the Revenue MRR dashboard to surface the coverage gap and subscription MRR as the primary tiles
- Sub-goals
- Remove mrr_total, mrr_by_plan, mrr_by_segment (event-based plan-floor insights with known limitations)
- Remove mrr_by_product, mrr_by_product_summary, usage_by_product_month, active_subs_by_plan (D3 static tables superseded by pivot)
- Reorganize dashboard layout: mrr_coverage_gap promoted to top full-width, mrr_subscription_based and churned_mrr in second row
- What
- 7 PostHog insights deleted from insights.tf, Revenue MRR dashboard layout restructured in dashboards.tf from 9 to 5 codified tiles
- Why
- Static MRR tables replaced by interactive pivot with HogQL SQL variables (which Terraform provider cannot declare); event-based insights were stuck at ~$66k due to excluding overage/subs
- Areas
- infra/posthog/insights.tf+18−323infra/posthog/dashboards.tf+12−30
- Blast
- 2 files, +30/−353 lines; analytics IaC only — no app code, no DB migrations, no API changes
Findings · 11
correctness3
.claude/rules/posthog-api-insights.md does not exist in working tree
infra/posthog/dashboards.tf:166
Referenced as maintenance SSOT for the out-of-band pivot in two places. Absent from this branch (exists in a sibling commit not yet merged here).
Customer names (Neto, Pilgrim's) in PostHog insight description field
infra/posthog/insights.tf:1023
Description is a PostHog API/UI attribute readable by anyone with project access. Prefer generic label; keep specifics in code comments.
Finance MRR figures committed to git history (accepted trade-off)
infra/posthog/insights.tf:1106
Product-level MRR breakdown (~$396k MXN total) from June 2026 finance sheet in Terraform locals. Permanent in git history. Noted as Approach A in comments.
security1
No credentials/secrets in surviving HogQL queries
infra/posthog/insights.tf
All supabase.public__* references use only table/column names — no connection strings, API keys, or PII selected at row level.
conventions3
scripts/posthog-mrr-pivot.mjs does not exist
infra/posthog/dashboards.tf:165
Comment says pivot is 'created OUT-OF-BAND by scripts/posthog-mrr-pivot.mjs'. Script does not exist anywhere in the repo. The pivot's SQL lives only in PostHog UI — no code-backed definition, silent-drift-prone.
Stale comments reference mrr_por_producto / mrr_por_org as current MRR SOT
infra/posthog/insights.tf:838
Comments at lines 838, 1003, 1007 recommend 'use the D3 insights (mrr_por_producto / mrr_por_org)' but those insights were deleted in this PR. Should reference the pivot + mrr_coverage_gap.
Block tombstone style vs per-insight one-liner style elsewhere
infra/posthog/insights.tf
Three D3 insights removed under one block comment; other removals use individual one-liner tombstones.
tests1
No .tftest.hcl; CI validates via live terraform apply
.github/workflows/pr-checks.yml
Consistent with rest of repo. Reference integrity pre-verified by cross-check.
improvement3
Double blank line after tombstone comment at ~line 1008
infra/posthog/insights.tf:1008
Two consecutive blank lines between tombstone comments; Terraform style uses one.
d3_led_cte local is not orphaned — used by mrr_coverage_gap
infra/posthog/insights.tf:1090
All 5 d3_* locals consumed by the surviving mrr_coverage_gap insight.
No lingering references to removed insights in alerts/outputs/variables
infra/posthog/alerts.tf
Confirmed clean across all support .tf files.