Phase 2: analytics rollups, geo breakdown, event feed (backend)
CI / policy (push) Successful in 4s
CI / backend (push) Failing after 1m13s
CI / mobile (push) Successful in 19s
CI / profile (push) Successful in 48s

- Idempotent hourly rollup (run_rollup, INSERT ... ON CONFLICT DO UPDATE into
  analytics_rollups_hourly) + Tokio background task (startup then hourly)
- GET /v1/cards/{id}/analytics/geo — country-grouped visit counts
- GeoResolver trait: real MaxMind under the `geoip` feature, no-op default;
  raw IP resolved then discarded (only hash + coarse country/city persisted)
- analytics_events now store country/city; rollups read query for the dashboard

2 new tests (geo grouping, rollup aggregation + idempotency); 75 backend tests.
fmt + clippy clean; geoip feature compiles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
Omar Sobh
2026-06-04 11:34:52 -05:00
co-authored by Claude Opus 4.8
parent e66813ef58
commit 4770efd861
14 changed files with 419 additions and 11 deletions
@@ -14,6 +14,7 @@ workspace = true
# structurally-correct but unsigned passes — logged loudly at startup.
default = []
apple-signing = ["cardclaws-wallet/apple-signing"]
geoip = ["dep:maxminddb"]
[[bin]]
name = "cardclaws-api"
@@ -43,6 +44,7 @@ rand = { workspace = true }
base64 = { workspace = true }
validator = { workspace = true }
async-trait = { workspace = true }
maxminddb = { version = "0.24", optional = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
thiserror = { workspace = true }
@@ -51,6 +53,7 @@ thiserror = { workspace = true }
cardclaws-auth = { workspace = true }
cardclaws-wallet = { workspace = true }
cardclaws-config = { workspace = true }
cardclaws-db = { workspace = true }
tower = { workspace = true, features = ["util"] }
http-body-util = "0.1"
tokio = { workspace = true }