groupEventDetailsContent.tsx 14 KB

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