From cd6f018c950f1940f285fa03668682bead9f5051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Fern=C3=A1ndez?= Date: Mon, 15 Jul 2024 12:00:29 +0200 Subject: [PATCH] RestoreDashboards: Add event tracking (#90321) --- .../components/BrowseActions/BrowseActions.tsx | 1 + .../components/PermanentlyDeleteModal.tsx | 6 ++++++ .../components/RecentlyDeletedActions.tsx | 11 +++++++++++ .../browse-dashboards/components/RestoreModal.tsx | 6 ++++++ .../settings/DeleteDashboardButton.tsx | 8 ++++++++ .../DeleteDashboard/DeleteDashboardModal.tsx | 9 ++++++++- scripts/levitate-show-affected-plugins.js | 3 +-- 7 files changed, 41 insertions(+), 3 deletions(-) diff --git a/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx b/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx index c9f3f46dfe9..ecc96464c2a 100644 --- a/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx +++ b/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx @@ -127,5 +127,6 @@ function trackAction(action: keyof typeof actionMap, selectedItems: Omit { + reportInteraction('grafana_delete_permanently_confirm_clicked', { + item_counts: { + dashboard: numberOfDashboards, + }, + }); await onConfirm(); onDismiss(); }; diff --git a/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx b/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx index e2c087e3718..acabd5e7391 100644 --- a/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx +++ b/public/app/features/browse-dashboards/components/RecentlyDeletedActions.tsx @@ -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, diff --git a/public/app/features/browse-dashboards/components/RestoreModal.tsx b/public/app/features/browse-dashboards/components/RestoreModal.tsx index 6d4c0686e11..22ac1f97c95 100644 --- a/public/app/features/browse-dashboards/components/RestoreModal.tsx +++ b/public/app/features/browse-dashboards/components/RestoreModal.tsx @@ -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(); }; diff --git a/public/app/features/dashboard-scene/settings/DeleteDashboardButton.tsx b/public/app/features/dashboard-scene/settings/DeleteDashboardButton.tsx index fffa45b91db..aca70195cf1 100644 --- a/public/app/features/dashboard-scene/settings/DeleteDashboardButton.tsx +++ b/public/app/features/dashboard-scene/settings/DeleteDashboardButton.tsx @@ -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]); diff --git a/public/app/features/dashboard/components/DeleteDashboard/DeleteDashboardModal.tsx b/public/app/features/dashboard/components/DeleteDashboard/DeleteDashboardModal.tsx index 21d67bc057f..acc8cc1e12a 100644 --- a/public/app/features/dashboard/components/DeleteDashboard/DeleteDashboardModal.tsx +++ b/public/app/features/dashboard/components/DeleteDashboard/DeleteDashboardModal.tsx @@ -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(); diff --git a/scripts/levitate-show-affected-plugins.js b/scripts/levitate-show-affected-plugins.js index 17d619ca8b5..8c02fd34004 100644 --- a/scripts/levitate-show-affected-plugins.js +++ b/scripts/levitate-show-affected-plugins.js @@ -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 += `

Number of affected plugins: ${affectedPlugins.size}

`; - markdown += "

To check the plugins affected by each import, click on the links below.

"; + markdown += '

To check the plugins affected by each import, click on the links below.

'; const propertiesColumnIndex = 1; const affectingProperties = getColumn(rows, propertiesColumnIndex);