-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(insights): add issues to issue-based charts on session health #88499
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5633d73
feat(insights): add issues to issue-based charts on session health
michellewzhang c51c21b
:recycle: use constant
michellewzhang fa78773
:lipstick: consolidate styles
michellewzhang 358d0b4
:twisted_rightwards_arrows: merge master
michellewzhang 2b2c097
:art: rm prop
michellewzhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
static/app/views/insights/sessions/charts/chartWithIssues.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import {Fragment} from 'react'; | ||
import styled from '@emotion/styled'; | ||
|
||
import {openInsightChartModal} from 'sentry/actionCreators/modal'; | ||
import {Button} from 'sentry/components/core/button'; | ||
import EventOrGroupExtraDetails from 'sentry/components/eventOrGroupExtraDetails'; | ||
import EventOrGroupHeader from 'sentry/components/eventOrGroupHeader'; | ||
import Panel from 'sentry/components/panels/panel'; | ||
import {GroupSummary} from 'sentry/components/stream/group'; | ||
import {IconExpand} from 'sentry/icons'; | ||
import {t} from 'sentry/locale'; | ||
import {space} from 'sentry/styles/space'; | ||
import type {Project} from 'sentry/types/project'; | ||
import usePageFilters from 'sentry/utils/usePageFilters'; | ||
import {useReleaseStats} from 'sentry/utils/useReleaseStats'; | ||
import type {LegendSelection} from 'sentry/views/dashboards/widgets/common/types'; | ||
import type {Plottable} from 'sentry/views/dashboards/widgets/timeSeriesWidget/plottables/plottable'; | ||
import {TimeSeriesWidgetVisualization} from 'sentry/views/dashboards/widgets/timeSeriesWidget/timeSeriesWidgetVisualization'; | ||
import {Widget} from 'sentry/views/dashboards/widgets/widget/widget'; | ||
import type {DiscoverSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries'; | ||
import {ModalChartContainer} from 'sentry/views/insights/pages/backend/laravel/styles'; | ||
import {WidgetVisualizationStates} from 'sentry/views/insights/pages/backend/laravel/widgetVisualizationStates'; | ||
import useRecentIssues from 'sentry/views/insights/sessions/queries/useRecentIssues'; | ||
import {SESSION_HEALTH_CHART_HEIGHT} from 'sentry/views/insights/sessions/utils/sessions'; | ||
|
||
export default function ChartWithIssues({ | ||
project, | ||
series, | ||
plottables, | ||
title, | ||
description, | ||
isPending, | ||
error, | ||
legendSelection, | ||
}: { | ||
description: string; | ||
error: Error | null; | ||
isPending: boolean; | ||
plottables: Plottable[]; | ||
project: Project; | ||
series: DiscoverSeries[]; | ||
title: string; | ||
legendSelection?: LegendSelection | undefined; | ||
}) { | ||
const {recentIssues, isPending: isPendingRecentIssues} = useRecentIssues({ | ||
projectId: project.id, | ||
}); | ||
const pageFilters = usePageFilters(); | ||
|
||
const {releases: releasesWithDate} = useReleaseStats(pageFilters.selection); | ||
const releases = | ||
releasesWithDate?.map(({date, version}) => ({ | ||
timestamp: date, | ||
version, | ||
})) ?? []; | ||
|
||
const hasData = series?.length; | ||
const isLoading = isPending || isPendingRecentIssues; | ||
|
||
if (isLoading) { | ||
return ( | ||
<Widget | ||
height={SESSION_HEALTH_CHART_HEIGHT} | ||
Visualization={<TimeSeriesWidgetVisualization.LoadingPlaceholder />} | ||
/> | ||
); | ||
} | ||
|
||
const visualization = ( | ||
<WidgetVisualizationStates | ||
isEmpty={!hasData} | ||
isLoading={isLoading} | ||
error={error} | ||
VisualizationType={TimeSeriesWidgetVisualization} | ||
visualizationProps={{ | ||
legendSelection, | ||
plottables, | ||
}} | ||
/> | ||
); | ||
|
||
const footer = hasData && recentIssues && ( | ||
<FooterIssues> | ||
{recentIssues.map((group, index) => ( | ||
<GroupWrapper canSelect key={group.id}> | ||
<EventOrGroupHeader index={index} data={group} source={'session-health'} /> | ||
<EventOrGroupExtraDetails data={group} showLifetime={false} /> | ||
</GroupWrapper> | ||
))} | ||
</FooterIssues> | ||
); | ||
|
||
return ( | ||
<Widget | ||
Title={<Widget.WidgetTitle title={title} />} | ||
height={SESSION_HEALTH_CHART_HEIGHT} | ||
Visualization={visualization} | ||
Actions={ | ||
<Widget.WidgetToolbar> | ||
<Widget.WidgetDescription description={description} /> | ||
<Button | ||
size="xs" | ||
aria-label={t('Open Full-Screen View')} | ||
borderless | ||
icon={<IconExpand />} | ||
onClick={() => { | ||
openInsightChartModal({ | ||
title, | ||
children: ( | ||
<Fragment> | ||
<ModalChartContainer> | ||
<TimeSeriesWidgetVisualization | ||
releases={releases ?? []} | ||
plottables={plottables} | ||
legendSelection={legendSelection} | ||
/> | ||
</ModalChartContainer> | ||
<ModalFooterWrapper>{footer}</ModalFooterWrapper> | ||
</Fragment> | ||
), | ||
}); | ||
}} | ||
/> | ||
</Widget.WidgetToolbar> | ||
} | ||
noFooterPadding | ||
Footer={footer} | ||
/> | ||
); | ||
} | ||
|
||
const FooterIssues = styled('div')` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
const GroupWrapper = styled(GroupSummary)` | ||
border-top: 1px solid ${p => p.theme.border}; | ||
padding: ${space(1)} ${space(0.5)} ${space(1.5)} ${space(0.5)}; | ||
|
||
&:first-child { | ||
border-top: none; | ||
} | ||
`; | ||
|
||
const ModalFooterWrapper = styled(Panel)` | ||
margin-top: 50px; | ||
`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 30 additions & 7 deletions
37
static/app/views/insights/sessions/charts/newAndResolvedIssueChart.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 23 additions & 6 deletions
29
static/app/views/insights/sessions/charts/releaseNewIssuesChart.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
import {useTheme} from '@emotion/react'; | ||
|
||
import {t} from 'sentry/locale'; | ||
import {InsightsLineChartWidget} from 'sentry/views/insights/common/components/insightsLineChartWidget'; | ||
import type {Project} from 'sentry/types/project'; | ||
import {Line} from 'sentry/views/dashboards/widgets/timeSeriesWidget/plottables/line'; | ||
import {convertSeriesToTimeseries} from 'sentry/views/insights/common/utils/convertSeriesToTimeseries'; | ||
import ChartWithIssues from 'sentry/views/insights/sessions/charts/chartWithIssues'; | ||
import useReleaseNewIssues from 'sentry/views/insights/sessions/queries/useReleaseNewIssues'; | ||
|
||
export default function ReleaseNewIssuesChart() { | ||
export default function ReleaseNewIssuesChart({project}: {project: Project}) { | ||
const {series, isPending, error} = useReleaseNewIssues(); | ||
const theme = useTheme(); | ||
|
||
const colorPalette = theme.chart.getColorPalette(series.length - 2); | ||
const plottables = series.map( | ||
(ts, index) => | ||
new Line(convertSeriesToTimeseries(ts), { | ||
alias: ts.seriesName, | ||
color: colorPalette[index], | ||
}) | ||
); | ||
|
||
return ( | ||
<InsightsLineChartWidget | ||
<ChartWithIssues | ||
project={project} | ||
series={series} | ||
title={t('New Issues by Release')} | ||
description={t('New issue counts over time, grouped by release.')} | ||
series={series} | ||
isLoading={isPending} | ||
isPending={isPending} | ||
error={error} | ||
legendSelection={{ | ||
// disable the 'other' series by default since its large values can cause the other lines to be insignificant | ||
other: false, | ||
}} | ||
error={error} | ||
plottables={plottables} | ||
/> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like every chart has the same height 👍
this'll make it easy to put any chart in any position per #88502
also, we'll get a merge conflict from editing similar lines, but it'll be easy to resolve.
the resolution will be about the same in all cases: