diff --git a/static/app/components/events/eventXrayDiff.tsx b/static/app/components/events/eventXrayDiff.tsx new file mode 100644 index 000000000000..faf8f4ab944b --- /dev/null +++ b/static/app/components/events/eventXrayDiff.tsx @@ -0,0 +1,103 @@ +import EmptyStateWarning from 'sentry/components/emptyStateWarning'; +import ErrorBoundary from 'sentry/components/errorBoundary'; +import LoadingError from 'sentry/components/loadingError'; +import LoadingIndicator from 'sentry/components/loadingIndicator'; +import {t} from 'sentry/locale'; +import type {Event} from 'sentry/types/event'; +import type {Project} from 'sentry/types/project'; +import {useApiQuery} from 'sentry/utils/queryClient'; +import useOrganization from 'sentry/utils/useOrganization'; +import {SectionKey} from 'sentry/views/issueDetails/streamline/context'; +import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection'; +import {TreemapDiffSection} from 'sentry/views/preprod/buildComparison/main/treemapDiffSection'; +import type {SizeAnalysisComparisonResults} from 'sentry/views/preprod/types/appSizeTypes'; + +// Currently Content and Section props are identical. +type ContentProps = SectionProps; + +function EventXrayDiffContent({baseMetricId, headMetricId, project}: ContentProps) { + const organization = useOrganization(); + + const query = useApiQuery( + [ + `/projects/${organization.slug}/${project.id}/preprodartifacts/size-analysis/compare/${headMetricId}/${baseMetricId}/download/`, + ], + { + staleTime: 0, + } + ); + + if (query.isLoading) { + return ; + } + + if (query.isError) { + return ( + + ); + } + + const diffItems = query.data?.diff_items; + + if (!diffItems || diffItems.length === 0) { + return {t('No diff found.')}; + } + + return ; +} + +type SectionProps = { + baseMetricId: string; + headMetricId: string; + project: Project; +}; + +function EventXrayDiffSection({baseMetricId, headMetricId, project}: SectionProps) { + return ( + + + + + + ); +} + +interface MetricIds { + baseMetricId: string; + headMetricId: string; +} + +function getMetricIds(event: Event): MetricIds | undefined { + const headMetricId = event.occurrence?.evidenceData?.headSizeMetricId; + const baseMetricId = event.occurrence?.evidenceData?.baseSizeMetricId; + + if (baseMetricId && headMetricId) { + return { + baseMetricId, + headMetricId, + }; + } + return undefined; +} + +type Props = { + event: Event; + project: Project; +}; + +function EventXrayDiff(props: Props) { + const ids = getMetricIds(props.event); + if (ids) { + return ; + } + return null; +} + +export {EventXrayDiff}; diff --git a/static/app/views/issueDetails/groupEventDetails/groupEventDetailsContent.tsx b/static/app/views/issueDetails/groupEventDetails/groupEventDetailsContent.tsx index 538fbc440f1a..527da01c08db 100644 --- a/static/app/views/issueDetails/groupEventDetails/groupEventDetailsContent.tsx +++ b/static/app/views/issueDetails/groupEventDetails/groupEventDetailsContent.tsx @@ -29,6 +29,7 @@ import {EventTagsAndScreenshot} from 'sentry/components/events/eventTagsAndScree import {ScreenshotDataSection} from 'sentry/components/events/eventTagsAndScreenshot/screenshot/screenshotDataSection'; import {EventTagsDataSection} from 'sentry/components/events/eventTagsAndScreenshot/tags'; import {EventViewHierarchy} from 'sentry/components/events/eventViewHierarchy'; +import {EventXrayDiff} from 'sentry/components/events/eventXrayDiff'; import {EventFeatureFlagSection} from 'sentry/components/events/featureFlags/eventFeatureFlagSection'; import {EventGroupingInfoSection} from 'sentry/components/events/groupingInfo/groupingInfoSection'; import HighlightsDataSection from 'sentry/components/events/highlights/highlightsDataSection'; @@ -414,6 +415,7 @@ export function EventDetailsContent({ + diff --git a/static/app/views/issueDetails/streamline/context.tsx b/static/app/views/issueDetails/streamline/context.tsx index be5b7d7bee36..51a4e12ae359 100644 --- a/static/app/views/issueDetails/streamline/context.tsx +++ b/static/app/views/issueDetails/streamline/context.tsx @@ -94,6 +94,8 @@ export const enum SectionKey { MCP_OUTPUT = 'mcp-output', SPAN_LINKS = 'span-links', + + XRAY_DIFF = 'xray-diff', } /**