Skip to content

Commit 50ac539

Browse files
authored
ref(vitals): Clean up web vitals constants (#21389)
1 parent df441c8 commit 50ac539

File tree

1 file changed

+16
-12
lines changed
  • src/sentry/static/sentry/app/views/performance/realUserMonitoring

1 file changed

+16
-12
lines changed

src/sentry/static/sentry/app/views/performance/realUserMonitoring/constants.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,29 @@ export const FILTER_OPTIONS: SelectValue<string>[] = [
8080
{label: t('View All'), value: 'all'},
8181
];
8282

83-
export const ZOOM_KEYS = Object.values(WebVital).reduce((zoomKeys: string[], vital) => {
84-
const vitalSlug = WEB_VITAL_DETAILS[vital].slug;
85-
zoomKeys.push(`${vitalSlug}Start`);
86-
zoomKeys.push(`${vitalSlug}End`);
87-
return zoomKeys;
88-
}, []);
89-
9083
/**
9184
* This defines the grouping for histograms. Histograms that are in the same group
9285
* will be queried together on initial load for alignment. However, the zoom controls
9386
* are defined for each measurement independently.
9487
*/
88+
const _VITAL_GROUPS = [[WebVital.FP, WebVital.FCP, WebVital.LCP], [WebVital.FID]];
89+
9590
const _COLORS = [
96-
...theme.charts.getColorPalette(Object.values(WebVital).length - 1),
91+
...theme.charts.getColorPalette(
92+
_VITAL_GROUPS.reduce((count, group) => count + group.length, 0) - 1
93+
),
9794
].reverse();
98-
export const VITAL_GROUPS = [
99-
[WebVital.FP, WebVital.FCP, WebVital.LCP],
100-
[WebVital.FID],
101-
].map(group => ({
95+
96+
export const VITAL_GROUPS = _VITAL_GROUPS.map(group => ({
10297
group,
10398
colors: _COLORS.splice(0, group.length),
10499
}));
100+
101+
export const ZOOM_KEYS = _VITAL_GROUPS.reduce((keys: string[], group) => {
102+
group.forEach(vital => {
103+
const vitalSlug = WEB_VITAL_DETAILS[vital].slug;
104+
keys.push(`${vitalSlug}Start`);
105+
keys.push(`${vitalSlug}End`);
106+
});
107+
return keys;
108+
}, []);

0 commit comments

Comments
 (0)