Self-hosting

The Cloudflare backend in the public repo is the whole backend, not a reduced one: POST /v1/events, GET /v1/summary, GET /v1/events/top, a nightly Cron Trigger that rolls up closed days and prunes raw events past 90 days, migrations, an admin CLI and a conformance suite.

git clone https://github.com/awizemann/swift-stats
cd swift-stats/backends/cloudflare
npm install
npx wrangler login
npx wrangler d1 create stats
npm run deploy

# then create a project and mint a write key
node scripts/admin.mjs create-project myapp "My App" --remote
node scripts/admin.mjs mint-key myapp --write --remote

Point CloudflareEndpoint at your own Worker URL and nothing else in your app changes. Keys are stored only as SHA-256 hashes, and the project is derived from the key's scope rather than from anything the client sends.

Moving between self-hosted and hosted later is a URL and a key: the wire contract is identical, because the hosted service runs this same Worker.