traceLink.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 {useLocation} from 'sentry/utils/useLocation';
  11. import useOrganization from 'sentry/utils/useOrganization';
  12. import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceMetadataHeader';
  13. interface TraceLinkProps {
  14. event: Event;
  15. }
  16. export function TraceLink({event}: TraceLinkProps) {
  17. const organization = useOrganization();
  18. const location = useLocation();
  19. const traceTarget = generateTraceTarget(
  20. event,
  21. organization,
  22. {
  23. ...location,
  24. query: {
  25. ...location.query,
  26. groupId: event.groupID,
  27. },
  28. },
  29. TraceViewSources.ISSUE_DETAILS
  30. );
  31. if (!event.contexts?.trace?.trace_id) {
  32. return (
  33. <NoTraceAvailable>
  34. {t('No Trace Available')}
  35. <QuestionTooltip
  36. position="bottom"
  37. size="sm"
  38. title={t(
  39. 'Traces help you understand if there are any issues with other services connected to this event'
  40. )}
  41. />
  42. </NoTraceAvailable>
  43. );
  44. }
  45. return (
  46. <StyledLink
  47. to={traceTarget}
  48. onClick={() => {
  49. trackAnalytics('quick_trace.trace_id.clicked', {
  50. organization,
  51. source: 'issues',
  52. });
  53. }}
  54. >
  55. <span>{t('View Full Trace')}</span>
  56. <IconChevron direction="right" size="xs" />
  57. </StyledLink>
  58. );
  59. }
  60. const StyledLink = styled(Link)`
  61. display: flex;
  62. align-items: center;
  63. gap: ${space(0.25)};
  64. line-height: 1.2;
  65. font-size: ${p => p.theme.fontSizeMedium};
  66. svg {
  67. margin-top: 1px;
  68. }
  69. `;
  70. const NoTraceAvailable = styled('span')`
  71. display: flex;
  72. align-items: center;
  73. gap: ${space(0.25)};
  74. line-height: 1.2;
  75. color: ${p => p.theme.subText};
  76. font-size: ${p => p.theme.fontSizeMedium};
  77. svg {
  78. margin-top: 1px;
  79. }
  80. `;