eventMissingBanner.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import styled from '@emotion/styled';
  2. import compassImage from 'sentry-images/spot/onboarding-compass.svg';
  3. import {Flex} from 'sentry/components/container/flex';
  4. import Link from 'sentry/components/links/link';
  5. import {MAX_PICKABLE_DAYS} from 'sentry/constants';
  6. import {t, tct} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import {useLocation} from 'sentry/utils/useLocation';
  9. import useOrganization from 'sentry/utils/useOrganization';
  10. import {useParams} from 'sentry/utils/useParams';
  11. import {RESERVED_EVENT_IDS} from 'sentry/views/issueDetails/useGroupEvent';
  12. import {useDefaultIssueEvent} from 'sentry/views/issueDetails/utils';
  13. export function EventMissingBanner() {
  14. const location = useLocation();
  15. const organization = useOrganization();
  16. const defaultEventId = useDefaultIssueEvent();
  17. const {groupId, eventId = defaultEventId} = useParams<{
  18. eventId: string;
  19. groupId: string;
  20. }>();
  21. const baseUrl = `/organizations/${organization.slug}/issues/${groupId}/events`;
  22. const isReservedEventId = RESERVED_EVENT_IDS.has(eventId);
  23. const specificEventTips = [
  24. t(
  25. 'Double check the event ID. It may be incorrect, or its age exceeded the retention policy.'
  26. ),
  27. tct(
  28. 'Switch over to a [link:recommended] event instead, it should have more useful data.',
  29. {
  30. link: (
  31. <Link
  32. to={{
  33. pathname: `${baseUrl}/recommended/`,
  34. query: {
  35. statsPeriod: `${MAX_PICKABLE_DAYS}d`,
  36. ...(location.query.project ? {project: location.query.project} : {}),
  37. },
  38. }}
  39. aria-label={t('View recommended event')}
  40. />
  41. ),
  42. }
  43. ),
  44. ];
  45. const reservedEventTips = [
  46. t(
  47. 'Change up your filters. Try more environments, a wider date range, or a different query'
  48. ),
  49. tct('If nothing stands out, try [link:clearing your filters] all together', {
  50. link: (
  51. <Link
  52. to={{
  53. pathname: `${baseUrl}/${eventId}/`,
  54. query: {
  55. statsPeriod: `${MAX_PICKABLE_DAYS}d`,
  56. ...(location.query.project ? {project: location.query.project} : {}),
  57. },
  58. }}
  59. aria-label={t('Clear event filters')}
  60. />
  61. ),
  62. }),
  63. ];
  64. const tips = isReservedEventId ? reservedEventTips : specificEventTips;
  65. return (
  66. <Flex align="center" justify="center">
  67. <Flex align="center" gap={36}>
  68. <img src={compassImage} alt="Compass illustration" height={122} />
  69. <Flex justify="center" column gap={space(1)}>
  70. <MainText>
  71. {tct("We couldn't track down [prep] event", {
  72. prep: isReservedEventId ? 'an' : 'that',
  73. })}
  74. {!isReservedEventId && eventId ? (
  75. <EventIdText>({eventId})</EventIdText>
  76. ) : null}
  77. </MainText>
  78. <SubText>
  79. {t('If this is unexpected, here are some things to try:')}
  80. <ul style={{margin: 0}}>
  81. {tips.map((tip, i) => (
  82. <li key={i}>{tip}</li>
  83. ))}
  84. </ul>
  85. </SubText>
  86. </Flex>
  87. </Flex>
  88. </Flex>
  89. );
  90. }
  91. const MainText = styled('div')`
  92. font-size: ${p => p.theme.fontSizeExtraLarge};
  93. font-weight: ${p => p.theme.fontWeightBold};
  94. `;
  95. const SubText = styled('div')`
  96. font-size: ${p => p.theme.fontSizeMedium};
  97. font-weight: ${p => p.theme.fontWeightNormal};
  98. `;
  99. const EventIdText = styled(SubText)`
  100. font-style: italic;
  101. color: ${p => p.theme.subText};
  102. `;