Skip to content

Commit

Permalink
[Step 2] VisEditors Telemetry enhancements (remove legacy Lens teleme…
Browse files Browse the repository at this point in the history
…tries) (#135684)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
  • Loading branch information
3 people authored Jul 25, 2022
1 parent ee3cfb6 commit 51816a0
Show file tree
Hide file tree
Showing 41 changed files with 7 additions and 2,349 deletions.
3 changes: 0 additions & 3 deletions x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { tableHasFormulas } from '@kbn/data-plugin/common';
import { exporters, getEsQueryConfig } from '@kbn/data-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { trackUiEvent } from '../lens_ui_telemetry';
import type { StateSetter } from '../types';
import {
LensAppServices,
Expand Down Expand Up @@ -559,15 +558,13 @@ export const LensTopNavMenu = ({
const currentRange = data.query.timefilter.timefilter.getTime();
if (dateRange.from !== currentRange.from || dateRange.to !== currentRange.to) {
data.query.timefilter.timefilter.setTime(dateRange);
trackUiEvent('app_date_change');
} else {
// Query has changed, renew the session id.
// recalculate resolvedDateRange (relevant for relative time range)
dispatchSetState({
searchSessionId: data.search.session.start(),
resolvedDateRange: getResolvedDateRange(data.query.timefilter.timefilter),
});
trackUiEvent('app_query_change');
}
if (newQuery) {
if (!isEqual(newQuery, query)) {
Expand Down
12 changes: 1 addition & 11 deletions x-pack/plugins/lens/public/app_plugin/mounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { ACTION_CONVERT_TO_LENS } from '@kbn/visualizations-plugin/public';
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { EuiLoadingSpinner } from '@elastic/eui';
import { syncQueryStateWithUrl } from '@kbn/data-plugin/public';
import { LensReportManager, setReportManager, trackUiEvent } from '../lens_ui_telemetry';

import { App } from './app';
import { EditorFrameStart, LensTopNavMenuEntryGenerator } from '../types';
Expand Down Expand Up @@ -134,7 +133,7 @@ export async function mountApp(

const lensServices = await getLensServices(coreStart, startDependencies, attributeService);

const { stateTransfer, data, storage } = lensServices;
const { stateTransfer, data } = lensServices;

const embeddableEditorIncomingState = stateTransfer?.getIncomingEditorState(APP_ID);

Expand All @@ -154,13 +153,6 @@ export async function mountApp(
i18n.translate('xpack.lens.pageTitle', { defaultMessage: 'Lens' })
);

setReportManager(
new LensReportManager({
http: core.http,
storage,
})
);

const getInitialInput = (id?: string, editByValue?: boolean): LensEmbeddableInput | undefined => {
if (editByValue) {
return embeddableEditorIncomingState?.valueInput as LensByValueInput;
Expand Down Expand Up @@ -282,7 +274,6 @@ export async function mountApp(
initCallback();
})();
}, [initCallback, initialInput, props.history, redirectCallback]);
trackUiEvent('loaded');

if (editorState === 'loading') {
return <EuiLoadingSpinner />;
Expand Down Expand Up @@ -343,7 +334,6 @@ export async function mountApp(
};

function NotFound() {
trackUiEvent('loaded_404');
return <FormattedMessage id="xpack.lens.app404" defaultMessage="404 Not Found" />;
}
// dispatch synthetic hash change event to update hash history objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import React, { useEffect, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { METRIC_TYPE } from '@kbn/analytics';
import { isFilterPinned } from '@kbn/es-query';

import type { SavedObjectReference } from '@kbn/core/public';
Expand All @@ -17,7 +16,6 @@ import type { SaveProps } from './app';
import { Document, checkForDuplicateTitle } from '../persistence';
import type { LensByReferenceInput, LensEmbeddableInput } from '../embeddable';
import { APP_ID, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../common';
import { trackUiEvent } from '../lens_ui_telemetry';
import type { LensAppState } from '../state_management';
import { getPersisted } from '../state_management/init_middleware/load_initial';

Expand Down Expand Up @@ -200,15 +198,13 @@ export const runSaveLensVisualization = async (
const {
chrome,
initialInput,
originatingApp,
lastKnownDoc,
persistedDoc,
savedObjectsClient,
overlays,
notifications,
stateTransfer,
attributeService,
usageCollection,
savedObjectsTagging,
getIsByValueMode,
redirectToOrigin,
Expand All @@ -221,10 +217,6 @@ export const runSaveLensVisualization = async (
return;
}

if (usageCollection) {
usageCollection.reportUiCounter(originatingApp || 'visualize', METRIC_TYPE.CLICK, 'lens:save');
}

let references = lastKnownDoc.references;

if (savedObjectsTagging) {
Expand Down Expand Up @@ -345,7 +337,6 @@ export const runSaveLensVisualization = async (
} catch (e) {
// eslint-disable-next-line no-console
console.dir(e);
trackUiEvent('save_failed');
throw e;
}
};
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/lens/public/app_plugin/settings_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
useLensDispatch,
useLensSelector,
} from '../state_management';
import { trackUiEvent } from '../lens_ui_telemetry';
import { writeToStorage } from '../settings_storage';
import { AUTO_APPLY_DISABLED_STORAGE_KEY } from '../editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper';

Expand All @@ -46,8 +45,6 @@ export function SettingsMenu({
const dispatch = useLensDispatch();

const toggleAutoApply = useCallback(() => {
trackUiEvent('toggle_autoapply');

writeToStorage(
new Storage(localStorage),
AUTO_APPLY_DISABLED_STORAGE_KEY,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/lens/public/async_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ export * from './editor_frame_service';
export * from './embeddable';
export * from './app_plugin/mounter';
export * from './lens_attribute_service';
export * from './lens_ui_telemetry';
export * from './app_plugin/save_modal_container';
3 changes: 0 additions & 3 deletions x-pack/plugins/lens/public/drag_drop/drag_drop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
announce,
Ghost,
} from './providers';
import { trackUiEvent } from '../lens_ui_telemetry';
import { DropType } from '../types';

export type DroppableEvent = React.DragEvent<HTMLElement>;
Expand Down Expand Up @@ -385,7 +384,6 @@ const DragInner = memo(function DragInner({

const dropToActiveDropTarget = () => {
if (activeDropTarget) {
trackUiEvent('drop_total');
const { dropType, humanData, onDrop: onTargetDrop } = activeDropTarget;
setTimeout(() => setA11yMessage(announce.dropped(value.humanData, humanData, dropType)));
onTargetDrop(value, dropType);
Expand Down Expand Up @@ -953,7 +951,6 @@ const ReorderableDrop = memo(function ReorderableDrop(
setKeyboardMode(false);

if (onDrop && dragging) {
trackUiEvent('drop_total');
onDrop(dragging, 'reorder');
// setTimeout ensures it will run after dragEnd messaging
setTimeout(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from '@kbn/unified-search-plugin/public';
import { Visualization } from '../../../types';
import { LayerPanel } from './layer_panel';
import { trackUiEvent } from '../../../lens_ui_telemetry';
import { generateId } from '../../../id_generator';
import { ConfigPanelWrapperProps } from './types';
import { useFocusUpdate } from './use_focus_update';
Expand Down Expand Up @@ -222,7 +221,6 @@ export function LayerPanels(
onAddLayerClick={(layerType) => {
const layerId = generateId();
dispatchLens(addLayer({ layerId, layerType }));
trackUiEvent('layer_added');
setNextFocusedLayerId(layerId);
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from '../../../types';
import { DragDropIdentifier, ReorderProvider } from '../../../drag_drop';
import { LayerSettings } from './layer_settings';
import { trackUiEvent } from '../../../lens_ui_telemetry';
import { LayerPanelProps, ActiveDimensionState } from './types';
import { DimensionContainer } from './dimension_container';
import { RemoveLayerButton } from './remove_layer_button';
Expand Down Expand Up @@ -456,7 +455,6 @@ export function LayerPanel(
});
}}
onRemoveClick={(id: string) => {
trackUiEvent('indexpattern_dimension_removed');
if (datasourceId && layerDatasource) {
props.updateAll(
datasourceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { WorkspacePanel } from './workspace_panel';
import { DragDropIdentifier, RootDragDropProvider } from '../../drag_drop';
import { EditorFrameStartPlugins } from '../service';
import { getTopSuggestionForField, switchToSuggestion } from './suggestion_helpers';
import { trackUiEvent } from '../../lens_ui_telemetry';
import {
useLensSelector,
useLensDispatch,
Expand Down Expand Up @@ -78,7 +77,6 @@ export function EditorFrame(props: EditorFrameProps) {
(field) => {
const suggestion = getSuggestionForField.current!(field);
if (suggestion) {
trackUiEvent('drop_onto_workspace');
switchToSuggestion(dispatchLens, suggestion, { clearStagedPreview: true });
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
} from '../../types';
import { getSuggestions, switchToSuggestion } from './suggestion_helpers';
import { getDatasourceExpressionsByLayers } from './expression_helpers';
import { trackUiEvent, trackSuggestionEvent } from '../../lens_ui_telemetry';
import {
getMissingIndexPattern,
validateDatasourceAndVisualization,
Expand Down Expand Up @@ -345,7 +344,6 @@ export function SuggestionPanel({

function rollbackToCurrentVisualization() {
if (lastSelectedSuggestion !== -1) {
trackSuggestionEvent('back_to_current');
setLastSelectedSuggestion(-1);
dispatchLens(rollbackSuggestion());
dispatchLens(applyChanges());
Expand Down Expand Up @@ -411,7 +409,6 @@ export function SuggestionPanel({
ExpressionRenderer={AutoRefreshExpressionRenderer}
key={index}
onSelect={() => {
trackUiEvent('suggestion_clicked');
if (lastSelectedSuggestion === index) {
rollbackToCurrentVisualization();
} else {
Expand Down Expand Up @@ -455,7 +452,6 @@ export function SuggestionPanel({
size="xs"
iconType="refresh"
onClick={() => {
trackUiEvent('suggestion_confirmed');
dispatchLens(submitSuggestion());
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
Suggestion,
} from '../../../types';
import { getSuggestions, switchToSuggestion } from '../suggestion_helpers';
import { trackUiEvent } from '../../../lens_ui_telemetry';
import {
insertLayer,
removeLayers,
Expand Down Expand Up @@ -124,8 +123,6 @@ export const ChartSwitch = memo(function ChartSwitch(props: Props) {
const commitSelection = (selection: VisualizationSelection) => {
setFlyoutOpen(false);

trackUiEvent(`chart_switch`);

switchToSuggestion(
dispatchLens,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
import { DragDrop, DragContext, DragDropIdentifier } from '../../../drag_drop';
import { switchToSuggestion } from '../suggestion_helpers';
import { buildExpression } from '../expression_helpers';
import { trackUiEvent } from '../../../lens_ui_telemetry';
import { WorkspacePanelWrapper } from './workspace_panel_wrapper';
import { DropIllustration } from '../../../assets/drop_illustration';
import applyChangesIllustrationDark from '../../../assets/render_dark@2x.png';
Expand Down Expand Up @@ -358,11 +357,9 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({

const onDrop = useCallback(() => {
if (suggestionForDraggedField) {
trackUiEvent('drop_onto_workspace');
trackUiEvent(expressionExists ? 'drop_non_empty' : 'drop_empty');
switchToSuggestion(dispatchLens, suggestionForDraggedField, { clearStagedPreview: true });
}
}, [suggestionForDraggedField, expressionExists, dispatchLens]);
}, [suggestionForDraggedField, dispatchLens]);

const IS_DARK_THEME = core.uiSettings.get('theme:darkMode');

Expand Down Expand Up @@ -625,7 +622,6 @@ export const VisualizationWrapper = ({
<EuiButton
data-test-subj="errorFixAction"
onClick={async () => {
trackUiEvent('error_fix_action');
const newState = await validationError.fixAction?.newState({
...framePublicAPI,
...context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { EuiPopover, EuiPopoverTitle, EuiSelectableProps } from '@elastic/eui';
import { ToolbarButton, ToolbarButtonProps } from '@kbn/kibana-react-plugin/public';
import { DataViewsList } from '@kbn/unified-search-plugin/public';
import { IndexPatternRef } from './types';
import { trackUiEvent } from '../lens_ui_telemetry';

export type ChangeIndexPatternTriggerProps = ToolbarButtonProps & {
label: string;
Expand Down Expand Up @@ -81,7 +80,6 @@ export function ChangeIndexPattern({
<DataViewsList
dataViewsList={indexPatternRefs}
onChangeDataView={(newId) => {
trackUiEvent('indexpattern_changed');
onChangeIndexPattern(newId);
setPopoverIsOpen(false);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import type {
IndexPatternField,
IndexPatternRef,
} from './types';
import { trackUiEvent } from '../lens_ui_telemetry';
import { loadIndexPatterns, syncExistingFields } from './loader';
import { fieldExists } from './pure_helpers';
import { Loader } from '../loader';
Expand Down Expand Up @@ -533,15 +532,13 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
() =>
editPermission
? async (fieldName?: string, uiAction: 'edit' | 'add' = 'edit') => {
trackUiEvent(`open_field_editor_${uiAction}`);
const indexPatternInstance = await dataViews.get(currentIndexPattern.id);
closeFieldEditor.current = indexPatternFieldEditor.openEditor({
ctx: {
dataView: indexPatternInstance,
},
fieldName,
onSave: async () => {
trackUiEvent(`save_field_${uiAction}`);
await refreshFieldList();
},
});
Expand All @@ -554,15 +551,13 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
() =>
editPermission
? async (fieldName: string) => {
trackUiEvent('open_field_delete_modal');
const indexPatternInstance = await dataViews.get(currentIndexPattern.id);
closeFieldEditor.current = indexPatternFieldEditor.openDeleteModal({
ctx: {
dataView: indexPatternInstance,
},
fieldName,
onDelete: async () => {
trackUiEvent('delete_field');
await refreshFieldList();
},
});
Expand Down Expand Up @@ -616,7 +611,6 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
defaultMessage: 'Clear name and type filters',
}),
onClick: () => {
trackUiEvent('indexpattern_filters_cleared');
clearLocalState();
},
}}
Expand Down Expand Up @@ -679,7 +673,6 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
icon={localState.typeFilter.includes(type) ? 'check' : 'empty'}
data-test-subj={`typeFilter-${type}`}
onClick={() => {
trackUiEvent('indexpattern_type_filter_toggled');
setLocalState((s) => ({
...s,
typeFilter: localState.typeFilter.includes(type)
Expand Down
Loading

0 comments on commit 51816a0

Please sign in to comment.