Alerting: Add interactions for Fullstory (#94631)

add interactions for Fullstory
This commit is contained in:
Sonia Aguilar 2024-10-11 19:23:58 +02:00 committed by GitHub
parent 19a9a79467
commit 0dd5373e4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View File

@ -190,6 +190,18 @@ export const trackAlertRuleFormError = (
reportInteraction('grafana_alerting_rule_form_error', props);
};
export const trackNewGrafanaAlertRuleFormSavedSuccess = () => {
reportInteraction('grafana_alerting_grafana_rule_creation_new_success');
};
export const trackNewGrafanaAlertRuleFormCancelled = () => {
reportInteraction('grafana_alerting_grafana_rule_creation_new_aborted');
};
export const trackNewGrafanaAlertRuleFormError = () => {
reportInteraction('grafana_alerting_grafana_rule_creation_new_error');
};
export const trackInsightsFeedback = async (props: { useful: boolean; panel: string }) => {
const defaults = {
grafana_version: config.buildInfo.version,

View File

@ -29,6 +29,9 @@ import {
trackAlertRuleFormCancelled,
trackAlertRuleFormError,
trackAlertRuleFormSaved,
trackNewGrafanaAlertRuleFormCancelled,
trackNewGrafanaAlertRuleFormError,
trackNewGrafanaAlertRuleFormSavedSuccess,
} from '../../../Analytics';
import { shouldUsePrometheusRulesPrimary } from '../../../featureToggles';
import { useDeleteRuleFromGroup } from '../../../hooks/ruleGroup/useDeleteRuleFromGroup';
@ -138,6 +141,10 @@ export const AlertRuleForm = ({ existing, prefill }: Props) => {
const submit = async (values: RuleFormValues, exitOnSave: boolean) => {
if (conditionErrorMsg !== '') {
notifyApp.error(conditionErrorMsg);
if (!existing && grafanaTypeRule) {
// new Grafana-managed rule
trackNewGrafanaAlertRuleFormError();
}
return;
}
@ -154,6 +161,7 @@ export const AlertRuleForm = ({ existing, prefill }: Props) => {
// when creating a new rule, we save the manual routing setting , and editorSettings.simplifiedQueryEditor to the local storage
storeInLocalStorageValues(values);
await addRuleToRuleGroup.execute(ruleGroupIdentifier, ruleDefinition, evaluateEvery);
grafanaTypeRule && trackNewGrafanaAlertRuleFormSavedSuccess(); // new Grafana-managed rule
} else {
const ruleIdentifier = fromRulerRuleAndRuleGroupIdentifier(ruleGroupIdentifier, existing.rule);
const targetRuleGroupIdentifier = getRuleGroupLocationFromFormValues(values);
@ -207,6 +215,10 @@ export const AlertRuleForm = ({ existing, prefill }: Props) => {
const cancelRuleCreation = () => {
logInfo(LogMessages.cancelSavingAlertRule);
trackAlertRuleFormCancelled({ formAction: existing ? 'update' : 'create' });
if (!existing && grafanaTypeRule) {
// new Grafana-managed rule
trackNewGrafanaAlertRuleFormCancelled();
}
locationService.getHistory().goBack();
};