← all branches

fix/ph-insights

needs attentionviewing older commit
a97e2f0 · fullpre-PRreviewed 2026-07-31 17:23 UTC1H · 2M · 2L · 4I
The branch
Purpose
Fix PostHog analytics IaC that was permanently lying — four dashboard tiles built on events the production Lambda pipeline never emits, making dashboards show empty funnels and zero-data health tiles.
Goal
Remove the dead signal from PostHog dashboards while preserving the Terraform resources that alerts.tf depends on, and repoint funnel insights to live events with accurate naming.
Sub-goals
  • Repoint file_consumption_funnel and data_consumption_funnel step-1 from dead cfe_job.succeeded to live cfe_job.created
  • Detach job_success_rate and job_failure_by_error from all dashboards (dashboard_ids=[]) while retaining as alerts.tf ID dependencies
  • Add DEAD TERMINAL JOB EVENTS comment block explaining the pipeline gap and what events are safe to use
The changes (whole branch)
What
Single file change to infra/posthog/insights.tf: two funnel insights repointed to live events + renamed, two platform health insights renamed as dead and detached from dashboards, one large explanatory comment block added.
Why
cfe_job.succeeded/failed/partial_success were only ever emitted by the retired Vercel HTTP endpoint. When transitions moved to Lambda, these events were never ported. This means the funnel insights had a permanently-empty step 1 and the platform health insights showed zero data — silently lying rather than erroring.
Areas
infra/posthog/insights.tf+4714
Blast
1 file, +47/-14 lines. Purely analytics IaC — no application code, no DB schema, no customer data. Risk is limited to PostHog dashboard state after terraform apply.
analytics-iac posthog no-pr
CI· No PR — CI signals not availableCodeRabbit· No .coderabbit.yaml in reposeo· Self-skip: no apps/web/** files in diff

Findings · 8

correctness1

info

Console-managed insight IDs referenced in comments only — no Terraform guard if recycled

infra/posthog/insights.tf

kC1Q0m1b and frlG0rEQ are console-managed and cannot be deleted via Terraform. If those insights are ever deleted from the PostHog UI, the Terraform state won't reflect it. Acknowledged in the comment block as a known gap pending provider support.

conventions1

low

Dead-insight comment names alert labels but not the file

infra/posthog/insights.tf

The DEAD TERMINAL JOB EVENTS block correctly names posthog_alert.job_success_rate and posthog_alert.job_failure_spike as the reason these resources are retained, but doesn't cite the file (alerts.tf). Adding 'alerts.tf:posthog_alert.job_success_rate_low / posthog_alert.job_failure_spike' makes the dependency verifiable without grepping.

tests1

info

No automated validation of PostHog event names against emitted events

infra/posthog/insights.tf

The root cause of this fix — a funnel step referencing a dead event — could recur. A lightweight CI check cross-referencing event names in *.tf against known-emitted events (grepped from the platform source) would catch this class of regression before apply. Worth a follow-up ticket.

improvement5

high

Dead insights retained as alert anchors with no enforce-guard

infra/posthog/insights.tf

job_success_rate and job_failure_by_error are kept solely because alerts.tf references their IDs (posthog_alert.job_success_rate_low, posthog_alert.job_failure_spike). Nothing enforces this. A future editor seeing two resources named 'DEAD' with dashboard_ids=[] will reasonably delete them and break alerts.tf silently. Recommend adding `lifecycle { prevent_destroy = true }` to each and an inline comment citing the exact alerts.tf resource names that depend on them.

medium

Floor-denominator caveat (BAT-286) not co-located with each query

infra/posthog/insights.tf

The detailed explanation of why cfe_job.created is a floor metric appears in the block comment above file_consumption_funnel, but data_consumption_funnel only gets a brief 'same problem, same fix' cross-reference. Anyone reading the data_consumption_funnel query in isolation won't see the denominator caveat. A short inline comment on each funnelsFilter block would keep the intent visible without hunting for the parent block.

medium

Console-managed insight IDs (kC1Q0m1b, frlG0rEQ) are bare strings with no staleness guard

infra/posthog/insights.tf

These IDs appear in comments as the canonical replacement metrics but have no Terraform representation. If the PostHog project is re-provisioned or those insights are edited in the UI, the IDs silently go stale. Add a comment per ID with the insight name and why it cannot be IaC-managed, and consider a Linear ticket to bring them under Terraform once the provider supports DataVisualizationNode.

low

DEAD naming prefix is informal and not machine-enforceable

infra/posthog/insights.tf

Prefixing insight names with '(dead — …)' is a human convention. A future alert added against one of these resources would not be blocked. A lifecycle block or a comment registry at the top of insights.tf listing 'retained-dead' resources would give auditors a single place to check.

info

Large DEAD TERMINAL JOB EVENTS comment block reduces file scannability

infra/posthog/insights.tf

The comment block is accurate and necessary, but at its current length it makes the surrounding Terraform harder to scan. Consider condensing to a two-line summary + link to .claude/rules/posthog-annotations.md or a docs/ companion. Low priority — correctness is the goal.

History · 5 commits

  1. ba4f438safeincremental0H · 0M · 1L2026-08-01 00:54
  2. f9ad657needs attentionincremental0H · 1M · 2L2026-08-01 00:35
  3. 1475bfbsafeincremental0H · 0M · 0L2026-07-31 20:34
  4. 6b58b01needs attentionfull0H · 3M · 5L2026-07-31 18:10
  5. a97e2f0needs attentionfull1H · 2M · 2L2026-07-31 17:23current