Skip to content

feat(analytics): app-scoped analytics read endpoint (2/3) - #2192

Open
soamdesai-tfh wants to merge 4 commits into
feat/world-id-analytics-datafrom
feat/world-id-analytics-read
Open

feat(analytics): app-scoped analytics read endpoint (2/3)#2192
soamdesai-tfh wants to merge 4 commits into
feat/world-id-analytics-datafrom
feat/world-id-analytics-read

Conversation

@soamdesai-tfh

@soamdesai-tfh soamdesai-tfh commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Second of three stacked PRs (on #2191). Implements the one authenticated read path for all analytics surfaces.

Scope

  • GET /api/portal/apps/{app_id}/world-id-analytics?environment&period[&action_ids]
  • Database-backed authorization via getIsUserAllowedToReadApp (404, no existence leak) + independent soft-delete 404
  • Requested-id resolution against both action tables: missing/ambiguous/cross-app/cross-environment/wrong-source all reject 400 before any analytics read
  • App series always covers every in-scope v3+v4 action (combined in PostgreSQL, never merged in Node); legacy_actions/actions blocks cover only requested ids
  • UTC zero-filling; Last 7 Days age truncation; the three All Time start branches (v3 history → app creation; v4-only → RP registration; v3-only/no-RP → app creation); bigint-safe integer-string counts
  • Lands the fresh-stack integration suite + opt-in million-row gate, which exercise PR 1's data layer and this endpoint together

Verification

  • Endpoint unit tests 26/26; tsc --noEmit
  • Fresh-stack suite 22/22 (canonical v3/v4 parity, cold backfill, overlap recapture, cutoff/safety delay, advisory-lock exclusion vs legacy (533214,42), watermark monotonicity, atomic rollback, deletion-wins races, service-only role isolation, cron metadata)
  • Million gate: 1,000,000 seeded rows → catch-up to 1,010,000 with full parity; backfill 264ms, catch-up 43ms, endpoint p95 ~29ms both periods, payloads 358B/7.4KB; auto_explain plans prove endpoint reads never scan raw nullifier history

@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-data branch from 2d9c3d9 to 093f412 Compare July 31, 2026 07:41
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 7b12100 to 705315e Compare July 31, 2026 07:41
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 705315e to 268ecfc Compare July 31, 2026 14:31
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 268ecfc to 3abc011 Compare July 31, 2026 16:46
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 3abc011 to e7030b9 Compare July 31, 2026 21:29
@soamdesai-tfh
soamdesai-tfh marked this pull request as ready for review August 3, 2026 00:49
soamdesai-tfh and others added 3 commits August 3, 2026 14:44
GET /api/portal/apps/{app_id}/world-id-analytics: database-backed app
authorization with soft-delete 404s, id resolution against both action
tables with ambiguity/cross-app/cross-environment/wrong-source rejection,
PostgreSQL-side combined app aggregation, UTC zero-filling with the
three All Time start branches, bigint-safe integer-string counts, and
source-specific legacy_actions/actions blocks. Lands the fresh-stack
integration suite and the opt-in million-row load gate, which exercise
the data layer and this endpoint together.
The data slice scoped the fresh-stack runner to its own suites; now
that integration.test.ts and million.test.ts exist in this tree,
re-extend the default path and restore the --million entrypoint and
its package script.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Follows up 2191's action_v3_stats_daily -> action_legacy_stats_daily
rename: the field name and alias in get-world-id-analytics.graphql,
the endpoint's literal refs and hasV3History/has_v3_history naming,
and every test call site (integration.test.ts, million.test.ts,
world-id-analytics.test.ts). Regenerated the operation's generated.ts.

Also fixes a real bug the rename exposed: integration.test.ts's
tracked-table discovery regex hardcoded action_v[34]_stats_daily,
so it silently stopped matching the renamed table. Broadened to
action_(?:legacy|v4)_stats_daily.

Verified: tsc, prettier, unit 26/26, fresh-stack smoke+backfill+
integration 29/29, million gate 1/1 (1M-row backfill+catchup+parity).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from fee4fd4 to 6c3f84d Compare August 3, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant