traceTimelineOrRelatedIssue.tsx 1.6 KB

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