mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Add telemetry events for rename and move in sql project (#22068)
* add telemetry events for rename and move in sql project * remove check * update telemetry events
This commit is contained in:
@@ -47,5 +47,7 @@ export enum TelemetryActions {
|
|||||||
optionsChanged = 'optionsChanged',
|
optionsChanged = 'optionsChanged',
|
||||||
profileLoaded = 'profileLoaded',
|
profileLoaded = 'profileLoaded',
|
||||||
SchemaComparisonFinished = 'SchemaComparisonFinished',
|
SchemaComparisonFinished = 'SchemaComparisonFinished',
|
||||||
SchemaComparisonStarted = 'SchemaComparisonStarted'
|
SchemaComparisonStarted = 'SchemaComparisonStarted',
|
||||||
|
rename = "rename",
|
||||||
|
move = "move"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -857,10 +857,13 @@ export class ProjectsController {
|
|||||||
|
|
||||||
const newFilePath = path.join(path.dirname(utils.getPlatformSafeFileEntryPath(file?.relativePath!)), `${newFileName}.sql`);
|
const newFilePath = path.join(path.dirname(utils.getPlatformSafeFileEntryPath(file?.relativePath!)), `${newFileName}.sql`);
|
||||||
|
|
||||||
try {
|
const renameResult = await this.move(node, node.projectFileUri.fsPath, newFilePath);
|
||||||
await this.move(node, node.projectFileUri.fsPath, newFilePath);
|
|
||||||
} catch (e) {
|
if (renameResult?.success) {
|
||||||
void vscode.window.showErrorMessage(constants.errorRenamingFile(file?.relativePath!, newFilePath, utils.getErrorMessage(e)));
|
TelemetryReporter.sendActionEvent(TelemetryViews.ProjectTree, TelemetryActions.rename);
|
||||||
|
} else {
|
||||||
|
TelemetryReporter.sendErrorEvent2(TelemetryViews.ProjectTree, TelemetryActions.rename);
|
||||||
|
void vscode.window.showErrorMessage(constants.errorRenamingFile(file?.relativePath!, newFilePath, utils.getErrorMessage(renameResult?.errorMessage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refreshProjectsTree(context);
|
this.refreshProjectsTree(context);
|
||||||
@@ -1867,7 +1870,7 @@ export class ProjectsController {
|
|||||||
const newPath = path.join(folderPath!, sourceFileNode.friendlyName);
|
const newPath = path.join(folderPath!, sourceFileNode.friendlyName);
|
||||||
|
|
||||||
// don't do anything if the path is the same
|
// don't do anything if the path is the same
|
||||||
if (newPath === sourceFileNode.fileSystemUri.fsPath) {
|
if (newPath === sourceFileNode.relativeProjectUri.fsPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1877,10 +1880,13 @@ export class ProjectsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move the file
|
// Move the file
|
||||||
try {
|
const moveResult = await this.move(sourceFileNode, projectUri.fsPath, newPath);
|
||||||
await this.move(sourceFileNode, projectUri.fsPath, newPath);
|
|
||||||
} catch (e) {
|
if (moveResult?.success) {
|
||||||
void vscode.window.showErrorMessage(constants.errorMovingFile(sourceFileNode.fileSystemUri.fsPath, newPath, utils.getErrorMessage(e)));
|
TelemetryReporter.sendActionEvent(TelemetryViews.ProjectTree, TelemetryActions.move);
|
||||||
|
} else {
|
||||||
|
TelemetryReporter.sendErrorEvent2(TelemetryViews.ProjectTree, TelemetryActions.move);
|
||||||
|
void vscode.window.showErrorMessage(constants.errorMovingFile(sourceFileNode.fileSystemUri.fsPath, newPath, utils.getErrorMessage(moveResult?.errorMessage)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1890,7 +1896,7 @@ export class ProjectsController {
|
|||||||
* @param projectFilePath Full file path to .sqlproj
|
* @param projectFilePath Full file path to .sqlproj
|
||||||
* @param destinationRelativePath path of the destination, relative to .sqlproj
|
* @param destinationRelativePath path of the destination, relative to .sqlproj
|
||||||
*/
|
*/
|
||||||
private async move(node: BaseProjectTreeItem, projectFilePath: string, destinationRelativePath: string): Promise<void> {
|
private async move(node: BaseProjectTreeItem, projectFilePath: string, destinationRelativePath: string): Promise<azdataType.ResultStatus | undefined> {
|
||||||
// trim off the project folder at the beginning of the relative path stored in the tree
|
// trim off the project folder at the beginning of the relative path stored in the tree
|
||||||
const projectRelativeUri = vscode.Uri.file(path.basename(projectFilePath, constants.sqlprojExtension));
|
const projectRelativeUri = vscode.Uri.file(path.basename(projectFilePath, constants.sqlprojExtension));
|
||||||
const originalRelativePath = utils.trimUri(projectRelativeUri, node.relativeProjectUri);
|
const originalRelativePath = utils.trimUri(projectRelativeUri, node.relativeProjectUri);
|
||||||
@@ -1902,15 +1908,18 @@ export class ProjectsController {
|
|||||||
|
|
||||||
const sqlProjectsService = await utils.getSqlProjectsService();
|
const sqlProjectsService = await utils.getSqlProjectsService();
|
||||||
|
|
||||||
|
let result;
|
||||||
if (node instanceof SqlObjectFileNode) {
|
if (node instanceof SqlObjectFileNode) {
|
||||||
await sqlProjectsService.moveSqlObjectScript(projectFilePath, destinationRelativePath, originalRelativePath)
|
result = await sqlProjectsService.moveSqlObjectScript(projectFilePath, destinationRelativePath, originalRelativePath)
|
||||||
} else if (node instanceof PreDeployNode) {
|
} else if (node instanceof PreDeployNode) {
|
||||||
await sqlProjectsService.movePreDeploymentScript(projectFilePath, destinationRelativePath, originalRelativePath)
|
result = await sqlProjectsService.movePreDeploymentScript(projectFilePath, destinationRelativePath, originalRelativePath)
|
||||||
} else if (node instanceof PostDeployNode) {
|
} else if (node instanceof PostDeployNode) {
|
||||||
await sqlProjectsService.movePostDeploymentScript(projectFilePath, destinationRelativePath, originalRelativePath)
|
result = await sqlProjectsService.movePostDeploymentScript(projectFilePath, destinationRelativePath, originalRelativePath)
|
||||||
}
|
}
|
||||||
// TODO add support for renaming none scripts after those are added in STS
|
// TODO add support for renaming none scripts after those are added in STS
|
||||||
// TODO add support for renaming publish profiles when support is added in DacFx
|
// TODO add support for renaming publish profiles when support is added in DacFx
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user