internal/aggregate: handle empty country labels; default to 'unknown'

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib35708154ba06816817f094698799b7c6a6a6964
This commit is contained in:
raf 2026-03-10 10:38:47 +03:00
commit d1d450ec11
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -162,7 +162,11 @@ func (m *MetricsAggregator) RecordPageview(path, country, device, referrer, doma
labels := prometheus.Labels{"path": sanitizeLabel(path)}
if m.cfg.Site.Collect.Country {
labels["country"] = sanitizeLabel(country)
if country == "" {
labels["country"] = "unknown"
} else {
labels["country"] = sanitizeLabel(country)
}
}
if m.cfg.Site.Collect.Device {