Skip to content

[Feature] AI Credits analytics data widget #176

Description

@goodbounties-nanoclaw-agent

Feature summary

Create a standalone AI Credits analytics data widget — a new GoodWidget app
(apps/ai-credits-analytics-web) that fetches AntSeed AI Credits analytics data and
visualizes it using the chart components shipped in PR #148 (Scorecard, LineAreaChart,
BarChart, DataTable).

Problem or opportunity

The existing AntSeed analytics dashboard (data-team repo,
projects/antseed-analytics/dashboard/app.js) is a one-off vanilla JS + Chart.js static
page, live at https://gooddollar.github.io/data-team/antseed-analytics. It doesn't share
GoodWidget's design system/theme and can't be maintained or deployed alongside the other
GoodWidget standalone apps. Recreating it as a proper GoodWidget app lets it reuse the
new analytics chart components and follow the same build/deploy pipeline as
ai-credits-web / superfluid-campaign-web.

Proposed solution

  1. New app apps/ai-credits-analytics-web (Vite + React + TamaguiProvider), following the
    apps/ai-credits-web / apps/superfluid-campaign-web pattern (index.html, main.tsx,
    App.tsx, vite.config.ts, vercel.json, tsconfig.json, reactNativeSvgWeb shim,
    Playwright tests).
  2. Data-fetch/transform layer as an internal module inside the app (not a separate package
    for now — revisit only if a clear reuse case emerges), recreating app.js's flow:
    • GET {WORKER_URL}/v1/analytics?days=365, POST {WORKER_URL}/v1/analytics/refresh
    • BigInt-safe conversions: weiToGd (÷10^18), weiToUsd (÷10^6), flowRateToDaily
      (wei/sec × 86400, ÷10^18)
    • Live/Demo toggle with generated demo data as fallback when the live endpoint is
      unreachable
    • Auto-refresh every 5 minutes
  3. Visualize using PR feat(ui): add analytics chart components (Scorecard, Pie/Donut, Bar, Line/Area, DataTable) #148 components:
    • 3 Scorecards: Total G$ Spent, AI Credits Used (USD), G$ Flow Rate (G$/day)
    • Chart 1: G$ Volume — stacked area (LineAreaChart, one-time deposits + streamed)
    • Chart 2: AI Credits Used per Day (USD) — BarChart
    • Chart 3: Unique Wallets per Day — LineAreaChart, 2 series (G$ Buyers + Credit Users)
    • DataTable: daily summary (date, G$ deposited, G$ streamed, total G$, AI credits USD,
      wallets G$, wallets AI)
  4. No wallet connection anywhere — purely read-only internal visualization (unlike
    ai-credits-web/superfluid-campaign-web, which both require wallet connect).
  5. New deploy workflow mirroring deploy-ai-credits-web.yml / deploy-superfluid-campaign-web.yml
    (own VERCEL_*_PROJECT_ID secret, preview/production jobs) — hold this file until
    Laurence has confirmed specifics; do not push it without that sign-off.

Required states, flows, and behaviors

  • Initial load → attempt live fetch; on success, show live data with "Live" toggle active.
  • Live fetch fails/unreachable → fall back to generated demo data, "Demo" toggle active,
    demo banner/badge shown.
  • Manual Live/Demo toggle → switches source; if Live selected but endpoint unavailable, show
    an inline "endpoint not yet deployed" state in the chart/table sections (toggle stays
    visible/clickable).
  • Refresh button → POST to refresh endpoint, short delay, then re-fetch; button shows a
    loading state throughout.
  • Auto-refresh every 5 minutes using whichever source (live/demo) is currently active.
  • All wei-string fields converted via the documented decimal rules (18 for G$, 6 for
    USD/credits, flow-rate special case) — no precision loss.
  • Daily summary table paginated (10 rows/page, matching the reference) with
    first/prev/next/last controls.
  • Empty state (daily.length === 0) shown distinctly in both charts and table.

Acceptance criteria

  • apps/ai-credits-analytics-web exists, builds, and deploys as a standalone Vite+React app.
  • 3 scorecards render correct values (Total G$ Spent, AI Credits Used USD, G$ Flow Rate/day).
  • Chart 1 (G$ Volume stacked area), Chart 2 (AI Credits/day bar), Chart 3 (unique
    wallets/day, 2-series line) all render using PR feat(ui): add analytics chart components (Scorecard, Pie/Donut, Bar, Line/Area, DataTable) #148's chart components.
  • Daily summary table renders with correct columns and pagination.
  • Live/Demo toggle works, including graceful fallback when the live endpoint is unreachable.
  • Auto-refresh every 5 minutes; manual Refresh button triggers POST /v1/analytics/refresh
    then re-fetch.
  • BigInt wei-string conversions match the documented decimal rules.
  • No wallet-connection UI anywhere in the app.
  • New deploy workflow added, but only pushed after Laurence has confirmed its specifics.
  • All GoodWidget deploy workflows (existing + new) clearly show which app/widget/preview
    they relate to in job/environment naming, not just the workflow file name.

Additional context

Internal work (not a bounty), requested by Thales Barbosa (relaying from Lewis) in
#goodbounties-lead, 2026-08-18 — same track as the analytics chart components (#143-146, PR
#148): skips the contributor/[GoodBounty] pickup stage, implementation goes straight to a
coding agent → PR. Branch from feat/analytics-components; new PR opens against #148, not
main.
App/package naming and internal-module-vs-separate-package for the data layer are
an engineering judgment call, per Thales/Lewis ("start simple ... per needed basis") — revisit
if the data layer needs reuse elsewhere later. Thales has no GitHub write access — leave issue
unassigned, consistent with #143-146.

Reference:

Create the plan

Based on the above description create an execution plan in a new sub-issue and preserve the original issue content unchanged.
Do not execute the plan until given instructions to do so.

Sub-issue requirements:

  • Title format: [DRAFT][PLAN] <what issue is being planned>
  • Type: Task
  • Description must start with: <sub-issue title>
  • Link the sub-issue back to this parent issue.

Instructions when creating the plan:

  • Map relevant files that are too be used as reference from all repos mentioned
  • import existing @GoodDollar packages
  • Map new components that should be created. Assess when a new component should be created in the new savings widget package or made part of the reusable packages/ui

Plan specification required sections:

  • Required states, flows, and behaviors
  • Execution plan
  • acceptance criteria
  • human-reviewer checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions