modulesOnboarding.tsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. import {Fragment, useEffect, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import startCase from 'lodash/startCase';
  4. import {PlatformIcon} from 'platformicons';
  5. import appStartPreviewImg from 'sentry-images/insights/module-upsells/insights-app-starts-module-charts.svg';
  6. import assetsPreviewImg from 'sentry-images/insights/module-upsells/insights-assets-module-charts.svg';
  7. import cachesPreviewImg from 'sentry-images/insights/module-upsells/insights-caches-module-charts.svg';
  8. import llmPreviewImg from 'sentry-images/insights/module-upsells/insights-llm-module-charts.svg';
  9. import queriesPreviewImg from 'sentry-images/insights/module-upsells/insights-queries-module-charts.svg';
  10. import queuesPreviewImg from 'sentry-images/insights/module-upsells/insights-queues-module-charts.svg';
  11. import requestPreviewImg from 'sentry-images/insights/module-upsells/insights-requests-module-charts.svg';
  12. import screenLoadsPreviewImg from 'sentry-images/insights/module-upsells/insights-screen-loads-module-charts.svg';
  13. import screenRenderingPreviewImg from 'sentry-images/insights/module-upsells/insights-screen-rendering-module-charts.svg';
  14. import webVitalsPreviewImg from 'sentry-images/insights/module-upsells/insights-web-vitals-module-charts.svg';
  15. import emptyStateImg from 'sentry-images/spot/performance-waiting-for-span.svg';
  16. import {LinkButton} from 'sentry/components/button';
  17. import Panel from 'sentry/components/panels/panel';
  18. import {Tooltip} from 'sentry/components/tooltip';
  19. import {t, tct} from 'sentry/locale';
  20. import {space} from 'sentry/styles/space';
  21. import type {PlatformKey} from 'sentry/types/project';
  22. import useOrganization from 'sentry/utils/useOrganization';
  23. import useProjects from 'sentry/utils/useProjects';
  24. import * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
  25. import type {TitleableModuleNames} from 'sentry/views/insights/common/components/modulePageProviders';
  26. import {useHasFirstSpan} from 'sentry/views/insights/common/queries/useHasFirstSpan';
  27. import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
  28. import {
  29. MODULE_DATA_TYPES,
  30. MODULE_DATA_TYPES_PLURAL,
  31. MODULE_PRODUCT_DOC_LINKS,
  32. MODULE_TITLES,
  33. } from 'sentry/views/insights/settings';
  34. import {ModuleName} from 'sentry/views/insights/types';
  35. import PerformanceOnboarding from 'sentry/views/performance/onboarding';
  36. export function ModulesOnboarding({
  37. children,
  38. moduleName,
  39. }: {
  40. children: React.ReactNode;
  41. moduleName: ModuleName;
  42. }) {
  43. const organization = useOrganization();
  44. const onboardingProject = useOnboardingProject();
  45. const {reloadProjects} = useProjects();
  46. const hasData = useHasFirstSpan(moduleName);
  47. // Refetch the project metadata if the selected project does not have insights data, because
  48. // we may have received insight data (and subsequently updated `Project.hasInsightxx`)
  49. // after the initial project fetch.
  50. useEffect(() => {
  51. if (!hasData) {
  52. reloadProjects();
  53. }
  54. // eslint-disable-next-line react-hooks/exhaustive-deps
  55. }, [hasData]);
  56. if (onboardingProject) {
  57. return (
  58. <ModuleLayout.Full>
  59. <PerformanceOnboarding organization={organization} project={onboardingProject} />
  60. </ModuleLayout.Full>
  61. );
  62. }
  63. if (!hasData) {
  64. return (
  65. <ModuleLayout.Full>
  66. <ModulesOnboardingPanel moduleName={moduleName} />
  67. </ModuleLayout.Full>
  68. );
  69. }
  70. return children;
  71. }
  72. function ModulesOnboardingPanel({moduleName}: {moduleName: ModuleName}) {
  73. const emptyStateContent = EMPTY_STATE_CONTENT[moduleName];
  74. return (
  75. <Panel>
  76. <Container>
  77. <SplitMainContent>
  78. <ModuleInfo>
  79. <Fragment>
  80. <Header>{emptyStateContent.heading}</Header>
  81. <p>{emptyStateContent.description}</p>
  82. </Fragment>
  83. <SplitContainer>
  84. <ModulePreview moduleName={moduleName} />
  85. <ValueProp>
  86. {emptyStateContent.valuePropDescription}
  87. <ul>
  88. {emptyStateContent.valuePropPoints.map(point => (
  89. <li key={point?.toString()}>{point}</li>
  90. ))}
  91. </ul>
  92. </ValueProp>
  93. </SplitContainer>
  94. </ModuleInfo>
  95. <Sidebar>
  96. <PerfImage src={emptyStateImg} />
  97. </Sidebar>
  98. </SplitMainContent>
  99. <LinkButton
  100. priority="primary"
  101. external
  102. href={MODULE_PRODUCT_DOC_LINKS[moduleName]}
  103. >
  104. {t('Read the docs')}
  105. </LinkButton>
  106. </Container>
  107. </Panel>
  108. );
  109. }
  110. type ModulePreviewProps = {moduleName: ModuleName};
  111. function ModulePreview({moduleName}: ModulePreviewProps) {
  112. const emptyStateContent = EMPTY_STATE_CONTENT[moduleName];
  113. const [hoveredIcon, setHoveredIcon] = useState<PlatformKey | null>(null);
  114. return (
  115. <ModulePreviewContainer>
  116. <ModulePreviewImage src={emptyStateContent.imageSrc} />
  117. {emptyStateContent.supportedSdks && (
  118. <SupportedSdkContainer>
  119. <div>{t('Supported Today: ')}</div>
  120. <SupportedSdkList>
  121. {emptyStateContent.supportedSdks.map((sdk: PlatformKey) => (
  122. <Tooltip title={startCase(sdk)} key={sdk} position="top">
  123. <SupportedSdkIconContainer
  124. onMouseOver={() => setHoveredIcon(sdk)}
  125. onMouseOut={() => setHoveredIcon(null)}
  126. >
  127. <PlatformIcon
  128. platform={sdk}
  129. size={hoveredIcon === sdk ? '30px' : '25px'}
  130. />
  131. </SupportedSdkIconContainer>
  132. </Tooltip>
  133. ))}
  134. </SupportedSdkList>
  135. </SupportedSdkContainer>
  136. )}
  137. </ModulePreviewContainer>
  138. );
  139. }
  140. const Sidebar = styled('div')`
  141. position: relative;
  142. flex: 3;
  143. `;
  144. const PerfImage = styled('img')`
  145. max-width: 100%;
  146. min-width: 200px;
  147. `;
  148. const Container = styled('div')`
  149. position: relative;
  150. overflow: hidden;
  151. min-height: 160px;
  152. padding: ${space(4)};
  153. `;
  154. const SplitMainContent = styled('div')`
  155. display: flex;
  156. align-items: stretch;
  157. flex-wrap: wrap-reverse;
  158. gap: ${space(4)};
  159. `;
  160. const Header = styled('h3')`
  161. margin-bottom: ${space(1)};
  162. `;
  163. const SplitContainer = styled(Panel)`
  164. display: flex;
  165. justify-content: center;
  166. overflow: hidden;
  167. `;
  168. const ModuleInfo = styled('div')`
  169. flex: 5;
  170. width: 100%;
  171. `;
  172. const ModulePreviewImage = styled('img')`
  173. max-width: 100%;
  174. display: block;
  175. margin: auto;
  176. margin-bottom: ${space(2)};
  177. object-fit: contain;
  178. `;
  179. const ModulePreviewContainer = styled('div')`
  180. flex: 2;
  181. width: 100%;
  182. padding: ${space(3)};
  183. background-color: ${p => p.theme.backgroundSecondary};
  184. `;
  185. const SupportedSdkContainer = styled('div')`
  186. display: flex;
  187. flex-direction: column;
  188. gap: ${space(1)};
  189. align-items: center;
  190. color: ${p => p.theme.gray300};
  191. `;
  192. const SupportedSdkList = styled('div')`
  193. display: flex;
  194. flex-wrap: wrap;
  195. gap: ${space(0.5)};
  196. justify-content: center;
  197. `;
  198. const SupportedSdkIconContainer = styled('div')`
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. background-color: ${p => p.theme.gray100};
  203. width: 42px;
  204. height: 42px;
  205. border-radius: 3px;
  206. &:hover {
  207. box-shadow: 0 0 0 1px ${p => p.theme.gray200};
  208. }
  209. `;
  210. const ValueProp = styled('div')`
  211. flex: 1;
  212. padding: ${space(3)};
  213. ul {
  214. margin-top: ${space(1)};
  215. }
  216. `;
  217. type EmptyStateContent = {
  218. description: React.ReactNode;
  219. heading: React.ReactNode;
  220. imageSrc: any;
  221. valuePropDescription: React.ReactNode;
  222. valuePropPoints: React.ReactNode[];
  223. supportedSdks?: PlatformKey[];
  224. };
  225. const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
  226. app_start: {
  227. heading: t(`Don't lose your user's attention before your app loads`),
  228. description: tct(
  229. 'Monitor cold and warm [dataTypePlural] and track down the operations and releases contributing to regressions.',
  230. {
  231. dataTypePlural:
  232. MODULE_DATA_TYPES_PLURAL[ModuleName.APP_START].toLocaleLowerCase(),
  233. }
  234. ),
  235. valuePropDescription: tct(`Mobile [dataType] insights give you visibility into:`, {
  236. dataType: MODULE_DATA_TYPES[ModuleName.APP_START],
  237. }),
  238. valuePropPoints: [
  239. t('Application start duration broken down by release.'),
  240. t('Performance by device class.'),
  241. t('Real user performance metrics.'),
  242. ],
  243. imageSrc: appStartPreviewImg,
  244. supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
  245. },
  246. ai: {
  247. heading: t('Find out what your LLM model is actually saying'),
  248. description: tct(
  249. 'Get insights into critical [dataType] metrics, like token usage, to monitor and fix issues with AI pipelines.',
  250. {
  251. dataType: MODULE_DATA_TYPES[ModuleName.AI],
  252. }
  253. ),
  254. valuePropDescription: tct(
  255. 'See what your [dataTypePlural] are doing in production by monitoring:',
  256. {
  257. dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.AI],
  258. }
  259. ),
  260. valuePropPoints: [
  261. t('Token cost and usage per-provider and per-pipeline.'),
  262. tct('The inputs and outputs of [dataType] calls.', {
  263. dataType: MODULE_DATA_TYPES[ModuleName.AI],
  264. }),
  265. tct('Performance and timing information about [dataTypePlural] in production.', {
  266. dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.AI],
  267. }),
  268. ],
  269. imageSrc: llmPreviewImg,
  270. supportedSdks: ['python'],
  271. },
  272. // Mobile UI is not released yet
  273. 'mobile-ui': {
  274. heading: t('TODO'),
  275. description: t('TODO'),
  276. valuePropDescription: t('Mobile UI load insights include:'),
  277. valuePropPoints: [],
  278. imageSrc: screenLoadsPreviewImg,
  279. },
  280. // Mobile Screens is not released yet
  281. 'mobile-screens': {
  282. heading: t('Mobile Screens'),
  283. description: t('Explore mobile app metrics.'),
  284. valuePropDescription: '',
  285. valuePropPoints: [],
  286. imageSrc: screenLoadsPreviewImg,
  287. },
  288. cache: {
  289. heading: t('Bringing you one less hard problem in computer science'),
  290. description: t(
  291. 'We’ll tell you if the parts of your application that interact with caches are hitting cache as often as intended, and whether caching is providing the performance improvements expected.'
  292. ),
  293. valuePropDescription: tct('[dataType] insights include:', {
  294. dataType: MODULE_DATA_TYPES[ModuleName.CACHE],
  295. }),
  296. valuePropPoints: [
  297. t('Throughput of your cached endpoints.'),
  298. tct('Average [dataType] hit and miss duration.', {
  299. dataType: MODULE_DATA_TYPES[ModuleName.CACHE].toLocaleLowerCase(),
  300. }),
  301. t('Hit / miss ratio of keys accessed by your application.'),
  302. ],
  303. imageSrc: cachesPreviewImg,
  304. supportedSdks: ['python', 'javascript', 'php', 'java', 'ruby', 'dotnet'],
  305. },
  306. db: {
  307. heading: tct(
  308. 'Fix the slow [dataTypePlural] you honestly intended to get back to later',
  309. {dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.DB].toLocaleLowerCase()}
  310. ),
  311. description: tct(
  312. 'Investigate the performance of database [dataTypePlural] and get the information necessary to improve them.',
  313. {dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.DB].toLocaleLowerCase()}
  314. ),
  315. valuePropDescription: tct('[dataType] insights give you visibility into:', {
  316. dataType: MODULE_DATA_TYPES[ModuleName.DB],
  317. }),
  318. valuePropPoints: [
  319. tct('Slow [dataTypePlural].', {
  320. dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.DB].toLocaleLowerCase(),
  321. }),
  322. tct('High volume [dataTypePlural].', {
  323. dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.DB].toLocaleLowerCase(),
  324. }),
  325. t('One off slow queries, vs. trends'),
  326. ],
  327. imageSrc: queriesPreviewImg,
  328. },
  329. http: {
  330. heading: t(
  331. 'Are your API dependencies working as well as their landing page promised? '
  332. ),
  333. description: t(
  334. 'See the outbound HTTP requests being made to internal and external APIs, allowing you to understand trends in status codes, latency, and throughput.'
  335. ),
  336. valuePropDescription: tct('[dataType] insights give you visibility into:', {
  337. dataType: MODULE_DATA_TYPES[ModuleName.HTTP],
  338. }),
  339. valuePropPoints: [
  340. t('Anomalies in status codes by domain.'),
  341. t('Request throughput by domain.'),
  342. t('Average duration of requests.'),
  343. ],
  344. imageSrc: requestPreviewImg,
  345. },
  346. resource: {
  347. heading: t('Is your favorite animated gif worth the time it takes to load?'),
  348. description: tct(
  349. 'Find large and slow-to-load [dataTypePlurl] used by your application and understand their impact on page performance.',
  350. {dataTypePlurl: MODULE_DATA_TYPES_PLURAL[ModuleName.RESOURCE].toLocaleLowerCase()}
  351. ),
  352. valuePropDescription: tct('[dataType] insights give you visibility into:', {
  353. dataType: MODULE_DATA_TYPES[ModuleName.RESOURCE],
  354. }),
  355. valuePropPoints: [
  356. tct('[dataType] performance broken down by category and domain.', {
  357. dataType: MODULE_DATA_TYPES[ModuleName.RESOURCE],
  358. }),
  359. tct('Whether [dataTypePlural] are blocking page rendering.', {
  360. dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.RESOURCE].toLocaleLowerCase(),
  361. }),
  362. tct('[dataType] size and whether it’s growing over time.', {
  363. dataType: MODULE_DATA_TYPES[ModuleName.RESOURCE],
  364. }),
  365. ],
  366. imageSrc: assetsPreviewImg,
  367. // TODO - this is a lot of manual work, and its duplicated between here and our docs, it would great if there's a single source of truth
  368. supportedSdks: [
  369. 'javascript',
  370. 'javascript-angular',
  371. 'javascript-astro',
  372. 'javascript-ember',
  373. 'javascript-gatsby',
  374. 'javascript-nextjs',
  375. 'javascript-react',
  376. 'javascript-remix',
  377. 'javascript-solid',
  378. 'javascript-svelte',
  379. 'javascript-sveltekit',
  380. 'javascript-vue',
  381. ],
  382. },
  383. vital: {
  384. heading: t('Finally answer, is this page slow for everyone or just me?'),
  385. description: t(
  386. 'Get industry standard metrics telling you the quality of user experience on a web page and see what needs improving.'
  387. ),
  388. valuePropDescription: tct('[dataType] insights give you visibility into:', {
  389. dataType: MODULE_DATA_TYPES[ModuleName.VITAL],
  390. }),
  391. valuePropPoints: [
  392. t('Performance scores broken down by page.'),
  393. t('Performance metrics for individual operations that affect page performance.'),
  394. t('Drill down to real user sessions.'),
  395. ],
  396. imageSrc: webVitalsPreviewImg,
  397. },
  398. queue: {
  399. heading: t('Ensure your background jobs aren’t being sent to /dev/null'),
  400. description: tct(
  401. 'Understand the health and performance impact that [dataTypePlural] have on your application and diagnose errors tied to jobs.',
  402. {
  403. dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.QUEUE].toLocaleLowerCase(),
  404. }
  405. ),
  406. valuePropDescription: tct('[dataType] insights give you visibility into:', {
  407. dataType: MODULE_DATA_TYPES[ModuleName.QUEUE],
  408. }),
  409. valuePropPoints: [
  410. t('Metrics for how long jobs spend processing and waiting in queue.'),
  411. t('Job error rates and retry counts.'),
  412. t('Published vs., processed job volume.'),
  413. ],
  414. imageSrc: queuesPreviewImg,
  415. supportedSdks: ['python', 'javascript', 'php', 'java', 'ruby', 'dotnet'],
  416. },
  417. screen_load: {
  418. heading: t(`Don’t lose your user's attention once your app loads`),
  419. description: tct(
  420. 'View the most active [dataTypePlural] in your mobile application and monitor your releases for screen load performance.',
  421. {
  422. dataTypePlural:
  423. MODULE_DATA_TYPES_PLURAL[ModuleName.SCREEN_LOAD].toLocaleLowerCase(),
  424. }
  425. ),
  426. valuePropDescription: tct('[dataType] insights include:', {
  427. dataType: MODULE_DATA_TYPES[ModuleName.SCREEN_LOAD],
  428. }),
  429. valuePropPoints: [
  430. t('Compare metrics across releases, root causing performance degradations.'),
  431. t('See performance by device class.'),
  432. t('Drill down to real user sessions.'),
  433. ],
  434. imageSrc: screenLoadsPreviewImg,
  435. supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
  436. },
  437. 'screen-rendering': {
  438. description: t(
  439. 'Screen Rendering identifies slow and frozen interactions, helping you find and fix problems that might cause users to complain, or uninstall.'
  440. ),
  441. heading: t('Fast-loading apps can still be janky'),
  442. imageSrc: screenRenderingPreviewImg,
  443. valuePropDescription: tct('With [moduleTitle]:', {
  444. moduleTitle: MODULE_TITLES[ModuleName.SCREEN_RENDERING],
  445. }),
  446. valuePropPoints: [
  447. tct('Find and debug slow rendering interactions.', {
  448. dataType: MODULE_DATA_TYPES[ModuleName.SCREEN_RENDERING].toLowerCase(),
  449. }),
  450. t('Compare render performance between releases.'),
  451. tct('Correlate [dataType] performance with real-user metrics.', {
  452. dataType: MODULE_DATA_TYPES[ModuleName.SCREEN_RENDERING].toLowerCase(),
  453. }),
  454. ],
  455. supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
  456. },
  457. };