index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {Fragment, ReactChild} from 'react';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import {IssueCategory} from 'sentry/types';
  4. import {SpanEvidencePreview} from './spanEvidencePreview';
  5. import {StackTracePreview} from './stackTracePreview';
  6. type GroupPreviewTooltipProps = {
  7. children: ReactChild;
  8. groupId: string;
  9. issueCategory: IssueCategory;
  10. // we need eventId only when hovering over Event, not Group
  11. // (different API call is made to get the stack trace then)
  12. eventId?: string;
  13. groupingCurrentLevel?: number;
  14. projectId?: string;
  15. };
  16. const GroupPreviewTooltip = ({
  17. children,
  18. eventId,
  19. groupId,
  20. groupingCurrentLevel,
  21. issueCategory,
  22. projectId,
  23. }: GroupPreviewTooltipProps) => {
  24. const projectSlug = eventId ? ProjectsStore.getById(projectId)?.slug : undefined;
  25. switch (issueCategory) {
  26. case IssueCategory.ERROR:
  27. return (
  28. <StackTracePreview
  29. issueId={groupId}
  30. groupingCurrentLevel={groupingCurrentLevel}
  31. eventId={eventId}
  32. projectSlug={projectSlug}
  33. >
  34. {children}
  35. </StackTracePreview>
  36. );
  37. case IssueCategory.PERFORMANCE:
  38. return (
  39. <SpanEvidencePreview
  40. groupId={groupId}
  41. eventId={eventId}
  42. projectSlug={projectSlug}
  43. >
  44. {children}
  45. </SpanEvidencePreview>
  46. );
  47. default:
  48. return <Fragment>{children}</Fragment>;
  49. }
  50. };
  51. export default GroupPreviewTooltip;