Skip to content

Fixes to telemetry Keyboard and mouse nb telemetry #11220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 4 additions & 35 deletions src/client/datascience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { PYTHON_LANGUAGE } from '../common/constants';
import { IS_WINDOWS } from '../common/platform/constants';
import { IVariableQuery } from '../common/types';
import { NativeCommandType } from './interactive-common/interactiveWindowTypes';

export const DefaultTheme = 'Default Light+';
// Identifier for the output panel that will display the output from the Jupyter Server.
Expand Down Expand Up @@ -305,70 +304,40 @@ export enum Telemetry {
}

export enum NativeKeyboardCommandTelemetry {
AddToEnd = 'DATASCIENCE.NATIVE.KEYBOARD.ADD_TO_END',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these cannot be done using keyboard, only possible via mouse clicks (hmm, highlights accessibility issues)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our accessibility is rough, but pretty soon a big chunk of that will be on the VS Code notebook editor.

ArrowDown = 'DATASCIENCE.NATIVE.KEYBOARD.ARROW_DOWN',
ArrowUp = 'DATASCIENCE.NATIVE.KEYBOARD.ARROW_UP',
ChangeToCode = 'DATASCIENCE.NATIVE.KEYBOARD.CHANGE_TO_CODE',
ChangeToMarkdown = 'DATASCIENCE.NATIVE.KEYBOARD.CHANGE_TO_MARKDOWN',
CollapseInput = 'DATASCIENCE.NATIVE.KEYBOARD.COLLAPSE_INPUT',
CollapseOutput = 'DATASCIENCE.NATIVE.KEYBOARD.COLLAPSE_OUTPUT',
DeleteCell = 'DATASCIENCE.NATIVE.KEYBOARD.DELETE_CELL',
InsertAbove = 'DATASCIENCE.NATIVE.KEYBOARD.INSERT_ABOVE',
InsertBelow = 'DATASCIENCE.NATIVE.KEYBOARD.INSERT_BELOW',
MoveCellDown = 'DATASCIENCE.NATIVE.KEYBOARD.MOVE_CELL_DOWN',
MoveCellUp = 'DATASCIENCE.NATIVE.KEYBOARD.MOVE_CELL_UP',
Redo = 'DATASCIENCE.NATIVE.KEYBOARD.REDO',
Run = 'DATASCIENCE.NATIVE.KEYBOARD.RUN',
Save = 'DATASCIENCE.NATIVE.KEYBOARD.SAVE',
RunAbove = 'DATASCIENCE.NATIVE.KEYBOARD.RUN_ABOVE',
RunAll = 'DATASCIENCE.NATIVE.KEYBOARD.RUN_ALL',
RunAndAdd = 'DATASCIENCE.NATIVE.KEYBOARD.RUN_AND_ADD',
RunAndMove = 'DATASCIENCE.NATIVE.KEYBOARD.RUN_AND_MOVE',
RunBelow = 'DATASCIENCE.NATIVE.KEYBOARD.RUN_BELOW',
ToggleLineNumbers = 'DATASCIENCE.NATIVE.KEYBOARD.TOGGLE_LINE_NUMBERS',
ToggleOutput = 'DATASCIENCE.NATIVE.KEYBOARD.TOGGLE_OUTPUT',
ToggleVariableExplorer = 'DATASCIENCE.NATIVE.KEYBOARD.TOGGLE_VARIABLE_EXPLORER',
Undo = 'DATASCIENCE.NATIVE.KEYBOARD.UNDO',
Unfocus = 'DATASCIENCE.NATIVE.KEYBOARD.UNFOCUS'
}

export let NativeKeyboardCommandTelemetryLookup: { [id: number]: NativeKeyboardCommandTelemetry } = {};
const keys = [...Object.keys(NativeCommandType)];
const values1 = [...Object.values(NativeKeyboardCommandTelemetry)];
for (let i = 0; i < keys.length; i += 1) {
NativeKeyboardCommandTelemetryLookup[i] = values1[i];
}

export enum NativeMouseCommandTelemetry {
AddToEnd = 'DATASCIENCE.NATIVE.MOUSE.ADD_TO_END',
ArrowDown = 'DATASCIENCE.NATIVE.MOUSE.ARROW_DOWN',
ArrowUp = 'DATASCIENCE.NATIVE.MOUSE.ARROW_UP',
ChangeToCode = 'DATASCIENCE.NATIVE.MOUSE.CHANGE_TO_CODE',
ChangeToMarkdown = 'DATASCIENCE.NATIVE.MOUSE.CHANGE_TO_MARKDOWN',
CollapseInput = 'DATASCIENCE.NATIVE.MOUSE.COLLAPSE_INPUT',
CollapseOutput = 'DATASCIENCE.NATIVE.MOUSE.COLLAPSE_OUTPUT',
DeleteCell = 'DATASCIENCE.NATIVE.MOUSE.DELETE_CELL',
InsertAbove = 'DATASCIENCE.NATIVE.MOUSE.INSERT_ABOVE',
InsertBelow = 'DATASCIENCE.NATIVE.MOUSE.INSERT_BELOW',
MoveCellDown = 'DATASCIENCE.NATIVE.MOUSE.MOVE_CELL_DOWN',
MoveCellUp = 'DATASCIENCE.NATIVE.MOUSE.MOVE_CELL_UP',
Run = 'DATASCIENCE.NATIVE.MOUSE.RUN',
RunAbove = 'DATASCIENCE.NATIVE.MOUSE.RUN_ABOVE',
RunAll = 'DATASCIENCE.NATIVE.MOUSE.RUN_ALL',
RunAndAdd = 'DATASCIENCE.NATIVE.MOUSE.RUN_AND_ADD',
RunAndMove = 'DATASCIENCE.NATIVE.MOUSE.RUN_AND_MOVE',
RunBelow = 'DATASCIENCE.NATIVE.MOUSE.RUN_BELOW',
SelectKernel = 'DATASCIENCE.NATIVE.MOUSE.SELECT_KERNEL',
SelectServer = 'DATASCIENCE.NATIVE.MOUSE.SELECT_SERVER',
Save = 'DATASCIENCE.NATIVE.MOUSE.SAVE',
ToggleLineNumbers = 'DATASCIENCE.NATIVE.MOUSE.TOGGLE_LINE_NUMBERS',
ToggleOutput = 'DATASCIENCE.NATIVE.MOUSE.TOGGLE_OUTPUT',
ToggleVariableExplorer = 'DATASCIENCE.NATIVE.MOUSE.TOGGLE_VARIABLE_EXPLORER',
Undo = 'DATASCIENCE.NATIVE.MOUSE.UNDO',
Unfocus = 'DATASCIENCE.NATIVE.MOUSE.UNFOCUS'
}

export let NativeMouseCommandTelemetryLookup: { [id: number]: NativeMouseCommandTelemetry } = {};
const values2 = [...Object.values(NativeMouseCommandTelemetry)];
for (let i = 0; i < keys.length; i += 1) {
NativeMouseCommandTelemetryLookup[i] = values2[i];
ToggleVariableExplorer = 'DATASCIENCE.NATIVE.MOUSE.TOGGLE_VARIABLE_EXPLORER'
}

export namespace HelpLinks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
LoadIPyWidgetClassLoadAction
} from '../../../datascience-ui/interactive-common/redux/reducers/types';
import { PythonInterpreter } from '../../interpreter/contracts';
import { NativeKeyboardCommandTelemetry, NativeMouseCommandTelemetry } from '../constants';
import { WidgetScriptSource } from '../ipywidgets/types';
import { LiveKernelModel } from '../jupyter/kernels/types';
import { CssMessages, IGetCssRequest, IGetCssResponse, IGetMonacoThemeRequest, SharedMessages } from '../messages';
Expand Down Expand Up @@ -142,35 +143,6 @@ export enum IPyWidgetMessages {
IPyWidgets_MessageHookResult = 'IPyWidgets_MessageHookResult',
IPyWidgets_mirror_execute = 'IPyWidgets_mirror_execute'
}
export enum NativeCommandType {
AddToEnd = 0,
ArrowDown,
ArrowUp,
ChangeToCode,
ChangeToMarkdown,
CollapseInput,
CollapseOutput,
DeleteCell,
Save,
InsertAbove,
InsertBelow,
MoveCellDown,
MoveCellUp,
Redo,
Run,
RunAbove,
RunAll,
RunAndAdd,
RunAndMove,
RunBelow,
SelectKernel,
SelectServer,
ToggleLineNumbers,
ToggleOutput,
ToggleVariableExplorer,
Undo,
Unfocus
}

// These are the messages that will mirror'd to guest/hosts in
// a live share session
Expand Down Expand Up @@ -338,8 +310,7 @@ export interface ISaveAll {
}

export interface INativeCommand {
command: NativeCommandType;
source: 'keyboard' | 'mouse';
command: NativeKeyboardCommandTelemetry | NativeMouseCommandTelemetry;
}

export interface IRenderComplete {
Expand Down
14 changes: 2 additions & 12 deletions src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ import { StopWatch } from '../../common/utils/stopWatch';
import { EXTENSION_ROOT_DIR } from '../../constants';
import { PythonInterpreter } from '../../interpreter/contracts';
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
import {
EditorContexts,
Identifiers,
NativeKeyboardCommandTelemetryLookup,
NativeMouseCommandTelemetryLookup,
Telemetry
} from '../constants';
import { EditorContexts, Identifiers, Telemetry } from '../constants';
import { InteractiveBase } from '../interactive-common/interactiveBase';
import {
INativeCommand,
Expand Down Expand Up @@ -672,11 +666,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
}

private logNativeCommand(args: INativeCommand) {
const telemetryEvent =
args.source === 'mouse'
? NativeMouseCommandTelemetryLookup[args.command]
: NativeKeyboardCommandTelemetryLookup[args.command];
sendTelemetryEvent(telemetryEvent);
sendTelemetryEvent(args.command);
}

private async loadCellsComplete() {
Expand Down
23 changes: 3 additions & 20 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1678,54 +1678,37 @@ export interface IEventNamePropertyMapping {
*/
result?: 'notSelected' | 'selected' | 'installationCancelled';
};
[NativeKeyboardCommandTelemetry.AddToEnd]: never | undefined;
[NativeKeyboardCommandTelemetry.ArrowDown]: never | undefined;
[NativeKeyboardCommandTelemetry.ArrowUp]: never | undefined;
[NativeKeyboardCommandTelemetry.ChangeToCode]: never | undefined;
[NativeKeyboardCommandTelemetry.ChangeToMarkdown]: never | undefined;
[NativeKeyboardCommandTelemetry.CollapseInput]: never | undefined;
[NativeKeyboardCommandTelemetry.CollapseOutput]: never | undefined;
[NativeKeyboardCommandTelemetry.DeleteCell]: never | undefined;
[NativeKeyboardCommandTelemetry.InsertAbove]: never | undefined;
[NativeKeyboardCommandTelemetry.InsertBelow]: never | undefined;
[NativeKeyboardCommandTelemetry.MoveCellDown]: never | undefined;
[NativeKeyboardCommandTelemetry.MoveCellUp]: never | undefined;
[NativeKeyboardCommandTelemetry.Redo]: never | undefined;
[NativeKeyboardCommandTelemetry.Run]: never | undefined;
[NativeKeyboardCommandTelemetry.RunAbove]: never | undefined;
[NativeKeyboardCommandTelemetry.RunAll]: never | undefined;
[NativeKeyboardCommandTelemetry.RunAndAdd]: never | undefined;
[NativeKeyboardCommandTelemetry.RunAndMove]: never | undefined;
[NativeKeyboardCommandTelemetry.RunBelow]: never | undefined;
[NativeKeyboardCommandTelemetry.Save]: never | undefined;
[NativeKeyboardCommandTelemetry.ToggleLineNumbers]: never | undefined;
[NativeKeyboardCommandTelemetry.ToggleOutput]: never | undefined;
[NativeKeyboardCommandTelemetry.ToggleVariableExplorer]: never | undefined;
[NativeKeyboardCommandTelemetry.Undo]: never | undefined;
[NativeKeyboardCommandTelemetry.Unfocus]: never | undefined;
[NativeMouseCommandTelemetry.AddToEnd]: never | undefined;
[NativeMouseCommandTelemetry.ArrowDown]: never | undefined;
[NativeMouseCommandTelemetry.ArrowUp]: never | undefined;
[NativeMouseCommandTelemetry.ChangeToCode]: never | undefined;
[NativeMouseCommandTelemetry.ChangeToMarkdown]: never | undefined;
[NativeMouseCommandTelemetry.CollapseInput]: never | undefined;
[NativeMouseCommandTelemetry.CollapseOutput]: never | undefined;
[NativeMouseCommandTelemetry.DeleteCell]: never | undefined;
[NativeMouseCommandTelemetry.InsertAbove]: never | undefined;
[NativeMouseCommandTelemetry.InsertBelow]: never | undefined;
[NativeMouseCommandTelemetry.MoveCellDown]: never | undefined;
[NativeMouseCommandTelemetry.MoveCellUp]: never | undefined;
[NativeMouseCommandTelemetry.Run]: never | undefined;
[NativeMouseCommandTelemetry.RunAbove]: never | undefined;
[NativeMouseCommandTelemetry.RunAll]: never | undefined;
[NativeMouseCommandTelemetry.RunAndAdd]: never | undefined;
[NativeMouseCommandTelemetry.RunAndMove]: never | undefined;
[NativeMouseCommandTelemetry.RunBelow]: never | undefined;
[NativeMouseCommandTelemetry.Save]: never | undefined;
[NativeMouseCommandTelemetry.ToggleLineNumbers]: never | undefined;
[NativeMouseCommandTelemetry.ToggleOutput]: never | undefined;
[NativeMouseCommandTelemetry.SelectKernel]: never | undefined;
[NativeMouseCommandTelemetry.SelectServer]: never | undefined;
[NativeMouseCommandTelemetry.ToggleVariableExplorer]: never | undefined;
[NativeMouseCommandTelemetry.Undo]: never | undefined;
[NativeMouseCommandTelemetry.Unfocus]: never | undefined;
/*
Telemetry event sent with details of Jedi Memory usage.
mem_use - Memory usage of Process in kb.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export namespace Transfer {

export function sendCommand(arg: CommonReducerArg<CommonActionType, ISendCommandAction>): IMainState {
postActionToExtension(arg, InteractiveWindowMessages.NativeCommand, {
command: arg.payload.data.command,
source: arg.payload.data.commandType
command: arg.payload.data.command
});
return arg.prevState;
}
Expand Down
7 changes: 3 additions & 4 deletions src/datascience-ui/interactive-common/redux/reducers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License.
'use strict';

import { NativeKeyboardCommandTelemetry, NativeMouseCommandTelemetry } from '../../../../client/datascience/constants';
import {
IEditorContentChange,
InteractiveWindowMessages,
IShowDataViewer,
NativeCommandType
IShowDataViewer
} from '../../../../client/datascience/interactive-common/interactiveWindowTypes';
import { BaseReduxActionPayload } from '../../../../client/datascience/interactive-common/types';
import { IJupyterVariablesRequest } from '../../../../client/datascience/types';
Expand Down Expand Up @@ -201,8 +201,7 @@ export interface IRefreshVariablesAction {
export interface IShowDataViewerAction extends IShowDataViewer {}

export interface ISendCommandAction {
commandType: 'mouse' | 'keyboard';
command: NativeCommandType;
command: NativeKeyboardCommandTelemetry | NativeMouseCommandTelemetry;
}

export interface IChangeCellTypeAction {
Expand Down
Loading