constants.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {WebVital} from 'sentry/utils/fields';
  2. import {WEB_VITAL_DETAILS} from 'sentry/utils/performance/vitals/constants';
  3. import {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.getColorPalette(
  30. _VITAL_GROUPS.reduce((count, {vitals}) => count + vitals.length, 0) - 1
  31. ),
  32. ].reverse();
  33. export const VITAL_GROUPS: VitalGroup[] = _VITAL_GROUPS.map(group => ({
  34. ...group,
  35. colors: _COLORS.splice(0, group.vitals.length),
  36. }));
  37. export const ZOOM_KEYS = _VITAL_GROUPS.reduce((keys: string[], {vitals}) => {
  38. vitals.forEach(vital => {
  39. const vitalSlug = WEB_VITAL_DETAILS[vital].slug;
  40. keys.push(`${vitalSlug}Start`);
  41. keys.push(`${vitalSlug}End`);
  42. });
  43. return keys;
  44. }, []);