提交 5c4923b2 编写于 作者: J Joao Moreno

git: telemetry events

上级 9ae2575f
......@@ -7,6 +7,7 @@
"engines": {
"vscode": "^1.5.0"
},
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"enableProposedApi": true,
"categories": [
"Other"
......@@ -588,9 +589,10 @@
}
},
"dependencies": {
"vscode-extension-telemetry": "0.0.5",
"vscode-nls": "^2.0.1"
},
"devDependencies": {
"@types/node": "^7.0.4"
}
}
\ No newline at end of file
}
......@@ -11,6 +11,7 @@ import { Model, Resource, Status, CommitOptions } from './model';
import * as staging from './staging';
import * as path from 'path';
import * as os from 'os';
import TelemetryReporter from 'vscode-extension-telemetry';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
......@@ -95,14 +96,15 @@ export class CommandCenter {
constructor(
model: Model | undefined,
private outputChannel: OutputChannel
private outputChannel: OutputChannel,
private telemetryReporter: TelemetryReporter
) {
if (model) {
this.model = model;
}
this.disposables = Commands
.map(({ commandId, method }) => commands.registerCommand(commandId, this.createCommand(method)));
.map(({ commandId, method }) => commands.registerCommand(commandId, this.createCommand(commandId, method)));
}
@command('git.refresh')
......@@ -693,13 +695,15 @@ export class CommandCenter {
this.outputChannel.show();
}
private createCommand(method: Function): (...args: any[]) => any {
private createCommand(id: string, method: Function): (...args: any[]) => any {
return (...args) => {
if (!this.model) {
window.showInformationMessage(localize('disabled', "Git is either disabled or not supported in this workspace"));
return;
}
this.telemetryReporter.sendTelemetryEvent('git.command', { command: id });
const result = Promise.resolve(method.apply(this, args));
return result.catch(async err => {
......
......@@ -15,11 +15,15 @@ import { GitContentProvider } from './contentProvider';
import { AutoFetcher } from './autofetch';
import { MergeDecorator } from './merge';
import { Askpass } from './askpass';
import TelemetryReporter from 'vscode-extension-telemetry';
import * as nls from 'vscode-nls';
const localize = nls.config()();
async function init(disposables: Disposable[]): Promise<void> {
async function init(context: ExtensionContext, disposables: Disposable[]): Promise<void> {
const { name, version, aiKey } = require(context.asAbsolutePath('./package.json')) as { name: string, version: string, aiKey: string };
const telemetryReporter: TelemetryReporter = new TelemetryReporter(name, version, aiKey);
const outputChannel = window.createOutputChannel('Git');
disposables.push(outputChannel);
......@@ -28,7 +32,7 @@ async function init(disposables: Disposable[]): Promise<void> {
const rootPath = workspace.rootPath;
if (!rootPath || !enabled) {
const commandCenter = new CommandCenter(undefined, outputChannel);
const commandCenter = new CommandCenter(undefined, outputChannel, telemetryReporter);
disposables.push(commandCenter);
return;
}
......@@ -42,7 +46,7 @@ async function init(disposables: Disposable[]): Promise<void> {
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
git.onOutput(str => outputChannel.append(str), null, disposables);
const commandCenter = new CommandCenter(model, outputChannel);
const commandCenter = new CommandCenter(model, outputChannel, telemetryReporter);
const provider = new GitSCMProvider(model, commandCenter);
const contentProvider = new GitContentProvider(model);
const checkoutStatusBar = new CheckoutStatusBar(model);
......@@ -81,6 +85,6 @@ export function activate(context: ExtensionContext): any {
const disposables: Disposable[] = [];
context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));
init(disposables)
init(context, disposables)
.catch(err => console.error(err));
}
\ No newline at end of file
declare module 'vscode-extension-telemetry' {
export default class TelemetryReporter {
constructor(extensionId: string, extensionVersion: string, key: string);
sendTelemetryEvent(eventName: string, properties?: { [key: string]: string }, measures?: { [key: string]: number }): void;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册