feat: optional anonymous usage statistics (off by default)
What
Optional anonymous usage statistics, off by default. With TR_EVER_STATS_ENABLED=true the API sends Ever Platform one small signed report a day about the installation as a whole; without it, nothing is loaded and nothing leaves the installation.
- What is sent (
ever.stats.v1, closed schema): counts of users, projects, terms, translations, project locales and API clients; translations changed this month; whether Google sign-in and sign-ups are on; release version and channel; install source and country as the operator declares them (self-hosted/ZZby default). Never a name, e-mail, id of a user or project, term, translation or key. - Before sending: the report is serialised once and those exact bytes are checked like Ever Platform checks them (16 KiB, strict JSON, the vendored schema with ajv strict, a walker binding every string). A report that fails is never signed or sent.
- Identity: one
ever_instancerow with a random instance id and an Ed25519 statistics key; the private key is stored AES-256-GCM encrypted under HKDF(TR_SECRET). NoTR_SECRETconfigured: nothing is created or sent.TR_SECRETchanged: a new identity is made. - Schedule: once a day at a random second (UTC), the previous month once more on days 1-3, back-off after failures; a lease in the database so several API processes send once.
setTimeoutchain withunref(), no new scheduler dependency. - Operator page (Ever Platform in the account menu, only for
TR_EVER_ADMIN_EMAILS, defaultTR_ADMIN_EMAIL): state, What is sent, Last payload (exact bytes), Send now, on/off switch, Reset instance identity. Routes under/api/v1/ever-stats; everyone else and every API client gets "not found". - Tables (one migration, sqlite / postgres / mysql):
ever_instance,ever_stats_report(last 12),ever_stats_schedule, plus an index ontranslation's modification date for the monthly count. Times are epoch milliseconds inbigintcolumns, so all three databases compare them the same way. - Wiring:
AppModuleimports the two modules only when the switch istrue. The catch-allindex.htmlroute moves into its ownIndexModuleimported last: Nest registers the root module's routes first, so an imported module's GET routes would otherwise be shadowed by it. Behaviour of every existing route is unchanged. - Contract files are vendored byte for byte from the public SDK (
ever-co/ever-connect-sdk, contracts 1.0.0-rc.8) with their SHA-256 inVENDOR.json; a drift test checks them. - New dependency:
ajv(already used by the webapp toolchain).
Tests
- Unit: settings parsing, key wrapping and identity (in-memory sqlite: one row under concurrent creation, key never stored in clear, new identity after a
TR_SECRETchange), operator guard, schema allow-list (published valid/invalid examples, closed objects, string walker, extracounts.emailsrefused), collector (UTC month bounds), sender (signature verifies over the exact bytes, 202/409/422/503/connection error, last 12 kept, unusable address sends nothing), scheduler (slot, day-2 closing report, switch off, lease held elsewhere, back-off, Send now limits), route manifest, static checks (no host/Docker/db-type inference, one HTTP client, Ever address only in the settings, no key in logs or answers), AppModule wiring. - e2e (sqlite): seeded instance with canary names/e-mails/project/term/translation, preview names none of them; operator-only routes (401 signed out, 404 other user and API client); Send now signs and posts once, stored payload = sent bytes; rate limit; switch off sends nothing (409); reset gives a new id and key; with the switch unset there is no route and no row.
- Webapp: the Statistics component (switch calls
PUT enabled, Send now disabled while off, read-only on cloud) and the menu check (hidden on 403/404/other bodies).
Docs
docs/ever-platform/anonymous-usage-statistics.md, docs/ever-platform/outbound-calls.md (sidebar), docs/configuration.md rows, .env.sample, changelog.
🤖 Generated with Claude Code
Summary by cubic
Adds optional anonymous usage statistics, off by default. With TR_EVER_STATS_ENABLED=true, the API sends Ever Platform one signed report a day about the installation as a whole; without it, nothing is loaded and nothing leaves the installation.
Reports contain counts only (users, projects, terms, translations, locales, API clients, translations changed this month) plus two settings flags and declared version, channel, install source and country — never a name, e-mail, id, term, translation or key. The exact bytes are validated against the vendored ever.stats.v1 schema (16 KiB, strict JSON, ajv strict) before signing, and a report that fails is never signed or sent; oversized reports are not kept. One ever_instance row holds a random instance id and an Ed25519 key, stored AES-256-GCM encrypted under a key derived from TR_SECRET; without TR_SECRET nothing is created or sent, and changing it makes a new identity. Only canonical 32-byte statistics keys are verified.
Operator page
- The operator (a signed-in user with a confirmed e-mail in
TR_EVER_ADMIN_EMAILS, defaultTR_ADMIN_EMAIL) gets an Ever Platform page with state, last payload, send now, an on/off switch and reset identity; routes live under/api/v1/ever-statsand answer everyone else with not found. - Reset identity runs under the shared sending lease, a missing
TR_SECRETanswers 409secret_missing, and a new identity also lifts a refusal until upgrade.
Schedule and wiring
- Reports go once a day at a random UTC second, with a database lease so several API processes send once, back-off after failures, and a refused closing report ends the slot.
- The connection closes as soon as the answer's status arrives, so the send timeout covers the whole exchange.
- The destination address resolves in order
TR_EVER_STATS_API_URL,TR_EVER_PLATFORM_API_URL, thenhttps://api.ever.co. - One migration adds
ever_instance,ever_stats_report,ever_stats_scheduleand atranslationindex for sqlite, postgres and mysql. - The catch-all
index.htmlroute moves to its own module imported last so new GET routes are not shadowed. Contract files are vendored byte for byte with a drift test; new dependency:ajv.