Repository navigation
feat(preprod): Add treemap diff UI #105331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<SizeAnalysisComparisonResults>( | ||
| [ | ||
| `/projects/${organization.slug}/${project.id}/preprodartifacts/size-analysis/compare/${headMetricId}/${baseMetricId}/download/`, | ||
| ], | ||
| { | ||
| staleTime: 0, | ||
| } | ||
| ); | ||
|
|
||
| if (query.isLoading) { | ||
| return <LoadingIndicator />; | ||
| } | ||
|
|
||
| if (query.isError) { | ||
| return ( | ||
| <LoadingError | ||
| message={t('Failed to load X-Ray diff data.')} | ||
| onRetry={query.refetch} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const diffItems = query.data?.diff_items; | ||
|
|
||
| if (!diffItems || diffItems.length === 0) { | ||
| return <EmptyStateWarning small>{t('No diff found.')}</EmptyStateWarning>; | ||
| } | ||
|
|
||
| return <TreemapDiffSection diffItems={diffItems} />; | ||
|
Comment on lines
+30
to
+49
This comment was marked as outdated.
Sorry, something went wrong. |
||
| } | ||
|
|
||
| type SectionProps = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the difference between
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing currently, I've made it so one aliases the other |
||
| baseMetricId: string; | ||
| headMetricId: string; | ||
| project: Project; | ||
| }; | ||
|
|
||
| function EventXrayDiffSection({baseMetricId, headMetricId, project}: SectionProps) { | ||
| return ( | ||
| <InterimSection title={t('X-Ray diff')} type={SectionKey.XRAY_DIFF}> | ||
| <ErrorBoundary mini> | ||
| <EventXrayDiffContent | ||
| project={project} | ||
| headMetricId={headMetricId} | ||
| baseMetricId={baseMetricId} | ||
| /> | ||
| </ErrorBoundary> | ||
| </InterimSection> | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate section headers when rendering treemap diffThe Additional Locations (1)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will solve this later |
||
| } | ||
|
|
||
| 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; | ||
| } | ||
|
Comment on lines
+78
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The 🔍 Detailed AnalysisThe 💡 Suggested FixEnsure the backend populates 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| type Props = { | ||
| event: Event; | ||
| project: Project; | ||
| }; | ||
|
|
||
| function EventXrayDiff(props: Props) { | ||
| const ids = getMetricIds(props.event); | ||
| if (ids) { | ||
| return <EventXrayDiffSection {...props} {...ids} />; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| export {EventXrayDiff}; | ||
Uh oh!
There was an error while loading. Please reload this page.