Skip to content

feat(api): add secure aggregated signup statistics - #778

Merged
unjica merged 2 commits into
developfrom
feat/signup-stats-endpoint
Oct 16, 2026
Merged

unjica merged 2 commits into
developfrom
feat/signup-stats-endpoint

Conversation

@unjica

@unjica unjica commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Add GET /api/signup-stats for private signup analytics with a separate SIGNUP_STATS_TOKEN, constant-time digest comparison, 404 when disabled, and a 30/minute per-IP limiter covering failed authentication.

Returns UTC daily and Monday-start ISO weekly signup/affiliate counts over an inclusive 1–366-day range (30-day default), plus first-touch source/medium/campaign/referrer breakdowns. PostgreSQL performs read-only aggregation; no schema changes or historical backfills. Only explicitly approved non-personal acquisition labels are returned; other non-null labels are reaggregated as redacted, and null attribution is unattributed.

Conversion metrics return null with an explanation because mutable organization plans/subscriptions cannot establish historical free-to-paid transitions or unique signup-cohort ownership. See docs/SIGNUP-STATS.md for the contract, configuration and privacy decisions.

Validation:

  • pnpm test: 1,553 passed, 146 skipped, zero failures; includes 20 new endpoint tests.
  • pnpm lint: passed with zero warnings.
  • pnpm build: passed for all workspaces; API rebuilt after the final SQL timestamp-bound refinement.
  • Standalone API/dashboard type-checks: 106/6 existing test-file diagnostics, respectively; independently reproduced against unchanged branch sources and confirmed identical after this change. Normal production builds/type-checks pass.
  • Self-reviewed committed and working-tree changes against origin/develop; git diff --check passes.

Tests use mocked database aggregates; optional DB integration tests remain skipped under the standard test command. No production database access, migrations, merge, deployment or publishing performed. Generated build output is excluded.

Add a dedicated token-protected read-only analytics endpoint with UTC daily
and ISO weekly buckets, approved acquisition labels and affiliate counts.
Return null for unreliable conversion metrics and document privacy, range
validation, configuration and rate limits. Add endpoint coverage.
@unjica
unjica force-pushed the feat/signup-stats-endpoint branch from 1a1fd8e to 4b15ae4 Compare October 16, 2026 15:54
@unjica
unjica merged commit 3f7ae12 into develop Oct 16, 2026
7 checks passed
@unjica unjica mentioned this pull request Oct 16, 2026
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