issueQuickTrace.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import styled from '@emotion/styled';
  2. import {Location} from 'history';
  3. import ErrorBoundary from 'sentry/components/errorBoundary';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import QuickTrace from 'sentry/components/quickTrace';
  6. import {
  7. ErrorNodeContent,
  8. EventNode,
  9. QuickTraceContainer,
  10. TraceConnector,
  11. } from 'sentry/components/quickTrace/styles';
  12. import {IconFire} from 'sentry/icons';
  13. import {t, tct} from 'sentry/locale';
  14. import {space} from 'sentry/styles/space';
  15. import {Group, Organization} from 'sentry/types';
  16. import {Event} from 'sentry/types/event';
  17. import {defined} from 'sentry/utils';
  18. import {QuickTraceQueryChildrenProps} from 'sentry/utils/performance/quickTrace/types';
  19. import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
  20. import {TraceLink} from 'sentry/views/issueDetails/quickTrace/traceLink';
  21. type Props = {
  22. event: Event;
  23. group: Group;
  24. location: Location;
  25. organization: Organization;
  26. quickTrace: undefined | QuickTraceQueryChildrenProps;
  27. };
  28. function TransactionMissingPlaceholder({
  29. type,
  30. event,
  31. }: {
  32. event: Event;
  33. type?: QuickTraceQueryChildrenProps['type'];
  34. }) {
  35. useRouteAnalyticsParams({
  36. trace_status: type === 'missing' ? 'transaction missing' : 'trace missing',
  37. });
  38. return (
  39. <QuickTraceWrapper>
  40. <QuickTraceContainer data-test-id="missing-trace-placeholder">
  41. <EventNode
  42. type="white"
  43. icon={null}
  44. tooltipProps={{isHoverable: true, position: 'bottom'}}
  45. tooltipText={tct(
  46. 'The [type] for this event cannot be found. [link:Read the docs] to understand why.',
  47. {
  48. type: type === 'missing' ? t('transaction') : t('trace'),
  49. link: (
  50. <ExternalLink href="https://docs.sentry.io/product/sentry-basics/tracing/trace-view/#troubleshooting" />
  51. ),
  52. }
  53. )}
  54. >
  55. ???
  56. </EventNode>
  57. <TraceConnector />
  58. <EventNode type="error" data-test-id="event-node">
  59. <ErrorNodeContent>
  60. <IconFire size="xs" />
  61. {t('This Event')}
  62. </ErrorNodeContent>
  63. </EventNode>
  64. <TraceLink event={event} />
  65. </QuickTraceContainer>
  66. </QuickTraceWrapper>
  67. );
  68. }
  69. function IssueQuickTrace({event, location, organization, quickTrace}: Props) {
  70. const shouldShowPlaceholder =
  71. !quickTrace ||
  72. quickTrace.error ||
  73. !defined(quickTrace.trace) ||
  74. quickTrace.trace.length === 0;
  75. useRouteAnalyticsParams(shouldShowPlaceholder ? {} : {trace_status: 'success'});
  76. if (shouldShowPlaceholder) {
  77. return <TransactionMissingPlaceholder event={event} type={quickTrace?.type} />;
  78. }
  79. return (
  80. <ErrorBoundary mini>
  81. <QuickTraceWrapper>
  82. <QuickTrace
  83. event={event}
  84. quickTrace={quickTrace}
  85. location={location}
  86. organization={organization}
  87. anchor="left"
  88. errorDest="issue"
  89. transactionDest="performance"
  90. />
  91. <TraceLink event={event} />
  92. </QuickTraceWrapper>
  93. </ErrorBoundary>
  94. );
  95. }
  96. const QuickTraceWrapper = styled('div')`
  97. display: flex;
  98. align-items: center;
  99. flex-wrap: wrap;
  100. margin-top: ${space(0.75)};
  101. `;
  102. export default IssueQuickTrace;