setupDocs.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import {Fragment, useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion} from 'framer-motion';
  4. import {SdkDocumentation} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  5. import type {ProductSolution} from 'sentry/components/onboarding/productSelection';
  6. import platforms, {otherPlatform} from 'sentry/data/platforms';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import {trackAnalytics} from 'sentry/utils/analytics';
  10. import {browserHistory} from 'sentry/utils/browserHistory';
  11. import {platformToIntegrationMap} from 'sentry/utils/integrationUtil';
  12. import {decodeList} from 'sentry/utils/queryString';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import SetupIntroduction from 'sentry/views/onboarding/components/setupIntroduction';
  15. import {useOnboardingQueryParams} from 'sentry/views/onboarding/components/useOnboardingQueryParams';
  16. import {OtherPlatformsInfo} from 'sentry/views/projectInstall/otherPlatformsInfo';
  17. import FirstEventFooter from './components/firstEventFooter';
  18. import IntegrationSetup from './integrationSetup';
  19. import type {StepProps} from './types';
  20. function SetupDocs({location, recentCreatedProject: project}: StepProps) {
  21. const organization = useOrganization();
  22. const products = useMemo<ProductSolution[]>(
  23. () => decodeList(location.query.product ?? []) as ProductSolution[],
  24. [location.query.product]
  25. );
  26. const currentPlatformKey = project?.platform ?? 'other';
  27. const currentPlatform =
  28. platforms.find(p => p.id === currentPlatformKey) ?? otherPlatform;
  29. const [params, setParams] = useOnboardingQueryParams();
  30. if (!project || !currentPlatform) {
  31. return null;
  32. }
  33. const platformName = currentPlatform.name;
  34. const integrationSlug = project.platform && platformToIntegrationMap[project.platform];
  35. const showIntegrationOnboarding = integrationSlug && !params.showManualSetup;
  36. return (
  37. <Fragment>
  38. <Wrapper>
  39. <MainContent>
  40. {showIntegrationOnboarding ? (
  41. <IntegrationSetup
  42. integrationSlug={integrationSlug}
  43. project={project}
  44. onClickManualSetup={() => {
  45. setParams({showManualSetup: true});
  46. }}
  47. />
  48. ) : (
  49. <Fragment>
  50. <SetupIntroduction
  51. stepHeaderText={t('Configure %s SDK', platformName)}
  52. platform={currentPlatformKey}
  53. />
  54. {currentPlatformKey === 'other' ? (
  55. <OtherPlatformsInfo
  56. projectSlug={project.slug}
  57. platform={currentPlatform.name}
  58. />
  59. ) : (
  60. <SdkDocumentation
  61. platform={currentPlatform}
  62. organization={organization}
  63. projectSlug={project.slug}
  64. projectId={project.id}
  65. activeProductSelection={products}
  66. newOrg
  67. />
  68. )}
  69. </Fragment>
  70. )}
  71. </MainContent>
  72. </Wrapper>
  73. <FirstEventFooter
  74. project={project}
  75. organization={organization}
  76. isLast
  77. onClickSetupLater={() => {
  78. const orgIssuesURL = `/organizations/${organization.slug}/issues/?project=${project.id}&referrer=onboarding-setup-docs`;
  79. trackAnalytics('growth.onboarding_clicked_setup_platform_later', {
  80. organization,
  81. platform: currentPlatformKey,
  82. project_id: project.id,
  83. });
  84. browserHistory.push(orgIssuesURL);
  85. }}
  86. />
  87. </Fragment>
  88. );
  89. }
  90. export default SetupDocs;
  91. const AnimatedContentWrapper = styled(motion.div)`
  92. overflow: hidden;
  93. `;
  94. AnimatedContentWrapper.defaultProps = {
  95. initial: {
  96. height: 0,
  97. },
  98. animate: {
  99. height: 'auto',
  100. },
  101. exit: {
  102. height: 0,
  103. },
  104. };
  105. const DocsWrapper = styled(motion.div)``;
  106. DocsWrapper.defaultProps = {
  107. initial: {opacity: 0, y: 40},
  108. animate: {opacity: 1, y: 0},
  109. exit: {opacity: 0},
  110. };
  111. const Wrapper = styled('div')`
  112. display: flex;
  113. flex-direction: row;
  114. margin: ${space(2)};
  115. justify-content: center;
  116. `;
  117. const MainContent = styled('div')`
  118. max-width: 850px;
  119. min-width: 0;
  120. flex-grow: 1;
  121. `;