Skip to content

Commit c193343

Browse files
committed
feat: add backend middleware analytics for prometheus
* Add custom metrics to estimate unique visitors. * Add custom metrics to estimate usefull client information (browser, os, device) * Add PRIVACY.md file Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
1 parent 3c9ac93 commit c193343

10 files changed

Lines changed: 971 additions & 0 deletions

File tree

PRIVACY.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Privacy Policy
2+
3+
This Privacy Policy explains what data the KernelCI Dashboard collects when you
4+
use it, why, and how we protect it. It is written for users of the service.
5+
Operators deploying the Dashboard are responsible for keeping this document
6+
accurate for their own instance and for surfacing it to their users.
7+
8+
## Summary
9+
10+
The KernelCI Dashboard collects **anonymous, aggregate usage analytics** only.
11+
We do **not** build user profiles, do **not** sell data, and do **not** store
12+
any personal identifier.
13+
14+
## What we collect
15+
16+
When you make requests to the Dashboard API (`/api/`), the backend records
17+
aggregate usage metrics. These are stored only as counts (Prometheus counters),
18+
never as per-user records or per-user timestamps:
19+
20+
- **Request attributes**: the API endpoint name, HTTP method, response status
21+
class (e.g. `2xx`), and coarse client buckets derived from your browser's
22+
User-Agent (e.g. browser family `Chrome`, operating system `Linux`, device
23+
type `desktop`). Automated clients are bucketed as `bot`.
24+
- **Referrer domain**: only the external domain that linked you to the
25+
Dashboard (e.g. `example.org`). Same-site and direct visits are recorded as
26+
`direct_or_internal`. The full referring URL is never stored.
27+
- **Unique visitor estimates**: daily de-duplicated visit counts, in total and
28+
per endpoint.
29+
30+
## What we do NOT collect or store
31+
32+
- Your raw IP address.
33+
- Your raw, full User-Agent string.
34+
- The full referrer URL or any query parameters.
35+
- Any account, name, email, or other directly identifying information.
36+
- Any cross-day or long-term tracking identifier.
37+
38+
## How unique visitors are counted
39+
40+
To estimate unique visitors without identifying you, the backend:
41+
42+
1. Computes a one-way fingerprint as
43+
`HMAC-SHA256(daily_salt, "<your_ip>|<your_user_agent>")`.
44+
2. Uses a `daily_salt` — a random 256-bit secret generated fresh each UTC day,
45+
held only in an ephemeral cache (Redis/memcached) with a ~25 hour lifetime.
46+
3. Uses only the resulting hash as a short-lived de-duplication key. Your raw
47+
IP and User-Agent are discarded immediately after the hash is computed and
48+
are never written to any metric or to disk.
49+
50+
Because the salt is secret and rotates every day, fingerprints cannot be linked
51+
across days, and the hash cannot be reversed back to your IP/User-Agent in
52+
practice.
53+
54+
## Legal basis and retention
55+
56+
- **Purpose**: understanding aggregate usage and load to operate and improve
57+
the service.
58+
- **Legal basis** (where GDPR applies): legitimate interest in operating and
59+
improving the service, using the most privacy-preserving design we can.
60+
- **Retention**: the transient daily fingerprints and salt expire automatically
61+
within ~25 hours. Only anonymous aggregate counters are retained beyond that;
62+
these contain no personal data.
63+
64+
## Your rights
65+
66+
Because we retain only anonymous, aggregate counts and hold no identifier that
67+
can single you out beyond a single day, we cannot link any stored data to a
68+
specific person and therefore cannot act on individual access/deletion requests
69+
against the aggregate metrics. If you have questions about privacy on a specific
70+
deployment, contact that deployment's operator.
71+
72+
## Data controller and contact
73+
74+
For the upstream instance at
75+
[dashboard.kernelci.org](https://dashboard.kernelci.org), the data controller
76+
is **The Linux Foundation**. For privacy inquiries contact
77+
[privacy@linuxfoundation.org](mailto:privacy@linuxfoundation.org), or write to:
78+
79+
> The Linux Foundation, Attn: Legal Department, 548 Market St, PMB 57274,
80+
> San Francisco, California 94104-5401, USA.
81+
82+
Third-party deployments are controlled by their respective operators, who are
83+
responsible for providing their own contact details.
84+
85+
## Changes
86+
87+
We may update this policy as the service evolves. Changes are tracked in the
88+
repository's git history.
89+
90+
## Technical reference
91+
92+
For implementation details, see
93+
[`docs/monitoring.md`](docs/monitoring.md#client-analytics).

backend/kernelCI/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def get_json_env_var(name, default):
8989
"django.contrib.messages.middleware.MessageMiddleware",
9090
"django.middleware.clickjacking.XFrameOptionsMiddleware",
9191
"kernelCI_app.middleware.logServerErrorMiddleware.LogServerErrorMiddleware",
92+
"kernelCI_app.middleware.backendRequestMetricsMiddleware.BackendRequestMetricsMiddleware",
9293
"django_prometheus.middleware.PrometheusAfterMiddleware",
9394
]
9495

0 commit comments

Comments
 (0)