groupEventDetailsContent.tsx 13 KB

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