Add more telemetry for sql database projects (#18751)

* add more telemetry for sql database projects

* add publishToContainer events

* send target platform when publishing

* add duration for createProjectFromDb and updateProjectFromDb
This commit is contained in:
Kim Santiago
2022-03-17 16:44:10 -07:00
committed by GitHub
parent 6c51b934f9
commit 3071a7b710
2 changed files with 39 additions and 2 deletions

View File

@@ -154,7 +154,11 @@ export class ProjectsController {
*/
public async createNewProject(creationParams: NewProjectParams): Promise<string> {
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.createNewProject)
.withAdditionalProperties({ template: creationParams.projectTypeId, sdkStyle: creationParams.sdkStyle!.toString() })
.withAdditionalProperties({
template: creationParams.projectTypeId,
sdkStyle: creationParams.sdkStyle!.toString(),
targetPlatform: creationParams.targetPlatform?.toString() ?? ''
})
.send();
if (creationParams.projectGuid && !UUID.isUUID(creationParams.projectGuid)) {
@@ -270,6 +274,8 @@ export class ProjectsController {
public async publishToDockerContainer(context: Project | dataworkspace.WorkspaceTreeItem, deployProfile: IDeployProfile): Promise<void> {
const project: Project = this.getProjectFromContext(context);
try {
TelemetryReporter.sendActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer);
if (deployProfile && deployProfile.deploySettings) {
let connectionUri: string | undefined;
if (deployProfile.localDbSetting) {
@@ -279,6 +285,7 @@ export class ProjectsController {
deployProfile.deploySettings.connectionUri = connectionUri;
}
}
if (deployProfile.deploySettings.connectionUri) {
const publishResult = await this.publishOrScriptProject(project, deployProfile.deploySettings, true);
if (publishResult && publishResult.success) {
@@ -295,6 +302,7 @@ export class ProjectsController {
}
} catch (error) {
void utils.showErrorMessageWithOutputChannel(constants.publishToContainerFailed, error, this._outputChannel);
TelemetryReporter.sendErrorEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer);
}
return;
}
@@ -442,6 +450,8 @@ export class ProjectsController {
const timeToPublish = actionEndTime - actionStartTime;
telemetryProps.actionDuration = timeToPublish.toString();
telemetryProps.totalDuration = (actionEndTime - buildStartTime).toString();
telemetryProps.sqlcmdVariablesCount = Object.keys(project.sqlCmdVariables).length.toString();
telemetryProps.projectTargetPLatform = project.getProjectTargetVersion();
const currentPublishIndex = this.publishInfo.findIndex(d => d.startDate === currentPublishTimeInfo);
this.publishInfo[currentPublishIndex].status = result.success ? Status.success : Status.failed;
@@ -669,10 +679,12 @@ export class ProjectsController {
}
try {
TelemetryReporter.sendActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addExistingItem);
await project.addExistingItem(uris[0].fsPath);
this.refreshProjectsTree(treeNode);
} catch (err) {
void vscode.window.showErrorMessage(utils.getErrorMessage(err));
TelemetryReporter.sendErrorEvent(TelemetryViews.ProjectTree, TelemetryActions.addExistingItem);
}
}
@@ -1282,6 +1294,7 @@ export class ProjectsController {
public async createProjectFromDatabaseCallback(model: ImportDataModel) {
try {
const newProjFolderUri = model.filePath;
const newProjFilePath = await this.createNewProject({
@@ -1295,7 +1308,16 @@ export class ProjectsController {
this.setFilePath(model);
const project = await Project.openProject(newProjFilePath);
const startTime = new Date();
await this.createProjectFromDatabaseApiCall(model); // Call ExtractAPI in DacFx Service
const timeToExtract = new Date().getTime() - startTime.getTime();
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.createProjectFromDatabase)
.withAdditionalMeasurements({ durationMs: timeToExtract })
.send();
let fileFolderList: vscode.Uri[] = model.extractTarget === mssql.ExtractTarget.file ? [vscode.Uri.file(model.filePath)] : await this.generateList(model.filePath); // Create a list of all the files and directories to be added to project
if (!model.sdkStyle) {
@@ -1308,6 +1330,7 @@ export class ProjectsController {
await workspaceApi.addProjectsToWorkspace([vscode.Uri.file(newProjFilePath)]);
} catch (err) {
void vscode.window.showErrorMessage(utils.getErrorMessage(err));
TelemetryReporter.sendErrorEvent(TelemetryViews.ProjectController, TelemetryActions.createProjectFromDatabase);
}
}
@@ -1373,9 +1396,17 @@ export class ProjectsController {
public async updateProjectFromDatabaseCallback(model: UpdateProjectDataModel) {
try {
const startTime = new Date();
await this.updateProjectFromDatabaseApiCall(model);
const timeToUpdate = new Date().getTime() - startTime.getTime();
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.updateProjectFromDatabase)
.withAdditionalMeasurements({ durationMs: timeToUpdate })
.send();
} catch (err) {
void vscode.window.showErrorMessage(utils.getErrorMessage(err));
TelemetryReporter.sendErrorEvent(TelemetryViews.ProjectController, TelemetryActions.updateProjectFromDatabase);
}
}