setupDocs.tsx 3.6 KB

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