fix/ph-insights
needs attentionviewing older commita97e2f0 · fullpre-PRreviewed 2026-07-31 17:23 UTC1H · 2M · 2L · 4I- 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
- 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+47−14
- 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.
Findings · 8
correctness1
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
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
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
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.
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.
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.
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.
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.