eventMissingBanner.tsx 2.8 KB

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