groupEventDetailsContent.tsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. import {Fragment, lazy, useRef} from 'react';
  2. import styled from '@emotion/styled';
  3. import {CommitRow} from 'sentry/components/commitRow';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import BreadcrumbsDataSection from 'sentry/components/events/breadcrumbs/breadcrumbsDataSection';
  6. import {EventContexts} from 'sentry/components/events/contexts';
  7. import {EventDevice} from 'sentry/components/events/device';
  8. import {EventAttachments} from 'sentry/components/events/eventAttachments';
  9. import {EventDataSection} from 'sentry/components/events/eventDataSection';
  10. import {EventEntry} from 'sentry/components/events/eventEntry';
  11. import {EventEvidence} from 'sentry/components/events/eventEvidence';
  12. import {EventExtraData} from 'sentry/components/events/eventExtraData';
  13. import EventHydrationDiff from 'sentry/components/events/eventHydrationDiff';
  14. import EventReplay from 'sentry/components/events/eventReplay';
  15. import {EventSdk} from 'sentry/components/events/eventSdk';
  16. import AggregateSpanDiff from 'sentry/components/events/eventStatisticalDetector/aggregateSpanDiff';
  17. import EventBreakpointChart from 'sentry/components/events/eventStatisticalDetector/breakpointChart';
  18. import {EventAffectedTransactions} from 'sentry/components/events/eventStatisticalDetector/eventAffectedTransactions';
  19. import EventComparison from 'sentry/components/events/eventStatisticalDetector/eventComparison';
  20. import {EventDifferentialFlamegraph} from 'sentry/components/events/eventStatisticalDetector/eventDifferentialFlamegraph';
  21. import {EventFunctionComparisonList} from 'sentry/components/events/eventStatisticalDetector/eventFunctionComparisonList';
  22. import {EventRegressionSummary} from 'sentry/components/events/eventStatisticalDetector/eventRegressionSummary';
  23. import {EventFunctionBreakpointChart} from 'sentry/components/events/eventStatisticalDetector/functionBreakpointChart';
  24. import {TransactionsDeltaProvider} from 'sentry/components/events/eventStatisticalDetector/transactionsDeltaProvider';
  25. import {EventTagsAndScreenshot} from 'sentry/components/events/eventTagsAndScreenshot';
  26. import {EventViewHierarchy} from 'sentry/components/events/eventViewHierarchy';
  27. import {EventGroupingInfo} from 'sentry/components/events/groupingInfo';
  28. import HighlightsDataSection from 'sentry/components/events/highlights/highlightsDataSection';
  29. import {ActionableItems} from 'sentry/components/events/interfaces/crashContent/exception/actionableItems';
  30. import {actionableItemsEnabled} from 'sentry/components/events/interfaces/crashContent/exception/useActionableItems';
  31. import {CronTimelineSection} from 'sentry/components/events/interfaces/crons/cronTimelineSection';
  32. import {AnrRootCause} from 'sentry/components/events/interfaces/performance/anrRootCause';
  33. import {SpanEvidenceSection} from 'sentry/components/events/interfaces/performance/spanEvidence';
  34. import {EventPackageData} from 'sentry/components/events/packageData';
  35. import {EventRRWebIntegration} from 'sentry/components/events/rrwebIntegration';
  36. import {DataSection} from 'sentry/components/events/styles';
  37. import {SuspectCommits} from 'sentry/components/events/suspectCommits';
  38. import {EventUserFeedback} from 'sentry/components/events/userFeedback';
  39. import LazyLoad from 'sentry/components/lazyLoad';
  40. import {useHasNewTimelineUI} from 'sentry/components/timeline/utils';
  41. import {t} from 'sentry/locale';
  42. import {space} from 'sentry/styles/space';
  43. import {
  44. type EntryException,
  45. type Event,
  46. EventOrGroupType,
  47. type Group,
  48. IssueCategory,
  49. IssueType,
  50. type Project,
  51. } from 'sentry/types';
  52. import type {EventTransaction} from 'sentry/types/event';
  53. import {EntryType} from 'sentry/types/event';
  54. import {shouldShowCustomErrorResourceConfig} from 'sentry/utils/issueTypeConfig';
  55. import {QuickTraceContext} from 'sentry/utils/performance/quickTrace/quickTraceContext';
  56. import QuickTraceQuery from 'sentry/utils/performance/quickTrace/quickTraceQuery';
  57. import {getReplayIdFromEvent} from 'sentry/utils/replays/getReplayIdFromEvent';
  58. import {useLocation} from 'sentry/utils/useLocation';
  59. import useOrganization from 'sentry/utils/useOrganization';
  60. import {ResourcesAndPossibleSolutions} from 'sentry/views/issueDetails/resourcesAndPossibleSolutions';
  61. const LLMMonitoringSection = lazy(
  62. () => import('sentry/components/events/interfaces/llm-monitoring/llmMonitoringSection')
  63. );
  64. type GroupEventDetailsContentProps = {
  65. group: Group;
  66. project: Project;
  67. event?: Event;
  68. };
  69. type GroupEventEntryProps = {
  70. entryType: EntryType;
  71. event: Event;
  72. group: Group;
  73. project: Project;
  74. };
  75. function GroupEventEntry({event, entryType, group, project}: GroupEventEntryProps) {
  76. const organization = useOrganization();
  77. const matchingEntry = event.entries.find(entry => entry.type === entryType);
  78. if (!matchingEntry) {
  79. return null;
  80. }
  81. return (
  82. <EventEntry
  83. projectSlug={project.slug}
  84. group={group}
  85. entry={matchingEntry}
  86. {...{organization, event}}
  87. />
  88. );
  89. }
  90. function DefaultGroupEventDetailsContent({
  91. group,
  92. event,
  93. project,
  94. }: Required<GroupEventDetailsContentProps>) {
  95. const organization = useOrganization();
  96. const location = useLocation();
  97. const hasNewTimelineUI = useHasNewTimelineUI();
  98. const tagsRef = useRef<HTMLDivElement>(null);
  99. const projectSlug = project.slug;
  100. const hasReplay = Boolean(getReplayIdFromEvent(event));
  101. const mechanism = event.tags?.find(({key}) => key === 'mechanism')?.value;
  102. const isANR = mechanism === 'ANR' || mechanism === 'AppExitInfo';
  103. const hasAnrImprovementsFeature = organization.features.includes('anr-improvements');
  104. const showPossibleSolutionsHigher = shouldShowCustomErrorResourceConfig(group, project);
  105. const eventEntryProps = {group, event, project};
  106. const hasActionableItems = actionableItemsEnabled({
  107. eventId: event.id,
  108. organization,
  109. projectSlug,
  110. });
  111. return (
  112. <Fragment>
  113. {hasActionableItems && (
  114. <ActionableItems event={event} project={project} isShare={false} />
  115. )}
  116. <StyledDataSection>
  117. <SuspectCommits
  118. project={project}
  119. eventId={event.id}
  120. group={group}
  121. commitRow={CommitRow}
  122. />
  123. </StyledDataSection>
  124. {event.userReport && (
  125. <EventDataSection title={t('User Feedback')} type="user-feedback">
  126. <EventUserFeedback
  127. report={event.userReport}
  128. orgSlug={organization.slug}
  129. issueId={group.id}
  130. showEventLink={false}
  131. />
  132. </EventDataSection>
  133. )}
  134. {event.type === EventOrGroupType.ERROR &&
  135. organization.features.includes('insights-addon-modules') &&
  136. event?.entries
  137. ?.filter((x): x is EntryException => x.type === EntryType.EXCEPTION)
  138. .flatMap(x => x.data.values ?? [])
  139. .some(({value}) => {
  140. const lowerText = value?.toLowerCase();
  141. return (
  142. lowerText &&
  143. (lowerText.includes('api key') || lowerText.includes('429')) &&
  144. (lowerText.includes('openai') ||
  145. lowerText.includes('anthropic') ||
  146. lowerText.includes('cohere') ||
  147. lowerText.includes('langchain'))
  148. );
  149. }) ? (
  150. <LazyLoad
  151. LazyComponent={LLMMonitoringSection}
  152. event={event}
  153. organization={organization}
  154. />
  155. ) : null}
  156. {group.issueCategory === IssueCategory.CRON && (
  157. <CronTimelineSection
  158. event={event}
  159. organization={organization}
  160. project={project}
  161. />
  162. )}
  163. <HighlightsDataSection
  164. event={event}
  165. group={group}
  166. project={project}
  167. viewAllRef={tagsRef}
  168. />
  169. {showPossibleSolutionsHigher && (
  170. <ResourcesAndPossibleSolutionsIssueDetailsContent
  171. event={event}
  172. project={project}
  173. group={group}
  174. />
  175. )}
  176. <EventEvidence event={event} group={group} project={project} />
  177. <GroupEventEntry entryType={EntryType.MESSAGE} {...eventEntryProps} />
  178. <GroupEventEntry entryType={EntryType.EXCEPTION} {...eventEntryProps} />
  179. <GroupEventEntry entryType={EntryType.STACKTRACE} {...eventEntryProps} />
  180. <GroupEventEntry entryType={EntryType.THREADS} {...eventEntryProps} />
  181. {hasAnrImprovementsFeature && isANR && (
  182. <QuickTraceQuery
  183. event={event}
  184. location={location}
  185. orgSlug={organization.slug}
  186. type={'spans'}
  187. skipLight
  188. >
  189. {results => {
  190. return (
  191. <QuickTraceContext.Provider value={results}>
  192. <AnrRootCause event={event} organization={organization} />
  193. </QuickTraceContext.Provider>
  194. );
  195. }}
  196. </QuickTraceQuery>
  197. )}
  198. {group.issueCategory === IssueCategory.PERFORMANCE && (
  199. <SpanEvidenceSection
  200. event={event as EventTransaction}
  201. organization={organization}
  202. projectSlug={project.slug}
  203. />
  204. )}
  205. <EventHydrationDiff event={event} group={group} />
  206. <EventReplay event={event} group={group} projectSlug={project.slug} />
  207. <GroupEventEntry entryType={EntryType.HPKP} {...eventEntryProps} />
  208. <GroupEventEntry entryType={EntryType.CSP} {...eventEntryProps} />
  209. <GroupEventEntry entryType={EntryType.EXPECTCT} {...eventEntryProps} />
  210. <GroupEventEntry entryType={EntryType.EXPECTSTAPLE} {...eventEntryProps} />
  211. <GroupEventEntry entryType={EntryType.TEMPLATE} {...eventEntryProps} />
  212. {hasNewTimelineUI ? (
  213. <BreadcrumbsDataSection event={event} />
  214. ) : (
  215. <GroupEventEntry entryType={EntryType.BREADCRUMBS} {...eventEntryProps} />
  216. )}
  217. {!showPossibleSolutionsHigher && (
  218. <ResourcesAndPossibleSolutionsIssueDetailsContent
  219. event={event}
  220. project={project}
  221. group={group}
  222. />
  223. )}
  224. <GroupEventEntry entryType={EntryType.DEBUGMETA} {...eventEntryProps} />
  225. <GroupEventEntry entryType={EntryType.REQUEST} {...eventEntryProps} />
  226. <div ref={tagsRef}>
  227. <EventTagsAndScreenshot event={event} projectSlug={project.slug} />
  228. </div>
  229. <EventContexts group={group} event={event} />
  230. <EventExtraData event={event} />
  231. <EventPackageData event={event} />
  232. <EventDevice event={event} />
  233. <EventViewHierarchy event={event} project={project} />
  234. <EventAttachments event={event} projectSlug={project.slug} />
  235. <EventSdk sdk={event.sdk} meta={event._meta?.sdk} />
  236. {event.groupID && (
  237. <EventGroupingInfo
  238. projectSlug={project.slug}
  239. event={event}
  240. showGroupingConfig={
  241. organization.features.includes('set-grouping-config') &&
  242. 'groupingConfig' in event
  243. }
  244. group={group}
  245. />
  246. )}
  247. {!hasReplay && (
  248. <EventRRWebIntegration
  249. event={event}
  250. orgId={organization.slug}
  251. projectSlug={project.slug}
  252. />
  253. )}
  254. </Fragment>
  255. );
  256. }
  257. function ResourcesAndPossibleSolutionsIssueDetailsContent({
  258. event,
  259. project,
  260. group,
  261. }: Required<GroupEventDetailsContentProps>) {
  262. return (
  263. <ErrorBoundary mini>
  264. <ResourcesAndPossibleSolutions event={event} project={project} group={group} />
  265. </ErrorBoundary>
  266. );
  267. }
  268. function PerformanceDurationRegressionIssueDetailsContent({
  269. group,
  270. event,
  271. project,
  272. }: Required<GroupEventDetailsContentProps>) {
  273. return (
  274. <Fragment>
  275. <ErrorBoundary mini>
  276. <EventRegressionSummary event={event} group={group} />
  277. </ErrorBoundary>
  278. <ErrorBoundary mini>
  279. <EventBreakpointChart event={event} />
  280. </ErrorBoundary>
  281. <ErrorBoundary mini>
  282. <AggregateSpanDiff event={event} project={project} />
  283. </ErrorBoundary>
  284. <ErrorBoundary mini>
  285. <EventComparison event={event} project={project} />
  286. </ErrorBoundary>
  287. </Fragment>
  288. );
  289. }
  290. function ProfilingDurationRegressionIssueDetailsContent({
  291. group,
  292. event,
  293. project,
  294. }: Required<GroupEventDetailsContentProps>) {
  295. return (
  296. <TransactionsDeltaProvider event={event} project={project}>
  297. <Fragment>
  298. <ErrorBoundary mini>
  299. <EventRegressionSummary event={event} group={group} />
  300. </ErrorBoundary>
  301. <ErrorBoundary mini>
  302. <EventFunctionBreakpointChart event={event} />
  303. </ErrorBoundary>
  304. <ErrorBoundary mini>
  305. <EventAffectedTransactions event={event} group={group} project={project} />
  306. </ErrorBoundary>
  307. <ErrorBoundary mini>
  308. <DataSection>
  309. <b>{t('Largest Changes in Call Stack Frequency')}</b>
  310. <p>
  311. {t(`See which functions changed the most before and after the regression. The
  312. frame with the largest increase in call stack population likely
  313. contributed to the cause for the duration regression.`)}
  314. </p>
  315. <EventDifferentialFlamegraph event={event} />
  316. </DataSection>
  317. </ErrorBoundary>
  318. <ErrorBoundary mini>
  319. <EventFunctionComparisonList event={event} group={group} project={project} />
  320. </ErrorBoundary>
  321. </Fragment>
  322. </TransactionsDeltaProvider>
  323. );
  324. }
  325. function GroupEventDetailsContent({
  326. group,
  327. event,
  328. project,
  329. }: GroupEventDetailsContentProps) {
  330. if (!event) {
  331. return (
  332. <NotFoundMessage>
  333. <h3>{t('Latest event not available')}</h3>
  334. </NotFoundMessage>
  335. );
  336. }
  337. switch (group.issueType) {
  338. case IssueType.PERFORMANCE_DURATION_REGRESSION:
  339. case IssueType.PERFORMANCE_ENDPOINT_REGRESSION: {
  340. return (
  341. <PerformanceDurationRegressionIssueDetailsContent
  342. group={group}
  343. event={event}
  344. project={project}
  345. />
  346. );
  347. }
  348. case IssueType.PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL:
  349. case IssueType.PROFILE_FUNCTION_REGRESSION: {
  350. return (
  351. <ProfilingDurationRegressionIssueDetailsContent
  352. group={group}
  353. event={event}
  354. project={project}
  355. />
  356. );
  357. }
  358. default: {
  359. return (
  360. <DefaultGroupEventDetailsContent group={group} event={event} project={project} />
  361. );
  362. }
  363. }
  364. }
  365. const NotFoundMessage = styled('div')`
  366. padding: ${space(2)} ${space(4)};
  367. `;
  368. const StyledDataSection = styled(DataSection)`
  369. padding: ${space(0.5)} ${space(2)};
  370. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  371. padding: ${space(1)} ${space(4)};
  372. }
  373. &:empty {
  374. display: none;
  375. }
  376. `;
  377. export default GroupEventDetailsContent;