groupEventDetailsContent.tsx 20 KB

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