提交 78fbb8d5 编写于 作者: B Bowden Kelly

Added telemetry event to look at fileTypes and config files in project folder...

Added telemetry event to look at fileTypes and config files in project folder for use in better workspace tagging.
上级 4e053774
...@@ -17,6 +17,7 @@ export interface WorkspaceStats { ...@@ -17,6 +17,7 @@ export interface WorkspaceStats {
configFiles: WorkspaceStatItem[]; configFiles: WorkspaceStatItem[];
fileCount: number; fileCount: number;
maxFilesReached: boolean; maxFilesReached: boolean;
launchConfigFiles: WorkspaceStatItem[];
} }
function asSortedItems(map: Map<string, number>): WorkspaceStatItem[] { function asSortedItems(map: Map<string, number>): WorkspaceStatItem[] {
...@@ -66,7 +67,7 @@ export function collectLaunchConfigs(folder: string): Promise<WorkspaceStatItem[ ...@@ -66,7 +67,7 @@ export function collectLaunchConfigs(folder: string): Promise<WorkspaceStatItem[
}); });
} }
export function collectWorkspaceStats(folder: string, filter: string[]): Promise<WorkspaceStats> { export async function collectWorkspaceStats(folder: string, filter: string[]): Promise<WorkspaceStats> {
const configFilePatterns = [ const configFilePatterns = [
{ 'tag': 'grunt.js', 'pattern': /^gruntfile\.js$/i }, { 'tag': 'grunt.js', 'pattern': /^gruntfile\.js$/i },
{ 'tag': 'gulp.js', 'pattern': /^gulpfile\.js$/i }, { 'tag': 'gulp.js', 'pattern': /^gulpfile\.js$/i },
...@@ -182,15 +183,17 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise ...@@ -182,15 +183,17 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Promise
let token: { count: number, maxReached: boolean } = { count: 0, maxReached: false }; let token: { count: number, maxReached: boolean } = { count: 0, maxReached: false };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
walk(folder, filter, token, (files) => { walk(folder, filter, token, async (files) => {
files.forEach(acceptFile); files.forEach(acceptFile);
let launchConfigs = await collectLaunchConfigs(folder);
resolve({ resolve({
configFiles: asSortedItems(configFiles), configFiles: asSortedItems(configFiles),
fileTypes: asSortedItems(fileTypes), fileTypes: asSortedItems(fileTypes),
fileCount: token.count, fileCount: token.count,
maxFilesReached: token.maxReached maxFilesReached: token.maxReached,
launchConfigFiles: launchConfigs
}); });
}); });
}); });
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { WorkspaceStats, collectWorkspaceStats, collectLaunchConfigs, WorkspaceStatItem } from 'vs/base/node/stats'; import { WorkspaceStats, collectWorkspaceStats, WorkspaceStatItem } from 'vs/base/node/stats';
import { IMainProcessInfo } from 'vs/platform/launch/electron-main/launchService'; import { IMainProcessInfo } from 'vs/platform/launch/electron-main/launchService';
import { ProcessItem, listProcesses } from 'vs/base/node/ps'; import { ProcessItem, listProcesses } from 'vs/base/node/ps';
import product from 'vs/platform/node/product'; import product from 'vs/platform/node/product';
...@@ -110,9 +110,8 @@ export class DiagnosticsService implements IDiagnosticsService { ...@@ -110,9 +110,8 @@ export class DiagnosticsService implements IDiagnosticsService {
workspaceInfoMessages.push(`| Folder (${basename(folder)}): ${countMessage}`); workspaceInfoMessages.push(`| Folder (${basename(folder)}): ${countMessage}`);
workspaceInfoMessages.push(this.formatWorkspaceStats(stats)); workspaceInfoMessages.push(this.formatWorkspaceStats(stats));
const launchConfigs = await collectLaunchConfigs(folder); if (stats.launchConfigFiles.length > 0) {
if (launchConfigs.length > 0) { workspaceInfoMessages.push(this.formatLaunchConfigs(stats.launchConfigFiles));
workspaceInfoMessages.push(this.formatLaunchConfigs(launchConfigs));
} }
})); }));
} else { } else {
...@@ -196,11 +195,9 @@ export class DiagnosticsService implements IDiagnosticsService { ...@@ -196,11 +195,9 @@ export class DiagnosticsService implements IDiagnosticsService {
console.log(`| Folder (${basename(folder)}): ${countMessage}`); console.log(`| Folder (${basename(folder)}): ${countMessage}`);
console.log(this.formatWorkspaceStats(stats)); console.log(this.formatWorkspaceStats(stats));
await collectLaunchConfigs(folder).then(launchConfigs => { if (stats.launchConfigFiles.length > 0) {
if (launchConfigs.length > 0) { console.log(this.formatLaunchConfigs(stats.launchConfigFiles));
console.log(this.formatLaunchConfigs(launchConfigs)); }
}
});
}).catch(error => { }).catch(error => {
console.log(`| Error: Unable to collect workspace stats for folder ${folder} (${error.toString()})`); console.log(`| Error: Unable to collect workspace stats for folder ${folder} (${error.toString()})`);
})); }));
......
...@@ -20,6 +20,7 @@ import { extname, join } from 'path'; ...@@ -20,6 +20,7 @@ import { extname, join } from 'path';
import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { collectWorkspaceStats, WorkspaceStats as WorkspaceStatsType } from 'vs/base/node/stats';
const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/; const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/;
const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/; const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/;
...@@ -225,10 +226,15 @@ export class WorkspaceStats implements IWorkbenchContribution { ...@@ -225,10 +226,15 @@ export class WorkspaceStats implements IWorkbenchContribution {
private report(): void { private report(): void {
// Workspace Stats // Workspace Tags
this.resolveWorkspaceTags(this.windowService.getConfiguration(), rootFiles => this.handleWorkspaceFiles(rootFiles)) this.resolveWorkspaceTags(this.windowService.getConfiguration(), rootFiles => this.handleWorkspaceFiles(rootFiles))
.then(tags => this.reportWorkspaceTags(tags), error => onUnexpectedError(error)); .then(tags => this.reportWorkspaceTags(tags), error => onUnexpectedError(error));
// Workspace file types, config files, and launch configs
this.getWorkspaceMetadata().then(stats => {
this.reportWorkspaceMetadata(stats);
});
// Cloud Stats // Cloud Stats
this.reportCloudStats(); this.reportCloudStats();
...@@ -731,4 +737,39 @@ export class WorkspaceStats implements IWorkbenchContribution { ...@@ -731,4 +737,39 @@ export class WorkspaceStats implements IWorkbenchContribution {
this.telemetryService.publicLog('resolveProxy.stats', { type }); this.telemetryService.publicLog('resolveProxy.stats', { type });
}).then(undefined, onUnexpectedError); }).then(undefined, onUnexpectedError);
} }
/* __GDPR__
"workspace.metadata" : {
"fileTypes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"configTypes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"launchConfigs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
}
*/
private reportWorkspaceMetadata(stats: WorkspaceStatsType[]): void {
for (let stat of stats) { // one event for each root folder in the workspace
this.telemetryService.publicLog('workspce.metadata', {
'fileTypes': stat.fileTypes,
'configTypes': stat.configFiles,
'launchConfigs': stat.launchConfigFiles
});
}
}
private getWorkspaceMetadata(): Promise<WorkspaceStatsType[]> {
const workspaceStatPromises: Promise<WorkspaceStatsType>[] = [];
const workspace = this.contextService.getWorkspace();
workspace.folders.forEach(folder => {
const folderUri = URI.revive(folder.uri);
if (folderUri.scheme === 'file') {
const folder = folderUri.fsPath;
workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(async stats => {
return stats;
}));
}
});
return Promise.all(workspaceStatPromises).then((stats) => {
return stats;
});
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册