traceLink.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import styled from '@emotion/styled';
  2. import {useAnalyticsArea} from 'sentry/components/analyticsArea';
  3. import Link from 'sentry/components/links/link';
  4. import QuestionTooltip from 'sentry/components/questionTooltip';
  5. import {generateTraceTarget} from 'sentry/components/quickTrace/utils';
  6. import {IconChevron} from 'sentry/icons';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import type {Event} from 'sentry/types/event';
  10. import {trackAnalytics} from 'sentry/utils/analytics';
  11. import {useLocation} from 'sentry/utils/useLocation';
  12. import useOrganization from 'sentry/utils/useOrganization';
  13. import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceHeader/breadcrumbs';
  14. interface TraceLinkProps {
  15. event: Event;
  16. }
  17. export function TraceLink({event}: TraceLinkProps) {
  18. const organization = useOrganization();
  19. const location = useLocation();
  20. const area = useAnalyticsArea();
  21. const traceTarget = generateTraceTarget(
  22. event,
  23. organization,
  24. {
  25. ...location,
  26. query: {
  27. ...location.query,
  28. groupId: event.groupID,
  29. },
  30. },
  31. area.startsWith('feedback')
  32. ? TraceViewSources.FEEDBACK_DETAILS
  33. : TraceViewSources.ISSUE_DETAILS
  34. // area can be leveraged for other TraceViewSources, but right now these
  35. // are the only 2 that use a TraceLink.
  36. );
  37. if (!event.contexts?.trace?.trace_id) {
  38. return (
  39. <NoTraceAvailable>
  40. {t('No Trace Available')}
  41. <QuestionTooltip
  42. position="bottom"
  43. size="sm"
  44. title={t(
  45. 'Traces help you understand if there are any issues with other services connected to this event'
  46. )}
  47. />
  48. </NoTraceAvailable>
  49. );
  50. }
  51. return (
  52. <StyledLink
  53. to={traceTarget}
  54. onClick={() => {
  55. // Source used to be hard-coded here, we keep the old value of issue details for backwards compatibility.
  56. trackAnalytics('quick_trace.trace_id.clicked', {
  57. organization,
  58. source: area.includes('issue_details') ? 'issues' : area,
  59. });
  60. }}
  61. >
  62. <span>{t('View Full Trace')}</span>
  63. <IconChevron direction="right" size="xs" />
  64. </StyledLink>
  65. );
  66. }
  67. const StyledLink = styled(Link)`
  68. display: flex;
  69. align-items: center;
  70. gap: ${space(0.25)};
  71. line-height: 1.2;
  72. font-size: ${p => p.theme.fontSizeMedium};
  73. svg {
  74. margin-top: 1px;
  75. }
  76. `;
  77. const NoTraceAvailable = styled('span')`
  78. display: flex;
  79. align-items: center;
  80. gap: ${space(0.25)};
  81. line-height: 1.2;
  82. color: ${p => p.theme.subText};
  83. font-size: ${p => p.theme.fontSizeMedium};
  84. svg {
  85. margin-top: 1px;
  86. }
  87. `;