mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
minor code refactoring (#18227)
This commit is contained in:
@@ -6,16 +6,14 @@
|
|||||||
import { AppContext } from '../appContext';
|
import { AppContext } from '../appContext';
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { sqlProviderName } from '../constants';
|
import { sqlProviderName, TableType } from '../constants';
|
||||||
import { generateUuid } from 'vscode-languageclient/lib/utils/uuid';
|
import { generateUuid } from 'vscode-languageclient/lib/utils/uuid';
|
||||||
import { ITelemetryEventProperties, Telemetry } from '../telemetry';
|
import { ITelemetryEventProperties, Telemetry } from '../telemetry';
|
||||||
|
|
||||||
export function registerTableDesignerCommands(appContext: AppContext) {
|
export function registerTableDesignerCommands(appContext: AppContext) {
|
||||||
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newTable', async (context: azdata.ObjectExplorerContext) => {
|
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newTable', async (context: azdata.ObjectExplorerContext) => {
|
||||||
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
||||||
const serverInfo = await azdata.connection.getServerInfo(context.connectionProfile.id);
|
const telemetryInfo = await getTelemetryInfo(context, TableType.Basic);
|
||||||
let telemetryInfo: ITelemetryEventProperties = {};
|
|
||||||
telemetryInfo = Telemetry.fillServerInfo(telemetryInfo, serverInfo);
|
|
||||||
await azdata.designers.openTableDesigner(sqlProviderName, {
|
await azdata.designers.openTableDesigner(sqlProviderName, {
|
||||||
server: context.connectionProfile.serverName,
|
server: context.connectionProfile.serverName,
|
||||||
database: context.connectionProfile.databaseName,
|
database: context.connectionProfile.databaseName,
|
||||||
@@ -31,9 +29,7 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
|||||||
const schema = context.nodeInfo.metadata.schema;
|
const schema = context.nodeInfo.metadata.schema;
|
||||||
const name = context.nodeInfo.metadata.name;
|
const name = context.nodeInfo.metadata.name;
|
||||||
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
||||||
const serverInfo = await azdata.connection.getServerInfo(context.connectionProfile.id);
|
const telemetryInfo = await getTelemetryInfo(context, TableType.Basic);
|
||||||
let telemetryInfo: ITelemetryEventProperties = {};
|
|
||||||
telemetryInfo = Telemetry.fillServerInfo(telemetryInfo, serverInfo);
|
|
||||||
await azdata.designers.openTableDesigner(sqlProviderName, {
|
await azdata.designers.openTableDesigner(sqlProviderName, {
|
||||||
server: server,
|
server: server,
|
||||||
database: database,
|
database: database,
|
||||||
@@ -45,3 +41,11 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
|||||||
}, telemetryInfo);
|
}, telemetryInfo);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getTelemetryInfo(context: azdata.ObjectExplorerContext, tableType: string): Promise<ITelemetryEventProperties> {
|
||||||
|
const serverInfo = await azdata.connection.getServerInfo(context.connectionProfile.id);
|
||||||
|
const telemetryInfo: ITelemetryEventProperties = {};
|
||||||
|
Telemetry.fillServerInfo(telemetryInfo, serverInfo);
|
||||||
|
telemetryInfo['tableType'] = tableType;
|
||||||
|
return telemetryInfo;
|
||||||
|
}
|
||||||
|
|||||||
@@ -114,21 +114,18 @@ export class Telemetry {
|
|||||||
// If sending telemetry event fails ignore it so it won't break the extension
|
// If sending telemetry event fails ignore it so it won't break the extension
|
||||||
console.error('Failed to send telemetry event. error: ' + telemetryErr);
|
console.error('Failed to send telemetry event. error: ' + telemetryErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects server information from ServerInfo to put into a
|
* Collects server information from ServerInfo to put into a
|
||||||
* property bag
|
* property bag
|
||||||
*/
|
*/
|
||||||
public static fillServerInfo(telemetryInfo: { [key: string]: string }, serverInfo: ServerInfo): { [key: string]: string } {
|
public static fillServerInfo(telemetryInfo: { [key: string]: string }, serverInfo: ServerInfo): void {
|
||||||
telemetryInfo['serverEdition'] = serverInfo?.serverEdition;
|
telemetryInfo['serverEdition'] = serverInfo?.serverEdition;
|
||||||
telemetryInfo['serverLevel'] = serverInfo?.serverLevel;
|
telemetryInfo['serverLevel'] = serverInfo?.serverLevel;
|
||||||
telemetryInfo['serverMajorVersion'] = serverInfo?.serverMajorVersion.toString();
|
telemetryInfo['serverMajorVersion'] = serverInfo?.serverMajorVersion.toString();
|
||||||
telemetryInfo['serverMinorVersion'] = serverInfo?.serverMinorVersion.toString();
|
telemetryInfo['serverMinorVersion'] = serverInfo?.serverMinorVersion.toString();
|
||||||
telemetryInfo['isCloud'] = serverInfo?.isCloud.toString();
|
telemetryInfo['isCloud'] = serverInfo?.isCloud.toString();
|
||||||
telemetryInfo['tableType'] = Constants.TableType.Basic;
|
|
||||||
return telemetryInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user