Skip to content

feat: aggregate statistics [ENG-2780, ENG-3139]#7751

Merged
speaker-ender merged 8 commits intomainfrom
feat/aggregate-statistics--ENG-2780
Mar 27, 2026
Merged

feat: aggregate statistics [ENG-2780, ENG-3139]#7751
speaker-ender merged 8 commits intomainfrom
feat/aggregate-statistics--ENG-2780

Conversation

@speaker-ender
Copy link
Copy Markdown
Contributor

@speaker-ender speaker-ender commented Mar 25, 2026

Ticket [ENG-2780, ENG-3139]

Description Of Changes

Adding a progress indicator widget to the action center

Code Changes

  • Updating the donut chard component to handle different types of dynamic sizing within containers

Steps to Confirm

  1. Go to the action center and confirm that the new widgets display correct empty states that link to the integrations page when no monitors exist
  2. Confirm that the correct visuals appear when monitors are added
  3. Visit individual monitor screens (datastore, web monitor, integrations) and confirm that only data relevant to that monitor are displayed
  4. Verify that the widgets do not display when the alpha flag is turned off

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fides-plus-nightly Ready Ready Preview, Comment Mar 27, 2026 4:27pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
fides-privacy-center Ignored Ignored Mar 27, 2026 4:27pm

Request Review

Comment on lines 282 to +312
@@ -310,6 +296,20 @@ export const snakeCaseToTitleCase = (
)
.join(" ");

/**
* Formats a number with a suffix for large numbers (K, M, etc.)
* @param num - The number to format
* @param digits - The number of digits to round to (default is 0)
* @returns The formatted number as a string
*
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
*
* @example
* nFormatter(1111); // returns "1K"
* nFormatter(1111, 0); // returns "1K"
* nFormatter(1111, 1); // returns "1.1K"
* nFormatter(1111, 2); // returns "1.11K"
*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by fixing of comments

@speaker-ender speaker-ender force-pushed the feat/aggregate-statistics--ENG-2780 branch from c07ee8e to 92bb486 Compare March 26, 2026 14:59
@speaker-ender speaker-ender changed the title feat: aggregate statistics [ENG-2780] feat: aggregate statistics [ENG-2780, ENG-3139] Mar 26, 2026
@speaker-ender speaker-ender marked this pull request as ready for review March 26, 2026 15:56
@speaker-ender speaker-ender requested a review from a team as a code owner March 26, 2026 15:56
@speaker-ender speaker-ender requested review from kruulik and removed request for a team March 26, 2026 15:56
@speaker-ender speaker-ender force-pushed the feat/aggregate-statistics--ENG-2780 branch from 64de1e1 to 86dd160 Compare March 26, 2026 15:56
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — feat: aggregate statistics [ENG-2780, ENG-3139]

Overall this is a well-structured feature: clean component decomposition, proper feature-flag gating, and the DonutChart enhancements (thin variant, fit prop) are nicely done. A few things to fix before merge:

Suggestions (fix before merge)

  • Typo in endpoint/hook names (getAggretateStatisticsgetAggregateStatistics): propagates to both exported hooks and all call sites — worth fixing now before the name spreads further.
  • monitor_type optional but used in URL path: the query arg is typed monitor_type? but interpolated directly into the URL. Either make it required or add a guard.
  • Duplicated getMonitorUpdateName: identical function exists in both MonitorResultDescription.tsx and ProgressCard/utils.ts. Extract to a shared location.
  • Typo in user-facing string: "accross""across" in MONITOR_TYPE_TO_EMPTY_TEXT.
  • Typo in constant name: MONITOR_TYPE_TO_PERECENT_STATISTIC_LABELMONITOR_TYPE_TO_PERCENT_STATISTIC_LABEL.

Nice to Have

  • content-center vs items-center in DonutChart.tsx: content-center only affects multi-line flex containers; items-center is likely what was intended.
  • PropsWithChildren without children: ProgressCard never renders children, so the PropsWithChildren wrapper is unnecessary.
  • renderIcon defined inside component: pure function, no closure needed — move it outside MonitorStats.
  • Overly complex classNames spread pattern: classNames(...["a", ...(cond ? ["b"] : [])]) can be simplified to classNames("a", cond && "b") throughout.
  • heliosInsights test flag is true: most alpha flags use test: false. Confirm existing tests that render ActionCenterLayout or the website monitor page have been updated to account for the new stats widgets.
  • ExtendedDatastoreMonitorUpdates.ts appears unused: not imported anywhere in the PR — remove if not needed yet.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR adds aggregate statistics widgets to the action center, introducing a new MonitorStats component and ProgressCard sub-components that display per-monitor-type progress (approval rate, status counts, top classifications) using a donut chart. The DonutChart component is also extended with a thin variant and a fit prop to support dynamic sizing within compact containers. All new widgets are gated behind the heliosInsights feature flag.

Key issues found:

  • Consistent typo in hook/endpoint name: getAggretateStatistics (and the exported hooks useGetAggretateStatisticsQuery / useLazyGetAggretateStatisticsQuery) are missing a "g" — should be getAggregateStatistics. This affects action-center.slice.ts and MonitorStats.tsx.
  • Typo in constant name: MONITOR_TYPE_TO_PERECENT_STATISTIC_LABEL in ProgressCard/utils.tsPERECENT should be PERCENT.
  • Typo in user-facing text: "accross" should be "across" in the website empty-state description.
  • Single-character variable names: The destructured parameter k in ([k]) => key === k violates the project's full-name convention. This appears in both ProgressCard/utils.ts (line 12) and MonitorResultDescription.tsx (line 16).
  • Hardcoded string union for monitor_type: action-center.slice.ts defines monitor_type as "website" | "datastore" | "infrastructure" rather than using the newly added APIMonitorType enum. MonitorStats.tsx also uses string literals directly instead of enum values.
  • Duplicate helper function: getMonitorUpdateName is defined identically in both ProgressCard/utils.ts and MonitorResultDescription.tsx — it should be extracted and shared.
  • div used for text display: <div className="text-xs">None</div> in ProgressCard.tsx should use the fidesui Text component.
  • PR size: This PR touches 27 files, which exceeds the 15-file guideline.

Confidence Score: 4/5

Safe to merge once the hook/endpoint typo and the minor style issues are addressed; the feature is fully gated behind a flag.

All issues are cosmetic (typos, naming conventions, one duplicate helper) with no functional impact — the typo in the hook name is consistent across all usage sites so nothing is broken at runtime. The feature flag means no production exposure until explicitly enabled. A quick round of fixes brings this to merge-ready.

ProgressCard/utils.ts (three separate typos + short variable name + duplicate function) and action-center.slice.ts (endpoint name typo, raw string union instead of enum).

Important Files Changed

Filename Overview
clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorStats.tsx New component that renders per-monitor-type statistics cards. Has a typo in the imported hook name (useGetAggretateStatisticsQuery) and uses hardcoded string literals instead of the APIMonitorType enum for monitor_type values.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts New utility file mapping monitor types to display labels and transforming API responses to card props. Contains two typos (accross, PERECENT), a single-char variable name (k), and duplicates getMonitorUpdateName from MonitorResultDescription.tsx.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/ProgressCard.tsx New 277-line card component displaying a donut chart with numeric/percentage stats in both compact and full layouts. One bare div wrapping a "None" text string should use the fidesui Text component instead.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/action-center.slice.ts Adds getAggretateStatistics RTK Query endpoint (typo — should be getAggregateStatistics) and a new child_staged_resource_urns array query param. The monitor_type param uses a raw string union rather than the APIMonitorType enum.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/constants.ts Refactors MONITOR_UPDATE_NAMES Map to a plain MONITOR_UPDATE_LABELS object and extends it with StatusCounts keys. Clean change.
clients/fidesui/src/components/charts/DonutChart.tsx Adds thin variant and a fit prop (contain/fill) to control how the chart scales within its container. Clean, well-scoped change.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorResultDescription.tsx Migrates from MONITOR_UPDATE_NAMES Map to MONITOR_UPDATE_LABELS object lookup. Introduces a single-char variable name (k) and duplicates the getMonitorUpdateName helper now also present in ProgressCard/utils.ts.

Reviews (1): Last reviewed commit: "refactor: flag naming" | Re-trigger Greptile

const { width, height } = useContainerSize(containerRef);
const size = Math.min(width, height);
const size =
fit === "contain" ? Math.min(width, height) : Math.max(width, height);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition!

Comment on lines +65 to +70
<div
className={classNames(
"w-full",
!monitorId && "grid grid-cols-3 gap-4 pb-4",
)}
>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth using Ant Col/Row for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I'll give it a look.
Ant Col/Row is disappointing imo since it uses flex + requires lots of component boilerplate.
Performance aside, css grids are way more powerful and predictable for layouts.

Comment on lines +95 to +99
className={classNames(
`grid overflow-hidden w-full gap-2 xl:gap-4`,
compact
? "grid-cols-[1fr,min-content,1fr,min-content,1fr]"
: "grid-cols-1 xl:grid-cols-[auto,1fr,1fr]",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as before - should we use Row/Col for this? Your approach is neater, just wanted to call out as an option.

Comment on lines +51 to +57
switch (true) {
case percent > 80:
return "colorSuccess";
case percent > 60:
return "colorWarning";
default:
return "colorErrorTextHover";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future consideration: I think we should standardize thresholds for colors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely.
We should have rules that also apply outside of numeric thresholds as well.
This was just an initial pass for now.

Copy link
Copy Markdown
Contributor

@kruulik kruulik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving - my comments are minor and don't need to be addressed in this PR, just future considerations.

chore: more types

chore: even more types

chore: all the types

wip: something that works

chore: adding query hook

chore: wip

chore: more types

chore: more type updates

wip: more card stuff

chore: update types

wip: some labels and such

chore: fix comments

core: layout improvements and refactoring

chore: linting and formatting

chore: more responsiveness

chore: further refactors

wip: stuf

chore: comment out

refactor: compact variant

chore: mostly there

fix: formatting

fix: donut chart fit feature

fix: formatting

chore: adding changelog
chore: update text

fix: linting and formatting
@speaker-ender speaker-ender force-pushed the feat/aggregate-statistics--ENG-2780 branch from 396d22b to 31ad093 Compare March 27, 2026 16:21
@speaker-ender speaker-ender enabled auto-merge March 27, 2026 16:22
@speaker-ender speaker-ender added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit f034bd8 Mar 27, 2026
47 of 50 checks passed
@speaker-ender speaker-ender deleted the feat/aggregate-statistics--ENG-2780 branch March 27, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants