index.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import {useCallback} from 'react';
  2. import {browserHistory} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import omit from 'lodash/omit';
  5. import Feature from 'sentry/components/acl/feature';
  6. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  7. import ButtonBar from 'sentry/components/buttonBar';
  8. import ErrorBoundary from 'sentry/components/errorBoundary';
  9. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  10. import * as Layout from 'sentry/components/layouts/thirds';
  11. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  12. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  13. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  14. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  15. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  16. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  17. import {t} from 'sentry/locale';
  18. import {space} from 'sentry/styles/space';
  19. import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
  20. import {useLocation} from 'sentry/utils/useLocation';
  21. import useOrganization from 'sentry/utils/useOrganization';
  22. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  23. import AppStartup from 'sentry/views/performance/appStarts/screens';
  24. import {StartTypeSelector} from 'sentry/views/performance/appStarts/screenSummary/startTypeSelector';
  25. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  26. import Onboarding from 'sentry/views/performance/onboarding';
  27. import {PlatformCompatibilityChecker} from 'sentry/views/performance/platformCompatibilityChecker';
  28. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  29. import {ROUTE_NAMES} from 'sentry/views/starfish/utils/routeNames';
  30. export default function InitializationModule() {
  31. const organization = useOrganization();
  32. const onboardingProject = useOnboardingProject();
  33. const location = useLocation();
  34. const handleProjectChange = useCallback(() => {
  35. browserHistory.replace({
  36. ...location,
  37. query: {
  38. ...omit(location.query, ['primaryRelease', 'secondaryRelease']),
  39. },
  40. });
  41. }, [location]);
  42. return (
  43. <Feature features="spans-first-ui" organization={organization}>
  44. <SentryDocumentTitle title={ROUTE_NAMES['app-startup']} orgSlug={organization.slug}>
  45. <Layout.Page>
  46. <PageAlertProvider>
  47. <Layout.Header>
  48. <Layout.HeaderContent>
  49. <Breadcrumbs
  50. crumbs={[
  51. {
  52. label: t('Performance'),
  53. to: normalizeUrl(
  54. `/organizations/${organization.slug}/performance/`
  55. ),
  56. preservePageFilters: true,
  57. },
  58. {
  59. label: ROUTE_NAMES['app-startup'],
  60. },
  61. ]}
  62. />
  63. <Layout.Title>{ROUTE_NAMES['app-startup']}</Layout.Title>
  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 onChange={handleProjectChange} />
  77. <EnvironmentPageFilter />
  78. <DatePageFilter />
  79. </PageFilterBar>
  80. <ReleaseComparisonSelector />
  81. <StartTypeSelector />
  82. </Container>
  83. </PageFiltersContainer>
  84. <PageAlert />
  85. <ErrorBoundary mini>
  86. <PlatformCompatibilityChecker
  87. compatibleSDKNames={['sentry.cocoa', 'sentry.java.android']}
  88. docsUrl="https://docs.sentry.io/product/performance/mobile-vitals/app-starts/#minimum-sdk-requirements"
  89. >
  90. {onboardingProject && (
  91. <Onboarding
  92. organization={organization}
  93. project={onboardingProject}
  94. />
  95. )}
  96. {!onboardingProject && <AppStartup chartHeight={200} />}
  97. </PlatformCompatibilityChecker>
  98. </ErrorBoundary>
  99. </Layout.Main>
  100. </Layout.Body>
  101. </PageAlertProvider>
  102. </Layout.Page>
  103. </SentryDocumentTitle>
  104. </Feature>
  105. );
  106. }
  107. const Container = styled('div')`
  108. display: flex;
  109. gap: ${space(2)};
  110. margin-bottom: ${space(2)};
  111. flex-wrap: wrap;
  112. `;