Skip to content

Commit 6b56feb

Browse files
authored
ref(grouping): change GroupingEventVariantType to use underscores in FE (#97683)
1 parent f8ebf07 commit 6b56feb

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {t} from 'sentry/locale';
22
import {
3+
convertVariantFromBackend,
34
EventGroupVariantType,
5+
isEventGroupVariantType,
46
type Event,
57
type EventGroupVariant,
68
} from 'sentry/types/event';
@@ -66,7 +68,16 @@ export function useEventGroupingInfo({
6668

6769
const groupInfo = hasPerformanceGrouping
6870
? generatePerformanceGroupInfo({group, event})
69-
: (data ?? null);
71+
: data
72+
? Object.fromEntries(
73+
Object.entries(data).map(([key, variant]) => [
74+
key,
75+
isEventGroupVariantType(variant.type)
76+
? convertVariantFromBackend(variant)
77+
: variant,
78+
])
79+
)
80+
: null;
7081

7182
return {groupInfo, isPending, isError, isSuccess, hasPerformanceGrouping};
7283
}

static/app/types/event.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,38 @@ type VariantEvidence = {
5050
export const enum EventGroupVariantType {
5151
CHECKSUM = 'checksum',
5252
FALLBACK = 'fallback',
53-
CUSTOM_FINGERPRINT = 'custom-fingerprint',
54-
BUILT_IN_FINGERPRINT = 'built-in-fingerprint',
53+
CUSTOM_FINGERPRINT = 'custom_fingerprint',
54+
BUILT_IN_FINGERPRINT = 'built_in_fingerprint',
5555
COMPONENT = 'component',
56-
SALTED_COMPONENT = 'salted-component',
57-
PERFORMANCE_PROBLEM = 'performance-problem',
56+
SALTED_COMPONENT = 'salted_component',
57+
PERFORMANCE_PROBLEM = 'performance_problem',
58+
}
59+
60+
function convertVariantTypeToUnderscore(type: string): EventGroupVariantType {
61+
const converted = type.replace(/-/g, '_');
62+
return converted as EventGroupVariantType;
63+
}
64+
65+
export function isEventGroupVariantType(value: string): value is EventGroupVariantType {
66+
const eventGroupVariantTypes = new Set<string>([
67+
'checksum',
68+
'fallback',
69+
'custom-fingerprint',
70+
'built-in-fingerprint',
71+
'component',
72+
'salted-component',
73+
'performance-problem',
74+
]);
75+
return eventGroupVariantTypes.has(value);
76+
}
77+
78+
export function convertVariantFromBackend(variant: any): EventGroupVariant {
79+
const convertedVariant = {
80+
...variant,
81+
type: convertVariantTypeToUnderscore(variant.type),
82+
};
83+
84+
return convertedVariant as EventGroupVariant;
5885
}
5986

6087
interface BaseVariant {

0 commit comments

Comments
 (0)