Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
TFVC: Add telemetry specific to Exe and CLC (#201)
Browse files Browse the repository at this point in the history
* Remove unused code and telemetry markers

* Add specific telemetry for Exe and CLC
  • Loading branch information
Jeff Young authored May 2, 2017
1 parent fde8255 commit 29f221d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 61 deletions.
8 changes: 0 additions & 8 deletions src/clients/gitclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ export class GitClient extends BaseClient {
Utils.OpenUrl(url);
}

public OpenPullRequestsPage(): void {
Telemetry.SendEvent(TelemetryEvents.OpenPullRequestsPage);

const url: string = GitVcService.GetPullRequestsUrl(this._serverContext.RepoInfo.RepositoryUrl);
Logger.LogInfo("OpenPullRequestsPage: " + url);
Utils.OpenUrl(url);
}

public async PollMyPullRequests(): Promise<void> {
try {
const requests: BaseQuickPickItem[] = await this.getMyPullRequests();
Expand Down
2 changes: 0 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand(CommandNames.OpenNewPullRequest, () => _extensionManager.Team.OpenNewPullRequest()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenNewTask, () => _extensionManager.Team.OpenNewTask()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenNewWorkItem, () => _extensionManager.Team.OpenNewWorkItem()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenPullRequestsPage, () => _extensionManager.Team.OpenPullRequestsPage()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenTeamSite, () => _extensionManager.Team.OpenTeamProjectWebSite()));
context.subscriptions.push(commands.registerCommand(CommandNames.ViewWorkItems, () => _extensionManager.Team.ViewMyWorkItems()));
context.subscriptions.push(commands.registerCommand(CommandNames.ViewPinnedQueryWorkItems, () => _extensionManager.Team.ViewPinnedQueryWorkItems()));
Expand All @@ -38,7 +37,6 @@ export async function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand(CommandNames.RefreshPollingStatus, () => _extensionManager.Team.RefreshPollingStatus()));

// TFVC Commands
context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Status, () => _extensionManager.Tfvc.Status()));
context.subscriptions.push(commands.registerCommand(TfvcCommandNames.UndoAll, () => {
_extensionManager.Tfvc.UndoAll();
}));
Expand Down
55 changes: 40 additions & 15 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class CommandNames {
static OpenNewTask: string = CommandNames.CommandPrefix + "OpenNewTask";
static OpenNewPullRequest: string = CommandNames.CommandPrefix + "OpenNewPullRequest";
static OpenNewWorkItem: string = CommandNames.CommandPrefix + "OpenNewWorkItem";
static OpenPullRequestsPage: string = CommandNames.CommandPrefix + "OpenPullRequestsPage";
static OpenTeamSite: string = CommandNames.CommandPrefix + "OpenTeamSite";
static RefreshPollingStatus: string = CommandNames.CommandPrefix + "RefreshPollingStatus";
static Reinitialize: string = CommandNames.CommandPrefix + "Reinitialize";
Expand All @@ -55,7 +54,6 @@ export class TfvcCommandNames {
static ResolveKeepYours: string = TfvcCommandNames.CommandPrefix + "ResolveKeepYours";
static ResolveTakeTheirs: string = TfvcCommandNames.CommandPrefix + "ResolveTakeTheirs";
static ShowOutput: string = TfvcCommandNames.CommandPrefix + "ShowOutput";
static Status: string = TfvcCommandNames.CommandPrefix + "Status";
static Sync: string = TfvcCommandNames.CommandPrefix + "Sync";
static Undo: string = TfvcCommandNames.CommandPrefix + "Undo";
static UndoAll: string = TfvcCommandNames.CommandPrefix + "UndoAll";
Expand Down Expand Up @@ -90,7 +88,6 @@ export class TelemetryEvents {
static OpenNewWorkItem: string = TelemetryEvents.TelemetryPrefix + "opennewworkitem";
static OpenRepositoryHistory: string = TelemetryEvents.TelemetryPrefix + "openrepohistory";
static OpenTeamSite: string = TelemetryEvents.TelemetryPrefix + "openteamprojectweb";
static OpenPullRequestsPage: string = TelemetryEvents.TelemetryPrefix + "openpullrequestspage";
static ReadmeLearnMoreClick: string = TelemetryEvents.TelemetryPrefix + "readmelearnmoreclick";
static SendAFrown: string = TelemetryEvents.TelemetryPrefix + "sendafrown";
static SendASmile: string = TelemetryEvents.TelemetryPrefix + "sendasmile";
Expand All @@ -108,19 +105,47 @@ export class TelemetryEvents {
static VS2015U3CSR: string = TelemetryEvents.TelemetryPrefix + "vs2015u3csr";
}

export class TfvcTelemetryEvents {
//Don't export this class. TfvcTelemetryEvents is the only one which should be used when sending telemetry
class TfvcBaseTelemetryEvents {
static TelemetryPrefix: string = "tfvc/";
static Checkin: string = TfvcTelemetryEvents.TelemetryPrefix + "checkin";
static NameAndContentConflict: string = TfvcTelemetryEvents.TelemetryPrefix + "nameandcontentconflict";
static OpenFileHistory: string = TfvcTelemetryEvents.TelemetryPrefix + "openfilehistory";
static OpenRepositoryHistory: string = TfvcTelemetryEvents.TelemetryPrefix + "openrepohistory";
static RenameConflict: string = TfvcTelemetryEvents.TelemetryPrefix + "renameconflict";
static RestrictWorkspace: string = TfvcTelemetryEvents.TelemetryPrefix + "restrictWorkspace";
static Status: string = TfvcTelemetryEvents.TelemetryPrefix + "status";
static StartUp: string = TfvcTelemetryEvents.TelemetryPrefix + "startup";
static Sync: string = TfvcTelemetryEvents.TelemetryPrefix + "sync";
static UsingClc: string = TfvcTelemetryEvents.TelemetryPrefix + "clc";
static UsingExe: string = TfvcTelemetryEvents.TelemetryPrefix + "exe";
static Clc: string = TfvcBaseTelemetryEvents.TelemetryPrefix + "clc";
static Exe: string = TfvcBaseTelemetryEvents.TelemetryPrefix + "exe";
static Checkin: string = "checkin";
static NameAndContentConflict: string = "nameandcontentconflict";
static OpenFileHistory: string = "openfilehistory";
static OpenRepositoryHistory: string = "openrepohistory";
static RenameConflict: string = "renameconflict";
static Rename: string = "rename";
static ResolveConflicts: string = "resolveconflicts";
static RestrictWorkspace: string = "restrictworkspace";
static StartUp: string = "startup";
static Sync: string = "sync";
static Undo: string = "undo";
static UndoAll: string = "undoall";
}

export class TfvcTelemetryEvents {
static UsingClc: string = TfvcBaseTelemetryEvents.Clc;
static UsingExe: string = TfvcBaseTelemetryEvents.Exe;
static NameAndContentConflict: string = TfvcBaseTelemetryEvents.TelemetryPrefix + TfvcBaseTelemetryEvents.NameAndContentConflict;
static OpenFileHistory: string = TfvcBaseTelemetryEvents.TelemetryPrefix + TfvcBaseTelemetryEvents.OpenFileHistory;
static OpenRepositoryHistory: string = TfvcBaseTelemetryEvents.TelemetryPrefix + TfvcBaseTelemetryEvents.OpenRepositoryHistory;
static RenameConflict: string = TfvcBaseTelemetryEvents.TelemetryPrefix + TfvcBaseTelemetryEvents.RenameConflict;
static RestrictWorkspace: string = TfvcBaseTelemetryEvents.TelemetryPrefix + TfvcBaseTelemetryEvents.RestrictWorkspace;
static StartUp: string = TfvcBaseTelemetryEvents.TelemetryPrefix + TfvcBaseTelemetryEvents.StartUp;
//Begin tooling-specific telemetry (tf.exe or CLC)
static CheckinExe: string = TfvcTelemetryEvents.UsingExe + "-" + TfvcBaseTelemetryEvents.Checkin;
static CheckinClc: string = TfvcTelemetryEvents.UsingClc + "-" + TfvcBaseTelemetryEvents.Checkin;
static RenameExe: string = TfvcTelemetryEvents.UsingExe + "-" + TfvcBaseTelemetryEvents.Rename;
static RenameClc: string = TfvcTelemetryEvents.UsingClc + "-" + TfvcBaseTelemetryEvents.Rename;
static ResolveConflictsExe: string = TfvcTelemetryEvents.UsingExe + "-" + TfvcBaseTelemetryEvents.ResolveConflicts;
static ResolveConflictsClc: string = TfvcTelemetryEvents.UsingClc + "-" + TfvcBaseTelemetryEvents.ResolveConflicts;
static SyncExe: string = TfvcTelemetryEvents.UsingExe + "-" + TfvcBaseTelemetryEvents.Sync;
static SyncClc: string = TfvcTelemetryEvents.UsingClc + "-" + TfvcBaseTelemetryEvents.Sync;
static UndoExe: string = TfvcTelemetryEvents.UsingExe + "-" + TfvcBaseTelemetryEvents.Undo;
static UndoClc: string = TfvcTelemetryEvents.UsingClc + "-" + TfvcBaseTelemetryEvents.Undo;
static UndoAllExe: string = TfvcTelemetryEvents.UsingExe + "-" + TfvcBaseTelemetryEvents.UndoAll;
static UndoAllClc: string = TfvcTelemetryEvents.UsingClc + "-" + TfvcBaseTelemetryEvents.UndoAll;
}

export class WellKnownRepositoryTypes {
Expand Down
11 changes: 0 additions & 11 deletions src/team-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,6 @@ export class TeamExtension {
}
}

//Opens the main pull requests page
public OpenPullRequestsPage(): void {
if (this._manager.EnsureInitialized(RepositoryType.GIT)) {
if (this._gitClient) {
this._gitClient.OpenPullRequestsPage();
}
} else {
this._manager.DisplayErrorMessage();
}
}

//Opens the team project web site
public OpenTeamProjectWebSite(): void {
if (this._manager.EnsureInitialized(RepositoryType.ANY)) {
Expand Down
34 changes: 9 additions & 25 deletions src/tfvc/tfvc-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"use strict";

import * as path from "path";
import { commands, Uri, window, workspace } from "vscode";
import { commands, Uri, window } from "vscode";
import { RepositoryType } from "../contexts/repositorycontext";
import { TfvcContext } from "../contexts/tfvccontext";
import { ExtensionManager } from "../extensionmanager";
Expand All @@ -21,7 +21,7 @@ import { TfvcSCMProvider } from "./tfvcscmprovider";
import { TfvcErrorCodes } from "./tfvcerror";
import { TfvcRepository } from "./tfvcrepository";
import { UIHelper } from "./uihelper";
import { AutoResolveType, ICheckinInfo, IItemInfo, IPendingChange, ISyncResults } from "./interfaces";
import { AutoResolveType, ICheckinInfo, IItemInfo, ISyncResults } from "./interfaces";
import { TfvcOutput } from "./tfvcoutput";

export class TfvcExtension {
Expand All @@ -42,10 +42,10 @@ export class TfvcExtension {
return;
}

Telemetry.SendEvent(TfvcTelemetryEvents.Checkin);
Telemetry.SendEvent(this._repo.IsExe ? TfvcTelemetryEvents.CheckinExe : TfvcTelemetryEvents.CheckinClc);
const changeset: string =
await this._repo.Checkin(checkinInfo.files, checkinInfo.comment, checkinInfo.workItemIds);
TfvcOutput.AppendLine("Changeset " + changeset + " checked in.");
TfvcOutput.AppendLine(`Changeset ${changeset} checked in.`);
TfvcSCMProvider.ClearCheckinMessage();
TfvcSCMProvider.Refresh();
},
Expand Down Expand Up @@ -169,7 +169,7 @@ export class TfvcExtension {
const destination: string = path.join(dirName, newFilename);

try {
//We decided not to send telemetry on file operations
Telemetry.SendEvent(this._repo.IsExe ? TfvcTelemetryEvents.RenameExe : TfvcTelemetryEvents.RenameClc);
await this._repo.Rename(uri.fsPath, destination);
} catch (err) {
//Provide a better error message if the file to be renamed isn't in the workspace (e.g., it's a new file)
Expand All @@ -196,6 +196,7 @@ export class TfvcExtension {
const basename: string = path.basename(localPath);
const message: string = `Are you sure you want to resolve changes in ${basename} as ${resolveTypeString}?`;
if (await UIHelper.PromptForConfirmation(message, resolveTypeString)) {
Telemetry.SendEvent(this._repo.IsExe ? TfvcTelemetryEvents.ResolveConflictsExe : TfvcTelemetryEvents.ResolveConflictsClc);
await this._repo.ResolveConflicts([localPath], autoResolveType);
TfvcSCMProvider.Refresh();
}
Expand All @@ -210,31 +211,14 @@ export class TfvcExtension {
TfvcOutput.Show();
}

/**
* This command runs a status command on the VSCode workspace folder and
* displays the results to the user. Selecting one of the files in the list will
* open the file in the editor.
*/
public async Status(): Promise<void> {
this.displayErrors(
async () => {
Telemetry.SendEvent(TfvcTelemetryEvents.Status);
const chosenItem: IPendingChange = await UIHelper.ChoosePendingChange(await this._repo.GetStatus());
if (chosenItem) {
window.showTextDocument(await workspace.openTextDocument(chosenItem.localItem));
}
},
"Status");
}

/**
* This command runs a 'tf get' command on the VSCode workspace folder and
* displays the results to the user.
*/
public async Sync(): Promise<void> {
this.displayErrors(
async () => {
Telemetry.SendEvent(TfvcTelemetryEvents.Sync);
Telemetry.SendEvent(this._repo.IsExe ? TfvcTelemetryEvents.SyncExe : TfvcTelemetryEvents.SyncClc);
const results: ISyncResults = await this._repo.Sync([this._repo.Path], true);
await UIHelper.ShowSyncResults(results, results.hasConflicts || results.hasErrors, true);
},
Expand Down Expand Up @@ -262,7 +246,7 @@ export class TfvcExtension {
message = `Are you sure you want to undo changes to ${pathsToUndo.length.toString()} files?`;
}
if (await UIHelper.PromptForConfirmation(message, Strings.UndoChanges)) {
//We decided not to send telemetry on file operations
Telemetry.SendEvent(this._repo.IsExe ? TfvcTelemetryEvents.UndoExe : TfvcTelemetryEvents.UndoClc);
await this._repo.Undo(pathsToUndo);
}
}
Expand All @@ -282,7 +266,7 @@ export class TfvcExtension {
if (TfvcSCMProvider.HasItems()) {
const message: string = `Are you sure you want to undo all changes?`;
if (await UIHelper.PromptForConfirmation(message, Strings.UndoChanges)) {
//We decided not to send telemetry on file operations
Telemetry.SendEvent(this._repo.IsExe ? TfvcTelemetryEvents.UndoAllExe : TfvcTelemetryEvents.UndoAllClc);
await this._repo.Undo(["*"]);
}
} else {
Expand Down

0 comments on commit 29f221d

Please sign in to comment.