constants.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {WebVital} from 'sentry/utils/fields';
  2. import {WEB_VITAL_DETAILS} from 'sentry/utils/performance/vitals/constants';
  3. import type {VitalGroup} from 'sentry/utils/performance/vitals/types';
  4. import theme from 'sentry/utils/theme';
  5. export const NUM_BUCKETS = 100;
  6. export const PERCENTILE = 0.75;
  7. /**
  8. * This defines the grouping for histograms. Histograms that are in the same group
  9. * will be queried together on initial load for alignment. However, the zoom controls
  10. * are defined for each measurement independently.
  11. */
  12. const _VITAL_GROUPS = [
  13. {
  14. vitals: [WebVital.FP, WebVital.FCP, WebVital.LCP],
  15. min: 0,
  16. },
  17. {
  18. vitals: [WebVital.FID],
  19. min: 0,
  20. precision: 2,
  21. },
  22. {
  23. vitals: [WebVital.CLS],
  24. min: 0,
  25. precision: 2,
  26. },
  27. ];
  28. const _COLORS = [
  29. ...((theme.charts
  30. .getColorPalette(
  31. _VITAL_GROUPS.reduce((count, {vitals}) => count + vitals.length, 0) - 1
  32. )
  33. ?.slice() as string[] | undefined) ?? []),
  34. ].reverse();
  35. export const VITAL_GROUPS: VitalGroup[] = _VITAL_GROUPS.map(group => ({
  36. ...group,
  37. colors: _COLORS.splice(0, group.vitals.length),
  38. }));
  39. export const ZOOM_KEYS = _VITAL_GROUPS.reduce((keys: string[], {vitals}) => {
  40. vitals.forEach(vital => {
  41. const vitalSlug = WEB_VITAL_DETAILS[vital].slug;
  42. keys.push(`${vitalSlug}Start`);
  43. keys.push(`${vitalSlug}End`);
  44. });
  45. return keys;
  46. }, []);