setupDocs.tsx 4.0 KB

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