@@ -10,11 +10,12 @@ import { ScriptedCheckSchema } from 'schemas/forms/ScriptedCheckSchema';
10
10
import { TCPCheckSchema } from 'schemas/forms/TCPCheckSchema' ;
11
11
import { TracerouteCheckSchema } from 'schemas/forms/TracerouteCheckSchema' ;
12
12
13
- import { Check , CheckAlertDraft , CheckAlertFormRecord , CheckFormValues , CheckType } from 'types' ;
13
+ import { Check , CheckAlertDraft , CheckAlertFormRecord , CheckFormValues , CheckType , FeatureName } from 'types' ;
14
14
import { ROUTES } from 'routing/types' ;
15
15
import { AdHocCheckResponse } from 'datasource/responses.types' ;
16
16
import { useUpdateAlertsForCheck } from 'data/useCheckAlerts' ;
17
17
import { useCUDChecks , useTestCheck } from 'data/useChecks' ;
18
+ import { useFeatureFlag } from 'hooks/useFeatureFlag' ;
18
19
import { useNavigation } from 'hooks/useNavigation' ;
19
20
import { toPayload } from 'components/CheckEditor/checkFormTransformations' ;
20
21
import { getAlertsPayload } from 'components/CheckEditor/transformations/toPayload.alerts' ;
@@ -54,6 +55,7 @@ export function useCheckForm({ check, checkType, onTestSuccess }: UseCheckFormPr
54
55
const { mutate : testCheck , isPending, error : testError } = useTestCheck ( { eventInfo : { checkType } } ) ;
55
56
56
57
const navigateToChecks = useCallback ( ( ) => navigate ( ROUTES . Checks ) , [ navigate ] ) ;
58
+ const alertsEnabled = useFeatureFlag ( FeatureName . AlertsPerCheck ) . isEnabled ;
57
59
58
60
const onError = ( err : Error | unknown ) => {
59
61
setSubmittingToApi ( false ) ;
@@ -102,9 +104,9 @@ export function useCheckForm({ check, checkType, onTestSuccess }: UseCheckFormPr
102
104
return testCheck ( toSubmit , { onSuccess : onTestSuccess } ) ;
103
105
}
104
106
105
- mutateCheck ( toSubmit , checkValues ?. alerts ) ;
107
+ mutateCheck ( toSubmit , alertsEnabled ? checkValues ?. alerts : undefined ) ;
106
108
} ,
107
- [ mutateCheck , onTestSuccess , testCheck ]
109
+ [ mutateCheck , onTestSuccess , testCheck , alertsEnabled ]
108
110
) ;
109
111
110
112
const handleInvalid = useCallback ( ( errs : FieldErrors ) => {
0 commit comments