feat(webapp): Free usage charts as progress toward the cap#6790
Open
macko911 wants to merge 8 commits into
Open
feat(webapp): Free usage charts as progress toward the cap#6790macko911 wants to merge 8 commits into
macko911 wants to merge 8 commits into
Conversation
Contributor
Preview Deploy
|
Contributor
There was a problem hiding this comment.
2 issues found across 15 files
Confidence score: 4/5
- In
scripts/seed-clickhouse.ts, buffering an entire account before flushing raises peak memory and could causeseed-clickhouseto OOM on larger multi-env/multi-day seeds, which would make seeding unreliable in CI or local setup—switch back to per-environment/chunked flushing or validate memory headroom on representative data before merging. - In
packages/webapp/src/utils/usage.ts, the JSDoc still documents the warning threshold as 80% whileNEAR_LIMIT_RATIOnow triggersnearat 70%, which can mislead future changes and debugging—update both doc blocks to match the current behavior.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/webapp/src/utils/usage.ts">
<violation number="1" location="packages/webapp/src/utils/usage.ts:47">
P3: Stale JSDoc still says the warning band starts at 80%. The `NEAR_LIMIT_RATIO` was lowered to 0.7 so `near` state now triggers at ≥70%. Update both docs to match.</violation>
</file>
<file name="scripts/seed-clickhouse.ts">
<violation number="1" location="scripts/seed-clickhouse.ts:628">
P2: Buffering the whole account before flushing increases peak memory use substantially compared with the previous per-environment flush path. For the seeded multi-env, multi-day dataset this can make `seed-clickhouse` much heavier or fail on larger `--days` runs.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
macko911
force-pushed
the
matej/nan-6237-free-plan-usage-caps-table
branch
from
July 15, 2026 15:55
4fec4b9 to
2d0c171
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 15, 2026 15:56
1a824d7 to
cbcf834
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 15, 2026 19:13
cbcf834 to
0ab045b
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 16, 2026 08:58
0ab045b to
33acee2
Compare
macko911
force-pushed
the
matej/nan-6237-free-plan-usage-caps-table
branch
from
July 16, 2026 12:24
8ae80d6 to
a7a06b5
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 16, 2026 12:24
dcab46e to
885186e
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 16, 2026 12:53
93d8f0a to
0e06ef7
Compare
macko911
force-pushed
the
matej/nan-6237-free-plan-usage-caps-table
branch
from
July 16, 2026 12:57
a7a06b5 to
1d68550
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 16, 2026 12:59
0e06ef7 to
a1d1ea9
Compare
macko911
force-pushed
the
matej/nan-6237-free-plan-usage-caps-table
branch
from
July 16, 2026 17:31
1d68550 to
5379170
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 07:07
a1d1ea9 to
ef0f0ca
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 07:59
d03f8ca to
cba0889
Compare
macko911
force-pushed
the
matej/nan-6237-free-plan-usage-caps-table
branch
from
July 17, 2026 09:48
fda6686 to
acc6f41
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 10:01
cba0889 to
23048c9
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 10:54
23048c9 to
1d5cdfd
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 11:16
1d5cdfd to
92b8965
Compare
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 14:15
a28ec2b to
e653760
Compare
Base automatically changed from
matej/nan-6237-free-plan-usage-caps-table
to
master
July 17, 2026 15:11
sahilnyk
pushed a commit
to sahilnyk/nango
that referenced
this pull request
Jul 17, 2026
## Problem Free accounts (\~97% of accounts) had no view of their usage against plan caps — the usage page showed charts with no limit framing, so users couldn't see how close they were to a cap or which metric was near/over. ## Solution * Free accounts get a per-metric caps table: used / limit, a progress bar, and % of limit / "Limit reached", driven by the live `plans/usage` gauge (warning at 70%, over at 100%). * A single month selector sits above the table and drives the whole table: rows show the live gauge for the current month and that month's usage for past months, and each row expands into the existing trend + dimension-breakdown drill-in for the selected month. * Add a point-in-time daily series to the billing usage endpoint so level metrics (connections, sync records) read as the concurrent daily count rather than the running monthly average — meaningful against a fixed cap. * Reuse one `MonthSelector` (backed by a shared `useSelectedMonth` hook) for both the paid usage header and the Free caps header. * Extract the sidebar's `formatUsage` / `formatLimit` / `getStylesForUsage` into a shared `utils/usage.ts`, plus `getUsageState` and the usage-bar / text-colour helpers used by the caps table. * Gated to `plan.name === 'free'`; paid/legacy keep the current view. Follow-up work is stacked on top of this PR: [NangoHQ#6790](<NangoHQ#6790>) renders the drill-in as progress toward the cap (cumulative area + cap line), and [NangoHQ#6791](<NangoHQ#6791>) adds the sidebar alert for accounts nearing or hitting their caps. Fixes [NAN-6237](https://linear.app/nango/issue/NAN-6237) ## Testing * Verified locally on a Free account with seeded ClickHouse usage: caps states (green / amber near-limit / red "Limit reached"), the month selector driving both the row gauges and the drill-in across current and past months, and the collapsible trend + breakdown. * Confirmed the sidebar `UsageCard` still renders after the helper extraction, and paid/legacy accounts are unaffected. * `npm run ts-build` and `npm run lint` clean. ## Demo https://github.com/user-attachments/assets/69f37518-8730-4102-8e92-cf594e9b7c7e
The Free-plan drill-in now shows usage against the plan cap: a dashed cap reference line, counter metrics as a cumulative month-to-date curve with a daily/cumulative toggle (icons + app focus ring), and connections/records as their point-in-time daily count. Rounds the y-axis to nice ticks with the cap as the top labelled tick and ~10% headroom, keeps the cap line only on the area (not daily) view, and lowers the near-limit warning threshold to 70%.
Add --mirror-db-counts to the clickhouse seed so the Free caps view has believable data: mirror the account's real Postgres connection/record counts into ClickHouse (ramping to the live count) so those AVG metrics match the DB-backed gauge, scale counter volume to a realistic fraction of the caps, and plateau counters at their monthly cap so usage stops instead of running arbitrarily over.
- Default the drill-in chart mode to daily; Free explicitly opts into cumulative, so paid charts no longer render as cumulative curves. - Show the daily/cumulative toggle whenever a chartMode is supplied (Free), independent of the breakdown rollout flag. - Add group / aria-pressed roles to the chart-mode toggle. - Scale the cap-line axis to the visible series so isolating/hiding a breakdown slice isn't flattened against the full stacked total. - Keep the compact month stepper's focus ring after the MonthStepper extraction.
The cap applies to the whole metric, so drawing it against a filtered slice or an isolated breakdown series is misleading — and the full cap dwarfs the slice, squishing its data flat. Hide the cap line whenever the chart is scoped to a slice.
getDbCounts summed every record_counts row, but the caps gauge only counts records for connections that still exist (paginateConnections filters deleted=false). Rows left behind by deleted connections pushed the mirrored records above the gauge, breaking the --mirror-db-counts chart/gauge match. Filter to live connections the same way the gauge does.
Follow the API rename in #6789: the drill-in chart's prop and its useApiGetBillingUsageDetail option are now avgPerDay.
Readability only (no behaviour change): hoist a shared monthOf, add a bump() accumulator and an FnAttrs/fnBag() helper to drop the repeated inline casts, and collapse the identical proxy/webhook cap branches into one capCounter().
macko911
force-pushed
the
matej/nan-6280-show-free-plan-drill-in-usage-as-progress-toward-the-cap
branch
from
July 17, 2026 15:47
b6be2c8 to
c1a3242
Compare
macko911
marked this pull request as ready for review
July 17, 2026 15:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the Free usage drill-in, the charts didn't frame usage against the cap: a daily bar chart under a monthly cap makes the limit effectively invisible, and level metrics (connections, sync records) had no cap reference to read against.
Solution
--mirror-db-counts): mirror the DB connection/record counts the gauge reads, scale counters to a fraction of the caps, and plateau them at the monthly cap.Fixes NAN-6280
Stacked on #6789 (Free caps table, NAN-6237).
Testing
npm run ts-buildandnpm run lintclean.Screen.Recording.2026-07-17.at.16.15.04.mov