groupEventDetailsContent.tsx 13 KB

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