issueQuickTrace.tsx 3.2 KB

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