Skip to content

Commit aa08616

Browse files
narsaynorathandrewshie-sentry
authored andcommitted
fix(release-health): Convert project IDs to slugs (#93053)
This is consistent with e.g. tables when a project column is added. Other datasets handle this project name properly, it seems like only the sessions data uses the project ID when requesting projects. We should probably patch the backend but this is an immediate fix for the feedback. Presumably, we can't join the data to easily get the slug for the ID from the sessions endpoint.
1 parent 66caff3 commit aa08616

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

static/app/components/modals/widgetViewerModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import {
9191
} from 'sentry/views/dashboards/widgetCard/dashboardsMEPContext';
9292
import type {GenericWidgetQueriesChildrenProps} from 'sentry/views/dashboards/widgetCard/genericWidgetQueries';
9393
import IssueWidgetQueries from 'sentry/views/dashboards/widgetCard/issueWidgetQueries';
94+
import type {ReleaseWidgetQueriesProps} from 'sentry/views/dashboards/widgetCard/releaseWidgetQueries';
9495
import ReleaseWidgetQueries from 'sentry/views/dashboards/widgetCard/releaseWidgetQueries';
9596
import {WidgetCardChartContainer} from 'sentry/views/dashboards/widgetCard/widgetCardChartContainer';
9697
import WidgetQueries from 'sentry/views/dashboards/widgetCard/widgetQueries';
@@ -627,7 +628,7 @@ function WidgetViewerModal(props: Props) {
627628
);
628629
};
629630

630-
const renderReleaseTable: ReleaseWidgetQueries['props']['children'] = ({
631+
const renderReleaseTable: ReleaseWidgetQueriesProps['children'] = ({
631632
tableResults,
632633
loading,
633634
pageLinks,

static/app/views/dashboards/widgetBuilder/releaseWidget/fields.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export const FIELD_TO_METRICS_EXPRESSION = {
6464
'crash_free_rate(user)': SessionMetric.USER_CRASH_FREE_RATE,
6565
'crash_rate(session)': SessionMetric.SESSION_CRASH_RATE,
6666
'crash_rate(user)': SessionMetric.USER_CRASH_RATE,
67-
project: 'project_id',
6867
};
6968

7069
export const METRICS_EXPRESSION_TO_FIELD = invert(FIELD_TO_METRICS_EXPRESSION);

static/app/views/dashboards/widgetCard/releaseWidgetQueries.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import {t} from 'sentry/locale';
1212
import type {PageFilters} from 'sentry/types/core';
1313
import type {Series} from 'sentry/types/echarts';
1414
import type {Organization, SessionApiResponse} from 'sentry/types/organization';
15+
import type {Project} from 'sentry/types/project';
1516
import type {Release} from 'sentry/types/release';
1617
import {defined, escapeDoubleQuotes} from 'sentry/utils';
1718
import type {TableDataWithTitle} from 'sentry/utils/discover/discoverQuery';
1819
import {stripDerivedMetricsPrefix} from 'sentry/utils/discover/fields';
1920
import {TOP_N} from 'sentry/utils/discover/types';
2021
import {TAG_VALUE_ESCAPE_PATTERN} from 'sentry/utils/queryString';
22+
import withProjects from 'sentry/utils/withProjects';
2123
import {ReleasesConfig} from 'sentry/views/dashboards/datasetConfig/releases';
2224
import type {DashboardFilters, Widget, WidgetQuery} from 'sentry/views/dashboards/types';
2325
import {DEFAULT_TABLE_LIMIT, DisplayType} from 'sentry/views/dashboards/types';
@@ -35,10 +37,11 @@ import type {
3537
} from './genericWidgetQueries';
3638
import GenericWidgetQueries from './genericWidgetQueries';
3739

38-
type Props = {
40+
export interface ReleaseWidgetQueriesProps {
3941
api: Client;
4042
children: (props: GenericWidgetQueriesChildrenProps) => React.JSX.Element;
4143
organization: Organization;
44+
projects: Project[];
4245
selection: PageFilters;
4346
widget: Widget;
4447
cursor?: string;
@@ -49,7 +52,7 @@ type Props = {
4952
tableResults?: TableDataWithTitle[];
5053
timeseriesResults?: Series[];
5154
}) => void;
52-
};
55+
}
5356

5457
type State = {
5558
loading: boolean;
@@ -142,7 +145,7 @@ export function requiresCustomReleaseSorting(query: WidgetQuery): boolean {
142145
return useMetricsAPI && rawOrderby === 'release';
143146
}
144147

145-
class ReleaseWidgetQueries extends Component<Props, State> {
148+
class ReleaseWidgetQueries extends Component<ReleaseWidgetQueriesProps, State> {
146149
state: State = {
147150
loading: false,
148151
errorMessage: undefined,
@@ -157,7 +160,7 @@ class ReleaseWidgetQueries extends Component<Props, State> {
157160
}
158161
}
159162

160-
componentDidUpdate(prevProps: Readonly<Props>): void {
163+
componentDidUpdate(prevProps: Readonly<ReleaseWidgetQueriesProps>): void {
161164
if (
162165
!requiresCustomReleaseSorting(prevProps.widget.queries[0]!) &&
163166
requiresCustomReleaseSorting(this.props.widget.queries[0]!) &&
@@ -317,7 +320,7 @@ class ReleaseWidgetQueries extends Component<Props, State> {
317320
};
318321

319322
afterFetchData = (data: SessionApiResponse) => {
320-
const {widget} = this.props;
323+
const {widget, projects} = this.props;
321324
const {releases} = this.state;
322325

323326
const isDescending = widget.queries[0]!.orderby.startsWith('-');
@@ -346,6 +349,15 @@ class ReleaseWidgetQueries extends Component<Props, State> {
346349
});
347350
data.groups = data.groups.slice(0, this.limit);
348351
}
352+
353+
data.groups.forEach(group => {
354+
// Convert the project ID in the grouping results to the project slug
355+
// for a more human readable display
356+
if (group.by.project) {
357+
const project = projects.find(p => p.id === String(group.by.project));
358+
group.by.project = project?.slug ?? group.by.project;
359+
}
360+
});
349361
};
350362

351363
render() {
@@ -395,4 +407,4 @@ class ReleaseWidgetQueries extends Component<Props, State> {
395407
}
396408
}
397409

398-
export default ReleaseWidgetQueries;
410+
export default withProjects(ReleaseWidgetQueries);

0 commit comments

Comments
 (0)