banner.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 'app/components/banner';
  6. import Button from 'app/components/button';
  7. import FeatureTourModal, {
  8. TourImage,
  9. TourStep,
  10. TourText,
  11. } from 'app/components/modals/featureTourModal';
  12. import {t} from 'app/locale';
  13. import {Organization} from 'app/types';
  14. import {trackAnalyticsEvent} from 'app/utils/analytics';
  15. import theme from 'app/utils/theme';
  16. import useMedia from 'app/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[1]})`);
  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 ? 'xsmall' : undefined}
  106. to={resultsUrl}
  107. onClick={() => {
  108. trackAnalyticsEvent({
  109. eventKey: 'discover_v2.build_new_query',
  110. eventName: 'Discoverv2: Build a new Discover Query',
  111. organization_id: parseInt(organization.id, 10),
  112. });
  113. }}
  114. >
  115. {t('Build a new query')}
  116. </Button>
  117. <FeatureTourModal
  118. steps={TOUR_STEPS}
  119. doneText={t('View all Events')}
  120. doneUrl={resultsUrl}
  121. onAdvance={onAdvance}
  122. onCloseModal={onCloseModal}
  123. >
  124. {({showModal}) => (
  125. <Button
  126. size={isSmallBanner ? 'xsmall' : undefined}
  127. onClick={() => {
  128. trackAnalyticsEvent({
  129. eventKey: 'discover_v2.tour.start',
  130. eventName: 'Discoverv2: Tour Start',
  131. organization_id: parseInt(organization.id, 10),
  132. });
  133. showModal();
  134. }}
  135. >
  136. {t('Get a Tour')}
  137. </Button>
  138. )}
  139. </FeatureTourModal>
  140. </Banner>
  141. );
  142. }
  143. export default DiscoverBanner;