welcome.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. import {Fragment, useEffect} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion, MotionProps} from 'framer-motion';
  4. import OnboardingInstall from 'sentry-images/spot/onboarding-install.svg';
  5. import OnboardingSetup from 'sentry-images/spot/onboarding-setup.svg';
  6. import {openInviteMembersModal} from 'sentry/actionCreators/modal';
  7. import {Button} from 'sentry/components/button';
  8. import Link from 'sentry/components/links/link';
  9. import {t, tct} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  12. import testableTransition from 'sentry/utils/testableTransition';
  13. import FallingError from 'sentry/views/onboarding/components/fallingError';
  14. import WelcomeBackground from 'sentry/views/onboarding/components/welcomeBackground';
  15. import {StepProps} from './types';
  16. import {usePersistedOnboardingState} from './utils';
  17. const fadeAway: MotionProps = {
  18. variants: {
  19. initial: {opacity: 0},
  20. animate: {opacity: 1, filter: 'blur(0px)'},
  21. exit: {opacity: 0, filter: 'blur(1px)'},
  22. },
  23. transition: testableTransition({duration: 0.8}),
  24. };
  25. type TextWrapperProps = {
  26. cta: React.ReactNode;
  27. src: string;
  28. subText: React.ReactNode;
  29. title: React.ReactNode;
  30. };
  31. function InnerAction({title, subText, cta, src}: TextWrapperProps) {
  32. return (
  33. <Fragment>
  34. <ActionImage src={src} />
  35. <TextWrapper>
  36. <ActionTitle>{title}</ActionTitle>
  37. <SubText>{subText}</SubText>
  38. </TextWrapper>
  39. <ButtonWrapper>{cta}</ButtonWrapper>
  40. </Fragment>
  41. );
  42. }
  43. function TargetedOnboardingWelcome({
  44. organization,
  45. jumpToSetupProject,
  46. ...props
  47. }: StepProps) {
  48. const source = 'targeted_onboarding';
  49. const [clientState, setClientState] = usePersistedOnboardingState();
  50. useEffect(() => {
  51. trackAdvancedAnalyticsEvent('growth.onboarding_start_onboarding', {
  52. organization,
  53. source,
  54. });
  55. });
  56. const onComplete = () => {
  57. trackAdvancedAnalyticsEvent('growth.onboarding_clicked_instrument_app', {
  58. organization,
  59. source,
  60. });
  61. if (clientState) {
  62. setClientState({
  63. ...clientState,
  64. url: 'select-platform/',
  65. state: 'started',
  66. });
  67. }
  68. props.onComplete();
  69. };
  70. // jump to setup project if the backend set this state for us
  71. useEffect(() => {
  72. if (clientState?.state === 'projects_selected') {
  73. jumpToSetupProject();
  74. }
  75. }, [clientState, jumpToSetupProject]);
  76. return (
  77. <FallingError>
  78. {({fallingError, fallCount, isFalling}) => (
  79. <Wrapper>
  80. <WelcomeBackground />
  81. <motion.h1 {...fadeAway} style={{marginBottom: space(0.5)}}>
  82. {t('Welcome to Sentry')}
  83. </motion.h1>
  84. <SubHeaderText style={{marginBottom: space(4)}} {...fadeAway}>
  85. {t(
  86. 'Your code is probably broken. Maybe not. Find out for sure. Get started below.'
  87. )}
  88. </SubHeaderText>
  89. <ActionItem {...fadeAway}>
  90. <InnerAction
  91. title={t('Install Sentry')}
  92. subText={t(
  93. 'Select your languages or frameworks and install the SDKs to start tracking issues'
  94. )}
  95. src={OnboardingInstall}
  96. cta={
  97. <Fragment>
  98. <ButtonWithFill
  99. onClick={() => {
  100. // triggerFall();
  101. onComplete();
  102. }}
  103. priority="primary"
  104. >
  105. {t('Start')}
  106. </ButtonWithFill>
  107. {(fallCount === 0 || isFalling) && (
  108. <PositionedFallingError>{fallingError}</PositionedFallingError>
  109. )}
  110. </Fragment>
  111. }
  112. />
  113. </ActionItem>
  114. <ActionItem {...fadeAway}>
  115. <InnerAction
  116. title={t('Set up my team')}
  117. subText={tct(
  118. 'Invite [friends] coworkers. You shouldn’t have to fix what you didn’t break',
  119. {friends: <Strike>{t('friends')}</Strike>}
  120. )}
  121. src={OnboardingSetup}
  122. cta={
  123. <ButtonWithFill
  124. onClick={() => {
  125. openInviteMembersModal({source});
  126. }}
  127. priority="primary"
  128. >
  129. {t('Invite Team')}
  130. </ButtonWithFill>
  131. }
  132. />
  133. </ActionItem>
  134. <motion.p style={{margin: 0}} {...fadeAway}>
  135. {t("Gee, I've used Sentry before.")}
  136. <br />
  137. <Link
  138. onClick={() => {
  139. trackAdvancedAnalyticsEvent('growth.onboarding_clicked_skip', {
  140. organization,
  141. source,
  142. });
  143. if (clientState) {
  144. setClientState({
  145. ...clientState,
  146. state: 'skipped',
  147. });
  148. }
  149. }}
  150. to={`/organizations/${organization.slug}/issues/?referrer=onboarding-welcome-skip`}
  151. >
  152. {t('Skip onboarding.')}
  153. </Link>
  154. </motion.p>
  155. </Wrapper>
  156. )}
  157. </FallingError>
  158. );
  159. }
  160. export default TargetedOnboardingWelcome;
  161. const PositionedFallingError = styled('span')`
  162. display: block;
  163. position: absolute;
  164. right: 0px;
  165. top: 30px;
  166. `;
  167. const Wrapper = styled(motion.div)`
  168. position: relative;
  169. margin-top: auto;
  170. margin-bottom: auto;
  171. max-width: 400px;
  172. display: flex;
  173. flex-direction: column;
  174. align-items: center;
  175. text-align: center;
  176. margin-left: auto;
  177. margin-right: auto;
  178. h1 {
  179. font-size: 42px;
  180. }
  181. `;
  182. const ActionItem = styled(motion.div)`
  183. min-height: 120px;
  184. border-radius: ${space(0.5)};
  185. padding: ${space(2)};
  186. margin-bottom: ${space(2)};
  187. justify-content: space-around;
  188. border: 1px solid ${p => p.theme.gray200};
  189. @media (min-width: ${p => p.theme.breakpoints.small}) {
  190. display: grid;
  191. grid-template-columns: 125px auto 125px;
  192. width: 680px;
  193. align-items: center;
  194. }
  195. @media (max-width: ${p => p.theme.breakpoints.small}) {
  196. display: flex;
  197. flex-direction: column;
  198. }
  199. `;
  200. const TextWrapper = styled('div')`
  201. text-align: left;
  202. margin: auto ${space(3)};
  203. min-height: 70px;
  204. @media (max-width: ${p => p.theme.breakpoints.small}) {
  205. text-align: center;
  206. margin: ${space(1)} ${space(1)};
  207. margin-top: ${space(3)};
  208. }
  209. `;
  210. const Strike = styled('span')`
  211. text-decoration: line-through;
  212. `;
  213. const ActionTitle = styled('h5')`
  214. font-weight: 900;
  215. margin: 0 0 ${space(0.5)};
  216. color: ${p => p.theme.gray400};
  217. `;
  218. const SubText = styled('span')`
  219. font-weight: 400;
  220. color: ${p => p.theme.gray400};
  221. `;
  222. const SubHeaderText = styled(motion.h6)`
  223. color: ${p => p.theme.gray300};
  224. `;
  225. const ButtonWrapper = styled('div')`
  226. margin: ${space(1)};
  227. position: relative;
  228. `;
  229. const ActionImage = styled('img')`
  230. height: 100px;
  231. `;
  232. const ButtonWithFill = styled(Button)`
  233. width: 100%;
  234. position: relative;
  235. z-index: 1;
  236. `;