traceLink.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import styled from '@emotion/styled';
  2. import Link from 'sentry/components/links/link';
  3. import QuestionTooltip from 'sentry/components/questionTooltip';
  4. import {generateTraceTarget} from 'sentry/components/quickTrace/utils';
  5. import {IconChevron} from 'sentry/icons';
  6. import {t} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import type {Event} from 'sentry/types/event';
  9. import {trackAnalytics} from 'sentry/utils/analytics';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. interface TraceLinkProps {
  12. event: Event;
  13. }
  14. export function TraceLink({event}: TraceLinkProps) {
  15. const organization = useOrganization();
  16. const traceTarget = generateTraceTarget(event, organization);
  17. if (!event.contexts?.trace?.trace_id) {
  18. return (
  19. <NoTraceAvailable>
  20. {t('No Trace Available')}
  21. <QuestionTooltip
  22. position="bottom"
  23. size="sm"
  24. title={t(
  25. 'Traces help you understand if there are any issues with other services connected to this event'
  26. )}
  27. />
  28. </NoTraceAvailable>
  29. );
  30. }
  31. return (
  32. <StyledLink
  33. to={traceTarget}
  34. onClick={() => {
  35. trackAnalytics('quick_trace.trace_id.clicked', {
  36. organization,
  37. source: 'issues',
  38. });
  39. }}
  40. >
  41. <span>{t('View Full Trace')}</span>
  42. <IconChevron direction="right" size="xs" />
  43. </StyledLink>
  44. );
  45. }
  46. const StyledLink = styled(Link)`
  47. display: flex;
  48. align-items: center;
  49. gap: ${space(0.25)};
  50. line-height: 1.2;
  51. font-size: ${p => p.theme.fontSizeMedium};
  52. svg {
  53. margin-top: 1px;
  54. }
  55. `;
  56. const NoTraceAvailable = styled('span')`
  57. display: flex;
  58. align-items: center;
  59. gap: ${space(0.25)};
  60. line-height: 1.2;
  61. color: ${p => p.theme.subText};
  62. font-size: ${p => p.theme.fontSizeMedium};
  63. svg {
  64. margin-top: 1px;
  65. }
  66. `;