Send telemetry action event when user selects 'Enable Trust Server Certificate' (#21113)

This commit is contained in:
Cheena Malhotra
2022-11-04 17:05:32 -07:00
committed by GitHub
parent 00b797b4f3
commit a1f5b403db
3 changed files with 8 additions and 1 deletions

View File

@@ -75,6 +75,7 @@ export const enum TelemetryAction {
DeleteAgentProxy = 'DeleteAgentProxy', DeleteAgentProxy = 'DeleteAgentProxy',
DeleteConnection = 'DeleteConnection', DeleteConnection = 'DeleteConnection',
DeleteServerGroup = 'DeleteServerGroup', DeleteServerGroup = 'DeleteServerGroup',
EnableTrustServerCertificate = 'EnableTrustServerCertificate',
FindNode = 'FindNode', FindNode = 'FindNode',
FirewallRuleRequested = 'FirewallRuleCreated', FirewallRuleRequested = 'FirewallRuleCreated',
GenerateScript = 'GenerateScript', GenerateScript = 'GenerateScript',

View File

@@ -27,6 +27,8 @@ import * as types from 'vs/base/common/types';
import { trim } from 'vs/base/common/strings'; import { trim } from 'vs/base/common/strings';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController'; import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController';
import { entries } from 'sql/base/common/collections'; import { entries } from 'sql/base/common/collections';
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
@@ -89,6 +91,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
@IClipboardService private _clipboardService: IClipboardService, @IClipboardService private _clipboardService: IClipboardService,
@ICommandService private _commandService: ICommandService, @ICommandService private _commandService: ICommandService,
@ILogService private _logService: ILogService, @ILogService private _logService: ILogService,
@IAdsTelemetryService private _telemetryService: IAdsTelemetryService
) { ) {
this.initializeConnectionProviders(); this.initializeConnectionProviders();
} }
@@ -524,6 +527,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
Note: A self-signed certificate offers only limited protection and is not a recommended practice for production environments. Do you want to enable 'Trust server certificate' on this connection and retry? `); Note: A self-signed certificate offers only limited protection and is not a recommended practice for production environments. Do you want to enable 'Trust server certificate' on this connection and retry? `);
let readMoreLink = "https://learn.microsoft.com/sql/database-engine/configure-windows/enable-encrypted-connections-to-the-database-engine" let readMoreLink = "https://learn.microsoft.com/sql/database-engine/configure-windows/enable-encrypted-connections-to-the-database-engine"
actions.push(new Action('trustServerCert', enableTrustServerCert, undefined, true, async () => { actions.push(new Action('trustServerCert', enableTrustServerCert, undefined, true, async () => {
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.ConnectionDialog, TelemetryKeys.TelemetryAction.EnableTrustServerCertificate);
this._model.options[Constants.trustServerCertificate] = true; this._model.options[Constants.trustServerCertificate] = true;
await this.handleOnConnect(this._connectionDialog.newConnectionParams, this._model as IConnectionProfile); await this.handleOnConnect(this._connectionDialog.newConnectionParams, this._model as IConnectionProfile);
return; return;

View File

@@ -108,8 +108,10 @@ suite('ConnectionDialogService tests', () => {
testInstantiationService.stub(ICapabilitiesService, new TestCapabilitiesService()); testInstantiationService.stub(ICapabilitiesService, new TestCapabilitiesService());
let logService: ILogService = new NullLogService(); let logService: ILogService = new NullLogService();
let telemetryService: IAdsTelemetryService = new NullAdsTelemetryService();
connectionDialogService = new ConnectionDialogService(testInstantiationService, capabilitiesService, errorMessageService.object, connectionDialogService = new ConnectionDialogService(testInstantiationService, capabilitiesService, errorMessageService.object,
new TestConfigurationService(), new BrowserClipboardService(layoutService, logService), NullCommandService, logService); new TestConfigurationService(), new BrowserClipboardService(layoutService, logService), NullCommandService, logService, telemetryService);
(connectionDialogService as any)._connectionManagementService = mockConnectionManagementService.object; (connectionDialogService as any)._connectionManagementService = mockConnectionManagementService.object;
let providerDisplayNames = ['Mock SQL Server']; let providerDisplayNames = ['Mock SQL Server'];
let providerNameToDisplayMap = { 'MSSQL': 'Mock SQL Server' }; let providerNameToDisplayMap = { 'MSSQL': 'Mock SQL Server' };