Skip to content

Commit 35f2723

Browse files
authored
ref(groupingInfo): Delete EventGroupingInfoResponseOld (#101223)
1 parent 8a12a05 commit 35f2723

File tree

2 files changed

+18
-45
lines changed

2 files changed

+18
-45
lines changed

static/app/components/events/groupingInfo/groupingInfoSection.spec.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ describe('EventGroupingInfo', () => {
3030
groupingInfoRequest = MockApiClient.addMockResponse({
3131
url: `/projects/org-slug/project-slug/events/${event.id}/grouping-info/`,
3232
body: {
33-
app: {
34-
contributes: true,
35-
description: 'variant description',
36-
hash: '123',
37-
hashMismatch: false,
38-
key: 'key',
39-
type: EventGroupVariantType.CHECKSUM,
33+
grouping_config: 'default:XXXX',
34+
variants: {
35+
app: {
36+
contributes: true,
37+
description: 'variant description',
38+
hash: '123',
39+
hashMismatch: false,
40+
key: 'key',
41+
type: EventGroupVariantType.CHECKSUM,
42+
},
4043
},
4144
},
4245
});

static/app/components/events/groupingInfo/useEventGroupingInfo.tsx

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,11 @@ import type {Group} from 'sentry/types/group';
88
import {useApiQuery} from 'sentry/utils/queryClient';
99
import useOrganization from 'sentry/utils/useOrganization';
1010

11-
type EventGroupingInfoResponseOld = Record<string, EventGroupVariant>;
1211
type EventGroupingInfoResponse = {
1312
grouping_config: string | null;
1413
variants: Record<string, EventGroupVariant>;
1514
};
1615

17-
// temporary function to convert the old response structure to the new one
18-
function eventGroupingInfoResponseOldToNew(
19-
old: EventGroupingInfoResponseOld | null
20-
): EventGroupingInfoResponse | null {
21-
const grouping_config = old
22-
? (
23-
Object.values(old).find(
24-
variant => 'config' in variant && variant.config?.id
25-
) as any
26-
)?.config?.id
27-
: null;
28-
return old
29-
? {
30-
grouping_config,
31-
variants: old,
32-
}
33-
: null;
34-
}
35-
36-
// temporary function to check if the respinse is old type
37-
function isOld(
38-
data: EventGroupingInfoResponseOld | EventGroupingInfoResponse | null
39-
): data is EventGroupingInfoResponseOld {
40-
return data ? !('grouping_config' in data) : false;
41-
}
42-
4316
function generatePerformanceGroupInfo({
4417
event,
4518
group,
@@ -94,21 +67,18 @@ export function useEventGroupingInfo({
9467

9568
const hasPerformanceGrouping = event.occurrence && event.type === 'transaction';
9669

97-
const {data, isPending, isError, isSuccess} = useApiQuery<
98-
EventGroupingInfoResponseOld | EventGroupingInfoResponse
99-
>([`/projects/${organization.slug}/${projectSlug}/events/${event.id}/grouping-info/`], {
100-
enabled: !hasPerformanceGrouping,
101-
staleTime: Infinity,
102-
});
70+
const {data, isPending, isError, isSuccess} = useApiQuery<EventGroupingInfoResponse>(
71+
[`/projects/${organization.slug}/${projectSlug}/events/${event.id}/grouping-info/`],
72+
{
73+
enabled: !hasPerformanceGrouping,
74+
staleTime: Infinity,
75+
}
76+
);
10377

104-
const groupInfoRaw = hasPerformanceGrouping
78+
const groupInfo = hasPerformanceGrouping
10579
? generatePerformanceGroupInfo({group, event})
10680
: (data ?? null);
10781

108-
const groupInfo = isOld(groupInfoRaw)
109-
? eventGroupingInfoResponseOldToNew(groupInfoRaw)
110-
: groupInfoRaw;
111-
11282
return {
11383
groupInfo,
11484
isPending,

0 commit comments

Comments
 (0)