fix(insights): propagate rrweb counters & resolve click targets #1
Reference in New Issue
Block a user
Delete Branch "fix/insights-rage-click-pipeline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Three coupled fixes that together stop frustrated sessions from being mislabelled as
power_user_pathand make click timelines actually diagnosable.1) Counter propagation
compress.tsnow returnsrageClickCount/network5xxCount/network4xxCountandcompress-sessions.tswrites them back toSessionMeta. Previously these stayed at0forever — PostHog recording metadata doesn't expose them and nothing updated the row after compress ran. Knock-on effect:tagger.tsrules likeux_friction(rageClickCount > 0) never fired.2) Tag rule hardening
power_user_pathv1 fallback now requiresrageClickCount===0. Without this guard any auth user with 20+ clicks (rage clusters included) was labelled a power user. This is the direct cause of the example session (019e4eda-…) showingpower_user_pathdespite 13 rage clusters.frustrated_sessiontag (rageClickCount >= 3, P2) for sustained friction beyond a single cluster.compress-sessions.tsre-runstagSession+scoreSessionafter writing fresh counters (using cached person+group for full enrichment), so the corrected tags land on the row in the same transaction.3) Click target enrichment
describeTargetused to readtagName/attributesoff MouseInteraction events — fields that don't exist on rrwebtype=3 source=2. Every click rendered as[el]. Now compress builds a node map from FullSnapshot (type=2) and keeps it in sync with mutations (type=3 source=0), then resolves clicks viad.id. Output goes fromclick [el]toclick [button:"VIN Sorgula"].Test plan
pnpm --filter worker typecheckpasses (verified locally)019e4eda-4d25-787f-bd75-19142eafe21f)SessionMeta.rageClickCount > 0after compress[power_user_path]to[ux_friction, frustrated_session], severity → P2[el]for elements present in the snapshot)Known limitation (not addressed here)
Tag step still runs before compress. If a session is
discardedat tag-time due to score threshold, compress never runs → re-tag never happens. Sessions with rage clicks but <20 clicks can slip through. Tracked separately.🤖 Generated with Claude Code
Three coupled fixes that together stop frustrated sessions from being mislabelled as `power_user_path` and make click timelines actually diagnosable. 1) Counter propagation (compress.ts, compress-sessions.ts): compress now returns rageClickCount / network5xxCount / network4xxCount and writes them back to SessionMeta. Previously these stayed at 0 forever because PostHog recording metadata doesn't expose them and nothing updated the row after compress ran. 2) Tag rule hardening (tagger.ts, compress-sessions.ts): - power_user_path v1 fallback now requires rageClickCount===0; without this guard any auth user with 20+ clicks (rage clusters included) was labelled a power user. - New frustrated_session tag (rageClickCount>=3, P2) for sustained friction beyond a single cluster. - compress-sessions re-runs tagSession+scoreSession after writing the fresh counters, so the corrected tags land on the row. 3) Click target enrichment (compress.ts): describeTarget used to read tagName/attributes off MouseInteraction events — fields that don't exist on rrweb type=3 source=2 — so every click rendered as `[el]`. Now compress builds a node map from FullSnapshot (type=2) and keeps it in sync with mutations (type=3 source=0), then resolves clicks via `d.id`. Clicks now show real tag + visible text / aria-label / name / data-testid. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.