appStartup.tsx 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {useEffect} from 'react';
  2. import {browserHistory} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import Feature from 'sentry/components/acl/feature';
  5. import ErrorBoundary from 'sentry/components/errorBoundary';
  6. import * as Layout from 'sentry/components/layouts/thirds';
  7. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  8. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  9. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  10. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  11. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  12. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  13. import {space} from 'sentry/styles/space';
  14. import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
  15. import {decodeScalar} from 'sentry/utils/queryString';
  16. import {useLocation} from 'sentry/utils/useLocation';
  17. import useOrganization from 'sentry/utils/useOrganization';
  18. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  19. import {SpanMetricsField} from 'sentry/views/starfish/types';
  20. import {ROUTE_NAMES} from 'sentry/views/starfish/utils/routeNames';
  21. import AppStartup from 'sentry/views/starfish/views/appStartup';
  22. import {
  23. COLD_START_TYPE,
  24. StartTypeSelector,
  25. } from 'sentry/views/starfish/views/appStartup/screenSummary/startTypeSelector';
  26. export default function InitializationModule() {
  27. const organization = useOrganization();
  28. const location = useLocation();
  29. const appStartType =
  30. decodeScalar(location.query[SpanMetricsField.APP_START_TYPE]) ?? '';
  31. useEffect(() => {
  32. // Default the start type to cold start if not present
  33. if (!appStartType) {
  34. browserHistory.replace({
  35. ...location,
  36. query: {
  37. ...location.query,
  38. [SpanMetricsField.APP_START_TYPE]: COLD_START_TYPE,
  39. },
  40. });
  41. }
  42. }, [location, appStartType]);
  43. return (
  44. <Feature features="starfish-mobile-appstart" organization={organization}>
  45. <SentryDocumentTitle title={ROUTE_NAMES['app-startup']} orgSlug={organization.slug}>
  46. <Layout.Page>
  47. <PageAlertProvider>
  48. <Layout.Header>
  49. <Layout.HeaderContent>
  50. <Layout.Title>{ROUTE_NAMES['app-startup']}</Layout.Title>
  51. </Layout.HeaderContent>
  52. </Layout.Header>
  53. <Layout.Body>
  54. <Layout.Main fullWidth>
  55. <PageAlert />
  56. <PageFiltersContainer>
  57. <Container>
  58. <PageFilterBar condensed>
  59. <ProjectPageFilter />
  60. <EnvironmentPageFilter />
  61. <DatePageFilter />
  62. </PageFilterBar>
  63. <ReleaseComparisonSelector />
  64. <StartTypeSelector />
  65. </Container>
  66. </PageFiltersContainer>
  67. <ErrorBoundary mini>
  68. <AppStartup chartHeight={200} />
  69. </ErrorBoundary>
  70. </Layout.Main>
  71. </Layout.Body>
  72. </PageAlertProvider>
  73. </Layout.Page>
  74. </SentryDocumentTitle>
  75. </Feature>
  76. );
  77. }
  78. const Container = styled('div')`
  79. display: flex;
  80. gap: ${space(2)};
  81. margin-bottom: ${space(2)};
  82. flex-wrap: wrap;
  83. `;