Scout Server

July 16, 2026 ยท View on GitHub

CI Docker License: MIT Swift

A Vapor backend for the Scout package. The server aggregates analytics data natively: clients upload only raw records, and the name-grouped metric series Scout's UI reads are synthesized on the fly with SQL aggregation. Active users (DAU/WAU/MAU) are aggregated the same way and served as a flat series.

Table of Contents

Features

๐Ÿ“ŠNative AggregationThe name-grouped metric series Scout's UI reads, the DAU/WAU/MAU active-user series, and the retention cohorts are synthesized on the fly with SQL โ€” clients upload only raw records.
๐Ÿ”Idempotent UpsertsRecords are upserted by recordID, so re-sent batches overwrite in place and sync retries stay safe. The Scout dashboard queries the API directly.
๐Ÿ”‘API KeysEndpoints are guarded by API keys, passed via an X-API-Key header or a bearer token.
๐Ÿ˜PostgresRecords persist in Postgres with migrations run automatically on boot; tests run against in-memory SQLite.
๐ŸณDockerShips as a container image on the GitHub Container Registry.

Running

docker compose up

brings up the server with Postgres on localhost:8080. Images are published to GitHub Container Registry as ghcr.io/kasianov-mikhail/scout-server.

Configuration

VariableMeaning
SCOUT_API_KEYSComma-separated list of accepted API keys
DATABASE_URLPostgres connection string (takes precedence)
DATABASE_HOST / DATABASE_PORT / DATABASE_USERNAME / DATABASE_PASSWORD / DATABASE_NAMEComponent-wise Postgres configuration

Migrations run automatically on boot.

API

The server exposes a small HTTP API under /api/v1 for uploading and querying records. See API.md for the full reference.

Development

swift test

Tests run against an in-memory SQLite database; the aggregation SQL is portable across both drivers (grouping happens on epoch-second bucket columns).

License

Scout Server is released under the MIT License. See LICENSE for details.