Add rudderstack tracking for table panel (#71836)

This commit is contained in:
Victor Marin 2023-09-13 10:32:00 +03:00 committed by GitHub
parent 69737cba6d
commit b4851904ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -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);
}
};

View File

@ -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<Options> {}
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 <PanelDataErrorView panelId={id} fieldConfig={fieldConfig} data={data} />;
}
@ -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<number>, props: Props) {
reportInteraction(INTERACTION_EVENT_NAME, { item: INTERACTION_ITEM.TABLE_SELECTION_CHANGE });
props.onOptionsChange({
...props.options,
frameIndex: val.value || 0,