mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
added graph node types from edit and publish results (#18891)
* added graph node types from edit and publish results * make generic property bag * review comments * add comment for function * edit comment * change name to telemetry info
This commit is contained in:
12
src/sql/azdata.proposed.d.ts
vendored
12
src/sql/azdata.proposed.d.ts
vendored
@@ -1111,6 +1111,10 @@ declare module 'azdata' {
|
|||||||
* The input validation error.
|
* The input validation error.
|
||||||
*/
|
*/
|
||||||
inputValidationError?: string;
|
inputValidationError?: string;
|
||||||
|
/**
|
||||||
|
* Metadata related to the table
|
||||||
|
*/
|
||||||
|
metadata?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1129,6 +1133,10 @@ declare module 'azdata' {
|
|||||||
* The new view.
|
* The new view.
|
||||||
*/
|
*/
|
||||||
view: TableDesignerView;
|
view: TableDesignerView;
|
||||||
|
/**
|
||||||
|
* Metadata related to the table to be captured
|
||||||
|
*/
|
||||||
|
metadata?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GeneratePreviewReportResult {
|
export interface GeneratePreviewReportResult {
|
||||||
@@ -1144,6 +1152,10 @@ declare module 'azdata' {
|
|||||||
* The table schema validation error.
|
* The table schema validation error.
|
||||||
*/
|
*/
|
||||||
schemaValidationError?: string;
|
schemaValidationError?: string;
|
||||||
|
/**
|
||||||
|
* Metadata related to the table to be captured
|
||||||
|
*/
|
||||||
|
metadata?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export const enum TelemetryAction {
|
|||||||
Click = 'Click',
|
Click = 'Click',
|
||||||
FirewallRuleRequested = 'FirewallRuleCreated',
|
FirewallRuleRequested = 'FirewallRuleCreated',
|
||||||
GenerateScript = 'GenerateScript',
|
GenerateScript = 'GenerateScript',
|
||||||
|
GeneratePreviewReport = 'GeneratePreviewReport',
|
||||||
GetDataGridItems = 'GetDataGridItems',
|
GetDataGridItems = 'GetDataGridItems',
|
||||||
GetDataGridColumns = 'GetDataGridColumns',
|
GetDataGridColumns = 'GetDataGridColumns',
|
||||||
ModelViewDashboardOpened = 'ModelViewDashboardOpened',
|
ModelViewDashboardOpened = 'ModelViewDashboardOpened',
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { TableDesignerPublishDialogResult, TableDesignerPublishDialog } from 'sq
|
|||||||
import { IAdsTelemetryService, ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService, ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry';
|
||||||
import { TelemetryAction, TelemetryView } from 'sql/platform/telemetry/common/telemetryKeys';
|
import { TelemetryAction, TelemetryView } from 'sql/platform/telemetry/common/telemetryKeys';
|
||||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||||
|
import { TableDesignerMetadata } from 'sql/workbench/services/tableDesigner/browser/tableDesignerMetadata';
|
||||||
|
|
||||||
const ErrorDialogTitle: string = localize('tableDesigner.ErrorDialogTitle', "Table Designer Error");
|
const ErrorDialogTitle: string = localize('tableDesigner.ErrorDialogTitle', "Table Designer Error");
|
||||||
export class TableDesignerComponentInput implements DesignerComponentInput {
|
export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||||
@@ -107,9 +108,10 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
refreshView: !!result.view
|
refreshView: !!result.view
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const metadataTelemetryInfo = TableDesignerMetadata.getTelemetryInfo(this._provider.providerId, result.metadata);
|
||||||
editAction.withAdditionalMeasurements({
|
editAction.withAdditionalMeasurements({
|
||||||
'elapsedTimeMs': new Date().getTime() - startTime
|
'elapsedTimeMs': new Date().getTime() - startTime
|
||||||
}).send();
|
}).withAdditionalProperties(metadataTelemetryInfo).send();
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.errorProcessingEdit', "An error occured while processing the change: {0}", error?.message ?? error));
|
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.errorProcessingEdit', "An error occured while processing the change: {0}", error?.message ?? error));
|
||||||
@@ -164,9 +166,10 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
this.tableInfo = result.newTableInfo;
|
this.tableInfo = result.newTableInfo;
|
||||||
this.updateState(true, false);
|
this.updateState(true, false);
|
||||||
this._onRefreshRequested.fire();
|
this._onRefreshRequested.fire();
|
||||||
|
const metadataTelemetryInfo = TableDesignerMetadata.getTelemetryInfo(this._provider.providerId, result.metadata);
|
||||||
publishEvent.withAdditionalMeasurements({
|
publishEvent.withAdditionalMeasurements({
|
||||||
'elapsedTimeMs': new Date().getTime() - startTime
|
'elapsedTimeMs': new Date().getTime() - startTime
|
||||||
}).send();
|
}).withAdditionalProperties(metadataTelemetryInfo).send();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.publishChangeError', "An error occured while publishing changes: {0}", error?.message ?? error));
|
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.publishChangeError', "An error occured while publishing changes: {0}", error?.message ?? error));
|
||||||
this.updateState(this.valid, this.dirty);
|
this.updateState(this.valid, this.dirty);
|
||||||
@@ -180,16 +183,23 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
|
|||||||
message: localize('tableDesigner.generatingPreviewReport', "Generating preview report..."),
|
message: localize('tableDesigner.generatingPreviewReport', "Generating preview report..."),
|
||||||
sticky: true
|
sticky: true
|
||||||
});
|
});
|
||||||
|
const telemetryInfo = this.createTelemetryInfo();
|
||||||
|
const generatePreviewEvent = this._adsTelemetryService.createActionEvent(TelemetryView.TableDesigner, TelemetryAction.GeneratePreviewReport).withAdditionalProperties(telemetryInfo);
|
||||||
|
const startTime = new Date().getTime();
|
||||||
let previewReportResult: azdata.designers.GeneratePreviewReportResult;
|
let previewReportResult: azdata.designers.GeneratePreviewReportResult;
|
||||||
try {
|
try {
|
||||||
this.updateState(this.valid, this.dirty, 'generateReport');
|
this.updateState(this.valid, this.dirty, 'generateReport');
|
||||||
previewReportResult = await this._provider.generatePreviewReport(this.tableInfo);
|
previewReportResult = await this._provider.generatePreviewReport(this.tableInfo);
|
||||||
|
const metadataTelemetryInfo = TableDesignerMetadata.getTelemetryInfo(this._provider.providerId, previewReportResult.metadata);
|
||||||
|
generatePreviewEvent.withAdditionalMeasurements({
|
||||||
|
'elapsedTimeMs': new Date().getTime() - startTime
|
||||||
|
}).withAdditionalProperties(metadataTelemetryInfo).send();
|
||||||
reportNotificationHandle.close();
|
reportNotificationHandle.close();
|
||||||
this.updateState(this.valid, this.dirty);
|
this.updateState(this.valid, this.dirty);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.generatePreviewReportError', "An error occured while generating preview report: {0}", error?.message ?? error));
|
this._errorMessageService.showDialog(Severity.Error, ErrorDialogTitle, localize('tableDesigner.generatePreviewReportError', "An error occured while generating preview report: {0}", error?.message ?? error));
|
||||||
this.updateState(this.valid, this.dirty);
|
this.updateState(this.valid, this.dirty);
|
||||||
|
this._adsTelemetryService.createErrorEvent(TelemetryView.TableDesigner, TelemetryAction.GeneratePreviewReport).withAdditionalProperties(telemetryInfo).send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (previewReportResult.schemaValidationError) {
|
if (previewReportResult.schemaValidationError) {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
export class TableDesignerMetadata {
|
||||||
|
|
||||||
|
// Allowed metadata for every provider
|
||||||
|
public static mssqlAllowedMetdata: Set<string> = new Set(['isNode', 'isEdge', 'isSystemVersioned']);
|
||||||
|
|
||||||
|
// Provider ID to allowed metadata list set mapping
|
||||||
|
public static providerMetadataMap: Map<string, Set<string>> = new Map<string, Set<string>>([
|
||||||
|
['MSSQL', TableDesignerMetadata.mssqlAllowedMetdata]
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates given metadata and adds metadata from the allowed list
|
||||||
|
* @param providerId provider ID for the table designer provider
|
||||||
|
* @param metadata incoming metadata from the table designer provider
|
||||||
|
* @returns filtered telemetry info with only allowed metadata points
|
||||||
|
*/
|
||||||
|
public static getTelemetryInfo(providerId: string, metadata: { [key: string]: string }): { [key: string]: string } {
|
||||||
|
if (!TableDesignerMetadata.providerMetadataMap.has(providerId)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const allowedSet = TableDesignerMetadata.providerMetadataMap.get(providerId);
|
||||||
|
for (const key of Object.keys(metadata)) {
|
||||||
|
if (!allowedSet.has(key)) {
|
||||||
|
delete metadata[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -44,10 +44,7 @@ export class TableDesignerService implements ITableDesignerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): Promise<void> {
|
public async openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, telemetryInfo?: ITelemetryEventProperties): Promise<void> {
|
||||||
this._adsTelemetryService.createActionEvent(TelemetryView.TableDesigner, TelemetryAction.Open).withAdditionalProperties({
|
this._adsTelemetryService.createActionEvent(TelemetryView.TableDesigner, TelemetryAction.Open).withAdditionalProperties(telemetryInfo).send();
|
||||||
provider: providerId,
|
|
||||||
newTable: tableInfo.isNewTable
|
|
||||||
}).send();
|
|
||||||
const provider = this.getProvider(providerId);
|
const provider = this.getProvider(providerId);
|
||||||
const tableDesignerInput = this._instantiationService.createInstance(TableDesignerInput, provider, tableInfo, telemetryInfo);
|
const tableDesignerInput = this._instantiationService.createInstance(TableDesignerInput, provider, tableInfo, telemetryInfo);
|
||||||
await this._editorService.openEditor(tableDesignerInput, { pinned: true }, ACTIVE_GROUP);
|
await this._editorService.openEditor(tableDesignerInput, { pinned: true }, ACTIVE_GROUP);
|
||||||
|
|||||||
Reference in New Issue
Block a user