setupDocs.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/gettingStartedDoc/types';
  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. // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
  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 Wrapper = styled('div')`
  89. display: flex;
  90. flex-direction: row;
  91. margin: ${space(2)};
  92. justify-content: center;
  93. `;
  94. const MainContent = styled('div')`
  95. max-width: 850px;
  96. min-width: 0;
  97. flex-grow: 1;
  98. `;