velxio/backend/app/services
David Montero Crespo 5bf3a3d5ed feat(metrics): add usage analytics dashboard with country tracking
Track per-user, per-project, and per-board usage to inform pricing tier
decisions. Adds an admin dashboard with KPIs (DAU/WAU/MAU, totals,
success rate), time-series charts for compiles/runs, board family +
FQBN breakdowns, "board diversity" pie chart (key freemium signal),
top users/projects, and per-country breakdown via Cloudflare's
CF-IPCountry header. Admin can now also view private projects.

Backend:
- New UsageEvent table (append-only event log with user_id, project_id,
  event_type, board_fqbn/family, country, error_kind, duration_ms)
- Aggregate counters on User (total_compiles/runs/errors, last_active,
  signup_country, last_country) and Project (compile/run/update counts,
  last_compiled/run timestamps) kept in sync by MetricsService for O(1)
  dashboard reads
- 10 admin endpoints under /api/admin/metrics/{overview, timeseries,
  boards, board-diversity, top-users, top-projects, countries,
  users/{id}, projects/{id}}
- POST /api/metrics/run for client-side run telemetry
- Country detection via cf-ipcountry header (no DB / no API calls)
- Auto-migrations in lifespan for legacy DBs

Frontend:
- recharts-powered Dashboard tab with KPI cards and 4 charts
- New Boards tab with per-family + per-FQBN breakdown
- Country column with flag emoji on Users tab
- Top countries card on Dashboard
- compileCode now forwards project_id; Run button reports via WS

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 19:47:40 -03:00
..
esp-idf-template feat: enhance Arduino library handling by detecting external libraries and creating IDF components, add tests for library resolution logic 2026-04-07 14:59:51 -03:00
__init__.py feat: Implement Arduino Simulator with component management and simulation features 2026-03-03 00:20:49 -03:00
arduino_cli.py feat: Add compiler flag for BitOrder restoration in Arduino CLI; mark subproject commits as dirty 2026-04-12 00:23:06 -03:00
esp32_i2c_slaves.py feat: add BMP280 sensor component and circuit preview 2026-04-14 17:27:30 -03:00
esp32_lib_bridge.py V1 feat: Enhance ESP32 emulation support and logging 2026-03-14 16:57:22 -03:00
esp32_lib_manager.py Add end-to-end tests for ammeter, voltmeter, and capacitor charging behavior 2026-04-21 02:17:30 -03:00
esp32_worker.py Add end-to-end tests for ammeter, voltmeter, and capacitor charging behavior 2026-04-21 02:17:30 -03:00
esp_qemu_manager.py feat: implement ESP32 QEMU backend manager and frontend simulation interface 2026-04-01 22:41:52 -03:00
espidf_compiler.py feat: Enhance ESPIDFCompiler library resolution logic; add support for dynamic library detection and patching in CMakeLists.txt 2026-04-11 15:25:40 -03:00
gpio_shim.py feat: add board types and mappings for Raspberry Pi 3B 2026-03-12 23:39:04 -03:00
metrics.py feat(metrics): add usage analytics dashboard with country tracking 2026-04-25 19:47:40 -03:00
project_files.py feat: /project/:id URL, per-project file volumes, and public/private access control 2026-03-06 20:38:06 -03:00
qemu_manager.py feat: Implement Virtual File System for Raspberry Pi 3 with context menu and upload functionality 2026-03-15 14:04:01 -03:00
wifi_status_parser.py feat: implement ESP32 QEMU backend manager and frontend simulation interface 2026-04-01 22:41:52 -03:00