Skip to content

Commit 85fbc7c

Browse files
committed
feat(preprod): Add treemap diff UI
1 parent 443fca1 commit 85fbc7c

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import EmptyStateWarning from 'sentry/components/emptyStateWarning';
2+
import ErrorBoundary from 'sentry/components/errorBoundary';
3+
import LoadingIndicator from 'sentry/components/loadingIndicator';
4+
import {t} from 'sentry/locale';
5+
import type {Event} from 'sentry/types/event';
6+
import type {Project} from 'sentry/types/project';
7+
import {useApiQuery} from 'sentry/utils/queryClient';
8+
import useOrganization from 'sentry/utils/useOrganization';
9+
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
10+
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
11+
import {TreemapDiffSection} from 'sentry/views/preprod/buildComparison/main/treemapDiffSection';
12+
import type {SizeAnalysisComparisonResults} from 'sentry/views/preprod/types/appSizeTypes';
13+
14+
type ContentProps = {
15+
baseMetricId: string;
16+
headMetricId: string;
17+
project: Project;
18+
};
19+
20+
function EventXrayDiffContent({baseMetricId, headMetricId, project}: ContentProps) {
21+
const organization = useOrganization();
22+
23+
const query = useApiQuery<SizeAnalysisComparisonResults>(
24+
[
25+
`/projects/${organization.slug}/${project.id}/preprodartifacts/size-analysis/compare/${headMetricId}/${baseMetricId}/download/`,
26+
],
27+
{
28+
staleTime: 0,
29+
}
30+
);
31+
32+
if (query.isLoading) {
33+
return <LoadingIndicator />;
34+
}
35+
36+
const diffItems = query.data?.diff_items;
37+
38+
if (!diffItems || diffItems.length === 0) {
39+
return <EmptyStateWarning small>No diff found.</EmptyStateWarning>;
40+
}
41+
42+
return <TreemapDiffSection diffItems={diffItems} />;
43+
}
44+
45+
type SectionProps = {
46+
baseMetricId: string;
47+
headMetricId: string;
48+
project: Project;
49+
};
50+
51+
function EventXrayDiffSection({baseMetricId, headMetricId, project}: SectionProps) {
52+
return (
53+
<InterimSection title={t('X-Ray diff')} type={SectionKey.XRAY_DIFF}>
54+
<ErrorBoundary mini>
55+
<EventXrayDiffContent
56+
project={project}
57+
headMetricId={headMetricId}
58+
baseMetricId={baseMetricId}
59+
/>
60+
</ErrorBoundary>
61+
</InterimSection>
62+
);
63+
}
64+
65+
interface MetricIds {
66+
baseMetricId: string;
67+
headMetricId: string;
68+
}
69+
70+
function getMetricIds(event: Event): MetricIds | undefined {
71+
const headMetricId = event.occurrence?.evidenceData?.headSizeMetricId;
72+
const baseMetricId = event.occurrence?.evidenceData?.baseSizeMetricId;
73+
74+
if (baseMetricId && headMetricId) {
75+
return {
76+
baseMetricId,
77+
headMetricId,
78+
};
79+
}
80+
return undefined;
81+
}
82+
83+
type Props = {
84+
event: Event;
85+
project: Project;
86+
};
87+
88+
function EventXrayDiff(props: Props) {
89+
const ids = getMetricIds(props.event);
90+
if (ids) {
91+
return <EventXrayDiffSection {...props} {...ids} />;
92+
}
93+
return null;
94+
}
95+
96+
export {EventXrayDiff};

‎static/app/views/issueDetails/groupEventDetails/groupEventDetailsContent.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {EventTagsAndScreenshot} from 'sentry/components/events/eventTagsAndScree
2929
import {ScreenshotDataSection} from 'sentry/components/events/eventTagsAndScreenshot/screenshot/screenshotDataSection';
3030
import {EventTagsDataSection} from 'sentry/components/events/eventTagsAndScreenshot/tags';
3131
import {EventViewHierarchy} from 'sentry/components/events/eventViewHierarchy';
32+
import {EventXrayDiff} from 'sentry/components/events/eventXrayDiff';
3233
import {EventFeatureFlagSection} from 'sentry/components/events/featureFlags/eventFeatureFlagSection';
3334
import {EventGroupingInfoSection} from 'sentry/components/events/groupingInfo/groupingInfoSection';
3435
import HighlightsDataSection from 'sentry/components/events/highlights/highlightsDataSection';
@@ -414,6 +415,7 @@ export function EventDetailsContent({
414415
</ErrorBoundary>
415416
<EventExtraData event={event} />
416417
<EventViewHierarchy event={event} project={project} />
418+
<EventXrayDiff event={event} project={project} />
417419
<EventPackageData event={event} />
418420
<EventDevice event={event} />
419421
<EventAttachments event={event} project={project} group={group} />

‎static/app/views/issueDetails/streamline/context.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export const enum SectionKey {
9494
MCP_OUTPUT = 'mcp-output',
9595

9696
SPAN_LINKS = 'span-links',
97+
98+
XRAY_DIFF = 'xray-diff',
9799
}
98100

99101
/**

0 commit comments

Comments
 (0)