From b348b08f759a802b71a99978d5fdb51194891b97 Mon Sep 17 00:00:00 2001 From: Sudhir Verma Date: Mon, 25 Apr 2022 13:18:22 +0530 Subject: [PATCH] Added Run, undeploy and configure function command --- USAGE_DATA.md | 17 ++++++++++------- .../function-command/configure-function.ts | 5 +++++ src/functions/function-command/run-function.ts | 2 ++ .../function-command/undeploy-function.ts | 3 +++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/USAGE_DATA.md b/USAGE_DATA.md index 31a46bb2..c6d2bc4c 100644 --- a/USAGE_DATA.md +++ b/USAGE_DATA.md @@ -2,13 +2,16 @@ ### Usage Data -* when the extension is activated -* when following command(s) contributed by extension is executed - * command's ID - * command's error message (in case of exception) - * command's specific data like kn version, fn version and to check which command user has used. -* when the extension is deactivated +* When the extension is activated +* When following command(s) contributed by extension is executed + * Command's ID + * Command's error message (in case of exception) + * Command's specific data like kn version, fn version and to check which command user has used. +* When the extension is deactivated * Following are the commands which send data to telemetry. * Build and Deploy command. * Create function command. - * Invoke function command. \ No newline at end of file + * Invoke function command. + * Run function command. + * Undeploy function command. + * Configure function command. \ No newline at end of file diff --git a/src/functions/function-command/configure-function.ts b/src/functions/function-command/configure-function.ts index 0100f750..d0f88a80 100644 --- a/src/functions/function-command/configure-function.ts +++ b/src/functions/function-command/configure-function.ts @@ -9,6 +9,7 @@ import { selectFunctionFolder } from './build-and-deploy-function'; import { CliCommand } from '../../cli/cmdCli'; import { knExecutor } from '../../cli/execute'; import { FuncAPI } from '../../cli/func-api'; +import { telemetryLog } from '../../telemetry'; import { FunctionNode } from '../function-tree-view/functionsTreeItem'; export const enum ConfigAction { @@ -21,15 +22,19 @@ export const VOLUMES = 'Volumes'; function getConfigEnvsCliCommand(action: ConfigAction, funcPath: string) { if (action === ConfigAction.Add) { + telemetryLog('Function_add_environment_variable', 'Click on add environment variable command'); return FuncAPI.addEnvironmentVariable(funcPath); } + telemetryLog('Function_remove_environment_variable', 'Click on remove environment variable command'); return FuncAPI.removeEnvironmentVariable(funcPath); } function getConfigVolumesCliCommand(action: ConfigAction, funcPath: string) { if (action === ConfigAction.Add) { + telemetryLog('Function_add_volume', 'Click on add volume command'); return FuncAPI.addVolumes(funcPath); } + telemetryLog('Function_remove_volume', 'Click on remove volume command'); return FuncAPI.removeVolumes(funcPath); } diff --git a/src/functions/function-command/run-function.ts b/src/functions/function-command/run-function.ts index 6eabf279..e4fb8085 100644 --- a/src/functions/function-command/run-function.ts +++ b/src/functions/function-command/run-function.ts @@ -6,12 +6,14 @@ import { knExecutor } from '../../cli/execute'; import { FuncAPI } from '../../cli/func-api'; +import { telemetryLog } from '../../telemetry'; import { FunctionNode } from '../function-tree-view/functionsTreeItem'; export async function runFunction(context?: FunctionNode): Promise { if (!context) { return null; } + telemetryLog('Function_run_command', `Function run command click name: ${context.getName()}`); // TO DO await knExecutor.executeInTerminal(FuncAPI.runFunc(context.contextPath.fsPath)); } diff --git a/src/functions/function-command/undeploy-function.ts b/src/functions/function-command/undeploy-function.ts index 167b16c5..f66726fb 100644 --- a/src/functions/function-command/undeploy-function.ts +++ b/src/functions/function-command/undeploy-function.ts @@ -7,6 +7,7 @@ import * as vscode from 'vscode'; import { CliExitData, executeCmdCli } from '../../cli/cmdCli'; import { FuncAPI } from '../../cli/func-api'; +import { telemetryLog, telemetryLogError } from '../../telemetry'; import { getStderrString } from '../../util/stderrstring'; import { FunctionNode } from '../function-tree-view/functionsTreeItem'; import { functionExplorer } from '../functionsExplorer'; @@ -36,12 +37,14 @@ export async function undeployFunction(context: FunctionNode): Promise { vscode.window.showErrorMessage( `Failed to undeploy function ${context.getName()} - error ${getStderrString(result.error)}`, ); + telemetryLogError('Function_undeploy_error', getStderrString(result.error)); return null; } // eslint-disable-next-line @typescript-eslint/no-floating-promises vscode.window.showInformationMessage(`Function ${context.getName()} successfully undeployed`); // eslint-disable-next-line @typescript-eslint/no-floating-promises functionExplorer.refresh(); + telemetryLog('Function_successfully_undeploy', context.getName()); return null; }, );