replayOnboardingPanel.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import emptyStateImg from 'sentry-images/spot/replays-empty-state.svg';
  4. import Feature from 'sentry/components/acl/feature';
  5. import {Button} from 'sentry/components/button';
  6. import ButtonBar from 'sentry/components/buttonBar';
  7. import HookOrDefault from 'sentry/components/hookOrDefault';
  8. import OnboardingPanel from 'sentry/components/onboardingPanel';
  9. import {t} from 'sentry/locale';
  10. import PreferencesStore from 'sentry/stores/preferencesStore';
  11. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  12. import {useReplayOnboardingSidebarPanel} from 'sentry/utils/replays/hooks/useReplayOnboarding';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. type Breakpoints = {
  15. large: string;
  16. medium: string;
  17. small: string;
  18. xlarge: string;
  19. };
  20. const OnboardingCTAHook = HookOrDefault({
  21. hookName: 'component:replay-onboarding-cta',
  22. defaultComponent: ({children}) => <Fragment>{children}</Fragment>,
  23. });
  24. export default function ReplayOnboardingPanel() {
  25. const preferences = useLegacyStore(PreferencesStore);
  26. const breakpoints = preferences.collapsed
  27. ? {
  28. small: '800px',
  29. medium: '992px',
  30. large: '1210px',
  31. xlarge: '1450px',
  32. }
  33. : {
  34. small: '800px',
  35. medium: '1175px',
  36. large: '1375px',
  37. xlarge: '1450px',
  38. };
  39. const organization = useOrganization();
  40. return (
  41. <OnboardingPanel image={<HeroImage src={emptyStateImg} breakpoints={breakpoints} />}>
  42. <Feature
  43. features={['session-replay-ga']}
  44. organization={organization}
  45. renderDisabled={() => <SetupReplaysCTA />}
  46. >
  47. <OnboardingCTAHook organization={organization}>
  48. <SetupReplaysCTA />
  49. </OnboardingCTAHook>
  50. </Feature>
  51. </OnboardingPanel>
  52. );
  53. }
  54. function SetupReplaysCTA() {
  55. const {activateSidebar} = useReplayOnboardingSidebarPanel();
  56. return (
  57. <Fragment>
  58. <h3>{t('Get to the root cause faster')}</h3>
  59. <p>
  60. {t(
  61. 'See a video-like reproduction of your user sessions so you can see what happened before, during, and after an error or latency issue occurred.'
  62. )}
  63. </p>
  64. <ButtonList gap={1}>
  65. <Button onClick={activateSidebar} priority="primary">
  66. {t('Set Up Replays')}
  67. </Button>
  68. <Button
  69. href="https://docs.sentry.io/platforms/javascript/session-replay/"
  70. external
  71. >
  72. {t('Read Docs')}
  73. </Button>
  74. </ButtonList>
  75. </Fragment>
  76. );
  77. }
  78. const HeroImage = styled('img')<{breakpoints: Breakpoints}>`
  79. @media (min-width: ${p => p.breakpoints.small}) {
  80. user-select: none;
  81. position: absolute;
  82. top: 0;
  83. bottom: 0;
  84. width: 220px;
  85. margin-top: auto;
  86. margin-bottom: auto;
  87. transform: translateX(-50%);
  88. left: 50%;
  89. }
  90. @media (min-width: ${p => p.breakpoints.medium}) {
  91. transform: translateX(-55%);
  92. width: 300px;
  93. min-width: 300px;
  94. }
  95. @media (min-width: ${p => p.breakpoints.large}) {
  96. transform: translateX(-60%);
  97. width: 380px;
  98. min-width: 380px;
  99. }
  100. @media (min-width: ${p => p.breakpoints.xlarge}) {
  101. transform: translateX(-65%);
  102. width: 420px;
  103. min-width: 420px;
  104. }
  105. `;
  106. const ButtonList = styled(ButtonBar)`
  107. grid-template-columns: repeat(auto-fit, minmax(130px, max-content));
  108. `;