mobileView.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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('insights-initial-modules')) {
  39. doubleRowAllowedCharts[0] = PerformanceWidgetSetting.SLOW_SCREENS_BY_TTID;
  40. }
  41. if (organization.features.includes('starfish-mobile-appstart')) {
  42. doubleRowAllowedCharts.push(
  43. PerformanceWidgetSetting.SLOW_SCREENS_BY_COLD_START,
  44. PerformanceWidgetSetting.SLOW_SCREENS_BY_WARM_START
  45. );
  46. }
  47. if (
  48. organization.features.includes('performance-new-trends') &&
  49. canUseMetricsData(props.organization)
  50. ) {
  51. doubleRowAllowedCharts.push(PerformanceWidgetSetting.MOST_CHANGED);
  52. } else {
  53. doubleRowAllowedCharts.push(
  54. ...[PerformanceWidgetSetting.MOST_IMPROVED, PerformanceWidgetSetting.MOST_REGRESSED]
  55. );
  56. }
  57. if (props.organization.features.includes('insights-initial-modules')) {
  58. doubleRowAllowedCharts.push(PerformanceWidgetSetting.MOST_TIME_CONSUMING_DOMAINS);
  59. }
  60. return (
  61. <PerformanceDisplayProvider value={{performanceType: ProjectPerformanceType.ANY}}>
  62. <div>
  63. <DoubleChartRow {...props} allowedCharts={doubleRowAllowedCharts} />
  64. <TripleChartRow {...props} allowedCharts={allowedCharts} />
  65. <Table {...props} columnTitles={columnTitles} setError={setPageError} />
  66. </div>
  67. </PerformanceDisplayProvider>
  68. );
  69. }