Skip to content
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

feat: personal flag metrics display #8232

Merged
merged 5 commits into from
Sep 24, 2024
Merged

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Sep 24, 2024

About the changes

Screenshot 2024-09-24 at 12 29 30

Details:

  • environment selection button from the active project environments
  • time period selector re-used after making it more generic (configurable label)
  • creating chartjs options and data based on the previous code we had in the feature metrics. I don't strive for re-use between the old line chart and the new bar chart since we'll most probably start using the bar charts in both places soon.
  • most of the code is copy pasted from the previous implementation of the metrics line chart and network data bar chart
  • making charts lazy loaded to avoid inflating the initial bundle with chartjs

Next steps:

  • we may consider adding highlighter when a bar is selected (however this chart may be too dense for this)

Important files

Discussion points

Copy link

vercel bot commented Sep 24, 2024

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

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 0:01am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Sep 24, 2024 0:01am

Copy link
Contributor

github-actions bot commented Sep 24, 2024

Dependency Review

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

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

}

export const FEATURE_METRIC_HOURS_BACK_DEFAULT = 48;

export const FeatureMetricsHours = ({
hoursBack,
setHoursBack,
label = <StyledTitle>Period</StyledTitle>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

allowing to disable the label by passing undefined. In the feature metrics the label is needed but in personal dashboard it's not.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as this doesn't cause any a11y issues, I have no problems. But I notice that the general select component doesn't have a label associated with it. Input elements should always be properly labeled (with label elements tied to the component). You can hide the label visually if you want, but it should def be there for assistive tech.

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course, the input's been around for a while, probably, but we can still fix it up now that we're here 💁🏼

return `${value} (${percentage}%) - ${key}`;
};

export const createPlaceholderBarChartOptions = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved from a separate file

hoursBack: number,
locationSettings: ILocationSettings,
): ChartOptions<'bar'> => {
const { plugins, responsive, elements, interaction, scales } =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reuse options that we share with the placeholder settings

return {
plugins: {
legend: plugins?.legend,
tooltip: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tooltip only shows up when we have metrics data, it's not present in the placeholder. The styles are copied from the NetworkTrafficUsage. We may eventually create a shared tooltip styling after we get another use case (avoid premature abstraction)

usePointStyle: true,
caretSize: 0,
boxPadding: 10,
callbacks: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all the callbacks are copied from the feature metrics line chart

ticks: {
color: theme.palette.text.secondary,
callback(tickValue) {
const label = this.getLabelForValue(Number(tickValue));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was tricky to find. chartjs doesn't return timestamps in the callback but indices. So I lookup the actual value using a utility function provided in the latest version of chartjs

return { environment, setEnvironment, activeEnvironments };
};

const useFlagMetrics = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

copied all this code from the feature metrics. One difference is that now we have a hook that prepares chart options + chart data in one function instead of going through multiple components

@@ -0,0 +1,42 @@
import type { IFeatureMetricsRaw } from 'interfaces/featureToggle';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a copy paste of the feature metrics with colors swapped and total series removed

}

export const FEATURE_METRIC_HOURS_BACK_DEFAULT = 48;

export const FeatureMetricsHours = ({
hoursBack,
setHoursBack,
label = <StyledTitle>Period</StyledTitle>,
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as this doesn't cause any a11y issues, I have no problems. But I notice that the general select component doesn't have a label associated with it. Input elements should always be properly labeled (with label elements tied to the component). You can hide the label visually if you want, but it should def be there for assistive tech.

}

export const FEATURE_METRIC_HOURS_BACK_DEFAULT = 48;

export const FeatureMetricsHours = ({
hoursBack,
setHoursBack,
label = <StyledTitle>Period</StyledTitle>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Of course, the input's been around for a while, probably, but we can still fix it up now that we're here 💁🏼

@kwasniew kwasniew merged commit 54432f3 into main Sep 24, 2024
5 of 7 checks passed
@kwasniew kwasniew deleted the personal-flag-metrics-display branch September 24, 2024 11:47
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