Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
Separated telemetry metrics for debugger (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandyliu committed Feb 21, 2020
1 parent 532d196 commit 97cb358
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,12 @@ export enum CONFIG_KEYS {

export enum TelemetryEventName {
FAILED_TO_OPEN_SIMULATOR = "SIMULATOR.FAILED_TO_OPEN",
DEBUGGER_INIT_SUCCESS = "DEBUGGER.INIT.SUCCESS",
DEBUGGER_INIT_FAIL = "DEBUGGER.INIT.FAIL",

// Debugger
CPX_DEBUGGER_INIT_SUCCESS = "CPX.DEBUGGER.INIT.SUCCESS",
CPX_DEBUGGER_INIT_FAIL = "CPX.DEBUGGER.INIT.FAIL",
MICROBIT_DEBUGGER_INIT_SUCCESS = "MICROBIT.DEBUGGER.INIT.SUCCESS",
MICROBIT_DEBUGGER_INIT_FAIL = "MICROBIT.DEBUGGER.INIT.FAIL",

// Extension commands
COMMAND_RUN_SIMULATOR_BUTTON = "COMMAND.RUN.SIMULATOR_BUTTON",
Expand Down
42 changes: 36 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,7 @@ export async function activate(context: vscode.ExtensionContext) {
utils.getServerPortConfig()
);

telemetryAI.trackFeatureUsage(
TelemetryEventName.DEBUGGER_INIT_SUCCESS
);
handleDebuggerTelemetry();

openWebview();
if (currentPanel) {
Expand All @@ -952,9 +950,7 @@ export async function activate(context: vscode.ExtensionContext) {
`Error trying to init the server on port ${utils.getServerPortConfig()}`
);

telemetryAI.trackFeatureUsage(
TelemetryEventName.DEBUGGER_INIT_FAIL
);
handleDebuggerFailTelemetry();

vscode.window.showErrorMessage(
CONSTANTS.ERROR.DEBUGGER_SERVER_INIT_FAILED(
Expand Down Expand Up @@ -1039,6 +1035,40 @@ const updateCurrentFileIfPython = async (
}
};

const handleDebuggerTelemetry = () => {
switch (currentActiveDevice) {
case CONSTANTS.DEVICE_NAME.CPX:
telemetryAI.trackFeatureUsage(
TelemetryEventName.CPX_DEBUGGER_INIT_SUCCESS
);
break;
case CONSTANTS.DEVICE_NAME.MICROBIT:
telemetryAI.trackFeatureUsage(
TelemetryEventName.MICROBIT_DEBUGGER_INIT_SUCCESS
);
break;
default:
break;
}
};

const handleDebuggerFailTelemetry = () => {
switch (currentActiveDevice) {
case CONSTANTS.DEVICE_NAME.CPX:
telemetryAI.trackFeatureUsage(
TelemetryEventName.CPX_DEBUGGER_INIT_FAIL
);
break;
case CONSTANTS.DEVICE_NAME.MICROBIT:
telemetryAI.trackFeatureUsage(
TelemetryEventName.MICROBIT_DEBUGGER_INIT_FAIL
);
break;
default:
break;
}
};

const handleButtonPressTelemetry = (buttonState: any) => {
switch (currentActiveDevice) {
case CONSTANTS.DEVICE_NAME.CPX:
Expand Down

0 comments on commit 97cb358

Please sign in to comment.