groupEventDetailsContent.tsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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 event={event} project={project} viewAllRef={tagsRef} />
  164. {showPossibleSolutionsHigher && (
  165. <ResourcesAndPossibleSolutionsIssueDetailsContent
  166. event={event}
  167. project={project}
  168. group={group}
  169. />
  170. )}
  171. <EventEvidence event={event} group={group} project={project} />
  172. <GroupEventEntry entryType={EntryType.MESSAGE} {...eventEntryProps} />
  173. <GroupEventEntry entryType={EntryType.EXCEPTION} {...eventEntryProps} />
  174. <GroupEventEntry entryType={EntryType.STACKTRACE} {...eventEntryProps} />
  175. <GroupEventEntry entryType={EntryType.THREADS} {...eventEntryProps} />
  176. {hasAnrImprovementsFeature && isANR && (
  177. <QuickTraceQuery
  178. event={event}
  179. location={location}
  180. orgSlug={organization.slug}
  181. type={'spans'}
  182. skipLight
  183. >
  184. {results => {
  185. return (
  186. <QuickTraceContext.Provider value={results}>
  187. <AnrRootCause event={event} organization={organization} />
  188. </QuickTraceContext.Provider>
  189. );
  190. }}
  191. </QuickTraceQuery>
  192. )}
  193. {group.issueCategory === IssueCategory.PERFORMANCE && (
  194. <SpanEvidenceSection
  195. event={event as EventTransaction}
  196. organization={organization}
  197. projectSlug={project.slug}
  198. />
  199. )}
  200. <EventHydrationDiff event={event} group={group} />
  201. <EventReplay event={event} group={group} projectSlug={project.slug} />
  202. <GroupEventEntry entryType={EntryType.HPKP} {...eventEntryProps} />
  203. <GroupEventEntry entryType={EntryType.CSP} {...eventEntryProps} />
  204. <GroupEventEntry entryType={EntryType.EXPECTCT} {...eventEntryProps} />
  205. <GroupEventEntry entryType={EntryType.EXPECTSTAPLE} {...eventEntryProps} />
  206. <GroupEventEntry entryType={EntryType.TEMPLATE} {...eventEntryProps} />
  207. {hasNewTimelineUI ? (
  208. <BreadcrumbsDataSection event={event} />
  209. ) : (
  210. <GroupEventEntry entryType={EntryType.BREADCRUMBS} {...eventEntryProps} />
  211. )}
  212. {!showPossibleSolutionsHigher && (
  213. <ResourcesAndPossibleSolutionsIssueDetailsContent
  214. event={event}
  215. project={project}
  216. group={group}
  217. />
  218. )}
  219. <GroupEventEntry entryType={EntryType.DEBUGMETA} {...eventEntryProps} />
  220. <GroupEventEntry entryType={EntryType.REQUEST} {...eventEntryProps} />
  221. <div ref={tagsRef}>
  222. <EventTagsAndScreenshot event={event} projectSlug={project.slug} />
  223. </div>
  224. <EventContexts group={group} event={event} />
  225. <EventExtraData event={event} />
  226. <EventPackageData event={event} />
  227. <EventDevice event={event} />
  228. <EventViewHierarchy event={event} project={project} />
  229. <EventAttachments event={event} projectSlug={project.slug} />
  230. <EventSdk sdk={event.sdk} meta={event._meta?.sdk} />
  231. {event.groupID && (
  232. <EventGroupingInfo
  233. projectSlug={project.slug}
  234. event={event}
  235. showGroupingConfig={
  236. organization.features.includes('set-grouping-config') &&
  237. 'groupingConfig' in event
  238. }
  239. group={group}
  240. />
  241. )}
  242. {!hasReplay && (
  243. <EventRRWebIntegration
  244. event={event}
  245. orgId={organization.slug}
  246. projectSlug={project.slug}
  247. />
  248. )}
  249. </Fragment>
  250. );
  251. }
  252. function ResourcesAndPossibleSolutionsIssueDetailsContent({
  253. event,
  254. project,
  255. group,
  256. }: Required<GroupEventDetailsContentProps>) {
  257. return (
  258. <ErrorBoundary mini>
  259. <ResourcesAndPossibleSolutions event={event} project={project} group={group} />
  260. </ErrorBoundary>
  261. );
  262. }
  263. function PerformanceDurationRegressionIssueDetailsContent({
  264. group,
  265. event,
  266. project,
  267. }: Required<GroupEventDetailsContentProps>) {
  268. return (
  269. <Fragment>
  270. <ErrorBoundary mini>
  271. <EventRegressionSummary event={event} group={group} />
  272. </ErrorBoundary>
  273. <ErrorBoundary mini>
  274. <EventBreakpointChart event={event} />
  275. </ErrorBoundary>
  276. <ErrorBoundary mini>
  277. <AggregateSpanDiff event={event} project={project} />
  278. </ErrorBoundary>
  279. <ErrorBoundary mini>
  280. <EventComparison event={event} project={project} />
  281. </ErrorBoundary>
  282. </Fragment>
  283. );
  284. }
  285. function ProfilingDurationRegressionIssueDetailsContent({
  286. group,
  287. event,
  288. project,
  289. }: Required<GroupEventDetailsContentProps>) {
  290. return (
  291. <TransactionsDeltaProvider event={event} project={project}>
  292. <Fragment>
  293. <ErrorBoundary mini>
  294. <EventRegressionSummary event={event} group={group} />
  295. </ErrorBoundary>
  296. <ErrorBoundary mini>
  297. <EventFunctionBreakpointChart event={event} />
  298. </ErrorBoundary>
  299. <ErrorBoundary mini>
  300. <EventAffectedTransactions event={event} group={group} project={project} />
  301. </ErrorBoundary>
  302. <ErrorBoundary mini>
  303. <DataSection>
  304. <b>{t('Largest Changes in Call Stack Frequency')}</b>
  305. <p>
  306. {t(`See which functions changed the most before and after the regression. The
  307. frame with the largest increase in call stack population likely
  308. contributed to the cause for the duration regression.`)}
  309. </p>
  310. <EventDifferentialFlamegraph event={event} />
  311. </DataSection>
  312. </ErrorBoundary>
  313. <ErrorBoundary mini>
  314. <EventFunctionComparisonList event={event} group={group} project={project} />
  315. </ErrorBoundary>
  316. </Fragment>
  317. </TransactionsDeltaProvider>
  318. );
  319. }
  320. function GroupEventDetailsContent({
  321. group,
  322. event,
  323. project,
  324. }: GroupEventDetailsContentProps) {
  325. if (!event) {
  326. return (
  327. <NotFoundMessage>
  328. <h3>{t('Latest event not available')}</h3>
  329. </NotFoundMessage>
  330. );
  331. }
  332. switch (group.issueType) {
  333. case IssueType.PERFORMANCE_DURATION_REGRESSION:
  334. case IssueType.PERFORMANCE_ENDPOINT_REGRESSION: {
  335. return (
  336. <PerformanceDurationRegressionIssueDetailsContent
  337. group={group}
  338. event={event}
  339. project={project}
  340. />
  341. );
  342. }
  343. case IssueType.PROFILE_FUNCTION_REGRESSION_EXPERIMENTAL:
  344. case IssueType.PROFILE_FUNCTION_REGRESSION: {
  345. return (
  346. <ProfilingDurationRegressionIssueDetailsContent
  347. group={group}
  348. event={event}
  349. project={project}
  350. />
  351. );
  352. }
  353. default: {
  354. return (
  355. <DefaultGroupEventDetailsContent group={group} event={event} project={project} />
  356. );
  357. }
  358. }
  359. }
  360. const NotFoundMessage = styled('div')`
  361. padding: ${space(2)} ${space(4)};
  362. `;
  363. const StyledDataSection = styled(DataSection)`
  364. padding: ${space(0.5)} ${space(2)};
  365. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  366. padding: ${space(1)} ${space(4)};
  367. }
  368. &:empty {
  369. display: none;
  370. }
  371. `;
  372. export default GroupEventDetailsContent;