runlight
Runlight is privacy friendly web analytics that runs inside your own Rust service. It counts visitors without cookies and without storing anyone's IP address. The numbers stay in your database, and the dashboard is served from your domain at /runlight.
This crate is the Rust version of Runlight. It runs on tokio behind axum, hyper, or any server that takes a tower service. It answers every request the way the TypeScript library does and uses the same tables, so either one can read the other's database. The store is the runlight-sqlx crate, which keeps the tables in your own SQLite, Postgres, MySQL, or MariaDB database.
Get started
Add the crates, and axum if your app does not have it already.
[]
= { = "0.2", = ["axum"] }
= { = "0.2", = ["sqlite"] }
= "0.8"
The runlight crate needs Rust 1.88 or later. runlight-sqlx needs Rust 1.94 or later, as sqlx 0.9 does, so an app that uses both needs 1.94.
Create one instance, merge its routers into your app, and add its middleware, which answers your link domains before your own routes.
use ;
# async
Add the script to every page, just before </head>.
Set RUNLIGHT_TOKEN to a long random string, then open /runlight/?token= followed by that string to sign in.
The Rust guide has the stores, other servers, the scheduled check, and location lookups.
License
Runlight is MIT licensed.