Skip to content

Feat: impact metrics fronted #10182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 30, 2025
Merged

Feat: impact metrics fronted #10182

merged 17 commits into from
Jun 30, 2025

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Jun 19, 2025

Impact Metrics - Frontend draft

  • Main component is frontend/src/component/insights/impact-metrics/ImpactMetrics.tsx
  • Left side "form" extracted to ImpactMetricsControls
  • New hooks for data fetching - useImpactMetricsData & useImpactMetricsMetadata

For now it's in "Analytics", but I'll move it somewhere else

Copy link

vercel bot commented Jun 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jun 29, 2025 0:06am

Copy link
Contributor

github-actions bot commented Jun 19, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@coveralls
Copy link

coveralls commented Jun 19, 2025

Coverage Status

coverage: 88.968% (-0.02%) from 88.99%
when pulling 5352b27 on feat/impact-metrics-frontend
into 632f3a0 on main.

const theme = useTheme();
const [selectedSeries, setSelectedSeries] = useState<string>('');
const [selectedRange, setSelectedRange] = useState<
'hour' | 'day' | 'week' | 'month'
Copy link
Member Author

@Tymek Tymek Jun 19, 2025

Choose a reason for hiding this comment

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

a lot of type duplication will be fixed when I generate backend types

? () => fetcher(formatApiPath(PATH), 'Impact metrics data')
: () => Promise.resolve([]),
{
refreshInterval: 30 * 1_000,
Copy link
Member Author

Choose a reason for hiding this comment

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

pull new data every 30s (opinion)

@Tymek Tymek requested review from kwasniew and sighphyre June 19, 2025 13:53
@Tymek Tymek marked this pull request as ready for review June 19, 2025 14:18
@Tymek Tymek changed the title Feat/impact metrics frontend Feat: impact metrics fronted Jun 19, 2025
@gastonfournier gastonfournier moved this from New to For later in Issues and PRs Jun 20, 2025
@gastonfournier gastonfournier moved this from For later to In Progress in Issues and PRs Jun 20, 2025
overrideOptions={
shouldShowPlaceholder
? {}
: {
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a lot of of whitespace on the left hear = code complexity (https://codescene.io/docs/guides/technical/complexity-trends.html#what-s-complexity-anyway)

Copy link
Contributor

Choose a reason for hiding this comment

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

can we make the file name more explicit to make searching and prompting LLM easier? e.g. impact-chart-formatters?

};

export const getSeriesLabel = (metric: Record<string, string>): string => {
const { __name__, ...labels } = metric;
Copy link
Contributor

Choose a reason for hiding this comment

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

not obvious what double underscores are

@@ -0,0 +1,17 @@
import { useTheme } from '@mui/material';

export const useSeriesColor = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am assuming it's some deterministic hashing for color assignment. However it's not obvious at first sight. Also is it the first time we're solving this problem in our codebase? I thought that variant colors had a similar case

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because prior code deals with this by assigning colors based on createdAt, instead of hashing.

selectedRange: 'hour' | 'day' | 'week' | 'month';
onRangeChange: (range: 'hour' | 'day' | 'week' | 'month') => void;
beginAtZero: boolean;
onBeginAtZeroChange: (beginAtZero: boolean) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

this one looks different from a typical component prop. what is it doing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Charts have an option for Y axis to be auto-adjusted, or always start at 0

}));
}, [metadata]);

const data = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can it be extracted so that it's not distracting when reading the component?

@github-project-automation github-project-automation bot moved this from In Progress to Approved PRs in Issues and PRs Jun 25, 2025
@Tymek Tymek merged commit 39cdc17 into main Jun 30, 2025
10 checks passed
@Tymek Tymek deleted the feat/impact-metrics-frontend branch June 30, 2025 07:48
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Issues and PRs Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants