From a4077c3d8933640c3364fa91c59854373228daad Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 11 May 2023 13:27:34 -0700 Subject: [PATCH] Adding telemetry to ads OE filter (#23089) * Adding telemetry to ads oe filter * Fixing prop names * fixing prop name * Fixing localized strings * Update src/sql/azdata.proposed.d.ts Co-authored-by: Charles Gagnon * Update src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts Co-authored-by: Charles Gagnon --------- Co-authored-by: Charles Gagnon --- src/sql/azdata.proposed.d.ts | 4 ++++ src/sql/platform/telemetry/common/telemetryKeys.ts | 5 ++++- .../contrib/objectExplorer/browser/serverTreeView.ts | 12 +++++++++++- .../test/browser/serverTreeView.test.ts | 2 +- .../objectExplorer/browser/connectionTreeAction.ts | 11 ++++++++++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 6fb4d8f400..1b161929f7 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -1797,6 +1797,10 @@ declare module 'azdata' { } export interface NodeFilterProperty { + /** + * The non-localized name of the filter property + */ + name: string; /** * The name of the filter property displayed to the user */ diff --git a/src/sql/platform/telemetry/common/telemetryKeys.ts b/src/sql/platform/telemetry/common/telemetryKeys.ts index 63206bf73f..745a35893f 100644 --- a/src/sql/platform/telemetry/common/telemetryKeys.ts +++ b/src/sql/platform/telemetry/common/telemetryKeys.ts @@ -50,7 +50,8 @@ export const enum TelemetryView { ResultsPanel = 'ResultsPanel', Shell = 'Shell', SqlAssessment = 'SqlAssessment', - TableDesigner = 'TableDesigner' + TableDesigner = 'TableDesigner', + ObjectExplorer = 'ObjectExplorer' } export const enum TelemetryError { @@ -98,6 +99,8 @@ export const enum TelemetryAction { MoveServerGroup = 'MoveServerGroup', NewQuery = 'NewQuery', ObjectExplorerExpand = 'ObjectExplorerExpand', + ObjectExplorerFilter = 'ObjectExplorerFilter', + ObjectExplorerRemoveFilter = 'ObjectExplorerRemoveFilter', Open = 'Open', OpenQuery = 'OpenQuery', OpenExecutionPlanProperties = 'OpenExecutionPlanProperties', diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index ecf8385fe2..abec13601d 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -48,6 +48,8 @@ import { IHostService } from 'vs/workbench/services/host/browser/host'; import { USE_ASYNC_SERVER_TREE_CONFIG } from 'sql/workbench/contrib/objectExplorer/common/serverGroup.contribution'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { FilterDialog } from 'sql/workbench/services/objectExplorer/browser/filterDialog/filterDialog'; +import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export const CONTEXT_SERVER_TREE_VIEW = new RawContextKey('serverTreeView.view', ServerTreeViewView.all); export const CONTEXT_SERVER_TREE_HAS_CONNECTIONS = new RawContextKey('serverTreeView.hasConnections', false); @@ -79,7 +81,8 @@ export class ServerTreeView extends Disposable implements IServerTreeView { @IKeybindingService private _keybindingService: IKeybindingService, @IContextKeyService contextKeyService: IContextKeyService, @IHostService private _hostService: IHostService, - @INotificationService private _notificationService: INotificationService + @INotificationService private _notificationService: INotificationService, + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService ) { super(); this._hasConnectionsKey = CONTEXT_SERVER_TREE_HAS_CONNECTIONS.bindTo(contextKeyService); @@ -619,6 +622,13 @@ export class ServerTreeView extends Disposable implements IServerTreeView { if (errorListener) { errorListener.dispose(); } + + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.ObjectExplorer, TelemetryKeys.TelemetryAction.ObjectExplorerFilter) + .withAdditionalProperties({ + filterPropertyNames: JSON.stringify(filters.map(f => node.filterProperties.find(p => f.displayName === p.displayName)?.name)), + filterCount: filters.length, + objectType: node.objectType + }).send(); } return; }, diff --git a/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts b/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts index aeeff43768..677309f462 100644 --- a/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts +++ b/src/sql/workbench/contrib/objectExplorer/test/browser/serverTreeView.test.ts @@ -39,7 +39,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => { ); mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []); mockConnectionManagementService.setup(x => x.hasRegisteredServers()).returns(() => true); - serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, new TestThemeService(), undefined, new TestConfigurationService(), capabilitiesService, undefined, undefined, new MockContextKeyService(), undefined, undefined); + serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, new TestThemeService(), undefined, new TestConfigurationService(), capabilitiesService, undefined, undefined, new MockContextKeyService(), undefined, undefined, undefined); mockTree = TypeMoq.Mock.ofType(TestTree); (serverTreeView as any)._tree = mockTree.object; mockRefreshTreeMethod = TypeMoq.Mock.ofType(Function); diff --git a/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts b/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts index 64dff96523..159d96aaf3 100644 --- a/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts +++ b/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts @@ -21,6 +21,8 @@ import { ILogService } from 'vs/platform/log/common/log'; import { AsyncServerTree, ServerTreeElement } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree'; import { SqlIconId } from 'sql/base/common/codicons'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; +import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; export interface IServerView { showFilteredTree(filter: string): void; @@ -338,7 +340,8 @@ export class RemoveFilterAction extends Action { private _node: TreeNode, private _tree: AsyncServerTree | ITree, private _profile: ConnectionProfile | undefined, - @IObjectExplorerService private _objectExplorerService: IObjectExplorerService + @IObjectExplorerService private _objectExplorerService: IObjectExplorerService, + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService ) { super(id, label); } @@ -362,5 +365,11 @@ export class RemoveFilterAction extends Action { await this._tree.refresh(nodeToRefresh); await this._tree.expand(nodeToRefresh); } + this._telemetryService.createActionEvent( + TelemetryKeys.TelemetryView.ObjectExplorer, + TelemetryKeys.TelemetryAction.ObjectExplorerRemoveFilter + ).withAdditionalProperties({ + objectType: node.objectType + }).send(); } }