Skip to content

feat(frontend): Trends view consuming GET /api/analytics/trends #30

Open

Description

@cristim

Problem

The savings-snapshot historical time-series is now collected and exposed via
GET /api/analytics/trends (PR for LeanerCloud/cloud-commitments-cli#1023/#1033), but there is no frontend view
consuming it. Users cannot yet see coverage %, utilization, committed spend, or
realized savings over time by account/provider/service.

Proposed work

Add a basic "Trends" view in frontend/src that consumes
/api/analytics/trends:

  • Render the monthly series (coverage %, committed spend, usage, realized
    savings) and the by-provider / by-service breakdowns.
  • Account scoping: pass the top-bar chip account_id through to the endpoint
    (the backend already enforces allowed_accounts scope).
  • Escape every API field rendered into any innerHTML template via
    escapeHtml() (feedback_innerhtml_xss).
  • Install event listeners once per element (stored ref / AbortController), never
    re-add on a repeatedly-called render (feedback_event_listener_dedup).
  • Do NOT touch frontend/src/dashboard.ts ServiceSavings or
    handler_dashboard.go / types.go ServiceSavings (owned elsewhere).

References

Filed as the deferred frontend follow-up noted in the analytics historical-savings PR.

Activity

  1. IAmJSD commented on Oct 24, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. self-assigned this
    on Oct 24, 2026
  3. IAmJSD commented on Oct 28, 2026

    @IAmJSD
    Collaborator

    Status update (2026-10-28): #1563 merged: each monthly row of GET /api/analytics/trends now has total_commitment (upfront amortized per month) and total_usage (recurring fees), with unknown kept unknown. Committed spend is their sum.

    Left: showing them on the Trends view (UI owner), and a coverage data source (design call: the collector has no on-demand baseline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions