Telemetry Command (#76029)
* Added telemetry command * Initial Build support * Added build logic for telemetry * Linux Builds * Windows builds sort of work * Remove arm telemetry extraction * Remove alpine telemetry extraction * Remove accidental s * More try catch
This commit is contained in:
parent
a77402669c
commit
4a69a71065
|
@ -59,6 +59,21 @@ steps:
|
||||||
node build/lib/builtInExtensions.js
|
node build/lib/builtInExtensions.js
|
||||||
displayName: Install distro dependencies and extensions
|
displayName: Install distro dependencies and extensions
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
set -e
|
||||||
|
cd ..
|
||||||
|
git clone https://github.com/microsoft/vscode-telemetry-extractor.git
|
||||||
|
cd vscode-telemetry-extractor
|
||||||
|
npm install
|
||||||
|
./node_modules/typescript/bin/tsc
|
||||||
|
npm run setup-extension-repos
|
||||||
|
node ./out/cli-extract.js --sourceDir ../s --excludedDirPattern extensions --outputDir . --applyEndpoints --includeIsMeasurement --patchWebsiteEvents
|
||||||
|
node ./out/cli-extract-extensions.js --sourceDir ./src/telemetry-sources/ --outputDir . --applyEndpoints --includeIsMeasurement
|
||||||
|
mv declarations-resolved.json ../s/src/telemetry-core.json
|
||||||
|
mv declarations-extensions-resolved.json ../s/src/telemetry-extensions.json
|
||||||
|
echo 'Moved Files'
|
||||||
|
displayName: Extract Telemetry
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
set -e
|
set -e
|
||||||
VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
|
VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
|
||||||
|
|
|
@ -60,6 +60,21 @@ steps:
|
||||||
node build/lib/builtInExtensions.js
|
node build/lib/builtInExtensions.js
|
||||||
displayName: Install distro dependencies and extensions
|
displayName: Install distro dependencies and extensions
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
set -e
|
||||||
|
cd ..
|
||||||
|
git clone https://github.com/microsoft/vscode-telemetry-extractor.git
|
||||||
|
cd vscode-telemetry-extractor
|
||||||
|
npm install
|
||||||
|
./node_modules/typescript/bin/tsc
|
||||||
|
npm run setup-extension-repos
|
||||||
|
node ./out/cli-extract.js --sourceDir ../s --excludedDirPattern extensions --outputDir . --applyEndpoints --includeIsMeasurement --patchWebsiteEvents
|
||||||
|
node ./out/cli-extract-extensions.js --sourceDir ./src/telemetry-sources/ --outputDir . --applyEndpoints --includeIsMeasurement
|
||||||
|
mv declarations-resolved.json ../s/src/telemetry-core.json
|
||||||
|
mv declarations-extensions-resolved.json ../s/src/telemetry-extensions.json
|
||||||
|
echo 'Moved Files'
|
||||||
|
displayName: Extract Telemetry
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
set -e
|
set -e
|
||||||
VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
|
VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
|
||||||
|
|
|
@ -65,6 +65,23 @@ steps:
|
||||||
exec { node build/lib/builtInExtensions.js }
|
exec { node build/lib/builtInExtensions.js }
|
||||||
displayName: Install distro dependencies and extensions
|
displayName: Install distro dependencies and extensions
|
||||||
|
|
||||||
|
- powershell: |
|
||||||
|
. build/azure-pipelines/win32/exec.ps1
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
cd ..
|
||||||
|
git clone https://github.com/microsoft/vscode-telemetry-extractor.git
|
||||||
|
cd vscode-telemetry-extractor
|
||||||
|
npm install
|
||||||
|
npm install -g typescript
|
||||||
|
tsc
|
||||||
|
npm run setup-extension-repos
|
||||||
|
node ./out/cli-extract.js --sourceDir ../s --excludedDirPattern extensions --outputDir . --applyEndpoints --includeIsMeasurement --patchWebsiteEvents
|
||||||
|
node ./out/cli-extract-extensions.js --sourceDir ./src/telemetry-sources/ --outputDir . --applyEndpoints --includeIsMeasurement
|
||||||
|
mv declarations-resolved.json ../s/src/telemetry-core.json
|
||||||
|
mv declarations-extensions-resolved.json ../s/src/telemetry-extensions.json
|
||||||
|
echo 'Moved Files'
|
||||||
|
displayName: Extract Telemetry
|
||||||
|
|
||||||
- powershell: |
|
- powershell: |
|
||||||
. build/azure-pipelines/win32/exec.ps1
|
. build/azure-pipelines/win32/exec.ps1
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
|
@ -62,6 +62,8 @@ const vscodeResources = [
|
||||||
'out-build/bootstrap-amd.js',
|
'out-build/bootstrap-amd.js',
|
||||||
'out-build/bootstrap-window.js',
|
'out-build/bootstrap-window.js',
|
||||||
'out-build/paths.js',
|
'out-build/paths.js',
|
||||||
|
'out-build/telemetry-core.json',
|
||||||
|
'out-build/telemetry-extensions.json',
|
||||||
'out-build/vs/**/*.{svg,png,cur,html}',
|
'out-build/vs/**/*.{svg,png,cur,html}',
|
||||||
'!out-build/vs/code/browser/**/*.html',
|
'!out-build/vs/code/browser/**/*.html',
|
||||||
'out-build/vs/base/common/performance.js',
|
'out-build/vs/base/common/performance.js',
|
||||||
|
@ -327,7 +329,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
|
||||||
.pipe(createAsar(path.join(process.cwd(), 'node_modules'), ['**/*.node', '**/vscode-ripgrep/bin/*', '**/node-pty/build/Release/*'], 'app/node_modules.asar'));
|
.pipe(createAsar(path.join(process.cwd(), 'node_modules'), ['**/*.node', '**/vscode-ripgrep/bin/*', '**/node-pty/build/Release/*'], 'app/node_modules.asar'));
|
||||||
|
|
||||||
let all = es.merge(
|
let all = es.merge(
|
||||||
packageJsonStream,
|
packageJsonStream,
|
||||||
productJsonStream,
|
productJsonStream,
|
||||||
license,
|
license,
|
||||||
api,
|
api,
|
||||||
|
|
|
@ -14,6 +14,7 @@ arguments=(
|
||||||
'--user-data-dir[specify the directory that user data is kept in]:directory:_directories'
|
'--user-data-dir[specify the directory that user data is kept in]:directory:_directories'
|
||||||
'(- *)'{-v,--version}'[print version]'
|
'(- *)'{-v,--version}'[print version]'
|
||||||
'(- *)'{-h,--help}'[print usage]'
|
'(- *)'{-h,--help}'[print usage]'
|
||||||
|
'(- *)'{--telemetry}'[Shows all telemetry events which VS code collects.]'
|
||||||
'--extensions-dir[set the root path for extensions]:root path:_directories'
|
'--extensions-dir[set the root path for extensions]:root path:_directories'
|
||||||
'--list-extensions[list the installed extensions]'
|
'--list-extensions[list the installed extensions]'
|
||||||
'--show-versions[show versions of installed extensions, when using --list-extension]'
|
'--show-versions[show versions of installed extensions, when using --list-extension]'
|
||||||
|
|
|
@ -25,7 +25,8 @@ function shouldSpawnCliProcess(argv: ParsedArgs): boolean {
|
||||||
|| !!argv['list-extensions']
|
|| !!argv['list-extensions']
|
||||||
|| !!argv['install-extension']
|
|| !!argv['install-extension']
|
||||||
|| !!argv['uninstall-extension']
|
|| !!argv['uninstall-extension']
|
||||||
|| !!argv['locate-extension'];
|
|| !!argv['locate-extension']
|
||||||
|
|| !!argv['telemetry'];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IMainCli {
|
interface IMainCli {
|
||||||
|
|
|
@ -41,6 +41,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
|
||||||
import { LocalizationsService } from 'vs/platform/localizations/node/localizations';
|
import { LocalizationsService } from 'vs/platform/localizations/node/localizations';
|
||||||
import { Schemas } from 'vs/base/common/network';
|
import { Schemas } from 'vs/base/common/network';
|
||||||
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
|
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
|
||||||
|
import { buildTelemetryMessage } from 'vs/platform/environment/node/argv';
|
||||||
|
|
||||||
const notFound = (id: string) => localize('notFound', "Extension '{0}' not found.", id);
|
const notFound = (id: string) => localize('notFound', "Extension '{0}' not found.", id);
|
||||||
const notInstalled = (id: string) => localize('notInstalled', "Extension '{0}' is not installed.", id);
|
const notInstalled = (id: string) => localize('notInstalled', "Extension '{0}' is not installed.", id);
|
||||||
|
@ -94,6 +95,8 @@ export class Main {
|
||||||
const arg = argv['locate-extension'];
|
const arg = argv['locate-extension'];
|
||||||
const ids: string[] = typeof arg === 'string' ? [arg] : arg;
|
const ids: string[] = typeof arg === 'string' ? [arg] : arg;
|
||||||
await this.locateExtension(ids);
|
await this.locateExtension(ids);
|
||||||
|
} else if (argv['telemetry']) {
|
||||||
|
console.log(buildTelemetryMessage(this.environmentService.appRoot, this.environmentService.extensionsPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ export interface ParsedArgs {
|
||||||
_urls?: string[];
|
_urls?: string[];
|
||||||
help?: boolean;
|
help?: boolean;
|
||||||
version?: boolean;
|
version?: boolean;
|
||||||
|
telemetry?: boolean;
|
||||||
status?: boolean;
|
status?: boolean;
|
||||||
wait?: boolean;
|
wait?: boolean;
|
||||||
waitMarkerFilePath?: string;
|
waitMarkerFilePath?: string;
|
||||||
|
|
|
@ -8,7 +8,8 @@ import * as os from 'os';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||||
import { join } from 'vs/base/common/path';
|
import { join } from 'vs/base/common/path';
|
||||||
import { writeFileSync } from 'vs/base/node/pfs';
|
import { statSync, readFileSync } from 'fs';
|
||||||
|
import { writeFileSync, readdirSync } from 'vs/base/node/pfs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This code is also used by standalone cli's. Avoid adding any other dependencies.
|
* This code is also used by standalone cli's. Avoid adding any other dependencies.
|
||||||
|
@ -41,6 +42,7 @@ export const options: Option[] = [
|
||||||
{ id: 'user-data-dir', type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") },
|
{ id: 'user-data-dir', type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") },
|
||||||
{ id: 'version', type: 'boolean', cat: 'o', alias: 'v', description: localize('version', "Print version.") },
|
{ id: 'version', type: 'boolean', cat: 'o', alias: 'v', description: localize('version', "Print version.") },
|
||||||
{ id: 'help', type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },
|
{ id: 'help', type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },
|
||||||
|
{ id: 'telemetry', type: 'boolean', cat: 'o', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },
|
||||||
{ id: 'folder-uri', type: 'string', cat: 'o', args: 'uri', description: localize('folderUri', "Opens a window with given folder uri(s)") },
|
{ id: 'folder-uri', type: 'string', cat: 'o', args: 'uri', description: localize('folderUri', "Opens a window with given folder uri(s)") },
|
||||||
{ id: 'file-uri', type: 'string', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") },
|
{ id: 'file-uri', type: 'string', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") },
|
||||||
|
|
||||||
|
@ -217,6 +219,38 @@ export function buildVersionMessage(version: string | undefined, commit: string
|
||||||
return `${version || localize('unknownVersion', "Unknown version")}\n${commit || localize('unknownCommit', "Unknown commit")}\n${process.arch}`;
|
return `${version || localize('unknownVersion', "Unknown version")}\n${commit || localize('unknownCommit', "Unknown commit")}\n${process.arch}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildTelemetryMessage(appRoot: string, extensionsPath: string): string {
|
||||||
|
try {
|
||||||
|
// Gets all the directories inside the extension directory
|
||||||
|
const dirs = readdirSync(extensionsPath).filter(files => statSync(join(extensionsPath, files)).isDirectory());
|
||||||
|
const telemetryJsonFolders: string[] = [];
|
||||||
|
dirs.forEach((dir) => {
|
||||||
|
const files = readdirSync(join(extensionsPath, dir)).filter(file => file === 'telemetry.json');
|
||||||
|
// We know it contains a telemetry.json file so we add it to the list of folders which have one
|
||||||
|
if (files.length === 1) {
|
||||||
|
telemetryJsonFolders.push(dir);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const mergedTelemetry = Object.create(null);
|
||||||
|
// Simple function to merge the telemetry into one json object
|
||||||
|
const mergeTelemetry = (contents: string, dirName: string) => {
|
||||||
|
const telemetryData = JSON.parse(contents);
|
||||||
|
mergedTelemetry[dirName] = telemetryData;
|
||||||
|
};
|
||||||
|
telemetryJsonFolders.forEach((folder) => {
|
||||||
|
const contents = readFileSync(join(extensionsPath, folder, 'telemetry.json')).toString();
|
||||||
|
mergeTelemetry(contents, folder);
|
||||||
|
});
|
||||||
|
let contents = readFileSync(join(appRoot, 'out/', 'telemetry-core.json')).toString();
|
||||||
|
mergeTelemetry(contents, 'vscode-core');
|
||||||
|
contents = readFileSync(join(appRoot, 'out/', 'telemetry-extensions.json')).toString();
|
||||||
|
mergeTelemetry(contents, 'vscode-extensions');
|
||||||
|
return JSON.stringify(mergedTelemetry, null, 4);
|
||||||
|
} catch (err) {
|
||||||
|
return 'Unable to read VS Code telemetry events!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an argument into an array
|
* Converts an argument into an array
|
||||||
* @param arg a argument value. Can be undefined, an entry or an array
|
* @param arg a argument value. Can be undefined, an entry or an array
|
||||||
|
|
Loading…
Reference in a new issue