Skip to content

Commit 55e8698

Browse files
h9jianggopherbot
authored andcommitted
extension/src: collect third party tool usage
CL 661055 under review for x/telemetry change. For golang/go#73036 Change-Id: I373d6217bdb206b967285c5ac3fddaba27cf2f67 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/661175 kokoro-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]>
1 parent ebc887f commit 55e8698

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

extension/src/goGenerateTests.ts

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { outputChannel } from './goStatus';
1919
import { getBinPath, resolvePath } from './util';
2020
import { CommandFactory } from './commands';
2121
import { GoExtensionContext } from './context';
22+
import { TelemetryKey, telemetryReporter } from './goTelemetry';
2223

2324
const generatedWord = 'Generated ';
2425

@@ -165,6 +166,8 @@ function generateTests(
165166
goConfig: vscode.WorkspaceConfiguration
166167
): Promise<boolean> {
167168
return new Promise<boolean>((resolve, reject) => {
169+
telemetryReporter.add(TelemetryKey.TOOL_USAGE_GOTESTS, 1);
170+
168171
const cmd = getBinPath('gotests');
169172
let args = ['-w'];
170173
const goGenerateTestsFlags: string[] = goConfig['generateTestsFlags'] || [];

extension/src/goModifytags.ts

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getGoConfig } from './config';
1414
import { toolExecutionEnvironment } from './goEnv';
1515
import { promptForMissingTool, promptForUpdatingTool } from './goInstallTools';
1616
import { byteOffsetAt, getBinPath, getFileArchive } from './util';
17+
import { TelemetryKey, telemetryReporter } from './goTelemetry';
1718

1819
// Interface for the output from gomodifytags
1920
interface GomodifytagsOutput {
@@ -162,6 +163,8 @@ function getTagsAndOptions(config: GoTagsConfig, commandArgs: GoTagsConfig): The
162163
}
163164

164165
function runGomodifytags(args: string[]) {
166+
telemetryReporter.add(TelemetryKey.TOOL_USAGE_GOMODIFYTAGS, 1);
167+
165168
const gomodifytags = getBinPath('gomodifytags');
166169
const editor = vscode.window.activeTextEditor;
167170
if (!editor) {

extension/src/goPlayground.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { outputChannel } from './goStatus';
1212
import { getBinPath } from './util';
1313
import vscode = require('vscode');
1414
import { CommandFactory } from './commands';
15+
import { TelemetryKey, telemetryReporter } from './goTelemetry';
1516

1617
const TOOL_CMD_NAME = 'goplay';
1718

@@ -46,6 +47,8 @@ export const playgroundCommand: CommandFactory = () => () => {
4647
};
4748

4849
export function goPlay(code: string, goConfig?: vscode.WorkspaceConfiguration): Thenable<string> {
50+
telemetryReporter.add(TelemetryKey.TOOL_USAGE_GOPLAY, 1);
51+
4952
const cliArgs = goConfig ? Object.keys(goConfig).map((key) => `-${key}=${goConfig[key]}`) : [];
5053
const binaryLocation = getBinPath(TOOL_CMD_NAME);
5154

extension/src/goTelemetry.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export enum TelemetryKey {
4949
ACTIVATION_LATENCY_L_500MS = 'activation_latency:<500ms',
5050
ACTIVATION_LATENCY_L_1000MS = 'activation_latency:<1000ms',
5151
ACTIVATION_LATENCY_L_5000MS = 'activation_latency:<5000ms',
52-
ACTIVATION_LATENCY_GE_5S = 'activation_latency:>=5s'
52+
ACTIVATION_LATENCY_GE_5S = 'activation_latency:>=5s',
53+
54+
// Indicates the tools usage.
55+
TOOL_USAGE_GOTESTS = 'vscode-go/tool/usage:gotests',
56+
TOOL_USAGE_GOPLAY = 'vscode-go/tool/usage:goplay',
57+
TOOL_USAGE_GOMODIFYTAGS = 'vscode-go/tool/usage:gomodifytags'
5358
}
5459

5560
/**

0 commit comments

Comments
 (0)