diff --git a/public/app/plugins/panel/table/TableCellOptionEditor.tsx b/public/app/plugins/panel/table/TableCellOptionEditor.tsx index 8de4e823063..b90fb577279 100644 --- a/public/app/plugins/panel/table/TableCellOptionEditor.tsx +++ b/public/app/plugins/panel/table/TableCellOptionEditor.tsx @@ -3,10 +3,11 @@ import { merge } from 'lodash'; import React, { useState } from 'react'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; -import { config } from '@grafana/runtime'; +import { config, reportInteraction } from '@grafana/runtime'; import { TableCellOptions } from '@grafana/schema'; import { Field, Select, TableCellDisplayMode, useStyles2 } from '@grafana/ui'; +import { INTERACTION_EVENT_NAME, INTERACTION_ITEM } from './TablePanel'; import { BarGaugeCellOptionsEditor } from './cells/BarGaugeCellOptionsEditor'; import { ColorBackgroundCellOptionsEditor } from './cells/ColorBackgroundCellOptionsEditor'; import { SparklineCellOptionsEditor } from './cells/SparklineCellOptionsEditor'; @@ -43,6 +44,8 @@ export const TableCellOptionEditor = ({ value, onChange }: Props) => { value = merge(value, settingCache[value.type]); } + reportInteraction(INTERACTION_EVENT_NAME, { item: INTERACTION_ITEM.CELL_TYPE_CHANGE, type: value.type }); + onChange(value); } }; diff --git a/public/app/plugins/panel/table/TablePanel.tsx b/public/app/plugins/panel/table/TablePanel.tsx index d9d4e85ec40..ff7771bd291 100644 --- a/public/app/plugins/panel/table/TablePanel.tsx +++ b/public/app/plugins/panel/table/TablePanel.tsx @@ -2,13 +2,22 @@ import { css } from '@emotion/css'; import React from 'react'; import { DataFrame, FieldMatcherID, getFrameDisplayName, PanelProps, SelectableValue } from '@grafana/data'; -import { PanelDataErrorView } from '@grafana/runtime'; +import { PanelDataErrorView, reportInteraction } from '@grafana/runtime'; import { Select, Table, usePanelContext, useTheme2 } from '@grafana/ui'; import { TableSortByFieldState } from '@grafana/ui/src/components/Table/types'; import { hasDeprecatedParentRowIndex, migrateFromParentRowIndexToNestedFrames } from './migrations'; import { Options } from './panelcfg.gen'; +export const INTERACTION_EVENT_NAME = 'table_panel_usage'; +export const INTERACTION_ITEM = { + COLUMN_RESIZE: 'column_resize', + SORT_BY: 'sort_by', + TABLE_SELECTION_CHANGE: 'table_selection_change', + ERROR_VIEW: 'error_view', + CELL_TYPE_CHANGE: 'cell_type_change', +}; + interface Props extends PanelProps {} export function TablePanel(props: Props) { @@ -27,6 +36,8 @@ export function TablePanel(props: Props) { let tableHeight = height; if (!count || !hasFields) { + reportInteraction(INTERACTION_EVENT_NAME, { item: INTERACTION_ITEM.ERROR_VIEW }); + return ; } @@ -106,6 +117,8 @@ function onColumnResize(fieldDisplayName: string, width: number, props: Props) { }); } + reportInteraction(INTERACTION_EVENT_NAME, { item: INTERACTION_ITEM.COLUMN_RESIZE }); + props.onFieldConfigChange({ ...fieldConfig, overrides, @@ -113,6 +126,8 @@ function onColumnResize(fieldDisplayName: string, width: number, props: Props) { } function onSortByChange(sortBy: TableSortByFieldState[], props: Props) { + reportInteraction(INTERACTION_EVENT_NAME, { item: INTERACTION_ITEM.SORT_BY }); + props.onOptionsChange({ ...props.options, sortBy, @@ -120,6 +135,8 @@ function onSortByChange(sortBy: TableSortByFieldState[], props: Props) { } function onChangeTableSelection(val: SelectableValue, props: Props) { + reportInteraction(INTERACTION_EVENT_NAME, { item: INTERACTION_ITEM.TABLE_SELECTION_CHANGE }); + props.onOptionsChange({ ...props.options, frameIndex: val.value || 0,