Skip to content

Commit

Permalink
Added USAGE_DATA.md (#247)
Browse files Browse the repository at this point in the history
* Added USAGE_DATA.md
  • Loading branch information
sudhirverma authored Apr 25, 2022
1 parent 4065abb commit c47a45d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions USAGE_DATA.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
## [knative Extension](https://github.com/redhat-developer/vscode-knative)

### 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
* Following are the commands which send data to telemetry.
* Build and Deploy command.
* Create function command.
* Invoke function command.
* Run function command.
* Undeploy function command.
* Configure function command.
5 changes: 5 additions & 0 deletions src/functions/function-command/configure-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

Expand Down
4 changes: 3 additions & 1 deletion src/functions/function-command/invoke-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { CliCommand, CliExitData, executeCmdCli } from '../../cli/cmdCli';
import { FuncAPI } from '../../cli/func-api';
// eslint-disable-next-line import/no-cycle
import { contextGlobalState } from '../../extension';
import { telemetryLog, telemetryLogError } from '../../telemetry';
import { getStderrString } from '../../util/stderrstring';
// eslint-disable-next-line import/no-cycle
import { FunctionNode } from '../function-tree-view/functionsTreeItem';
Expand Down Expand Up @@ -399,9 +400,10 @@ export const def: WizardDefinition = {
if (result.error) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
vscode.window.showErrorMessage(`Fail invoke Function: ${getStderrString(result.error)}`);
telemetryLogError('Invoke_error', getStderrString(result.error));
return false;
}

telemetryLog('Successfully_invoked', functionName);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
vscode.window.showInformationMessage(`Function ${functionName} successfully invoked.`);
return true;
Expand Down
2 changes: 2 additions & 0 deletions src/functions/function-command/run-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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));
}
3 changes: 3 additions & 0 deletions src/functions/function-command/undeploy-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -36,12 +37,14 @@ export async function undeployFunction(context: FunctionNode): Promise<string> {
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;
},
);
Expand Down

0 comments on commit c47a45d

Please # to comment.