index.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import {useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import ErrorBoundary from 'sentry/components/errorBoundary';
  6. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  7. import * as Layout from 'sentry/components/layouts/thirds';
  8. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  9. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  10. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  11. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  12. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  13. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  14. import {t} from 'sentry/locale';
  15. import {space} from 'sentry/styles/space';
  16. import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
  17. import useOrganization from 'sentry/utils/useOrganization';
  18. import usePageFilters from 'sentry/utils/usePageFilters';
  19. import useProjects from 'sentry/utils/useProjects';
  20. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  21. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  22. import {ScreensView, YAxis} from 'sentry/views/performance/mobile/screenload/screens';
  23. import {PlatformSelector} from 'sentry/views/performance/mobile/screenload/screens/platformSelector';
  24. import {isCrossPlatform} from 'sentry/views/performance/mobile/screenload/screens/utils';
  25. import Onboarding from 'sentry/views/performance/onboarding';
  26. import {PlatformCompatibilityChecker} from 'sentry/views/performance/platformCompatibilityChecker';
  27. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  28. import {ROUTE_NAMES} from 'sentry/views/starfish/utils/routeNames';
  29. export default function PageloadModule() {
  30. const organization = useOrganization();
  31. const onboardingProject = useOnboardingProject();
  32. const {selection} = usePageFilters();
  33. const {projects} = useProjects();
  34. const project = useMemo(() => {
  35. if (selection.projects.length !== 1) {
  36. return null;
  37. }
  38. return projects.find(p => p.id === String(selection.projects));
  39. }, [projects, selection.projects]);
  40. return (
  41. <SentryDocumentTitle title={t('Screen Loads')} orgSlug={organization.slug}>
  42. <Layout.Page>
  43. <PageAlertProvider>
  44. <Layout.Header>
  45. <Layout.HeaderContent>
  46. <Breadcrumbs
  47. crumbs={[
  48. {
  49. label: t('Performance'),
  50. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  51. preservePageFilters: true,
  52. },
  53. {
  54. label: ROUTE_NAMES.pageload,
  55. },
  56. ]}
  57. />
  58. <HeaderWrapper>
  59. <Layout.Title>{t('Screen Loads')}</Layout.Title>
  60. {organization.features.includes('spans-first-ui') &&
  61. project &&
  62. isCrossPlatform(project) && <PlatformSelector />}
  63. </HeaderWrapper>
  64. </Layout.HeaderContent>
  65. <Layout.HeaderActions>
  66. <ButtonBar gap={1}>
  67. <FeedbackWidgetButton />
  68. </ButtonBar>
  69. </Layout.HeaderActions>
  70. </Layout.Header>
  71. <Layout.Body>
  72. <Layout.Main fullWidth>
  73. <PageFiltersContainer>
  74. <Container>
  75. <PageFilterBar condensed>
  76. <ProjectPageFilter />
  77. <EnvironmentPageFilter />
  78. <DatePageFilter />
  79. </PageFilterBar>
  80. <ReleaseComparisonSelector />
  81. </Container>
  82. <PageAlert />
  83. <ErrorBoundary mini>
  84. <PlatformCompatibilityChecker
  85. compatibleSDKNames={[
  86. 'sentry.java.android',
  87. 'sentry.cocoa',
  88. 'sentry.javascript.react-native',
  89. 'sentry.dart.flutter',
  90. 'sentry.dart',
  91. ]}
  92. docsUrl="https://docs.sentry.io/product/performance/mobile-vitals/screen-loads/#minimum-sdk-requirements"
  93. >
  94. {onboardingProject && (
  95. <OnboardingContainer>
  96. <Onboarding
  97. organization={organization}
  98. project={onboardingProject}
  99. />
  100. </OnboardingContainer>
  101. )}
  102. {!onboardingProject && (
  103. <ScreensView
  104. yAxes={[YAxis.TTID, YAxis.TTFD]}
  105. chartHeight={240}
  106. project={project}
  107. />
  108. )}
  109. </PlatformCompatibilityChecker>
  110. </ErrorBoundary>
  111. </PageFiltersContainer>
  112. </Layout.Main>
  113. </Layout.Body>
  114. </PageAlertProvider>
  115. </Layout.Page>
  116. </SentryDocumentTitle>
  117. );
  118. }
  119. const Container = styled('div')`
  120. display: grid;
  121. grid-template-rows: auto auto auto;
  122. gap: ${space(2)};
  123. margin-bottom: ${space(2)};
  124. @media (min-width: ${p => p.theme.breakpoints.large}) {
  125. grid-template-rows: auto;
  126. grid-template-columns: auto 1fr auto;
  127. }
  128. `;
  129. const OnboardingContainer = styled('div')`
  130. margin-top: ${space(2)};
  131. `;
  132. const HeaderWrapper = styled('div')`
  133. display: flex;
  134. `;