Repository navigation
fix(gooddata-widget): AI Credits dashboard display, labeling, and scale fixes - #227
goodbounties-nanoclaw-agent[bot] wants to merge 13 commits into
Conversation
Adds an optional subLabel? prop rendered as a dim caption line below the value row, reusing the trend row's spacing tier. Needed by the AI Credits dashboard's "Total Credits Bought in G$" scorecard to show a streaming/subscription breakdown line (#222), but kept generic in packages/ui since it's a reusable KPI-card capability, not AI-Credits specific. Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…om 365 to 30 days A full year of daily points was an unnecessary perf hit for a dashboard that only visualizes the trailing month. Per #222 (fix 6). Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…ts (USD) column .toFixed(2) rounded most rows' sub-cent daily AI Credit usage to $0.00. Per #222 (fix 5). Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…monthly total Replaces flowRateToDaily with flowRateToMonthly (plain multiplication by 2629746 seconds/month, mirroring the existing BigInt-safe reduction) and relabels "G$ Flow Rate" -> "Total Monthly Subscriptions", dropping the "/day" suffix that read as a daily rate. Per #222 (fix 3). Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…USD equivalent Relabels the first AI Credits scorecard from "Total G$ Spent" to "Total Credits Bought in G$" and appends the USD-equivalent value (already computed for the separate "AI Credits Used" card) as a suffix, per CEO feedback after the PR #179 production deploy (#222, fix 1). Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…ine on total scorecard Adds a "out of X G$ in subscription (streaming)" caption under the first scorecard's value, using the already-computed streamed total, so the breakdown between one-time and recurring credit purchases is visible at a glance (#222, fix 2). Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…ility + cover scorecard label fixes Fix #4 investigation: the G$ Volume chart's secondaryYAxis mechanism (in LineAreaChart, present since #179) already computes each axis's scale independently from only its own series' values, so a large magnitude gap between one-time deposits and streamed G$ doesn't flatten the streamed line. Confirmed this against a fixture shaped after real production data pulled from the live AntSeed Worker (sparse deposit spikes up to ~40x the streamed band) — both lines render clearly distinguishable on their own axes. No LineAreaChart or dashboard code change was needed; the deliverable is the new "RealisticVolume" QA fixture plus a Playwright assertion so this stays covered going forward instead of relying on the smooth demo/live ramp. Also retrofits the live-state spec with text assertions for fixes #1-#3's renamed scorecard labels and sub-line, which had been verified visually but not covered by the Playwright spec, and refreshes all baseline screenshots to reflect the new label copy. Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
There was a problem hiding this comment.
Pull request overview
Updates the GoodData widget’s AI Credits dashboard to improve labeling, value presentation, and scale/legibility under realistic production-like data, and tightens the default analytics fetch window.
Changes:
- Renames/retunes dashboard scorecards (adds USD equivalent + subscription sub-line; switches flow-rate to monthly subscriptions via a new conversion).
- Improves daily table USD precision (3 decimals) and reduces analytics fetch window to 30 days.
- Adds a production-shaped Storybook fixture plus a Playwright regression test targeting dual-axis volume-chart legibility.
Reviewed changes
Copilot reviewed 7 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/widgets/gooddata-widget/states.spec.ts | Adds assertions for updated scorecard copy and a new “realistic volume” chart regression check. |
| packages/ui/src/components/Scorecard.tsx | Adds subLabel support to render a caption line under the value row. |
| packages/gooddata-widget/src/dashboards/aiCredits/connector.ts | Reduces default analytics history window from 365 days to 30 days. |
| packages/gooddata-widget/src/dashboards/aiCredits/analyticsConversions.ts | Introduces flowRateToMonthly() conversion using average seconds per month. |
| packages/gooddata-widget/src/dashboards/aiCredits/AiCreditsDashboard.tsx | Applies updated scorecard labels/values, monthly conversion, and 3-decimal USD formatting. |
| examples/storybook/src/stories/helpers/goodDataWidgetStories.tsx | Adds a realistic 30-day analytics fixture and story wrapper for QA/regression coverage. |
| examples/storybook/src/stories/gooddata-widget/GoodDataWidgetQA.stories.tsx | Exposes the new “RealisticVolume” QA story. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
…rd for flow rate, flag USD-deposit gap Total Monthly Subscriptions showed G$0.00 in the live preview because the flow-rate scorecard read global.gdTotalFlowRateWeiPerSecond directly, which mirrors the Worker's most recent daily record even when that record is today's still-accumulating, missing:true snapshot — right after a day boundary this reads as 0 until the new day's first streaming event lands. Reuse dailyRecords (already filtered to exclude missing:true records for the chart/table) so the scorecard reads the same latest-complete-day value. Also fixes Scorecard 1's USD line incorrectly reusing aiCreditsUsedWei (a different metric, "AI credits consumed") instead of the USD equivalent of the deposited/bought G$ total. The Worker's schema exposes no G$/USD exchange rate to compute that client-side, so per explicit request the USD line stays (not removed) but now reads as a labeled data-source-gap placeholder pending a rate field from the data team. Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…oss from wei-space truncation generateDemoData's per-day flow rate divided streamedGd (a plain integer, 200-800) by SECONDS_PER_DAY before scaling to wei, which always floors to exactly 0 for that range. Do the division after scaling to wei so the fractional per-second rate survives instead of being truncated away first. This is a separate root cause from the live-data flow-rate bug fixed separately (that one reads a stale/missing daily record; this one is pure integer-division precision loss) — fixing one does not fix the other. Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…m and scope dual-axis test to svg RealisticVolume fixture's global.gdStreamedWei used only the last day's value instead of summing the window, breaking the "out of X G$ in subscription" figure for that fixture (Copilot review on #227). The dual-axis Playwright test matched "Deposits"/"Streamed" text anywhere in the chart container, which could pass via the legend (rendered as a sibling YStack outside the chart's <svg>) even if the axis titles themselves were broken. Scope the lookup to the chart's own <svg> so the test actually guards axis-title legibility, which is its stated purpose. Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
…r bugfix round Regenerated after fixing the flow-rate/USD-line bugs and the two Copilot-flagged test/fixture issues. Co-Authored-By: Claude <noreply@anthropic.com> On-Behalf-Of: BountyCoder[onecli] (yaskkeryodtdijpv)
|
@copilot Please work on this PR's existing branch and push your changes here. Do not open a new pull request. packages/ui/src/components/Scorecard.tsx: keep main's version, which has the subtitle prop from #228. Remove this PR's subLabel prop. |
…oard-fixes-222 # Conflicts: # packages/ui/src/components/Scorecard.tsx # tests/widgets/gooddata-widget/test-results/gdw-02-live.png # tests/widgets/gooddata-widget/test-results/gdw-03-demo.png # tests/widgets/gooddata-widget/test-results/gdw-04-live-unavailable.png # tests/widgets/gooddata-widget/test-results/gdw-05-empty.png Co-authored-by: thalescb <8635591+thalescb@users.noreply.github.com>
... Pushed merge commit Resolution files:
Passed: workspace build, 17 unit tests, affected-package lint, all 6 GoodData smoke tests, Scorecard subtitle smoke test, secret scan, focused review, and CodeQL (0 alerts). Remaining failures, both reproduced against isolated main sources and not caused by this PR:
Working tree is clean. No new PR was opened. |
|
@thalescb there are two unresolved comments and if there are failing tests they should be fixed before asking for review |
|
@copilot Please work on this PR's existing branch and push your changes here. Do not open a new pull request. examples/storybook/src/stories/helpers/goodDataWidgetStories.tsx: set global.gdStreamedWei to the total streamed over the whole fixture window, the same way generateDemoData() and FIXED_ANALYTICS_RESPONSE compute it, so the "out of X G$ in subscription" line is right in the RealisticVolume story. |
... Both requested fixes are already committed in
Rechecked: targeted build passed (4 tasks), widget lint passed, and all 6 GoodData Playwright tests passed. Explicit lint of the two files reports an existing unused Files changed this round: none. Generated screenshots were restored; working tree is clean. No new commit, push, or PR was necessary. |
|
@sirpy just for the record that it was explicitely requested that any pre-existing failing tests are resolved separately |
Closes #222. Implements the plan from #224.
Fixes
weiToUsd(data.global.aiCreditsUsedWei).weiToGd(data.global.gdStreamedWei).flowRateToMonthly()conversion helper instead of the old daily rate./v1/analytics) and tracingLineAreaChart's dual-axis scaling code directly. ThesecondaryYAxismechanism has computed each axis independently since the original feat(apps): AI Credits analytics data widget #179 PR and already renders both series legibly, including at the ~40x deposit-vs-streamed magnitude disparity seen in real production data — no functional bug found, so no code change was needed here. Added a newRealisticVolumeStorybook QA fixture shaped after that real data plus a Playwright regression test asserting both axis labels stay visible, so this is guarded going forward instead of only being covered by the smooth demo/live ramp fixture..toFixed(2)→.toFixed(3).ANALYTICS_DAYS_REQUESTED: 365 → 30 inconnector.ts.The same commit (150ddd0) also retrofits
tests/widgets/gooddata-widget/states.spec.tswith text assertions covering fixes #1-#3's renamed labels/sub-line (previously verified only visually, not by the committed spec) and refreshes all baseline screenshots for the new copy, per repo convention.Out of scope, flagging rather than fixing here
While tracing the flow-rate conversion, found
generateDemoData.ts's demo-mode flow rate is computed asMath.floor(streamedGd / SECONDS_PER_DAY), which floors to0for any realistic demostreamedGdvalue — so demo mode'sgdTotalFlowRateWeiPerSecondis always"0". Not one of #222's 6 acceptance criteria and not touched by this PR; flagging so it can be tracked as its own fix rather than silently left in place.Verified
Each fix above was committed individually and visually verified via Storybook + Playwright before moving to the next, per the process used for the #179 rounds. Full pipeline (
pnpm build, scopedlint,npx playwright test tests/widgets/gooddata-widget/states.spec.ts) passes.Note on commit signatures: commits on this branch show as unsigned (neither the Git Data API nor the Contents API produce GPG/SSH-signed commits in this environment — confirmed empirically). This repo's ruleset requires signed commits on
main. Squash-merging this PR is safe (GitHub signs the resulting squash commit itself, independent of source-branch signatures) — please don't rebase-merge, which would carry the unsigned commits ontomaindirectly.Co-Authored-By: Claude noreply@anthropic.com