Skip to content

Commit

Permalink
remove legacy trackUiMetric telemetries
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Jul 5, 2022
1 parent 9101d05 commit 018e272
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import { HeatmapVisParams, HeatmapTypeProps } from '../../types';
const HeatmapOptionsLazy = lazy(() => import('./heatmap'));

export const getHeatmapOptions =
({ showElasticChartsOptions, palettes, trackUiMetric }: HeatmapTypeProps) =>
({ showElasticChartsOptions, palettes }: HeatmapTypeProps) =>
(props: VisEditorOptionsProps<HeatmapVisParams>) =>
(
<HeatmapOptionsLazy
{...props}
palettes={palettes}
showElasticChartsOptions={showElasticChartsOptions}
trackUiMetric={trackUiMetric}
/>
);
6 changes: 0 additions & 6 deletions src/plugins/vis_types/heatmap/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,10 @@ export class VisTypeHeatmapPlugin {
{ visualizations, charts, usageCollection }: VisTypeHeatmapSetupDependencies
) {
if (!core.uiSettings.get(LEGACY_HEATMAP_CHARTS_LIBRARY)) {
const trackUiMetric = usageCollection?.reportUiCounter.bind(
usageCollection,
'vis_type_heatmap'
);

visualizations.createBaseVisualization(
heatmapVisType({
showElasticChartsOptions: true,
palettes: charts.palettes,
trackUiMetric,
})
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/vis_types/heatmap/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { UiCounterMetricType } from '@kbn/analytics';
import type { Position } from '@elastic/charts';
import type { ChartsPluginSetup, Style, Labels, ColorSchemas } from '@kbn/charts-plugin/public';
import { Range } from '@kbn/expressions-plugin/public';
Expand All @@ -14,7 +13,6 @@ import { LegendSize } from '@kbn/visualizations-plugin/public';
export interface HeatmapTypeProps {
showElasticChartsOptions?: boolean;
palettes?: ChartsPluginSetup['palettes'];
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
}

export interface HeatmapVisParams {
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/vis_types/heatmap/public/vis_type/heatmap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { SplitTooltip } from './split_tooltip';
export const getHeatmapVisTypeDefinition = ({
showElasticChartsOptions = false,
palettes,
trackUiMetric,
}: HeatmapTypeProps): VisTypeDefinition<HeatmapVisParams> => ({
name: 'heatmap',
title: i18n.translate('visTypeHeatmap.heatmap.heatmapTitle', { defaultMessage: 'Heat map' }),
Expand Down Expand Up @@ -68,7 +67,6 @@ export const getHeatmapVisTypeDefinition = ({
optionsTemplate: getHeatmapOptions({
showElasticChartsOptions,
palettes,
trackUiMetric,
}),
schemas: [
{
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/vis_types/pie/public/editor/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import { PieTypeProps } from '../../types';
const PieOptionsLazy = lazy(() => import('./pie'));

export const getPieOptions =
({ showElasticChartsOptions, palettes, trackUiMetric }: PieTypeProps) =>
({ showElasticChartsOptions, palettes }: PieTypeProps) =>
(props: VisEditorOptionsProps<PartitionVisParams>) =>
(
<PieOptionsLazy
{...props}
palettes={palettes}
showElasticChartsOptions={showElasticChartsOptions}
trackUiMetric={trackUiMetric}
/>
);
13 changes: 0 additions & 13 deletions src/plugins/vis_types/pie/public/editor/components/pie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import React, { useState, useEffect, useCallback } from 'react';
import { METRIC_TYPE } from '@kbn/analytics';
import {
EuiPanel,
EuiTitle,
Expand Down Expand Up @@ -223,9 +222,6 @@ const PieOptions = (props: PieOptionsProps) => {
value={stateParams.nestedLegend}
disabled={stateParams.legendDisplay === LegendDisplay.HIDE}
setValue={(paramName, value) => {
if (props.trackUiMetric) {
props.trackUiMetric(METRIC_TYPE.CLICK, 'nested_legend_switched');
}
setValue(paramName, value);
}}
data-test-subj="visTypePieNestedLegendSwitch"
Expand Down Expand Up @@ -253,9 +249,6 @@ const PieOptions = (props: PieOptionsProps) => {
activePalette={stateParams.palette}
paramName="palette"
setPalette={(paramName, value) => {
if (props.trackUiMetric) {
props.trackUiMetric(METRIC_TYPE.CLICK, 'palette_selected');
}
setValue(paramName, value);
}}
/>
Expand Down Expand Up @@ -296,9 +289,6 @@ const PieOptions = (props: PieOptionsProps) => {
: stateParams.labels.position || LabelPositions.DEFAULT
}
setValue={(paramName, value) => {
if (props.trackUiMetric) {
props.trackUiMetric(METRIC_TYPE.CLICK, 'label_position_selected');
}
setLabels(paramName, value);
}}
data-test-subj="visTypePieLabelPositionSelect"
Expand Down Expand Up @@ -338,9 +328,6 @@ const PieOptions = (props: PieOptionsProps) => {
paramName="valuesFormat"
value={stateParams.labels.valuesFormat || ValueFormats.PERCENT}
setValue={(paramName, value) => {
if (props.trackUiMetric) {
props.trackUiMetric(METRIC_TYPE.CLICK, 'values_format_selected');
}
setLabels(paramName, value);
}}
data-test-subj="visTypePieValueFormatsSelect"
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/vis_types/pie/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ export class VisTypePiePlugin {
{ visualizations, charts, usageCollection }: VisTypePieSetupDependencies
) {
if (!core.uiSettings.get(LEGACY_PIE_CHARTS_LIBRARY, false)) {
const trackUiMetric = usageCollection?.reportUiCounter.bind(usageCollection, 'vis_type_pie');
visualizations.createBaseVisualization(
pieVisType({
showElasticChartsOptions: true,
palettes: charts.palettes,
trackUiMetric,
})
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/vis_types/pie/public/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

import { UiCounterMetricType } from '@kbn/analytics';
import { SerializedFieldFormat } from '@kbn/field-formats-plugin/common';
import { ChartsPluginSetup } from '@kbn/charts-plugin/public';

Expand All @@ -28,5 +27,4 @@ export interface Dimensions {
export interface PieTypeProps {
showElasticChartsOptions?: boolean;
palettes?: ChartsPluginSetup['palettes'];
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
}
2 changes: 0 additions & 2 deletions src/plugins/vis_types/pie/public/vis_type/pie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { getPieOptions } from '../editor/components';
export const getPieVisTypeDefinition = ({
showElasticChartsOptions = false,
palettes,
trackUiMetric,
}: PieTypeProps): VisTypeDefinition<PartitionVisParams> => ({
name: 'pie',
title: i18n.translate('visTypePie.pie.pieTitle', { defaultMessage: 'Pie' }),
Expand Down Expand Up @@ -68,7 +67,6 @@ export const getPieVisTypeDefinition = ({
optionsTemplate: getPieOptions({
showElasticChartsOptions,
palettes,
trackUiMetric,
}),
schemas: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
import React, { useState, useEffect } from 'react';
import type { PaletteRegistry } from '@kbn/coloring';
import { i18n } from '@kbn/i18n';
import { METRIC_TYPE } from '@kbn/analytics';
import { EuiFormRow, EuiRange } from '@elastic/eui';
import { SelectOption, SwitchOption, PalettePicker } from '@kbn/vis-default-editor-plugin/public';

import { ChartType } from '../../../../../common';
import { VisParams } from '../../../../types';
import { ValidationVisOptionsProps } from '../../common';
import { getPalettesService, getTrackUiMetric } from '../../../../services';
import { getPalettesService } from '../../../../services';
import { getFittingFunctions } from '../../../collections';

const fittingFunctions = getFittingFunctions();

export function ElasticChartsOptions(props: ValidationVisOptionsProps<VisParams>) {
const trackUiMetric = getTrackUiMetric();
const [palettesRegistry, setPalettesRegistry] = useState<PaletteRegistry | null>(null);
const { stateParams, setValue, aggs } = props;

Expand Down Expand Up @@ -58,9 +56,6 @@ export function ElasticChartsOptions(props: ValidationVisOptionsProps<VisParams>
paramName="detailedTooltip"
value={stateParams.detailedTooltip}
setValue={(paramName, value) => {
if (trackUiMetric) {
trackUiMetric(METRIC_TYPE.CLICK, 'detailed_tooltip_switched');
}
setValue(paramName, value);
}}
/>
Expand All @@ -75,9 +70,6 @@ export function ElasticChartsOptions(props: ValidationVisOptionsProps<VisParams>
paramName="fittingFunction"
value={stateParams.fittingFunction ?? fittingFunctions[2].value}
setValue={(paramName, value) => {
if (trackUiMetric) {
trackUiMetric(METRIC_TYPE.CLICK, 'fitting_function_selected');
}
setValue(paramName, value);
}}
/>
Expand All @@ -89,9 +81,6 @@ export function ElasticChartsOptions(props: ValidationVisOptionsProps<VisParams>
activePalette={stateParams.palette}
paramName="palette"
setPalette={(paramName, value) => {
if (trackUiMetric) {
trackUiMetric(METRIC_TYPE.CLICK, 'palette_selected');
}
setValue(paramName, value);
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ChartType } from '../../../../../common';
import { getAggs, getVis, getStateParams } from './point_series.mocks';

jest.mock('../../../../services', () => ({
getTrackUiMetric: jest.fn(() => null),
getPalettesService: jest.fn(() => {
return {
getPalettes: jest.fn(),
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/vis_types/xy/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
setUISettings,
setDocLinks,
setPalettesService,
setTrackUiMetric,
setActiveCursor,
} from './services';

Expand Down Expand Up @@ -85,9 +84,6 @@ export class VisTypeXyPlugin
expressions.registerFunction(expressionFunctions.visScale);

visTypesDefinitions.forEach(visualizations.createBaseVisualization);

setTrackUiMetric(usageCollection?.reportUiCounter.bind(usageCollection, 'vis_type_xy'));

return {};
}

Expand Down
6 changes: 0 additions & 6 deletions src/plugins/vis_types/xy/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

import { UiCounterMetricType } from '@kbn/analytics';
import { CoreSetup, DocLinksStart } from '@kbn/core/public';
import { createGetterSetter } from '@kbn/kibana-utils-plugin/public';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
Expand All @@ -31,8 +30,3 @@ export const [getPalettesService, setPalettesService] =
createGetterSetter<ChartsPluginSetup['palettes']>('xy charts.palette');

export const [getDocLinks, setDocLinks] = createGetterSetter<DocLinksStart>('DocLinks');

export const [getTrackUiMetric, setTrackUiMetric] =
createGetterSetter<(metricType: UiCounterMetricType, eventName: string | string[]) => void>(
'trackUiMetric'
);

0 comments on commit 018e272

Please sign in to comment.