banner.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import {useTheme} from '@emotion/react';
  2. import tourAlert from 'sentry-images/spot/discover-tour-alert.svg';
  3. import tourExplore from 'sentry-images/spot/discover-tour-explore.svg';
  4. import tourFilter from 'sentry-images/spot/discover-tour-filter.svg';
  5. import tourGroup from 'sentry-images/spot/discover-tour-group.svg';
  6. import Banner from 'sentry/components/banner';
  7. import Button from 'sentry/components/button';
  8. import FeatureTourModal, {
  9. TourImage,
  10. TourStep,
  11. TourText,
  12. } from 'sentry/components/modals/featureTourModal';
  13. import {t} from 'sentry/locale';
  14. import {Organization} from 'sentry/types';
  15. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  16. import useMedia from 'sentry/utils/useMedia';
  17. import BackgroundSpace from './backgroundSpace';
  18. const docsUrl = 'https://docs.sentry.io/product/discover-queries/';
  19. const docsLink = (
  20. <Button external href={docsUrl}>
  21. {t('View Docs')}
  22. </Button>
  23. );
  24. const TOUR_STEPS: TourStep[] = [
  25. {
  26. title: t('Explore Data over Time'),
  27. image: <TourImage src={tourExplore} />,
  28. body: (
  29. <TourText>
  30. {t(
  31. 'Analyze and visualize all of your data over time to find answers to your most complex problems.'
  32. )}
  33. </TourText>
  34. ),
  35. actions: docsLink,
  36. },
  37. {
  38. title: t('Filter on Event Attributes.'),
  39. image: <TourImage src={tourFilter} />,
  40. body: (
  41. <TourText>
  42. {t(
  43. 'Drill down on data by any custom tag or field to reduce noise and hone in on specific areas.'
  44. )}
  45. </TourText>
  46. ),
  47. actions: docsLink,
  48. },
  49. {
  50. title: t('Group Data by Tags'),
  51. image: <TourImage src={tourGroup} />,
  52. body: (
  53. <TourText>
  54. {t(
  55. 'Go beyond Issues and create custom groupings to investigate events from a different lens.'
  56. )}
  57. </TourText>
  58. ),
  59. actions: docsLink,
  60. },
  61. {
  62. title: t('Save, Share and Alert'),
  63. image: <TourImage src={tourAlert} />,
  64. body: (
  65. <TourText>
  66. {t('Send insights to your team and set alerts to monitor any future spikes.')}
  67. </TourText>
  68. ),
  69. },
  70. ];
  71. type Props = {
  72. organization: Organization;
  73. resultsUrl: string;
  74. };
  75. function DiscoverBanner({organization, resultsUrl}: Props) {
  76. function onAdvance(step: number, duration: number) {
  77. trackAdvancedAnalyticsEvent('discover_v2.tour.advance', {
  78. organization,
  79. step,
  80. duration,
  81. });
  82. }
  83. function onCloseModal(step: number, duration: number) {
  84. trackAdvancedAnalyticsEvent('discover_v2.tour.close', {organization, step, duration});
  85. }
  86. const theme = useTheme();
  87. const isSmallBanner = useMedia(`(max-width: ${theme.breakpoints.medium})`);
  88. return (
  89. <Banner
  90. title={t('Discover Trends')}
  91. subtitle={t(
  92. 'Customize and save queries by search conditions, event fields, and tags'
  93. )}
  94. backgroundComponent={<BackgroundSpace />}
  95. dismissKey="discover"
  96. >
  97. <Button
  98. size={isSmallBanner ? 'xs' : undefined}
  99. translucentBorder
  100. to={resultsUrl}
  101. onClick={() => {
  102. trackAdvancedAnalyticsEvent('discover_v2.build_new_query', {organization});
  103. }}
  104. >
  105. {t('Build a new query')}
  106. </Button>
  107. <FeatureTourModal
  108. steps={TOUR_STEPS}
  109. doneText={t('View all Events')}
  110. doneUrl={resultsUrl}
  111. onAdvance={onAdvance}
  112. onCloseModal={onCloseModal}
  113. >
  114. {({showModal}) => (
  115. <Button
  116. size={isSmallBanner ? 'xs' : undefined}
  117. translucentBorder
  118. onClick={() => {
  119. trackAdvancedAnalyticsEvent('discover_v2.tour.start', {organization});
  120. showModal();
  121. }}
  122. >
  123. {t('Get a Tour')}
  124. </Button>
  125. )}
  126. </FeatureTourModal>
  127. </Banner>
  128. );
  129. }
  130. export default DiscoverBanner;