groupEventDetailsContent.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. import {Fragment, lazy, useMemo, useRef} from 'react';
  2. import {ClassNames} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. import {usePrompt} from 'sentry/actionCreators/prompts';
  5. import GuideAnchor from 'sentry/components/assistant/guideAnchor';
  6. import {Button} from 'sentry/components/button';
  7. import {CommitRow} from 'sentry/components/commitRow';
  8. import ErrorBoundary from 'sentry/components/errorBoundary';
  9. import BreadcrumbsDataSection from 'sentry/components/events/breadcrumbs/breadcrumbsDataSection';
  10. import {EventContexts} from 'sentry/components/events/contexts';
  11. import {EventDevice} from 'sentry/components/events/device';
  12. import {EventAttachments} from 'sentry/components/events/eventAttachments';
  13. import {EventDataSection} from 'sentry/components/events/eventDataSection';
  14. import {EventEvidence} from 'sentry/components/events/eventEvidence';
  15. import {EventExtraData} from 'sentry/components/events/eventExtraData';
  16. import EventHydrationDiff from 'sentry/components/events/eventHydrationDiff';
  17. import {EventProcessingErrors} from 'sentry/components/events/eventProcessingErrors';
  18. import EventReplay from 'sentry/components/events/eventReplay';
  19. import {EventSdk} from 'sentry/components/events/eventSdk';
  20. import AggregateSpanDiff from 'sentry/components/events/eventStatisticalDetector/aggregateSpanDiff';
  21. import EventBreakpointChart from 'sentry/components/events/eventStatisticalDetector/breakpointChart';
  22. import EventComparison from 'sentry/components/events/eventStatisticalDetector/eventComparison';
  23. import {EventDifferentialFlamegraph} from 'sentry/components/events/eventStatisticalDetector/eventDifferentialFlamegraph';
  24. import {EventRegressionSummary} from 'sentry/components/events/eventStatisticalDetector/eventRegressionSummary';
  25. import {EventFunctionBreakpointChart} from 'sentry/components/events/eventStatisticalDetector/functionBreakpointChart';
  26. import {EventTagsAndScreenshot} from 'sentry/components/events/eventTagsAndScreenshot';
  27. import {ScreenshotDataSection} from 'sentry/components/events/eventTagsAndScreenshot/screenshot/screenshotDataSection';
  28. import EventTagsDataSection from 'sentry/components/events/eventTagsAndScreenshot/tags';
  29. import {EventViewHierarchy} from 'sentry/components/events/eventViewHierarchy';
  30. import {EventFeatureFlagList} from 'sentry/components/events/featureFlags/eventFeatureFlagList';
  31. import {EventGroupingInfoSection} from 'sentry/components/events/groupingInfo/groupingInfoSection';
  32. import HighlightsDataSection from 'sentry/components/events/highlights/highlightsDataSection';
  33. import {HighlightsIconSummary} from 'sentry/components/events/highlights/highlightsIconSummary';
  34. import {ActionableItems} from 'sentry/components/events/interfaces/crashContent/exception/actionableItems';
  35. import {actionableItemsEnabled} from 'sentry/components/events/interfaces/crashContent/exception/useActionableItems';
  36. import {CronTimelineSection} from 'sentry/components/events/interfaces/crons/cronTimelineSection';
  37. import {Csp} from 'sentry/components/events/interfaces/csp';
  38. import {DebugMeta} from 'sentry/components/events/interfaces/debugMeta';
  39. import {Exception} from 'sentry/components/events/interfaces/exception';
  40. import {Generic} from 'sentry/components/events/interfaces/generic';
  41. import {Message} from 'sentry/components/events/interfaces/message';
  42. import {AnrRootCause} from 'sentry/components/events/interfaces/performance/anrRootCause';
  43. import {EventTraceView} from 'sentry/components/events/interfaces/performance/eventTraceView';
  44. import {SpanEvidenceSection} from 'sentry/components/events/interfaces/performance/spanEvidence';
  45. import {Request} from 'sentry/components/events/interfaces/request';
  46. import {StackTrace} from 'sentry/components/events/interfaces/stackTrace';
  47. import {Template} from 'sentry/components/events/interfaces/template';
  48. import {Threads} from 'sentry/components/events/interfaces/threads';
  49. import {UptimeDataSection} from 'sentry/components/events/interfaces/uptime/uptimeDataSection';
  50. import {EventPackageData} from 'sentry/components/events/packageData';
  51. import {EventRRWebIntegration} from 'sentry/components/events/rrwebIntegration';
  52. import {DataSection} from 'sentry/components/events/styles';
  53. import {SuspectCommits} from 'sentry/components/events/suspectCommits';
  54. import {EventUserFeedback} from 'sentry/components/events/userFeedback';
  55. import LazyLoad from 'sentry/components/lazyLoad';
  56. import Placeholder from 'sentry/components/placeholder';
  57. import {IconChevron} from 'sentry/icons';
  58. import {t} from 'sentry/locale';
  59. import {space} from 'sentry/styles/space';
  60. import type {Entry, EntryException, Event, EventTransaction} from 'sentry/types/event';
  61. import {EntryType, EventOrGroupType} from 'sentry/types/event';
  62. import type {Group} from 'sentry/types/group';
  63. import {IssueCategory} from 'sentry/types/group';
  64. import type {Project} from 'sentry/types/project';
  65. import {defined} from 'sentry/utils';
  66. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  67. import {QuickTraceContext} from 'sentry/utils/performance/quickTrace/quickTraceContext';
  68. import QuickTraceQuery from 'sentry/utils/performance/quickTrace/quickTraceQuery';
  69. import {getReplayIdFromEvent} from 'sentry/utils/replays/getReplayIdFromEvent';
  70. import {useLocation} from 'sentry/utils/useLocation';
  71. import useOrganization from 'sentry/utils/useOrganization';
  72. import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
  73. import {EventDetails} from 'sentry/views/issueDetails/streamline/eventDetails';
  74. import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
  75. import {TraceDataSection} from 'sentry/views/issueDetails/traceDataSection';
  76. import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
  77. import MetricIssuesSection from '../metricIssuesSection';
  78. const LLMMonitoringSection = lazy(
  79. () => import('sentry/components/events/interfaces/llm-monitoring/llmMonitoringSection')
  80. );
  81. export interface EventDetailsContentProps {
  82. group: Group;
  83. project: Project;
  84. event?: Event;
  85. }
  86. export function EventDetailsContent({
  87. group,
  88. event,
  89. project,
  90. }: Required<Pick<EventDetailsContentProps, 'group' | 'event' | 'project'>>) {
  91. const organization = useOrganization();
  92. const location = useLocation();
  93. const hasStreamlinedUI = useHasStreamlinedUI();
  94. const tagsRef = useRef<HTMLDivElement>(null);
  95. const eventEntries = useMemo(() => {
  96. const {entries = []} = event;
  97. return entries.reduce<{[key in EntryType]?: Entry}>((entryMap, entry) => {
  98. entryMap[entry.type] = entry;
  99. return entryMap;
  100. }, {});
  101. }, [event]);
  102. const projectSlug = project.slug;
  103. const hasReplay = Boolean(getReplayIdFromEvent(event));
  104. const mechanism = event.tags?.find(({key}) => key === 'mechanism')?.value;
  105. const isANR = mechanism === 'ANR' || mechanism === 'AppExitInfo';
  106. const groupingCurrentLevel = group?.metadata?.current_level;
  107. const hasActionableItems = actionableItemsEnabled({
  108. eventId: event.id,
  109. organization,
  110. projectSlug,
  111. });
  112. const {
  113. isLoading: promptLoading,
  114. isError: promptError,
  115. isPromptDismissed,
  116. dismissPrompt,
  117. showPrompt,
  118. } = usePrompt({
  119. feature: 'issue_feedback_hidden',
  120. organization,
  121. projectId: project.id,
  122. });
  123. // default to show on error or isPromptDismissed === undefined
  124. const showFeedback = !isPromptDismissed || promptError || hasStreamlinedUI;
  125. const issueTypeConfig = getConfigForIssueType(group, group.project);
  126. return (
  127. <Fragment>
  128. {hasStreamlinedUI && <HighlightsIconSummary event={event} group={group} />}
  129. {hasActionableItems && !hasStreamlinedUI && (
  130. <ActionableItems event={event} project={project} isShare={false} />
  131. )}
  132. {issueTypeConfig.tags.enabled && (
  133. <HighlightsDataSection event={event} project={project} viewAllRef={tagsRef} />
  134. )}
  135. <StyledDataSection>
  136. {!hasStreamlinedUI && <TraceDataSection event={event} />}
  137. {!hasStreamlinedUI && (
  138. <SuspectCommits
  139. projectSlug={project.slug}
  140. eventId={event.id}
  141. group={group}
  142. commitRow={CommitRow}
  143. />
  144. )}
  145. </StyledDataSection>
  146. {event.userReport && (
  147. <InterimSection
  148. title={t('User Feedback')}
  149. type={SectionKey.USER_FEEDBACK}
  150. actions={
  151. hasStreamlinedUI ? null : (
  152. <ErrorBoundary mini>
  153. <Button
  154. size="xs"
  155. icon={<IconChevron direction={showFeedback ? 'up' : 'down'} />}
  156. onClick={showFeedback ? dismissPrompt : showPrompt}
  157. title={
  158. showFeedback
  159. ? t('Hide feedback on all issue details')
  160. : t('Unhide feedback on all issue details')
  161. }
  162. disabled={promptError}
  163. busy={promptLoading}
  164. >
  165. {showFeedback ? t('Hide') : t('Show')}
  166. </Button>
  167. </ErrorBoundary>
  168. )
  169. }
  170. >
  171. {promptLoading ? (
  172. <Placeholder />
  173. ) : showFeedback ? (
  174. <EventUserFeedback
  175. report={event.userReport}
  176. orgSlug={organization.slug}
  177. issueId={group.id}
  178. showEventLink={false}
  179. />
  180. ) : null}
  181. </InterimSection>
  182. )}
  183. {event.type === EventOrGroupType.ERROR &&
  184. organization.features.includes('insights-addon-modules') &&
  185. event?.entries
  186. ?.filter((x): x is EntryException => x.type === EntryType.EXCEPTION)
  187. .flatMap(x => x.data.values ?? [])
  188. .some(({value}) => {
  189. const lowerText = value?.toLowerCase();
  190. return (
  191. lowerText &&
  192. (lowerText.includes('api key') || lowerText.includes('429')) &&
  193. (lowerText.includes('openai') ||
  194. lowerText.includes('anthropic') ||
  195. lowerText.includes('cohere') ||
  196. lowerText.includes('langchain'))
  197. );
  198. }) ? (
  199. <LazyLoad
  200. LazyComponent={LLMMonitoringSection}
  201. event={event}
  202. organization={organization}
  203. />
  204. ) : null}
  205. {group.issueCategory === IssueCategory.UPTIME && (
  206. <UptimeDataSection event={event} project={project} group={group} />
  207. )}
  208. {group.issueCategory === IssueCategory.CRON && (
  209. <CronTimelineSection
  210. event={event}
  211. organization={organization}
  212. project={project}
  213. />
  214. )}
  215. {event.contexts?.metric_alert?.alert_rule_id && (
  216. <MetricIssuesSection
  217. organization={organization}
  218. group={group}
  219. event={event}
  220. project={project}
  221. />
  222. )}
  223. <EventEvidence event={event} group={group} project={project} />
  224. {defined(eventEntries[EntryType.MESSAGE]) && (
  225. <EntryErrorBoundary type={EntryType.MESSAGE}>
  226. <Message event={event} data={eventEntries[EntryType.MESSAGE].data} />
  227. </EntryErrorBoundary>
  228. )}
  229. {/* Wrapping all stacktrace components since multiple could appear */}
  230. <ClassNames>
  231. {({css}) => (
  232. <GuideAnchor
  233. target="stacktrace"
  234. position="top"
  235. disabled={
  236. !(
  237. defined(eventEntries[EntryType.EXCEPTION]) ||
  238. defined(eventEntries[EntryType.STACKTRACE]) ||
  239. defined(eventEntries[EntryType.THREADS])
  240. )
  241. }
  242. // Prevent the container span from shrinking the content
  243. containerClassName={css`
  244. display: block !important;
  245. `}
  246. >
  247. {defined(eventEntries[EntryType.EXCEPTION]) && (
  248. <EntryErrorBoundary type={EntryType.EXCEPTION}>
  249. <Exception
  250. event={event}
  251. data={eventEntries[EntryType.EXCEPTION].data}
  252. projectSlug={project.slug}
  253. group={group}
  254. groupingCurrentLevel={groupingCurrentLevel}
  255. />
  256. </EntryErrorBoundary>
  257. )}
  258. {issueTypeConfig.stacktrace.enabled &&
  259. defined(eventEntries[EntryType.STACKTRACE]) && (
  260. <EntryErrorBoundary type={EntryType.STACKTRACE}>
  261. <StackTrace
  262. event={event}
  263. data={eventEntries[EntryType.STACKTRACE].data}
  264. projectSlug={projectSlug}
  265. groupingCurrentLevel={groupingCurrentLevel}
  266. />
  267. </EntryErrorBoundary>
  268. )}
  269. {defined(eventEntries[EntryType.THREADS]) && (
  270. <EntryErrorBoundary type={EntryType.THREADS}>
  271. <Threads
  272. event={event}
  273. data={eventEntries[EntryType.THREADS].data}
  274. projectSlug={project.slug}
  275. groupingCurrentLevel={groupingCurrentLevel}
  276. group={group}
  277. />
  278. </EntryErrorBoundary>
  279. )}
  280. </GuideAnchor>
  281. )}
  282. </ClassNames>
  283. {defined(eventEntries[EntryType.DEBUGMETA]) && (
  284. <EntryErrorBoundary type={EntryType.DEBUGMETA}>
  285. <DebugMeta
  286. event={event}
  287. projectSlug={projectSlug}
  288. groupId={group?.id}
  289. data={eventEntries[EntryType.DEBUGMETA].data}
  290. />
  291. </EntryErrorBoundary>
  292. )}
  293. {hasStreamlinedUI && (
  294. <ScreenshotDataSection event={event} projectSlug={project.slug} />
  295. )}
  296. {isANR && (
  297. <QuickTraceQuery
  298. event={event}
  299. location={location}
  300. orgSlug={organization.slug}
  301. type={'spans'}
  302. skipLight
  303. >
  304. {results => {
  305. return (
  306. <QuickTraceContext.Provider value={results}>
  307. <AnrRootCause event={event} organization={organization} />
  308. </QuickTraceContext.Provider>
  309. );
  310. }}
  311. </QuickTraceQuery>
  312. )}
  313. {issueTypeConfig.spanEvidence.enabled && (
  314. <SpanEvidenceSection
  315. event={event as EventTransaction}
  316. organization={organization}
  317. projectSlug={project.slug}
  318. />
  319. )}
  320. {issueTypeConfig.regression.enabled && (
  321. <ErrorBoundary mini>
  322. <EventRegressionSummary event={event} group={group} />
  323. </ErrorBoundary>
  324. )}
  325. {issueTypeConfig.performanceDurationRegression.enabled && (
  326. <Fragment>
  327. <ErrorBoundary mini>
  328. <EventBreakpointChart event={event} />
  329. </ErrorBoundary>
  330. <ErrorBoundary mini>
  331. <AggregateSpanDiff event={event} project={project} />
  332. </ErrorBoundary>
  333. <ErrorBoundary mini>
  334. <EventComparison event={event} project={project} />
  335. </ErrorBoundary>
  336. </Fragment>
  337. )}
  338. {issueTypeConfig.profilingDurationRegression.enabled && (
  339. <Fragment>
  340. <ErrorBoundary mini>
  341. <EventFunctionBreakpointChart event={event} />
  342. </ErrorBoundary>
  343. <ErrorBoundary mini>
  344. <InterimSection
  345. type={SectionKey.REGRESSION_FLAMEGRAPH}
  346. title={t('Regression Flamegraph')}
  347. >
  348. <b>{t('Largest Changes in Call Stack Frequency')}</b>
  349. <p>
  350. {t(`See which functions changed the most before and after the regression. The
  351. frame with the largest increase in call stack population likely
  352. contributed to the cause for the duration regression.`)}
  353. </p>
  354. <EventDifferentialFlamegraph event={event} />
  355. </InterimSection>
  356. </ErrorBoundary>
  357. </Fragment>
  358. )}
  359. <EventHydrationDiff event={event} group={group} />
  360. {issueTypeConfig.replays.enabled && (
  361. <EventReplay event={event} group={group} projectSlug={project.slug} />
  362. )}
  363. {defined(eventEntries[EntryType.HPKP]) && (
  364. <EntryErrorBoundary type={EntryType.HPKP}>
  365. <Generic
  366. type={EntryType.HPKP}
  367. data={eventEntries[EntryType.HPKP].data}
  368. meta={event._meta?.hpkp ?? {}}
  369. />
  370. </EntryErrorBoundary>
  371. )}
  372. {defined(eventEntries[EntryType.CSP]) && (
  373. <EntryErrorBoundary type={EntryType.CSP}>
  374. <Csp event={event} data={eventEntries[EntryType.CSP].data} />
  375. </EntryErrorBoundary>
  376. )}
  377. {defined(eventEntries[EntryType.EXPECTCT]) && (
  378. <EntryErrorBoundary type={EntryType.EXPECTCT}>
  379. <Generic
  380. type={EntryType.EXPECTCT}
  381. data={eventEntries[EntryType.EXPECTCT].data}
  382. />
  383. </EntryErrorBoundary>
  384. )}
  385. {defined(eventEntries[EntryType.EXPECTSTAPLE]) && (
  386. <EntryErrorBoundary type={EntryType.EXPECTSTAPLE}>
  387. <Generic
  388. type={EntryType.EXPECTSTAPLE}
  389. data={eventEntries[EntryType.EXPECTSTAPLE].data}
  390. />
  391. </EntryErrorBoundary>
  392. )}
  393. {defined(eventEntries[EntryType.TEMPLATE]) && (
  394. <EntryErrorBoundary type={EntryType.TEMPLATE}>
  395. <Template event={event} data={eventEntries[EntryType.TEMPLATE].data} />
  396. </EntryErrorBoundary>
  397. )}
  398. <BreadcrumbsDataSection event={event} group={group} project={project} />
  399. {hasStreamlinedUI && event.contexts.trace?.trace_id && (
  400. <EventTraceView group={group} event={event} organization={organization} />
  401. )}
  402. {defined(eventEntries[EntryType.REQUEST]) && (
  403. <EntryErrorBoundary type={EntryType.REQUEST}>
  404. <Request event={event} data={eventEntries[EntryType.REQUEST].data} />
  405. </EntryErrorBoundary>
  406. )}
  407. {issueTypeConfig.tags.enabled ? (
  408. <Fragment>
  409. {hasStreamlinedUI ? (
  410. <EventTagsDataSection
  411. event={event}
  412. projectSlug={project.slug}
  413. ref={tagsRef}
  414. />
  415. ) : (
  416. <div ref={tagsRef}>
  417. <EventTagsAndScreenshot event={event} projectSlug={project.slug} />
  418. </div>
  419. )}
  420. </Fragment>
  421. ) : null}
  422. <EventContexts group={group} event={event} />
  423. <ErrorBoundary mini message={t('There was a problem loading feature flags.')}>
  424. <EventFeatureFlagList group={group} project={project} event={event} />
  425. </ErrorBoundary>
  426. <EventExtraData event={event} />
  427. <EventPackageData event={event} />
  428. <EventDevice event={event} />
  429. <EventViewHierarchy event={event} project={project} />
  430. <EventAttachments event={event} project={project} group={group} />
  431. <EventSdk sdk={event.sdk} meta={event._meta?.sdk} />
  432. {hasStreamlinedUI && (
  433. <EventProcessingErrors event={event} project={project} isShare={false} />
  434. )}
  435. {event.groupID && (
  436. <EventGroupingInfoSection
  437. projectSlug={project.slug}
  438. event={event}
  439. showGroupingConfig={
  440. organization.features.includes('set-grouping-config') &&
  441. 'groupingConfig' in event
  442. }
  443. group={group}
  444. />
  445. )}
  446. {!hasReplay && (
  447. <EventRRWebIntegration
  448. event={event}
  449. orgId={organization.slug}
  450. projectSlug={project.slug}
  451. />
  452. )}
  453. </Fragment>
  454. );
  455. }
  456. export default function GroupEventDetailsContent({
  457. group,
  458. event,
  459. project,
  460. }: EventDetailsContentProps) {
  461. const hasStreamlinedUI = useHasStreamlinedUI();
  462. if (hasStreamlinedUI) {
  463. return <EventDetails event={event} group={group} project={project} />;
  464. }
  465. if (!event) {
  466. return (
  467. <NotFoundMessage>
  468. <h3>{t('Latest event not available')}</h3>
  469. </NotFoundMessage>
  470. );
  471. }
  472. return <EventDetailsContent group={group} event={event} project={project} />;
  473. }
  474. /**
  475. * This component is only necessary while the streamlined UI is not in place.
  476. * The FoldSection by default wraps its children with an ErrorBoundary, preventing content
  477. * from crashing the whole page if an error occurs, but EventDataSection does not do this.
  478. */
  479. function EntryErrorBoundary({
  480. children,
  481. type,
  482. }: {
  483. children: React.ReactNode;
  484. type: EntryType;
  485. }) {
  486. return (
  487. <ErrorBoundary
  488. customComponent={
  489. <EventDataSection type={type} title={type}>
  490. <p>{t('There was an error rendering this data.')}</p>
  491. </EventDataSection>
  492. }
  493. >
  494. {children}
  495. </ErrorBoundary>
  496. );
  497. }
  498. const NotFoundMessage = styled('div')`
  499. padding: ${space(2)} ${space(4)};
  500. `;
  501. const StyledDataSection = styled(DataSection)`
  502. padding: ${space(0.5)} ${space(2)};
  503. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  504. padding: ${space(1)} ${space(4)};
  505. }
  506. &:empty {
  507. display: none;
  508. }
  509. `;