mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
Add additional telemetry for basic admin operations (#24526)
This commit is contained in:
@@ -130,7 +130,13 @@ async function handleNewObjectDialogCommand(context: azdata.ObjectExplorerContex
|
||||
objectExplorerContext: context
|
||||
};
|
||||
const dialog = getDialog(service, options);
|
||||
const startTime = Date.now();
|
||||
await dialog.open();
|
||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenNewObjectDialog, {
|
||||
objectType: objectType
|
||||
}, {
|
||||
elapsedTimeMs: Date.now() - startTime
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenNewObjectDialog, err).withAdditionalProperties({
|
||||
@@ -159,7 +165,13 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore
|
||||
objectExplorerContext: context
|
||||
};
|
||||
const dialog = getDialog(service, options);
|
||||
const startTime = Date.now();
|
||||
await dialog.open();
|
||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenPropertiesDialog, {
|
||||
objectType: object.type
|
||||
}, {
|
||||
elapsedTimeMs: Date.now() - startTime
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenPropertiesDialog, err).withAdditionalProperties({
|
||||
@@ -297,7 +309,13 @@ async function handleDetachDatabase(context: azdata.ObjectExplorerContext, servi
|
||||
objectExplorerContext: context
|
||||
};
|
||||
const dialog = new DetachDatabaseDialog(service, options);
|
||||
const startTime = Date.now();
|
||||
await dialog.open();
|
||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenDetachDatabaseDialog, {
|
||||
objectType: object.type
|
||||
}, {
|
||||
elapsedTimeMs: Date.now() - startTime
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenDetachDatabaseDialog, err).withAdditionalProperties({
|
||||
@@ -325,7 +343,13 @@ async function handleAttachDatabase(context: azdata.ObjectExplorerContext, servi
|
||||
objectExplorerContext: context
|
||||
};
|
||||
const dialog = new AttachDatabaseDialog(service, options);
|
||||
const startTime = Date.now();
|
||||
await dialog.open();
|
||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenAttachDatabaseDialog, {
|
||||
objectType: ObjectManagement.NodeType.Database
|
||||
}, {
|
||||
elapsedTimeMs: Date.now() - startTime
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenAttachDatabaseDialog, err).withAdditionalProperties({
|
||||
@@ -357,7 +381,13 @@ async function handleDropDatabase(context: azdata.ObjectExplorerContext, service
|
||||
objectExplorerContext: context
|
||||
};
|
||||
const dialog = new DropDatabaseDialog(service, options);
|
||||
const startTime = Date.now();
|
||||
await dialog.open();
|
||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenDropDatabaseDialog, {
|
||||
objectType: object.type
|
||||
}, {
|
||||
elapsedTimeMs: Date.now() - startTime
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenDropDatabaseDialog, err).withAdditionalProperties({
|
||||
|
||||
@@ -54,7 +54,9 @@ export const enum TelemetryActions {
|
||||
UpdateObject = 'UpdateObject',
|
||||
OpenDetachDatabaseDialog = 'OpenDetachDatabaseDialog',
|
||||
OpenAttachDatabaseDialog = 'OpenAttachDatabaseDialog',
|
||||
OpenDropDatabaseDialog = 'OpenDropDatabaseDialog'
|
||||
OpenDropDatabaseDialog = 'OpenDropDatabaseDialog',
|
||||
AttachDatabase = 'AttachDatabase',
|
||||
DetachDatabase = 'DetachDatabase'
|
||||
}
|
||||
|
||||
export const ObjectManagementViewName = 'ObjectManagement';
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as azdata from 'azdata';
|
||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||
import { DatabaseFileData, IObjectManagementService, ObjectManagement } from 'mssql';
|
||||
import { Database, DatabaseViewInfo } from '../interfaces';
|
||||
import { AttachDatabaseDocUrl } from '../constants';
|
||||
import { AttachDatabaseDocUrl, TelemetryActions } from '../constants';
|
||||
import * as loc from '../localizedConstants';
|
||||
import { RemoveText } from '../../ui/localizedConstants';
|
||||
import { DefaultMinTableRowCount, DialogButton, getTableHeight } from '../../ui/dialogBase';
|
||||
@@ -178,6 +178,10 @@ export class AttachDatabaseDialog extends ObjectManagementDialogBase<Database, D
|
||||
return AttachDatabaseDocUrl;
|
||||
}
|
||||
|
||||
protected override get actionName(): string {
|
||||
return TelemetryActions.AttachDatabase;
|
||||
}
|
||||
|
||||
protected override async validateInput(): Promise<string[]> {
|
||||
let errors = [];
|
||||
if (this._databasesToAttach.length === 0) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
||||
import { Database, DatabaseViewInfo } from '../interfaces';
|
||||
import { DetachDatabaseDocUrl } from '../constants';
|
||||
import { DetachDatabaseDocUrl, TelemetryActions } from '../constants';
|
||||
import * as loc from '../localizedConstants';
|
||||
|
||||
export class DetachDatabaseDialog extends ObjectManagementDialogBase<Database, DatabaseViewInfo> {
|
||||
@@ -48,6 +48,10 @@ export class DetachDatabaseDialog extends ObjectManagementDialogBase<Database, D
|
||||
return DetachDatabaseDocUrl;
|
||||
}
|
||||
|
||||
protected override get actionName(): string {
|
||||
return TelemetryActions.DetachDatabase;
|
||||
}
|
||||
|
||||
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
|
||||
await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._updateStatistics, false);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
||||
import { Database, DatabaseViewInfo } from '../interfaces';
|
||||
import { DropDatabaseDocUrl } from '../constants';
|
||||
import { DropDatabaseDocUrl, TelemetryActions } from '../constants';
|
||||
import * as loc from '../localizedConstants';
|
||||
|
||||
export class DropDatabaseDialog extends ObjectManagementDialogBase<Database, DatabaseViewInfo> {
|
||||
@@ -52,6 +52,10 @@ export class DropDatabaseDialog extends ObjectManagementDialogBase<Database, Dat
|
||||
return DropDatabaseDocUrl;
|
||||
}
|
||||
|
||||
protected override get actionName(): string {
|
||||
return TelemetryActions.DropObject;
|
||||
}
|
||||
|
||||
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
|
||||
await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._deleteBackupHistory, false);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
: localizedConstants.UpdateObjectOperationDisplayName(typeDisplayName, this.options.objectName);
|
||||
}
|
||||
|
||||
protected get actionName(): string {
|
||||
return this.options.isNewObject ? TelemetryActions.CreateObject : TelemetryActions.UpdateObject;
|
||||
}
|
||||
|
||||
protected override async initialize(): Promise<void> {
|
||||
await super.initialize();
|
||||
this.dialogObject.registerOperation({
|
||||
@@ -75,7 +79,6 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
description: '',
|
||||
isCancelable: false,
|
||||
operation: async (operation: azdata.BackgroundOperation): Promise<void> => {
|
||||
const actionName = this.options.isNewObject ? TelemetryActions.CreateObject : TelemetryActions.UpdateObject;
|
||||
try {
|
||||
if (this.isDirty) {
|
||||
const startTime = Date.now();
|
||||
@@ -89,7 +92,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
}
|
||||
}
|
||||
|
||||
TelemetryReporter.sendTelemetryEvent(actionName, {
|
||||
TelemetryReporter.sendTelemetryEvent(this.actionName, {
|
||||
objectType: this.options.objectType
|
||||
}, {
|
||||
elapsedTimeMs: Date.now() - startTime
|
||||
@@ -99,7 +102,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
}
|
||||
catch (err) {
|
||||
operation.updateStatus(azdata.TaskStatus.Failed, getErrorMessage(err));
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, actionName, err).withAdditionalProperties({
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, this.actionName, err).withAdditionalProperties({
|
||||
objectType: this.options.objectType
|
||||
}).send();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user