demoHeader.tsx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. import styled from '@emotion/styled';
  2. import Button from 'sentry/components/button';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import LogoSentry from 'sentry/components/logoSentry';
  5. import {t} from 'sentry/locale';
  6. import PreferencesStore from 'sentry/stores/preferencesStore';
  7. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  8. import space from 'sentry/styles/space';
  9. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  10. import {
  11. extraQueryParameter,
  12. extraQueryParameterWithEmail,
  13. urlAttachQueryParams,
  14. } from 'sentry/utils/demoMode';
  15. export default function DemoHeader() {
  16. const sandboxData = window.SandboxData;
  17. // if the user came from a SaaS org, we should send them back to upgrade when they leave the sandbox
  18. const extraSearchParams = extraQueryParameter();
  19. const walkthrough = localStorage.getItem('new-walkthrough');
  20. const collapsed = !!useLegacyStore(PreferencesStore).collapsed;
  21. let docsBtn, reqDemoBtn, signUpBtn;
  22. if (walkthrough === '1') {
  23. docsBtn = (
  24. <DocsDemoBtn
  25. onClick={() =>
  26. trackAdvancedAnalyticsEvent('growth.demo_click_docs', {organization: null})
  27. }
  28. href={urlAttachQueryParams('https://docs.sentry.io/', extraSearchParams)}
  29. target="_blank"
  30. rel="noreferrer noopener"
  31. >
  32. {t('Documentation')}
  33. </DocsDemoBtn>
  34. );
  35. reqDemoBtn = (
  36. <NewRequestDemoBtn
  37. priority="form"
  38. onClick={() =>
  39. trackAdvancedAnalyticsEvent('growth.demo_click_request_demo', {
  40. organization: null,
  41. })
  42. }
  43. href={urlAttachQueryParams('https://sentry.io/_/demo/', extraSearchParams)}
  44. target="_blank"
  45. rel="noreferrer noopener"
  46. >
  47. {t('Request a Demo')}
  48. </NewRequestDemoBtn>
  49. );
  50. signUpBtn = (
  51. <FreeTrial
  52. onClick={() => {
  53. const url =
  54. sandboxData?.cta?.url ||
  55. urlAttachQueryParams(
  56. 'https://sentry.io/signup/',
  57. extraQueryParameterWithEmail()
  58. );
  59. // Using window.open instead of href={} because we need to read `email`
  60. // from localStorage when the user clicks the button.
  61. window.open(url, '_blank');
  62. trackAdvancedAnalyticsEvent('growth.demo_click_get_started', {
  63. cta: sandboxData?.cta?.id,
  64. organization: null,
  65. });
  66. }}
  67. target="_blank"
  68. rel="noreferrer noopener"
  69. >
  70. <FreeTrialTextLong>
  71. {sandboxData?.cta?.title || t('Start Free Trial')}
  72. </FreeTrialTextLong>
  73. <FreeTrialTextShort>
  74. {sandboxData?.cta?.shortTitle || t('Sign Up')}
  75. </FreeTrialTextShort>
  76. </FreeTrial>
  77. );
  78. } else {
  79. docsBtn = (
  80. <StyledExternalLink
  81. onClick={() =>
  82. trackAdvancedAnalyticsEvent('growth.demo_click_docs', {organization: null})
  83. }
  84. href={urlAttachQueryParams('https://docs.sentry.io/', extraSearchParams)}
  85. openInNewTab
  86. >
  87. {t('Documentation')}
  88. </StyledExternalLink>
  89. );
  90. reqDemoBtn = (
  91. <RequestDemoBtn
  92. priority="form"
  93. onClick={() =>
  94. trackAdvancedAnalyticsEvent('growth.demo_click_request_demo', {
  95. organization: null,
  96. })
  97. }
  98. href={urlAttachQueryParams('https://sentry.io/_/demo/', extraSearchParams)}
  99. target="_blank"
  100. rel="noreferrer noopener"
  101. >
  102. {t('Request a Demo')}
  103. </RequestDemoBtn>
  104. );
  105. signUpBtn = (
  106. <GetStarted
  107. onClick={() => {
  108. const url =
  109. sandboxData?.cta?.url ||
  110. urlAttachQueryParams(
  111. 'https://sentry.io/signup/',
  112. extraQueryParameterWithEmail()
  113. );
  114. // Using window.open instead of href={} because we need to read `email`
  115. // from localStorage when the user clicks the button.
  116. window.open(url, '_blank');
  117. trackAdvancedAnalyticsEvent('growth.demo_click_get_started', {
  118. cta: sandboxData?.cta?.id,
  119. organization: null,
  120. });
  121. }}
  122. target="_blank"
  123. rel="noreferrer noopener"
  124. >
  125. <GetStartedTextLong>
  126. {sandboxData?.cta?.title || t('Sign Up for Free')}
  127. </GetStartedTextLong>
  128. <GetStartedTextShort>
  129. {sandboxData?.cta?.shortTitle || t('Sign Up')}
  130. </GetStartedTextShort>
  131. </GetStarted>
  132. );
  133. }
  134. return (
  135. <Wrapper collapsed={collapsed}>
  136. <StyledLogoSentry />
  137. {docsBtn}
  138. {reqDemoBtn}
  139. {signUpBtn}
  140. </Wrapper>
  141. );
  142. }
  143. // Note many of the colors don't come from the theme as they come from the marketing site
  144. const Wrapper = styled('div')<{collapsed: boolean}>`
  145. padding-right: ${space(3)};
  146. background-color: ${p => p.theme.white};
  147. height: ${p => p.theme.demo.headerSize};
  148. display: flex;
  149. justify-content: space-between;
  150. text-transform: uppercase;
  151. align-items: center;
  152. white-space: nowrap;
  153. gap: ${space(4)};
  154. margin-left: calc(
  155. -1 * ${p => (p.collapsed ? p.theme.sidebar.collapsedWidth : p.theme.sidebar.expandedWidth)}
  156. );
  157. position: fixed;
  158. width: 100%;
  159. border-bottom: 1px solid ${p => p.theme.border};
  160. z-index: ${p => p.theme.zIndex.settingsSidebarNav};
  161. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  162. height: ${p => p.theme.sidebar.mobileHeight};
  163. margin-left: 0;
  164. }
  165. `;
  166. const StyledLogoSentry = styled(LogoSentry)`
  167. margin-top: auto;
  168. margin-bottom: auto;
  169. margin-left: 20px;
  170. margin-right: auto;
  171. width: 130px;
  172. height: 30px;
  173. color: ${p => p.theme.textColor};
  174. `;
  175. const BaseButton = styled(Button)`
  176. border-radius: 2rem;
  177. text-transform: uppercase;
  178. `;
  179. const RequestDemoBtn = styled(BaseButton)`
  180. @media (max-width: ${p => p.theme.breakpoints.small}) {
  181. display: none;
  182. }
  183. `;
  184. const GetStartedTextShort = styled('span')`
  185. display: none;
  186. `;
  187. const GetStartedTextLong = styled('span')``;
  188. // Note many of the colors don't come from the theme as they come from the marketing site
  189. const GetStarted = styled(BaseButton)`
  190. border-color: transparent;
  191. box-shadow: 0 2px 0 rgb(54 45 89 / 10%);
  192. background-color: #e1567c;
  193. color: #fff;
  194. .short-text {
  195. display: none;
  196. }
  197. @media (max-width: 650px) {
  198. ${GetStartedTextLong} {
  199. display: none;
  200. }
  201. ${GetStartedTextShort} {
  202. display: inline;
  203. }
  204. }
  205. `;
  206. const StyledExternalLink = styled(ExternalLink)`
  207. color: #584774;
  208. @media (max-width: 500px) {
  209. display: none;
  210. }
  211. `;
  212. const FreeTrialTextShort = styled('span')`
  213. display: none;
  214. `;
  215. const FreeTrialTextLong = styled('span')``;
  216. const NewBaseButton = styled(Button)`
  217. text-transform: uppercase;
  218. `;
  219. const NewRequestDemoBtn = styled(NewBaseButton)`
  220. @media (max-width: ${p => p.theme.breakpoints.small}) {
  221. display: none;
  222. }
  223. `;
  224. const DocsDemoBtn = styled(NewBaseButton)`
  225. @media (max-width: 500px) {
  226. display: none;
  227. }
  228. `;
  229. const FreeTrial = styled(NewBaseButton)`
  230. border-color: transparent;
  231. background-color: #6c5fc7;
  232. color: #fff;
  233. .short-text {
  234. display: none;
  235. }
  236. @media (max-width: 650px) {
  237. ${FreeTrialTextLong} {
  238. display: none;
  239. }
  240. ${FreeTrialTextShort} {
  241. display: inline;
  242. }
  243. }
  244. `;