welcome.tsx 6.7 KB

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