feat(admin): analytics dashboard

Sprint 27.

New features/admin/analytics/ module + net-new /:lang/backoffice/analytics
route + Dashboard Quick Action.

- revenue/orders/avg-order-value/sales-over-time/top-products computed by
  composing AdminOrdersLocalGateway (Sprint 23's seeded mock orders) - real
  aggregation over mock data, not a separate fabricated dataset
- products/categories counts from AdminProductsLocalGateway/
  AdminCategoriesLocalGateway
- visitors/funnels/heatmaps render pending-backend badges (no analytics
  pipeline exists anywhere in this system) rather than fabricated numbers,
  same convention as the Sprint 19 dashboard's pre-Sprint-23 Orders/Revenue
  cards
- plain div-bar chart (no charting library), 7/30/90-day range toggle,
  CSV export

docs/ADMIN.md + docs/BACKEND.md (new item 16) updated.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sdarbinyan
2026-07-15 11:17:55 +04:00
parent a67ea17ad2
commit 88cc131fdc
11 changed files with 264 additions and 2 deletions

View File

@@ -391,6 +391,31 @@ routes at all, this is a net-new admin section.
audit and Sprint 25's per-user audit. No consolidation attempted - they
track different things.
## Sprint 27 - Analytics
`features/admin/analytics/`, net-new `/:lang/backoffice/analytics` route
+ Dashboard Quick Action.
- **Real, derived data**: revenue/orders/avg-order-value/sales-over-time
chart/top-products are computed by composing the existing
`AdminOrdersLocalGateway` (Sprint 23's seeded mock orders) - not a
separate fabricated dataset. Products/Categories counts come from
`AdminProductsLocalGateway`/`AdminCategoriesLocalGateway`. All of this is
still ultimately backed by mock order/product/category data (per those
sprints), but the *aggregation* is real arithmetic over that data, not
invented numbers.
- **Visitors, funnels, heatmaps**: no analytics/tracking pipeline exists
anywhere in this codebase, so these render an explicit
"Awaiting backend integration" (`pending-backend`) badge, same convention
as the Sprint 19 dashboard's Orders/Revenue cards before Sprint 23 -
not fabricated numbers, not a generic empty state.
- **Chart**: a plain inline `<div>`-bar chart driven by `[style.height.%]`,
no charting library pulled in - reasonable for one sales-over-time series
at this scale; revisit if more chart types are actually needed.
- **Date ranges**: 7/30/90-day toggle filters orders by `createdAt`.
- **Export**: CSV of the sales series (client-side `Blob` download, same
pattern as Orders/Transactions).
## Known gaps / backend needs
- **Dashboard metrics endpoint.** Categories/Products counts are computed

View File

@@ -168,6 +168,14 @@ Plus, if authenticated history/wishlist/compare/saved-searches sync is wanted: `
**Frontend files:** implement `AdminMonitoringApiGateway`-equivalent methods against a to-be-defined `AdminMonitoringGateway` interface (`AdminMonitoringLocalGateway` currently has no interface extracted — add one when a real implementation is built, mirroring the pattern used everywhere else in `admin/*`).
## 16. Analytics - visitors/funnels/heatmaps (Sprint 27, no backend at all)
**Current behavior:** `features/admin/analytics/` computes real revenue/orders/top-products aggregations from the existing mock order data (see item 7), but visitor traffic, conversion funnels, and heatmaps have zero data source anywhere in this system (no analytics/tracking pipeline, no event collection) — these render `pending-backend` badges rather than fabricated numbers.
**Needed:** a traffic/event tracking pipeline (page views, sessions, conversion events) and a funnel/heatmap aggregation service, before this section of the Analytics page can show anything real.
**Frontend files:** `features/admin/analytics/pages/admin-analytics-page.component.html` currently renders the pending-backend badge inline (no gateway method exists for this yet, unlike every other mocked domain in this doc).
## Known reliability issues
### Production 502/504 Bad Gateway on refresh / back-navigation

View File

@@ -64,8 +64,9 @@ Notify user: **from Sprint 20 (Categories) once product↔category link + admin
- [x] `docs/ADMIN.md` (new Sprint 26 section), `docs/BACKEND.md` item 15 added
- Commit: `feat(admin): monitoring center`
## Sprint 27 — Analytics
- [ ] Dashboard extensions: sales/revenue/orders/visitors/products/categories charts, date ranges, export
## Sprint 27 — Analytics ✅ done
- [x] Sales/revenue/orders/products/categories (real aggregation over mock order data), visitors/funnels/heatmaps (pending-backend badges, no fabricated data), sales-over-time bar chart, 7/30/90-day ranges, CSV export
- [x] `docs/ADMIN.md` (new Sprint 27 section), `docs/BACKEND.md` item 16 added
- Commit: `feat(admin): analytics dashboard`
## Sprint 28 — Marketplace Polish