RestoreDashboards: Add event tracking (#90321)

This commit is contained in:
Laura Fernández 2024-07-15 12:00:29 +02:00 committed by GitHub
parent 73336362a8
commit cd6f018c95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 41 additions and 3 deletions

View File

@ -127,5 +127,6 @@ function trackAction(action: keyof typeof actionMap, selectedItems: Omit<Dashboa
dashboard: selectedDashboards.length,
},
source: 'tree_actions',
restore_enabled: config.featureToggles.dashboardRestoreUI,
});
}

View File

@ -1,3 +1,4 @@
import { reportInteraction } from '@grafana/runtime';
import { ConfirmModal, Text } from '@grafana/ui';
import { Trans, t } from '../../../core/internationalization';
@ -14,6 +15,11 @@ export const PermanentlyDeleteModal = ({
const numberOfDashboards = selectedDashboards.length;
const onDelete = async () => {
reportInteraction('grafana_delete_permanently_confirm_clicked', {
item_counts: {
dashboard: numberOfDashboards,
},
});
await onConfirm();
onDismiss();
};

View File

@ -2,6 +2,7 @@ import { css } from '@emotion/css';
import { useMemo } from 'react';
import { GrafanaTheme2 } from '@grafana/data/';
import { reportInteraction } from '@grafana/runtime';
import { Button, useStyles2 } from '@grafana/ui';
import { GENERAL_FOLDER_UID } from 'app/features/search/constants';
@ -75,6 +76,11 @@ export function RecentlyDeletedActions() {
};
const showRestoreModal = () => {
reportInteraction('grafana_restore_clicked', {
item_counts: {
dashboard: selectedDashboards.length,
},
});
appEvents.publish(
new ShowModalReactEvent({
component: RestoreModal,
@ -88,6 +94,11 @@ export function RecentlyDeletedActions() {
};
const showDeleteModal = () => {
reportInteraction('grafana_delete_permanently_clicked', {
item_counts: {
dashboard: selectedDashboards.length,
},
});
appEvents.publish(
new ShowModalReactEvent({
component: PermanentlyDeleteModal,

View File

@ -1,3 +1,4 @@
import { reportInteraction } from '@grafana/runtime';
import { ConfirmModal, Text } from '@grafana/ui';
import { Trans, t } from '../../../core/internationalization';
@ -14,6 +15,11 @@ export const RestoreModal = ({ onConfirm, onDismiss, selectedDashboards, isLoadi
const numberOfDashboards = selectedDashboards.length;
const onRestore = async () => {
reportInteraction('grafana_restore_confirm_clicked', {
item_counts: {
dashboard: numberOfDashboards,
},
});
await onConfirm();
onDismiss();
};

View File

@ -1,6 +1,7 @@
import { useAsyncFn, useToggle } from 'react-use';
import { selectors } from '@grafana/e2e-selectors';
import { config, reportInteraction } from '@grafana/runtime';
import { Button, ConfirmModal, Modal } from '@grafana/ui';
import { Trans } from 'app/core/internationalization';
@ -35,6 +36,13 @@ interface ModalProps {
function DeleteDashboardModal({ dashboard, onClose }: ModalProps) {
const [, onConfirm] = useAsyncFn(async () => {
reportInteraction('grafana_manage_dashboards_delete_clicked', {
item_counts: {
dashboard: 1,
},
source: 'dashboard_scene_settings',
restore_enabled: config.featureToggles.dashboardRestoreUI,
});
onClose();
await dashboard.deleteDashboard();
}, [dashboard, onClose]);

View File

@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import { connect, ConnectedProps } from 'react-redux';
import useAsyncFn from 'react-use/lib/useAsyncFn';
import { locationService } from '@grafana/runtime';
import { locationService, config, reportInteraction } from '@grafana/runtime';
import { Modal, ConfirmModal, Button, Text, Space, TextLink } from '@grafana/ui';
import { DashboardModel } from 'app/features/dashboard/state';
import { cleanUpDashboardAndVariables } from 'app/features/dashboard/state/actions';
@ -27,6 +27,13 @@ const DeleteDashboardModalUnconnected = ({ hideModal, cleanUpDashboardAndVariabl
const isProvisioned = dashboard.meta.provisioned;
const [, onConfirm] = useAsyncFn(async () => {
reportInteraction('grafana_manage_dashboards_delete_clicked', {
item_counts: {
dashboard: 1,
},
source: 'dashboard_settings',
restore_enabled: config.featureToggles.dashboardRestoreUI,
});
await deleteDashboard(dashboard.uid, true);
cleanUpDashboardAndVariables();
hideModal();

View File

@ -98,7 +98,6 @@ function getColumn(lines, columnIndex) {
return set;
}
/**
* Generates a markdown section detailing the affected plugins based on the provided data.
*
@ -124,7 +123,7 @@ function printAffectedPluginsSection(data) {
const affectedPlugins = getColumn(rows, pluginsColumnIndex);
markdown += `<h3>Number of affected plugins: ${affectedPlugins.size}</h3>`;
markdown += "<p>To check the plugins affected by each import, click on the links below.</p>";
markdown += '<p>To check the plugins affected by each import, click on the links below.</p>';
const propertiesColumnIndex = 1;
const affectingProperties = getColumn(rows, propertiesColumnIndex);