"Add to plan" context menu telemetry

This commit is contained in:
Eduard Zambrano 2019-08-21 09:58:14 -07:00
Родитель d194e3ccf7
Коммит bc2a62f4e6
3 изменённых файлов: 51 добавлений и 17 удалений

Просмотреть файл

@ -31,6 +31,7 @@ export class PortfolioPlanActionsService {
if (plans.entries.length === 0) {
// Don't show any items if there are no plans created yet.
PortfolioTelemetry.getInstance().TrackAction("AddToPlanAction/NoPlansFoundInDirectory");
return result;
}
@ -67,6 +68,12 @@ export class PortfolioPlanActionsService {
}
private openAllPlansDialog(workItemIds: number[], directory: PortfolioPlanningDirectory): void {
const telemetryService = PortfolioTelemetry.getInstance();
const telemetryData = {
["WorkItemCount"]: workItemIds.length
};
PortfolioTelemetry.getInstance().TrackAction("AddToPlanAction/openAllPlansDialog", telemetryData);
let onOkClickHandler: () => Promise<void> = null;
const dialogInput: IDialogInputData = {
@ -74,7 +81,8 @@ export class PortfolioPlanActionsService {
directory,
setOnOkClickHandler: (onOkClickHandlerInstance: () => Promise<void>) => {
onOkClickHandler = onOkClickHandlerInstance;
}
},
telemetryService
};
VSS.getService(VSS.ServiceIds.Dialog).then((hostDialogService: IHostDialogService) => {
@ -151,6 +159,12 @@ export class PortfolioPlanActionsService {
}
private async addWorkItemIdsToPlan(planId: string, workItemIds: number[]): Promise<void> {
const telemetryData = {
["PlanId"]: planId,
["WorkItemCount"]: workItemIds.length
};
PortfolioTelemetry.getInstance().TrackAction("AddToPlanAction/addWorkItemIdsToPlan", telemetryData);
const plan = await PortfolioPlanningDataService.getInstance().AddWorkItemsToPlan(planId, workItemIds);
if (!plan) {

Просмотреть файл

@ -401,20 +401,31 @@ export class PortfolioPlanningDataService {
return totalThatWillBeDeleted;
}
public async AddWorkItemsToPlan(planId: string, workItemIds: number[]): Promise<PortfolioPlanning> {
public async AddWorkItemsToPlan(
planId: string,
workItemIds: number[],
telemetryService?: PortfolioTelemetry
): Promise<PortfolioPlanning> {
if (!telemetryService) {
telemetryService = PortfolioTelemetry.getInstance();
}
try {
console.log(`AddWorkItemsToPlan. WorkItemIds: ${workItemIds.join(", ")}. Plan: ${planId}`);
const telemetryData = {
["PlanId"]: planId,
["WorkItemCount"]: workItemIds.length
};
telemetryService.TrackAction("PortfolioPlanningDataService/AddWorkItemsToPlan", telemetryData);
if (workItemIds.length === 0) {
// No-op.
const props = {
["PlanId"]: planId
};
PortfolioTelemetry.getInstance().TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/NoOp",
props
);
telemetryService.TrackAction("PortfolioPlanningDataService/AddWorkItemsToPlan/NoOp", props);
return null;
}
@ -427,10 +438,7 @@ export class PortfolioPlanningDataService {
["WorkItemIds"]: workItemIds
};
PortfolioTelemetry.getInstance().TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/NoPlanFound",
props
);
telemetryService.TrackAction("PortfolioPlanningDataService/AddWorkItemsToPlan/NoPlanFound", props);
return null;
}
@ -452,7 +460,7 @@ export class PortfolioPlanningDataService {
["WorkItemIds"]: workItemIds
};
PortfolioTelemetry.getInstance().TrackAction(
telemetryService.TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/WorkItemProjectIdsNoResults",
props
);
@ -554,7 +562,7 @@ export class PortfolioPlanningDataService {
["WorkItemType"]: workItemTypeKey
};
PortfolioTelemetry.getInstance().TrackAction(
telemetryService.TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/WorkItemTypeNotSupported",
props
);
@ -609,7 +617,7 @@ export class PortfolioPlanningDataService {
["WorkItemType"]: workItemTypeKey
};
PortfolioTelemetry.getInstance().TrackAction(
telemetryService.TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/WorkItemTypeNotSupported",
props
);
@ -621,7 +629,7 @@ export class PortfolioPlanningDataService {
["ProjectId"]: projectIdKey
};
PortfolioTelemetry.getInstance().TrackAction(
telemetryService.TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/MissingProjectConfiguration",
props
);
@ -632,7 +640,7 @@ export class PortfolioPlanningDataService {
["WorkItemId"]: newWorkItemId
};
PortfolioTelemetry.getInstance().TrackAction(
telemetryService.TrackAction(
"PortfolioPlanningDataService/AddWorkItemsToPlan/MissingProjectIdForNewWorkItemId",
props
);
@ -642,7 +650,7 @@ export class PortfolioPlanningDataService {
// Persist plan changes
return await this.UpdatePortfolioPlan(plan);
} catch (error) {
PortfolioTelemetry.getInstance().TrackException(error);
telemetryService.TrackException(error);
console.log(error);
return Promise.reject(error);
}

Просмотреть файл

@ -33,6 +33,7 @@ export interface IDialogInputData {
workItemIds: number[];
directory: PortfolioPlanningDirectory;
setOnOkClickHandler: (onOkClickHandler: () => IPromise<void>) => void;
telemetryService: PortfolioTelemetry;
}
export interface ISelectPlanComponentProps {
@ -93,8 +94,19 @@ class SelectPlanComponent extends React.Component<ISelectPlanComponentProps, ISe
if (this.selection.value && this.selection.value[0]) {
const planSelected = this.indexToPlan[this.selection.value[0].beginIndex];
const workItemIds = this.props.inputData.workItemIds;
const telemetryService = this.props.inputData.telemetryService;
const plan = await PortfolioPlanningDataService.getInstance().AddWorkItemsToPlan(planSelected, workItemIds);
const telemetryData = {
["PlanId"]: planSelected,
["WorkItemCount"]: workItemIds.length
};
telemetryService.TrackAction("SelectPlanDialog/onOkClicked", telemetryData);
const plan = await PortfolioPlanningDataService.getInstance().AddWorkItemsToPlan(
planSelected,
workItemIds,
telemetryService
);
if (!plan) {
// TODO Error scenario handling - e.g. plan doesn't exist.
// Something went wrong. A valid plan should have been returned.