traceDataSection.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {t} from 'sentry/locale';
  4. import {space} from 'sentry/styles/space';
  5. import type {Event} from 'sentry/types/event';
  6. import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
  7. import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
  8. import {TraceIssueEvent} from './traceTimeline/traceIssue';
  9. import {TraceLink} from './traceTimeline/traceLink';
  10. import {TraceTimeline} from './traceTimeline/traceTimeline';
  11. import {useTraceTimelineEvents} from './traceTimeline/useTraceTimelineEvents';
  12. export function TraceDataSection({event}: {event: Event}) {
  13. const hasStreamlinedUI = useHasStreamlinedUI();
  14. // This is also called within the TraceTimeline component but caching will save a second call
  15. const {isLoading, oneOtherIssueEvent, traceEvents} = useTraceTimelineEvents({
  16. event,
  17. });
  18. let params: Record<string, boolean> = {};
  19. if (!isLoading && oneOtherIssueEvent !== undefined) {
  20. params = {
  21. has_related_trace_issue: true,
  22. };
  23. }
  24. useRouteAnalyticsParams(params);
  25. if (isLoading) {
  26. return null;
  27. }
  28. const noEvents = !isLoading && traceEvents.length === 0;
  29. if (hasStreamlinedUI && (!oneOtherIssueEvent || noEvents)) {
  30. return null;
  31. }
  32. return (
  33. <Fragment>
  34. <StyledTraceLink>
  35. {/* Used for trace-related issue */}
  36. {oneOtherIssueEvent && (
  37. <span>{t('One other issue appears in the same trace.')}</span>
  38. )}
  39. <TraceLink event={event} />
  40. </StyledTraceLink>
  41. {oneOtherIssueEvent === undefined ? (
  42. <TraceTimeline event={event} />
  43. ) : (
  44. <TraceIssueEvent event={oneOtherIssueEvent} />
  45. )}
  46. </Fragment>
  47. );
  48. }
  49. const StyledTraceLink = styled('div')`
  50. display: flex;
  51. white-space: nowrap;
  52. overflow: hidden;
  53. gap: ${space(0.25)};
  54. `;