groupEventDetailsContent.tsx 20 KB

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