mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Track plugin install and uninstall events (#62300)
* chore: track plugin install and uninstall events * chore: pass the type of the plugin to the tracking as well
This commit is contained in:
parent
533c8e4b7a
commit
f985f02584
@ -8,6 +8,7 @@ import appEvents from 'app/core/app_events';
|
|||||||
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
||||||
|
|
||||||
import { useInstallStatus, useUninstallStatus, useInstall, useUninstall } from '../../state/hooks';
|
import { useInstallStatus, useUninstallStatus, useInstall, useUninstall } from '../../state/hooks';
|
||||||
|
import { trackPluginInstalled, trackPluginUninstalled } from '../../tracking';
|
||||||
import { CatalogPlugin, PluginStatus, PluginTabIds, Version } from '../../types';
|
import { CatalogPlugin, PluginStatus, PluginTabIds, Version } from '../../types';
|
||||||
|
|
||||||
type InstallControlsButtonProps = {
|
type InstallControlsButtonProps = {
|
||||||
@ -27,8 +28,14 @@ export function InstallControlsButton({ plugin, pluginStatus, latestCompatibleVe
|
|||||||
const showConfirmModal = () => setIsConfirmModalVisible(true);
|
const showConfirmModal = () => setIsConfirmModalVisible(true);
|
||||||
const hideConfirmModal = () => setIsConfirmModalVisible(false);
|
const hideConfirmModal = () => setIsConfirmModalVisible(false);
|
||||||
const uninstallBtnText = isUninstalling ? 'Uninstalling' : 'Uninstall';
|
const uninstallBtnText = isUninstalling ? 'Uninstalling' : 'Uninstall';
|
||||||
|
const trackingProps = {
|
||||||
|
plugin_id: plugin.id,
|
||||||
|
plugin_type: plugin.type,
|
||||||
|
path: location.pathname,
|
||||||
|
};
|
||||||
|
|
||||||
const onInstall = async () => {
|
const onInstall = async () => {
|
||||||
|
trackPluginInstalled(trackingProps);
|
||||||
await install(plugin.id, latestCompatibleVersion?.version);
|
await install(plugin.id, latestCompatibleVersion?.version);
|
||||||
if (!errorInstalling) {
|
if (!errorInstalling) {
|
||||||
appEvents.emit(AppEvents.alertSuccess, [`Installed ${plugin.name}`]);
|
appEvents.emit(AppEvents.alertSuccess, [`Installed ${plugin.name}`]);
|
||||||
@ -37,6 +44,7 @@ export function InstallControlsButton({ plugin, pluginStatus, latestCompatibleVe
|
|||||||
|
|
||||||
const onUninstall = async () => {
|
const onUninstall = async () => {
|
||||||
hideConfirmModal();
|
hideConfirmModal();
|
||||||
|
trackPluginUninstalled(trackingProps);
|
||||||
await uninstall(plugin.id);
|
await uninstall(plugin.id);
|
||||||
if (!errorUninstalling) {
|
if (!errorUninstalling) {
|
||||||
// If an app plugin is uninstalled we need to reset the active tab when the config / dashboards tabs are removed.
|
// If an app plugin is uninstalled we need to reset the active tab when the config / dashboards tabs are removed.
|
||||||
|
18
public/app/features/plugins/admin/tracking.ts
Normal file
18
public/app/features/plugins/admin/tracking.ts
Normal file
@ -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);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user