traceLink.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import styled from '@emotion/styled';
  2. import Link from 'sentry/components/links/link';
  3. import {generateTraceTarget} from 'sentry/components/quickTrace/utils';
  4. import {IconChevron} from 'sentry/icons';
  5. import {t, tn} from 'sentry/locale';
  6. import {space} from 'sentry/styles/space';
  7. import type {Event} from 'sentry/types';
  8. import {trackAnalytics} from 'sentry/utils/analytics';
  9. import useOrganization from 'sentry/utils/useOrganization';
  10. import {useTraceTimelineEvents} from './useTraceTimelineEvents';
  11. interface TraceLinkProps {
  12. event: Event;
  13. }
  14. export function TraceLink({event}: TraceLinkProps) {
  15. const organization = useOrganization();
  16. const {data} = useTraceTimelineEvents({event});
  17. const traceTarget = generateTraceTarget(event, organization);
  18. if (!event.contexts?.trace?.trace_id) {
  19. return null;
  20. }
  21. return (
  22. <StyledLink
  23. to={traceTarget}
  24. onClick={() => {
  25. trackAnalytics('quick_trace.trace_id.clicked', {
  26. organization,
  27. source: 'issues',
  28. });
  29. }}
  30. >
  31. <span>
  32. {t('View Full Trace')}
  33. {data.length > 0 && tn(' (%s issue)', ' (%s issues)', data.length)}
  34. </span>
  35. <IconChevron direction="right" size="xs" />
  36. </StyledLink>
  37. );
  38. }
  39. const StyledLink = styled(Link)`
  40. display: flex;
  41. align-items: center;
  42. gap: ${space(0.25)};
  43. line-height: 1.2;
  44. font-size: ${p => p.theme.fontSizeMedium};
  45. `;