From 0dd5373e4aede11b44b7c06ff3f2d6970d35d03b Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Fri, 11 Oct 2024 19:23:58 +0200 Subject: [PATCH] Alerting: Add interactions for Fullstory (#94631) add interactions for Fullstory --- public/app/features/alerting/unified/Analytics.ts | 12 ++++++++++++ .../rule-editor/alert-rule-form/AlertRuleForm.tsx | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/public/app/features/alerting/unified/Analytics.ts b/public/app/features/alerting/unified/Analytics.ts index 93101ec6250..09a3da9f551 100644 --- a/public/app/features/alerting/unified/Analytics.ts +++ b/public/app/features/alerting/unified/Analytics.ts @@ -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, diff --git a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx index 6a72bdcab21..4d12179b1fc 100644 --- a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx @@ -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(); };