updatedEmptyState.tsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. import {Fragment, useEffect} from 'react';
  2. import styled from '@emotion/styled';
  3. import waitingForEventImg from 'sentry-images/spot/waiting-for-event.svg';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import {GuidedSteps} from 'sentry/components/guidedSteps/guidedSteps';
  6. import {AuthTokenGeneratorProvider} from 'sentry/components/onboarding/gettingStartedDoc/authTokenGenerator';
  7. import {OnboardingCodeSnippet} from 'sentry/components/onboarding/gettingStartedDoc/onboardingCodeSnippet';
  8. import {TabbedCodeSnippet} from 'sentry/components/onboarding/gettingStartedDoc/step';
  9. import type {DocsParams} from 'sentry/components/onboarding/gettingStartedDoc/types';
  10. import {useSourcePackageRegistries} from 'sentry/components/onboarding/gettingStartedDoc/useSourcePackageRegistries';
  11. import {useLoadGettingStarted} from 'sentry/components/onboarding/gettingStartedDoc/utils/useLoadGettingStarted';
  12. import platforms from 'sentry/data/platforms';
  13. import {t} from 'sentry/locale';
  14. import ConfigStore from 'sentry/stores/configStore';
  15. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  16. import {space} from 'sentry/styles/space';
  17. import type {PlatformIntegration, Project} from 'sentry/types/project';
  18. import {trackAnalytics} from 'sentry/utils/analytics';
  19. import useOrganization from 'sentry/utils/useOrganization';
  20. import FirstEventIndicator from 'sentry/views/onboarding/components/firstEventIndicator';
  21. export default function UpdatedEmptyState({project}: {project?: Project}) {
  22. const organization = useOrganization();
  23. const {isPending: isLoadingRegistry, data: registryData} =
  24. useSourcePackageRegistries(organization);
  25. const {isSelfHosted, urlPrefix} = useLegacyStore(ConfigStore);
  26. const currentPlatformKey = project?.platform ?? 'other';
  27. const currentPlatform = platforms.find(
  28. p => p.id === currentPlatformKey
  29. ) as PlatformIntegration;
  30. useEffect(() => {
  31. trackAnalytics('issue_stream.updated_empty_state_viewed', {
  32. organization,
  33. platform: currentPlatformKey,
  34. });
  35. }, [organization, currentPlatformKey]);
  36. const loadGettingStarted = useLoadGettingStarted({
  37. platform: currentPlatform,
  38. orgSlug: organization.slug,
  39. projSlug: project?.slug,
  40. });
  41. if (
  42. !currentPlatform ||
  43. !project ||
  44. loadGettingStarted.isError ||
  45. loadGettingStarted.isLoading ||
  46. !loadGettingStarted.docs ||
  47. !loadGettingStarted.dsn
  48. ) {
  49. return null;
  50. }
  51. const docParams: DocsParams<any> = {
  52. dsn: loadGettingStarted.dsn,
  53. organization,
  54. platformKey: currentPlatformKey,
  55. projectId: project.id,
  56. projectSlug: project.slug,
  57. isFeedbackSelected: false,
  58. isPerformanceSelected: true,
  59. isProfilingSelected: true,
  60. isReplaySelected: true,
  61. sourcePackageRegistries: {
  62. isLoading: isLoadingRegistry,
  63. data: registryData,
  64. },
  65. platformOptions: {installationMode: 'auto'},
  66. newOrg: false,
  67. replayOptions: {block: true, mask: true},
  68. isSelfHosted,
  69. urlPrefix,
  70. };
  71. if (currentPlatformKey === 'java' || currentPlatformKey === 'java-spring-boot') {
  72. docParams.platformOptions = {
  73. ...docParams.platformOptions,
  74. packageManager: 'gradle',
  75. };
  76. }
  77. const install = loadGettingStarted.docs.onboarding.install(docParams)[0];
  78. const configure = loadGettingStarted.docs.onboarding.configure(docParams);
  79. const verify = loadGettingStarted.docs.onboarding.verify(docParams);
  80. const {description: installDescription, additionalInfo: installInfo} = install;
  81. const installConfigurations = install.configurations ?? [];
  82. const {configurations, description: configureDescription} = configure[0] ?? {};
  83. const {
  84. configurations: extraConfigurations,
  85. description: extraConfigDescription,
  86. title: extraConfigTitle,
  87. } = configure[1] ?? {};
  88. const {description: verifyDescription, configurations: verifyConfigurations} =
  89. verify[0] ?? {};
  90. return (
  91. <AuthTokenGeneratorProvider projectSlug={project?.slug}>
  92. <div>
  93. <HeaderWrapper>
  94. <Title>{t('Get Started with Sentry Issues')}</Title>
  95. <Description>
  96. {t('Your code sleuth eagerly awaits its first mission.')}
  97. </Description>
  98. <Image src={waitingForEventImg} />
  99. </HeaderWrapper>
  100. <Divider />
  101. <Body>
  102. <Setup>
  103. <BodyTitle>{t('Set up the Sentry SDK')}</BodyTitle>
  104. <GuidedSteps>
  105. <GuidedSteps.Step stepKey="install-sentry" title={t('Install Sentry')}>
  106. <div>
  107. <div>
  108. <DescriptionWrapper>{installDescription}</DescriptionWrapper>
  109. {installConfigurations.map((configuration, index) => (
  110. <div key={index}>
  111. <DescriptionWrapper>
  112. {configuration.description}
  113. </DescriptionWrapper>
  114. <CodeSnippetWrapper>
  115. {configuration.code ? (
  116. Array.isArray(configuration.code) ? (
  117. <TabbedCodeSnippet tabs={configuration.code} />
  118. ) : (
  119. <OnboardingCodeSnippet language={configuration.language}>
  120. {configuration.code}
  121. </OnboardingCodeSnippet>
  122. )
  123. ) : null}
  124. </CodeSnippetWrapper>
  125. </div>
  126. ))}
  127. <DescriptionWrapper>{installInfo}</DescriptionWrapper>
  128. {!configurations &&
  129. !extraConfigDescription &&
  130. !verifyConfigurations && (
  131. <FirstEventIndicator
  132. organization={organization}
  133. project={project}
  134. eventType="error"
  135. >
  136. {({indicator, firstEventButton}) => (
  137. <FirstEventWrapper>
  138. <IndicatorWrapper>{indicator}</IndicatorWrapper>
  139. <StyledButtonBar gap={1}>
  140. <GuidedSteps.BackButton size="md" />
  141. {firstEventButton}
  142. </StyledButtonBar>
  143. </FirstEventWrapper>
  144. )}
  145. </FirstEventIndicator>
  146. )}
  147. </div>
  148. <GuidedSteps.ButtonWrapper>
  149. <GuidedSteps.BackButton size="md" />
  150. <GuidedSteps.NextButton size="md" />
  151. </GuidedSteps.ButtonWrapper>
  152. </div>
  153. </GuidedSteps.Step>
  154. {configurations ? (
  155. <GuidedSteps.Step
  156. stepKey="configure-sentry"
  157. title={t('Configure Sentry')}
  158. >
  159. <div>
  160. <div>
  161. <DescriptionWrapper>{configureDescription}</DescriptionWrapper>
  162. {configurations.map((configuration, index) => (
  163. <div key={index}>
  164. <DescriptionWrapper>
  165. {configuration.description}
  166. </DescriptionWrapper>
  167. <CodeSnippetWrapper>
  168. {configuration.code ? (
  169. Array.isArray(configuration.code) ? (
  170. <TabbedCodeSnippet tabs={configuration.code} />
  171. ) : (
  172. <OnboardingCodeSnippet language={configuration.language}>
  173. {configuration.code}
  174. </OnboardingCodeSnippet>
  175. )
  176. ) : null}
  177. </CodeSnippetWrapper>
  178. <CodeSnippetWrapper>
  179. {configuration.configurations &&
  180. configuration.configurations.length > 0 ? (
  181. Array.isArray(configuration.configurations[0].code) ? (
  182. <TabbedCodeSnippet
  183. tabs={configuration.configurations[0].code}
  184. />
  185. ) : null
  186. ) : null}
  187. </CodeSnippetWrapper>
  188. <DescriptionWrapper>
  189. {configuration.additionalInfo}
  190. </DescriptionWrapper>
  191. </div>
  192. ))}
  193. </div>
  194. <GuidedSteps.ButtonWrapper>
  195. <GuidedSteps.BackButton size="md" />
  196. <GuidedSteps.NextButton size="md" />
  197. </GuidedSteps.ButtonWrapper>
  198. </div>
  199. </GuidedSteps.Step>
  200. ) : (
  201. <Fragment />
  202. )}
  203. {extraConfigDescription ? (
  204. <GuidedSteps.Step
  205. stepKey="extra-configuration-sentry"
  206. title={extraConfigTitle || t('Upload Source Maps')}
  207. >
  208. <div>
  209. <div>
  210. <DescriptionWrapper>{extraConfigDescription}</DescriptionWrapper>
  211. {extraConfigurations?.map((configuration, index) => (
  212. <div key={index}>
  213. <DescriptionWrapper>
  214. {configuration.description}
  215. </DescriptionWrapper>
  216. <CodeSnippetWrapper>
  217. {configuration.code ? (
  218. Array.isArray(configuration.code) ? (
  219. <TabbedCodeSnippet tabs={configuration.code} />
  220. ) : (
  221. <OnboardingCodeSnippet language={configuration.language}>
  222. {configuration.code}
  223. </OnboardingCodeSnippet>
  224. )
  225. ) : null}
  226. </CodeSnippetWrapper>
  227. </div>
  228. ))}
  229. {!verifyConfigurations && !verifyDescription && (
  230. <FirstEventIndicator
  231. organization={organization}
  232. project={project}
  233. eventType="error"
  234. >
  235. {({indicator, firstEventButton}) => (
  236. <div>
  237. <IndicatorWrapper>{indicator}</IndicatorWrapper>
  238. <StyledButtonBar gap={1}>
  239. <GuidedSteps.BackButton size="md" />
  240. {firstEventButton}
  241. </StyledButtonBar>
  242. </div>
  243. )}
  244. </FirstEventIndicator>
  245. )}
  246. </div>
  247. {(verifyConfigurations || verifyDescription) && (
  248. <GuidedSteps.ButtonWrapper>
  249. <GuidedSteps.BackButton size="md" />
  250. <GuidedSteps.NextButton size="md" />
  251. </GuidedSteps.ButtonWrapper>
  252. )}
  253. </div>
  254. </GuidedSteps.Step>
  255. ) : (
  256. <Fragment />
  257. )}
  258. {verifyConfigurations || verifyDescription ? (
  259. <GuidedSteps.Step stepKey="verify-sentry" title={t('Verify')}>
  260. <div>
  261. <DescriptionWrapper>{verifyDescription}</DescriptionWrapper>
  262. {verifyConfigurations?.map((configuration, index) => (
  263. <div key={index}>
  264. <DescriptionWrapper>
  265. {configuration.description}
  266. </DescriptionWrapper>
  267. <CodeSnippetWrapper>
  268. {configuration.code ? (
  269. Array.isArray(configuration.code) ? (
  270. <TabbedCodeSnippet tabs={configuration.code} />
  271. ) : (
  272. <OnboardingCodeSnippet language={configuration.language}>
  273. {configuration.code}
  274. </OnboardingCodeSnippet>
  275. )
  276. ) : null}
  277. </CodeSnippetWrapper>
  278. </div>
  279. ))}
  280. <FirstEventIndicator
  281. organization={organization}
  282. project={project}
  283. eventType="error"
  284. >
  285. {({indicator, firstEventButton}) => (
  286. <FirstEventWrapper>
  287. <IndicatorWrapper>{indicator}</IndicatorWrapper>
  288. <StyledButtonBar gap={1}>
  289. <GuidedSteps.BackButton size="md" />
  290. {firstEventButton}
  291. </StyledButtonBar>
  292. </FirstEventWrapper>
  293. )}
  294. </FirstEventIndicator>
  295. </div>
  296. </GuidedSteps.Step>
  297. ) : (
  298. <Fragment />
  299. )}
  300. </GuidedSteps>
  301. </Setup>
  302. <Preview>
  303. <BodyTitle>{t('Preview a Sentry Issue')}</BodyTitle>
  304. <ArcadeWrapper>
  305. <Arcade
  306. src="https://demo.arcade.software/54VidzNthU5ykIFPCdW1?embed"
  307. loading="lazy"
  308. allowFullScreen
  309. />
  310. </ArcadeWrapper>
  311. </Preview>
  312. </Body>
  313. </div>
  314. </AuthTokenGeneratorProvider>
  315. );
  316. }
  317. const Title = styled('div')`
  318. font-size: 26px;
  319. font-weight: ${p => p.theme.fontWeightBold};
  320. `;
  321. const Description = styled('div')`
  322. max-width: 340px;
  323. `;
  324. const ArcadeWrapper = styled('div')`
  325. margin-top: ${space(1)};
  326. `;
  327. const HeaderWrapper = styled('div')`
  328. border-radius: ${p => p.theme.borderRadius};
  329. padding: ${space(4)};
  330. `;
  331. const BodyTitle = styled('div')`
  332. font-size: ${p => p.theme.fontSizeExtraLarge};
  333. font-weight: ${p => p.theme.fontWeightBold};
  334. margin-bottom: ${space(1)};
  335. `;
  336. const Setup = styled('div')`
  337. padding: ${space(4)};
  338. &:after {
  339. content: '';
  340. position: absolute;
  341. right: 50%;
  342. top: 19%;
  343. height: 78%;
  344. border-right: 1px ${p => p.theme.border} solid;
  345. }
  346. `;
  347. const Preview = styled('div')`
  348. padding: ${space(4)};
  349. `;
  350. const Body = styled('div')`
  351. display: grid;
  352. grid-auto-columns: minmax(0, 1fr);
  353. grid-auto-flow: column;
  354. h4 {
  355. margin-bottom: 0;
  356. }
  357. `;
  358. const Image = styled('img')`
  359. position: absolute;
  360. display: block;
  361. top: 0px;
  362. right: 20px;
  363. pointer-events: none;
  364. height: 120px;
  365. overflow: hidden;
  366. @media (max-width: ${p => p.theme.breakpoints.small}) {
  367. display: none;
  368. }
  369. `;
  370. const Divider = styled('hr')`
  371. height: 1px;
  372. width: 95%;
  373. background: ${p => p.theme.border};
  374. border: none;
  375. margin-top: 0;
  376. margin-bottom: 0;
  377. `;
  378. const Arcade = styled('iframe')`
  379. width: 750px;
  380. max-width: 100%;
  381. height: 500px;
  382. border: 0;
  383. `;
  384. const StyledButtonBar = styled(ButtonBar)`
  385. display: flex;
  386. `;
  387. const IndicatorWrapper = styled('div')`
  388. width: 300px;
  389. max-width: 100%;
  390. margin-bottom: ${space(1)};
  391. `;
  392. const CodeSnippetWrapper = styled('div')`
  393. margin-bottom: ${space(2)};
  394. `;
  395. const DescriptionWrapper = styled('div')`
  396. margin-bottom: ${space(1)};
  397. `;
  398. const FirstEventWrapper = styled('div')`
  399. padding-top: ${space(1)};
  400. `;