demoHeader.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import {useEffect, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import Button from 'app/components/button';
  4. import ButtonBar from 'app/components/buttonBar';
  5. import ExternalLink from 'app/components/links/externalLink';
  6. import LogoSentry from 'app/components/logoSentry';
  7. import {t} from 'app/locale';
  8. import PreferencesStore from 'app/stores/preferencesStore';
  9. import space from 'app/styles/space';
  10. import {trackAdvancedAnalyticsEvent} from 'app/utils/advancedAnalytics';
  11. import {emailQueryParameter, extraQueryParameter} from 'app/utils/demoMode';
  12. import getCookie from 'app/utils/getCookie';
  13. type Preferences = typeof PreferencesStore.prefs;
  14. export default function DemoHeader() {
  15. // if the user came from a SaaS org, we should send them back to upgrade when they leave the sandbox
  16. const saasOrgSlug = getCookie('saas_org_slug');
  17. const queryParameter = emailQueryParameter();
  18. const getStartedExtraParameter = extraQueryParameter(true);
  19. const extraParameter = extraQueryParameter(false);
  20. const getStartedText = saasOrgSlug ? t('Upgrade Now') : t('Sign Up for Free');
  21. const getStartedUrl = saasOrgSlug
  22. ? `https://sentry.io/settings/${saasOrgSlug}/billing/checkout/`
  23. : `https://sentry.io/signup/${queryParameter}${getStartedExtraParameter}`;
  24. const [collapsed, setCollapsed] = useState(PreferencesStore.prefs.collapsed);
  25. const preferenceUnsubscribe = PreferencesStore.listen(
  26. (preferences: Preferences) => onPreferenceChange(preferences),
  27. undefined
  28. );
  29. function onPreferenceChange(preferences: Preferences) {
  30. if (preferences.collapsed === collapsed) {
  31. return;
  32. }
  33. setCollapsed(!collapsed);
  34. }
  35. useEffect(() => {
  36. return () => {
  37. preferenceUnsubscribe();
  38. };
  39. });
  40. return (
  41. <Wrapper collapsed={collapsed}>
  42. <StyledLogoSentry />
  43. <ButtonBar gap={4}>
  44. <StyledExternalLink
  45. onClick={() => trackAdvancedAnalyticsEvent('growth.demo_click_docs', {}, null)}
  46. href={`https://docs.sentry.io/${extraParameter}`}
  47. >
  48. {t('Documentation')}
  49. </StyledExternalLink>
  50. <BaseButton
  51. priority="form"
  52. onClick={() =>
  53. trackAdvancedAnalyticsEvent('growth.demo_click_request_demo', {}, null)
  54. }
  55. href={`https://sentry.io/_/demo/${extraParameter}`}
  56. >
  57. {t('Request a Demo')}
  58. </BaseButton>
  59. <GetStarted
  60. onClick={() =>
  61. trackAdvancedAnalyticsEvent(
  62. 'growth.demo_click_get_started',
  63. {
  64. is_upgrade: !!saasOrgSlug,
  65. },
  66. null
  67. )
  68. }
  69. href={getStartedUrl}
  70. >
  71. {getStartedText}
  72. </GetStarted>
  73. </ButtonBar>
  74. </Wrapper>
  75. );
  76. }
  77. // Note many of the colors don't come from the theme as they come from the marketing site
  78. const Wrapper = styled('div')<{collapsed: boolean}>`
  79. padding-right: ${space(3)};
  80. background-color: ${p => p.theme.white};
  81. height: ${p => p.theme.demo.headerSize};
  82. display: flex;
  83. justify-content: space-between;
  84. text-transform: uppercase;
  85. margin-left: calc(
  86. -1 * ${p => (p.collapsed ? p.theme.sidebar.collapsedWidth : p.theme.sidebar.expandedWidth)}
  87. );
  88. position: fixed;
  89. width: 100%;
  90. border-bottom: 1px solid ${p => p.theme.border};
  91. z-index: ${p => p.theme.zIndex.settingsSidebarNav};
  92. @media (max-width: ${p => p.theme.breakpoints[1]}) {
  93. height: ${p => p.theme.sidebar.mobileHeight};
  94. margin-left: 0;
  95. }
  96. `;
  97. const StyledLogoSentry = styled(LogoSentry)`
  98. margin-top: auto;
  99. margin-bottom: auto;
  100. margin-left: 20px;
  101. width: 130px;
  102. height: 30px;
  103. color: ${p => p.theme.textColor};
  104. `;
  105. const BaseButton = styled(Button)`
  106. border-radius: 2rem;
  107. text-transform: uppercase;
  108. `;
  109. // Note many of the colors don't come from the theme as they come from the marketing site
  110. const GetStarted = styled(BaseButton)`
  111. border-color: transparent;
  112. box-shadow: 0 2px 0 rgb(54 45 89 / 10%);
  113. background-color: #e1567c;
  114. color: #fff;
  115. `;
  116. const StyledExternalLink = styled(ExternalLink)`
  117. color: #584774;
  118. `;