Repository navigation
feat(api): add secure aggregated signup statistics - #778
Merged
Merged
Conversation
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
force-pushed
the
feat/signup-stats-endpoint
branch
from
October 16, 2026 15:54
1a1fd8e to
4b15ae4
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
GET /api/signup-statsfor private signup analytics with a separateSIGNUP_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 isunattributed.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.mdfor 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.origin/develop;git diff --checkpasses.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.