Files
marketplaces/docs/superpowers/specs/2026-08-15-admin-product-views-column-design.md
sdarbinyan 7f3a22abb8
Some checks failed
Architecture Governance / architecture (push) Has been cancelled
docs: design spec for admin product views column (item 1)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-15 15:58:49 +04:00

3.4 KiB

Admin product view count column — design

Status: Approved Date: 2026-08-15 Related backlog item: #1 (site traffic counter)

Problem

User reported "site traffic isn't visible, counter shows low." Investigation found two separate things already exist and are working as intended, neither of which is the actual gap:

  • Admin Analytics → Traffic tab already shows an honest "Unknown - available after backend" badge (admin-analytics-page.component.html:231) — no fake data, correctly reflects that no traffic-tracking pipeline exists at all (BACKEND-API-REFERENCE.md §10 step 10).
  • The storefront Item.visits field is wired end-to-end from the live backend (api.service.ts:438) but is never rendered anywhere in the UI, and the backend mock always seeds it 0.

User confirmed (via clarifying question) the actual complaint is: no per-product view count visible in Admin Products.

Further investigation found Admin Products runs on a fully separate mock domain (AdminProduct model, admin-products-local.gateway.ts, seeded from list.json) that has no relationship to the storefront's live Item.visits pipeline at all. So a "Views" column here cannot show real per-product traffic today — there is no data source for it in the admin domain. This mirrors the currency/FX and order-notification gaps already documented this session: build the honest client-side piece, document the backend gap explicitly, never fabricate numbers.

Design

Model: add visits: number to AdminProduct (src/app/features/admin/products/models/admin-product.model.ts), alongside the other stat-like fields (priority, quantity).

Mock gateway: admin-products-local.gateway.ts defaults visits: 0 when building the in-memory seed from list.json — no fabricated numbers, matches the field's actual state (nothing increments it yet).

List column: ALL_PRODUCT_COLUMNS (admin-products.facade.ts:39) gains 'visits'. Rendered in admin-products-list.component.html table view only (grid view is out of scope per user's placement choice), following the exact existing isColumnVisible('stock')/isColumnVisible('price') pattern — toggleable via the same column-picker UI, persisted the same way (LocalStorageService, COLUMNS_KEY).

i18n: one new key, adminProducts.views (label for the column header), added to en.ts/ru.ts/hy.ts/translations.ts.

Backend doc update

New BACKEND-API-REFERENCE.md §12.x ask (numbered after the existing 12.8, following the established "Gap / Ask" format): the admin Products domain has no view-count source. Two options to raise:

  1. Once admin Products gets a real backend (§10 step 4), include a view/visit count per product in the response.
  2. Alternatively, bridge to the storefront's already-live Item.visits (§6, /items/{id}) by product id — smaller change if a unified product identity exists between the storefront and admin domains.

Out of scope

  • Storefront customer-facing "N people viewed this" display — not requested, deferred (was offered as a placement option, not chosen).
  • Product edit/detail page display — not requested (list column only, per user's placement choice).
  • Any client-side view tracking/incrementing — explicitly rejected in favor of the honest display-only approach; a client-only counter would only reflect the admin's own browser, not real shoppers, same trap already avoided for currency rates.