issueQuickTrace.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import styled from '@emotion/styled';
  2. import {Location} from 'history';
  3. import {Alert} from 'sentry/components/alert';
  4. import {Button} from 'sentry/components/button';
  5. import ErrorBoundary from 'sentry/components/errorBoundary';
  6. import ExternalLink from 'sentry/components/links/externalLink';
  7. import QuickTrace from 'sentry/components/quickTrace';
  8. import {IconClose} from 'sentry/icons';
  9. import {t, tct} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import {Organization} from 'sentry/types';
  12. import {Event} from 'sentry/types/event';
  13. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  14. import {QuickTraceQueryChildrenProps} from 'sentry/utils/performance/quickTrace/types';
  15. import usePromptCheck from 'sentry/views/issueDetails/quickTrace/usePromptCheck';
  16. type Props = {
  17. event: Event;
  18. location: Location;
  19. organization: Organization;
  20. quickTrace: undefined | QuickTraceQueryChildrenProps;
  21. isPerformanceIssue?: boolean;
  22. };
  23. function IssueQuickTrace({
  24. event,
  25. location,
  26. organization,
  27. quickTrace,
  28. isPerformanceIssue,
  29. }: Props) {
  30. const {shouldShowPrompt, snoozePrompt} = usePromptCheck({
  31. projectId: event.projectID,
  32. feature: 'quick_trace_missing',
  33. organization,
  34. });
  35. if (
  36. !quickTrace ||
  37. quickTrace.error ||
  38. quickTrace.trace === null ||
  39. quickTrace.trace.length === 0
  40. ) {
  41. if (!shouldShowPrompt) {
  42. return null;
  43. }
  44. trackAdvancedAnalyticsEvent('issue.quick_trace_status', {
  45. organization,
  46. status: quickTrace?.type === 'missing' ? 'transaction missing' : 'trace missing',
  47. is_performance_issue: isPerformanceIssue ?? false,
  48. });
  49. return (
  50. <StyledAlert
  51. type="info"
  52. showIcon
  53. trailingItems={
  54. <Button
  55. aria-label={t('Remind me later')}
  56. title={t('Dismiss for a month')}
  57. priority="link"
  58. size="xs"
  59. icon={<IconClose />}
  60. onClick={snoozePrompt}
  61. />
  62. }
  63. >
  64. {tct(
  65. 'The [type] for this event cannot be found. [link:Read the docs to understand why].',
  66. {
  67. type: quickTrace?.type === 'missing' ? t('transaction') : t('trace'),
  68. link: (
  69. <ExternalLink href="https://docs.sentry.io/product/sentry-basics/tracing/trace-view/#troubleshooting" />
  70. ),
  71. }
  72. )}
  73. </StyledAlert>
  74. );
  75. }
  76. trackAdvancedAnalyticsEvent('issue.quick_trace_status', {
  77. organization,
  78. status: 'success',
  79. is_performance_issue: isPerformanceIssue ?? false,
  80. });
  81. return (
  82. <ErrorBoundary mini>
  83. <QuickTraceWrapper>
  84. <QuickTrace
  85. event={event}
  86. quickTrace={quickTrace}
  87. location={location}
  88. organization={organization}
  89. anchor="left"
  90. errorDest="issue"
  91. transactionDest="performance"
  92. />
  93. </QuickTraceWrapper>
  94. </ErrorBoundary>
  95. );
  96. }
  97. const QuickTraceWrapper = styled('div')`
  98. margin-top: ${space(0.5)};
  99. `;
  100. const StyledAlert = styled(Alert)`
  101. margin: ${space(1)} 0;
  102. `;
  103. export default IssueQuickTrace;