banner.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import tourAlert from 'sentry-images/spot/discover-tour-alert.svg';
  2. import tourExplore from 'sentry-images/spot/discover-tour-explore.svg';
  3. import tourFilter from 'sentry-images/spot/discover-tour-filter.svg';
  4. import tourGroup from 'sentry-images/spot/discover-tour-group.svg';
  5. import Banner from 'sentry/components/banner';
  6. import Button from 'sentry/components/button';
  7. import FeatureTourModal, {
  8. TourImage,
  9. TourStep,
  10. TourText,
  11. } from 'sentry/components/modals/featureTourModal';
  12. import {t} from 'sentry/locale';
  13. import {Organization} from 'sentry/types';
  14. import {trackAnalyticsEvent} from 'sentry/utils/analytics';
  15. import theme from 'sentry/utils/theme';
  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. trackAnalyticsEvent({
  78. eventKey: 'discover_v2.tour.advance',
  79. eventName: 'Discoverv2: Tour Advance',
  80. organization_id: parseInt(organization.id, 10),
  81. step,
  82. duration,
  83. });
  84. }
  85. function onCloseModal(step: number, duration: number) {
  86. trackAnalyticsEvent({
  87. eventKey: 'discover_v2.tour.close',
  88. eventName: 'Discoverv2: Tour Close',
  89. organization_id: parseInt(organization.id, 10),
  90. step,
  91. duration,
  92. });
  93. }
  94. const isSmallBanner = useMedia(`(max-width: ${theme.breakpoints.medium})`);
  95. return (
  96. <Banner
  97. title={t('Discover Trends')}
  98. subtitle={t(
  99. 'Customize and save queries by search conditions, event fields, and tags'
  100. )}
  101. backgroundComponent={<BackgroundSpace />}
  102. dismissKey="discover"
  103. >
  104. <Button
  105. size={isSmallBanner ? 'xs' : undefined}
  106. translucentBorder
  107. to={resultsUrl}
  108. onClick={() => {
  109. trackAnalyticsEvent({
  110. eventKey: 'discover_v2.build_new_query',
  111. eventName: 'Discoverv2: Build a new Discover Query',
  112. organization_id: parseInt(organization.id, 10),
  113. });
  114. }}
  115. >
  116. {t('Build a new query')}
  117. </Button>
  118. <FeatureTourModal
  119. steps={TOUR_STEPS}
  120. doneText={t('View all Events')}
  121. doneUrl={resultsUrl}
  122. onAdvance={onAdvance}
  123. onCloseModal={onCloseModal}
  124. >
  125. {({showModal}) => (
  126. <Button
  127. size={isSmallBanner ? 'xs' : undefined}
  128. translucentBorder
  129. onClick={() => {
  130. trackAnalyticsEvent({
  131. eventKey: 'discover_v2.tour.start',
  132. eventName: 'Discoverv2: Tour Start',
  133. organization_id: parseInt(organization.id, 10),
  134. });
  135. showModal();
  136. }}
  137. >
  138. {t('Get a Tour')}
  139. </Button>
  140. )}
  141. </FeatureTourModal>
  142. </Banner>
  143. );
  144. }
  145. export default DiscoverBanner;