suggestProjectModal.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import {Component, Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import * as qs from 'query-string';
  4. import bgPattern from 'sentry-images/spot/mobile-hero.jpg';
  5. import {
  6. addErrorMessage,
  7. addLoadingMessage,
  8. addSuccessMessage,
  9. } from 'sentry/actionCreators/indicator';
  10. import {ModalRenderProps} from 'sentry/actionCreators/modal';
  11. import {Client} from 'sentry/api';
  12. import Access from 'sentry/components/acl/access';
  13. import Button from 'sentry/components/button';
  14. import ButtonBar from 'sentry/components/buttonBar';
  15. import EmailField from 'sentry/components/forms/emailField';
  16. import Form from 'sentry/components/forms/form';
  17. import List from 'sentry/components/list';
  18. import ListItem from 'sentry/components/list/listItem';
  19. import {t, tct} from 'sentry/locale';
  20. import space from 'sentry/styles/space';
  21. import {Organization} from 'sentry/types';
  22. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  23. import withApi from 'sentry/utils/withApi';
  24. type Props = ModalRenderProps & {
  25. api: Client;
  26. matchedUserAgentString: string;
  27. organization: Organization;
  28. };
  29. type State = {
  30. askTeammate: boolean;
  31. };
  32. class SuggestProjectModal extends Component<Props, State> {
  33. state: State = {
  34. askTeammate: false,
  35. };
  36. handleGetStartedClick = () => {
  37. const {matchedUserAgentString, organization} = this.props;
  38. trackAdvancedAnalyticsEvent('growth.clicked_mobile_prompt_setup_project', {
  39. matchedUserAgentString,
  40. organization,
  41. });
  42. };
  43. handleAskTeammate = () => {
  44. const {matchedUserAgentString, organization} = this.props;
  45. this.setState({askTeammate: true});
  46. trackAdvancedAnalyticsEvent('growth.clicked_mobile_prompt_ask_teammate', {
  47. matchedUserAgentString,
  48. organization,
  49. });
  50. };
  51. goBack = () => {
  52. this.setState({askTeammate: false});
  53. };
  54. handleSubmitSuccess = () => {
  55. const {matchedUserAgentString, organization, closeModal} = this.props;
  56. addSuccessMessage('Notified teammate successfully');
  57. trackAdvancedAnalyticsEvent('growth.submitted_mobile_prompt_ask_teammate', {
  58. matchedUserAgentString,
  59. organization,
  60. });
  61. closeModal();
  62. };
  63. handlePreSubmit = () => {
  64. addLoadingMessage(t('Submitting\u2026'));
  65. };
  66. handleSubmitError = () => {
  67. addErrorMessage(t('Error notifying teammate'));
  68. };
  69. renderAskTeammate() {
  70. const {Body, organization} = this.props;
  71. return (
  72. <Body>
  73. <Form
  74. apiEndpoint={`/organizations/${organization.slug}/request-project-creation/`}
  75. apiMethod="POST"
  76. submitLabel={t('Send')}
  77. onSubmitSuccess={this.handleSubmitSuccess}
  78. onSubmitError={this.handleSubmitError}
  79. onPreSubmit={this.handlePreSubmit}
  80. extraButton={
  81. <BackWrapper>
  82. <StyledBackButton onClick={this.goBack}>{t('Back')}</StyledBackButton>
  83. </BackWrapper>
  84. }
  85. >
  86. <p>
  87. {t('Let the right folks know about Sentry Mobile Application Monitoring.')}
  88. </p>
  89. <EmailField
  90. required
  91. name="targetUserEmail"
  92. inline={false}
  93. label={t('Email Address')}
  94. placeholder="name@example.com"
  95. stacked
  96. />
  97. </Form>
  98. </Body>
  99. );
  100. }
  101. renderMain() {
  102. const {Body, Footer, organization} = this.props;
  103. const paramString = qs.stringify({
  104. referrer: 'suggest_project',
  105. category: 'mobile',
  106. });
  107. const newProjectLink = `/organizations/${organization.slug}/projects/new/?${paramString}`;
  108. return (
  109. <Fragment>
  110. <Body>
  111. <ModalContainer>
  112. <SmallP>
  113. {t(
  114. "Sentry for Mobile shows a holistic overview of your application's health in real time. So you can correlate errors with releases, tags, and devices to solve problems quickly, decrease churn, and improve user retention."
  115. )}
  116. </SmallP>
  117. <StyledList symbol="bullet">
  118. <ListItem>
  119. {tct(
  120. '[see:See] session data, version adoption, and user impact by every release.',
  121. {
  122. see: <strong />,
  123. }
  124. )}
  125. </ListItem>
  126. <ListItem>
  127. {tct(
  128. '[solve:Solve] issues quickly with full context: contextualized stack traces, events that lead to the error, client, hardware information, and the very commit that introduced the error.',
  129. {
  130. solve: <strong />,
  131. }
  132. )}
  133. </ListItem>
  134. <ListItem>
  135. {tct(
  136. '[learn:Learn] and analyze event data to reduce regressions and ultimately improve user adoption and engagement.',
  137. {
  138. learn: <strong />,
  139. }
  140. )}
  141. </ListItem>
  142. </StyledList>
  143. <SmallP>{t('And guess what? Setup takes less than five minutes.')}</SmallP>
  144. </ModalContainer>
  145. </Body>
  146. <Footer>
  147. <Access organization={organization} access={['project:write']}>
  148. {({hasAccess}) => (
  149. <ButtonBar gap={1}>
  150. <Button
  151. priority={hasAccess ? 'default' : 'primary'}
  152. onClick={this.handleAskTeammate}
  153. >
  154. {t('Tell a Teammate')}
  155. </Button>
  156. {hasAccess && (
  157. <Button
  158. href={newProjectLink}
  159. onClick={this.handleGetStartedClick}
  160. priority="primary"
  161. >
  162. {t('Get Started')}
  163. </Button>
  164. )}
  165. </ButtonBar>
  166. )}
  167. </Access>
  168. </Footer>
  169. </Fragment>
  170. );
  171. }
  172. render() {
  173. const {Header} = this.props;
  174. const {askTeammate} = this.state;
  175. const header = askTeammate ? t('Tell a Teammate') : t('Try Sentry for Mobile');
  176. return (
  177. <Fragment>
  178. <Header>
  179. <PatternHeader />
  180. <Title>{header}</Title>
  181. </Header>
  182. {this.state.askTeammate ? this.renderAskTeammate() : this.renderMain()}
  183. </Fragment>
  184. );
  185. }
  186. }
  187. const ModalContainer = styled('div')`
  188. display: grid;
  189. gap: ${space(3)};
  190. code {
  191. word-break: break-word;
  192. }
  193. `;
  194. const Title = styled('h3')`
  195. margin-top: ${space(2)};
  196. margin-bottom: ${space(3)};
  197. `;
  198. const SmallP = styled('p')`
  199. margin: 0;
  200. `;
  201. const PatternHeader = styled('div')`
  202. margin: -${space(4)} -${space(4)} 0 -${space(4)};
  203. border-radius: 7px 7px 0 0;
  204. background-image: url(${bgPattern});
  205. background-size: 475px;
  206. background-color: black;
  207. background-repeat: no-repeat;
  208. overflow: hidden;
  209. background-position: center bottom;
  210. height: 156px;
  211. `;
  212. const StyledList = styled(List)`
  213. li {
  214. padding-left: ${space(3)};
  215. }
  216. `;
  217. const BackWrapper = styled('div')`
  218. width: 100%;
  219. margin-right: ${space(1)};
  220. `;
  221. const StyledBackButton = styled(Button)`
  222. float: right;
  223. `;
  224. export default withApi(SuggestProjectModal);