mobileView.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import {canUseMetricsData} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  2. import {usePageAlert} from 'sentry/utils/performance/contexts/pageAlert';
  3. import {PerformanceDisplayProvider} from 'sentry/utils/performance/contexts/performanceDisplayContext';
  4. import Table from '../../table';
  5. import {ProjectPerformanceType} from '../../utils';
  6. import {MOBILE_COLUMN_TITLES, REACT_NATIVE_COLUMN_TITLES} from '../data';
  7. import {checkIsReactNative} from '../utils';
  8. import {DoubleChartRow, TripleChartRow} from '../widgets/components/widgetChartRow';
  9. import {PerformanceWidgetSetting} from '../widgets/widgetDefinitions';
  10. import type {BasePerformanceViewProps} from './types';
  11. export function MobileView(props: BasePerformanceViewProps) {
  12. const {setPageError} = usePageAlert();
  13. let columnTitles = checkIsReactNative(props.eventView)
  14. ? REACT_NATIVE_COLUMN_TITLES
  15. : MOBILE_COLUMN_TITLES;
  16. const {organization} = props;
  17. const allowedCharts = [
  18. PerformanceWidgetSetting.TPM_AREA,
  19. PerformanceWidgetSetting.USER_MISERY_AREA,
  20. PerformanceWidgetSetting.COLD_STARTUP_AREA,
  21. PerformanceWidgetSetting.WARM_STARTUP_AREA,
  22. PerformanceWidgetSetting.SLOW_FRAMES_AREA,
  23. PerformanceWidgetSetting.FROZEN_FRAMES_AREA,
  24. ];
  25. const doubleRowAllowedCharts = [
  26. PerformanceWidgetSetting.MOST_SLOW_FRAMES,
  27. PerformanceWidgetSetting.MOST_FROZEN_FRAMES,
  28. ];
  29. if (organization.features.includes('mobile-vitals')) {
  30. columnTitles = [...columnTitles.slice(0, 5), 'ttid', ...columnTitles.slice(5, 0)];
  31. allowedCharts.push(
  32. ...[
  33. PerformanceWidgetSetting.TIME_TO_INITIAL_DISPLAY,
  34. PerformanceWidgetSetting.TIME_TO_FULL_DISPLAY,
  35. ]
  36. );
  37. }
  38. if (organization.features.includes('performance-screens-view')) {
  39. doubleRowAllowedCharts[0] = PerformanceWidgetSetting.SLOW_SCREENS_BY_TTID;
  40. }
  41. if (
  42. organization.features.includes('performance-new-trends') &&
  43. canUseMetricsData(props.organization)
  44. ) {
  45. doubleRowAllowedCharts.push(PerformanceWidgetSetting.MOST_CHANGED);
  46. } else {
  47. doubleRowAllowedCharts.push(
  48. ...[PerformanceWidgetSetting.MOST_IMPROVED, PerformanceWidgetSetting.MOST_REGRESSED]
  49. );
  50. }
  51. return (
  52. <PerformanceDisplayProvider value={{performanceType: ProjectPerformanceType.ANY}}>
  53. <div>
  54. <DoubleChartRow {...props} allowedCharts={doubleRowAllowedCharts} />
  55. <TripleChartRow {...props} allowedCharts={allowedCharts} />
  56. <Table {...props} columnTitles={columnTitles} setError={setPageError} />
  57. </div>
  58. </PerformanceDisplayProvider>
  59. );
  60. }