fix: prevent template DAU undercount from session telemetry gaps - #5530
Conversation
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":2,"expires_at":"2026-09-21T16:29:00Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":3,"expires_at":"2026-09-21T16:30:52Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":3,"expires_at":"2026-09-21T16:30:59Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
|
Here's a visual recap of what changed: Open the full interactive recap |
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":4,"expires_at":"2026-09-21T16:32:18Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
There was a problem hiding this comment.
Builder reviewed your changes — looks good ✅
Review Details
Code Review Summary
This PR fixes an analytics DAU undercount by expanding signed-in activity detection to include fallback event signals.
What Changed
The PR updates template analytics queries across 8 metrics (DAU, WAU, retention, recurring users) to count signed-in activity from:
- Both
session_statusandsession_statusevent name variants (handling telemetry aliases) app_enteredevents with identified users as a fallback when session telemetry gaps occur
Core filter updated from event-based to OR-based logic:
- Before:
event_name = 'session status' AND signed_in = 'true' - After:
((event_name IN ('session status', 'session_status') AND signed_in = 'true') OR (event_name = 'app_entered' AND identified user)) AND user_key IS NOT NULL
What I Verified
Filter Logic — Both PostgreSQL and BigQuery implementations correctly handle OR conditions with proper parenthesization. User key deduplication prevents double-counting across event types. ✓
Backward Compatibility — Legacy SQL constants preserve old behavior. Repair functions safely migrate stale BigQuery queries to new format using two-step replacement (full pattern → partial pattern). ✓
Data Consistency — All 8 affected panels have matching filters in the metric catalog, seed dashboard, and test expectations. Descriptions updated to reflect fallback behavior. ✓
Event Classification — isMarketingWebsiteSessionEvent() now accepts both event name variants. User identification checks properly validate required fields per event type. ✓
Test Coverage — Regression tests validate event aliases, fallback activity, and metric catalog/seed synchronization. All 111 tests passing. ✓
Risk: Standard — This is a scoped business logic fix to analytics query generation with no authentication, payment, or destructive changes involved. Backend-only change with no UI impact.
🧪 Browser testing: Skipped — PR only modifies backend analytics templates and tests, no UI code touched
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":5,"expires_at":"2026-09-21T16:40:04Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":6,"expires_at":"2026-09-21T16:49:49Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":7,"expires_at":"2026-09-21T16:59:39Z","observed_legacy_version":"none","legacy_retired":true,"status":"active"}
{"pr":5530,"owner_thread":"01a0c45d-ff61-7163-a15d-73b147fae4b6","owner":"codex","version":8,"expires_at":"2026-09-21T16:40:33Z","observed_legacy_version":"none","legacy_retired":true,"status":"released","released":true}

Summary
Root cause
The template DAU panels treated
session statusas the only signed-in activity signal. From Sep 15 through Sep 19, identified app-entry activity continued while session-status rows fell, so every template was undercounted. The BigQuery panel also did not recognize the canonicalsession_statusalias introduced later. This fix is scoped to the Sep 15+ decline; the known Sep 2-6 zero window is not changed.Validation
Deployment remains subject to the normal post-merge prebuilt publisher boundary.