diff --git a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx index b9ecdaf1de6..cf7ad12181f 100644 --- a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx +++ b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx @@ -8,6 +8,7 @@ import appEvents from 'app/core/app_events'; import { useQueryParams } from 'app/core/hooks/useQueryParams'; import { useInstallStatus, useUninstallStatus, useInstall, useUninstall } from '../../state/hooks'; +import { trackPluginInstalled, trackPluginUninstalled } from '../../tracking'; import { CatalogPlugin, PluginStatus, PluginTabIds, Version } from '../../types'; type InstallControlsButtonProps = { @@ -27,8 +28,14 @@ export function InstallControlsButton({ plugin, pluginStatus, latestCompatibleVe const showConfirmModal = () => setIsConfirmModalVisible(true); const hideConfirmModal = () => setIsConfirmModalVisible(false); const uninstallBtnText = isUninstalling ? 'Uninstalling' : 'Uninstall'; + const trackingProps = { + plugin_id: plugin.id, + plugin_type: plugin.type, + path: location.pathname, + }; const onInstall = async () => { + trackPluginInstalled(trackingProps); await install(plugin.id, latestCompatibleVersion?.version); if (!errorInstalling) { appEvents.emit(AppEvents.alertSuccess, [`Installed ${plugin.name}`]); @@ -37,6 +44,7 @@ export function InstallControlsButton({ plugin, pluginStatus, latestCompatibleVe const onUninstall = async () => { hideConfirmModal(); + trackPluginUninstalled(trackingProps); await uninstall(plugin.id); if (!errorUninstalling) { // If an app plugin is uninstalled we need to reset the active tab when the config / dashboards tabs are removed. diff --git a/public/app/features/plugins/admin/tracking.ts b/public/app/features/plugins/admin/tracking.ts new file mode 100644 index 00000000000..8e8e70756e1 --- /dev/null +++ b/public/app/features/plugins/admin/tracking.ts @@ -0,0 +1,18 @@ +import { reportInteraction } from '@grafana/runtime'; + +type PluginTrackingProps = { + // The ID of the plugin (e.g. grafana-azure-monitor-datasource) + plugin_id: string; + // The type of the plugin (e.g. 'app' or 'datasource') + plugin_type?: string; + // The path where the plugin details page was rendered (e.g. /plugins/grafana-azure-monitor-datasource ) + path: string; +}; + +export const trackPluginInstalled = (props: PluginTrackingProps) => { + reportInteraction('grafana_plugin_install_clicked', props); +}; + +export const trackPluginUninstalled = (props: PluginTrackingProps) => { + reportInteraction('grafana_plugin_uninstall_clicked', props); +};