replaySearchAlert.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {Fragment} from 'react';
  2. import {browserHistory} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import {ModalRenderProps, openModal} from 'sentry/actionCreators/modal';
  5. import {Button} from 'sentry/components/button';
  6. import ExternalLink from 'sentry/components/links/externalLink';
  7. import {ReplayNewFeatureBanner} from 'sentry/components/replays/replayNewFeatureBanner';
  8. import {IconBroadcast} from 'sentry/icons';
  9. import {t, tct} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import useDismissAlert from 'sentry/utils/useDismissAlert';
  12. import {useLocation} from 'sentry/utils/useLocation';
  13. const REPLAY_CLICK_SEARCH_FEATURE_BANNER_KEY = 'new-feature-banner-replays-click-search';
  14. interface Props {
  15. needSdkUpdates: boolean;
  16. }
  17. export function ReplaySearchAlert({needSdkUpdates}: Props) {
  18. const location = useLocation();
  19. const {dismiss, isDismissed} = useDismissAlert({
  20. key: REPLAY_CLICK_SEARCH_FEATURE_BANNER_KEY,
  21. });
  22. if (isDismissed) {
  23. return null;
  24. }
  25. const heading = (
  26. <Fragment>
  27. {tct('Introducing [feature]', {
  28. feature: (
  29. <ExternalLink href="https://blog.sentry.io/introducing-search-by-user-click-for-session-replay-zero-in-on-interesting/">
  30. {t('Click Search')}
  31. </ExternalLink>
  32. ),
  33. })}
  34. </Fragment>
  35. );
  36. const description = (
  37. <span>
  38. {tct(
  39. `Find replays which captured specific DOM elements using our new search key [key]`,
  40. {
  41. key: <strong>{t("'click'")}</strong>,
  42. }
  43. )}
  44. </span>
  45. );
  46. const handleTryNow = () => {
  47. browserHistory.push({
  48. ...location,
  49. query: {
  50. ...location.query,
  51. query: 'click.tag:button',
  52. },
  53. });
  54. dismiss();
  55. };
  56. const handleLearnMore = () => {
  57. openModal(LearnMoreModal);
  58. };
  59. if (isDismissed) {
  60. return null;
  61. }
  62. if (needSdkUpdates) {
  63. return (
  64. <ReplayNewFeatureBanner
  65. heading={heading}
  66. description={description}
  67. button={
  68. <Button priority="primary" onClick={handleLearnMore}>
  69. {t('Learn More')}
  70. </Button>
  71. }
  72. />
  73. );
  74. }
  75. return (
  76. <ReplayNewFeatureBanner
  77. heading={heading}
  78. description={description}
  79. button={
  80. <Button priority="primary" onClick={handleTryNow}>
  81. {t('Try Now')}
  82. </Button>
  83. }
  84. />
  85. );
  86. }
  87. function LearnMoreModal({Header, Body, Footer, closeModal}: ModalRenderProps) {
  88. return (
  89. <Fragment>
  90. <Header>
  91. <ModalHeaderContainer>
  92. <IconBroadcast />
  93. <h2>{t('Click Search')}</h2>
  94. </ModalHeaderContainer>
  95. </Header>
  96. <Body>
  97. <p>
  98. {t(
  99. 'Search by user click is a new feature which allows you to search for replays by DOM element - or in other words - where users have clicked to interact with specific parts of your web app.'
  100. )}
  101. </p>
  102. <strong>{t('Prerequisites')}</strong>
  103. <ul>
  104. <li>{t('JavaScript SDK Version is >= 7.44.0')}</li>
  105. </ul>
  106. </Body>
  107. <Footer>
  108. <Button priority="primary" onClick={closeModal}>
  109. {t('Got it')}
  110. </Button>
  111. </Footer>
  112. </Fragment>
  113. );
  114. }
  115. const ModalHeaderContainer = styled('div')`
  116. display: flex;
  117. align-items: center;
  118. gap: ${space(1)};
  119. `;