diff --git a/src/sql/platform/backup/common/backupServiceImp.ts b/src/sql/platform/backup/common/backupServiceImp.ts index 21f2378070..2d74ec1b66 100644 --- a/src/sql/platform/backup/common/backupServiceImp.ts +++ b/src/sql/platform/backup/common/backupServiceImp.ts @@ -6,11 +6,9 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; import * as azdata from 'azdata'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IBackupService, TaskExecutionMode } from 'sql/platform/backup/common/backupService'; import { invalidProvider } from 'sql/base/common/errors'; -import { ILogService } from 'vs/platform/log/common/log'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class BackupService implements IBackupService { @@ -19,8 +17,7 @@ export class BackupService implements IBackupService { constructor( @IConnectionManagementService private _connectionService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService, - @ILogService private logService: ILogService + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService ) { } @@ -45,7 +42,9 @@ export class BackupService implements IBackupService { return new Promise((resolve, reject) => { const providerResult = this.getProvider(connectionUri); if (providerResult) { - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.BackupCreated, { provider: providerResult.providerName }); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.BackupCreated) + .withAdditionalProperties({ providerId: providerResult.providerName }) + .send(); providerResult.provider.backup(connectionUri, backupInfo, taskExecutionMode).then(result => { resolve(result); }, error => { diff --git a/src/sql/platform/query/common/queryManagement.ts b/src/sql/platform/query/common/queryManagement.ts index 754c2cd93a..1378e5aa66 100644 --- a/src/sql/platform/query/common/queryManagement.ts +++ b/src/sql/platform/query/common/queryManagement.ts @@ -9,12 +9,10 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { IDisposable } from 'vs/base/common/lifecycle'; import * as azdata from 'azdata'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { Event, Emitter } from 'vs/base/common/event'; import { keys } from 'vs/base/common/map'; -import { ILogService } from 'vs/platform/log/common/log'; import { assign } from 'vs/base/common/objects'; +import { IAdsTelemetryService, ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry'; export const SERVICE_ID = 'queryManagementService'; @@ -104,8 +102,7 @@ export class QueryManagementService implements IQueryManagementService { constructor( @IConnectionManagementService private _connectionService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService, - @ILogService private logService: ILogService + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService ) { } @@ -169,18 +166,17 @@ export class QueryManagementService implements IQueryManagementService { } private addTelemetry(eventName: string, ownerUri: string, runOptions?: azdata.ExecutionPlanOptions): void { - let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri); - let data: TelemetryUtils.IConnectionTelemetryData = { + const providerId: string = this._connectionService.getProviderIdFromUri(ownerUri); + const data: ITelemetryEventProperties = { provider: providerId, }; if (runOptions) { - data = assign({}, data, { + assign(data, { displayEstimatedQueryPlan: runOptions.displayEstimatedQueryPlan, displayActualQueryPlan: runOptions.displayActualQueryPlan }); } - // tslint:disable-next-line:no-floating-promises - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, eventName, data); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, eventName).withAdditionalProperties(data).send(); } private _runAction(uri: string, action: (handler: IQueryRequestHandler) => Promise, fallBackToDefaultProvider: boolean = false): Promise { diff --git a/src/sql/platform/restore/browser/restoreServiceImpl.ts b/src/sql/platform/restore/browser/restoreServiceImpl.ts index 9fe45b5071..b747941180 100644 --- a/src/sql/platform/restore/browser/restoreServiceImpl.ts +++ b/src/sql/platform/restore/browser/restoreServiceImpl.ts @@ -3,7 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import * as types from 'vs/base/common/types'; import * as azdata from 'azdata'; @@ -20,11 +19,11 @@ import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/br import { ITaskService } from 'sql/platform/tasks/common/tasksService'; import { TaskStatus, TaskNode } from 'sql/platform/tasks/common/tasksNode'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; import { invalidProvider } from 'sql/base/common/errors'; import { ILogService } from 'vs/platform/log/common/log'; import { find } from 'vs/base/common/arrays'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class RestoreService implements IRestoreService { @@ -33,8 +32,7 @@ export class RestoreService implements IRestoreService { constructor( @IConnectionManagementService private _connectionService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService, - @ILogService private logService: ILogService + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService ) { } @@ -63,7 +61,10 @@ export class RestoreService implements IRestoreService { return new Promise((resolve, reject) => { const providerResult = this.getProvider(connectionUri); if (providerResult) { - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName }).catch((e) => this.logService.error(e)); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.RestoreRequested) + .withAdditionalProperties({ + provider: providerResult.providerName + }).send(); providerResult.provider.restore(connectionUri, restoreInfo).then(result => { resolve(result); }, error => { diff --git a/src/sql/platform/telemetry/common/adsTelemetryService.ts b/src/sql/platform/telemetry/common/adsTelemetryService.ts index 55922d3ba0..30ea4fc35f 100644 --- a/src/sql/platform/telemetry/common/adsTelemetryService.ts +++ b/src/sql/platform/telemetry/common/adsTelemetryService.ts @@ -55,6 +55,18 @@ class TelemetryEventImpl implements ITelemetryEvent { } } +class NullTelemetryEventImpl implements ITelemetryEvent { + constructor() { } + + public send(): void { } + + public withAdditionalProperties(additionalProperties: ITelemetryEventProperties): ITelemetryEvent { return this; } + + public withAdditionalMeasurements(additionalMeasurements: ITelemetryEventMeasures): ITelemetryEvent { return this; } + + public withConnectionInfo(connectionInfo: ITelemetryConnectionInfo): ITelemetryEvent { return this; } +} + export class AdsTelemetryService implements IAdsTelemetryService { _serviceBrand: undefined; @@ -188,3 +200,31 @@ export class AdsTelemetryService implements IAdsTelemetryService { this.createTelemetryEvent(eventName, properties, measurements).send(); } } + +export class NullAdsTelemetryService implements IAdsTelemetryService { + + _serviceBrand: undefined; + + get isOptedIn(): boolean { + return false; + } + + setEnabled(value: boolean): void { } + getTelemetryInfo(): Promise { + return Promise.resolve({ + sessionId: '', + machineId: '', + instanceId: '' + }); + } + createViewEvent(view: string): ITelemetryEvent { return new NullTelemetryEventImpl(); } + sendViewEvent(view: string): void { } + createActionEvent(view: string, action: string, target?: string, source?: string, durationInMs?: number): ITelemetryEvent { return new NullTelemetryEventImpl(); } + sendActionEvent(view: string, action: string, target?: string, source?: string, durationInMs?: number): void { } + createMetricsEvent(metrics: ITelemetryEventMeasures, groupName: string): ITelemetryEvent { return new NullTelemetryEventImpl(); } + sendMetricsEvent(metrics: ITelemetryEventMeasures, groupName: string): void { } + createErrorEvent(view: string, name: string, errorCode?: string, errorType?: string): ITelemetryEvent { return new NullTelemetryEventImpl(); } + sendErrorEvent(view: string, name: string, errorCode?: string, errorType?: string): void { } + createTelemetryEvent(eventName: string, properties?: ITelemetryEventProperties, measurements?: ITelemetryEventMeasures): ITelemetryEvent { return new NullTelemetryEventImpl(); } + sendTelemetryEvent(eventName: string, properties?: ITelemetryEventProperties, measurements?: ITelemetryEventMeasures): void { } +} diff --git a/src/sql/platform/telemetry/common/telemetry.ts b/src/sql/platform/telemetry/common/telemetry.ts index 61fb1a116d..5660e1daa8 100644 --- a/src/sql/platform/telemetry/common/telemetry.ts +++ b/src/sql/platform/telemetry/common/telemetry.ts @@ -11,7 +11,7 @@ export const IAdsTelemetryService = createDecorator('adsTe * Holds additional properties to send along with an event. */ export interface ITelemetryEventProperties { - [key: string]: string; + [key: string]: any; } /** diff --git a/src/sql/platform/telemetry/common/telemetryUtilities.ts b/src/sql/platform/telemetry/common/telemetryUtilities.ts deleted file mode 100644 index 39aea48094..0000000000 --- a/src/sql/platform/telemetry/common/telemetryUtilities.ts +++ /dev/null @@ -1,62 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { ITelemetryService, ITelemetryData } from 'vs/platform/telemetry/common/telemetry'; -import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; -import { ILogService } from 'vs/platform/log/common/log'; - -export interface IConnectionTelemetryData extends ITelemetryData { - provider?: string; -} - -/** - * Call the given telemetry service to log the telemetry event. - * If the provider is not in the data, tries to get it from connection inside the data. - * The connection in the data won't be included in the telemetry data - * Note: userId is added to all telemetry events so no need to add it here - * @param telemetryService Telemetry Service - * @param telemetryEventName Telemetry event name - * @param data Telemetry data - */ -export function addTelemetry( - telemetryService: ITelemetryService, - logService: ILogService, - telemetryEventName: string, - data?: IConnectionTelemetryData, - connection?: IConnectionProfile -): Promise { - return new Promise(resolve => { - try { - let telData: ITelemetryData = data === undefined ? {} : data; - - if (telData && telData.provider === undefined) { - - let provider: string = ''; - if (connection) { - provider = connection.providerName; - } - telData.provider = provider; - } - delete telData['connection']; - if (telemetryService) { - telemetryService.publicLog(telemetryEventName, telData).then(() => { - resolve(); - }, telemetryServiceError => { - if (logService) { - logService.warn(`Failed to add telemetry. error: ${telemetryServiceError}`); - } - resolve(); - }); - } else { - resolve(); - } - } catch (error) { - if (logService) { - logService.warn(`Failed to add telemetry. error: ${error}`); - } - resolve(); - } - }); -} diff --git a/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts b/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts deleted file mode 100644 index 5dbe563c8e..0000000000 --- a/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts +++ /dev/null @@ -1,107 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import * as TypeMoq from 'typemoq'; -import * as assert from 'assert'; -import { NullLogService } from 'vs/platform/log/common/log'; -import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; - -suite('SQL Telemetry Utilities tests', () => { - let telemetryService: TypeMoq.Mock; - let none: void; - let providerName: string = 'provider name'; - let telemetryKey: string = 'tel key'; - - let connectionProfile = { - connectionName: '', - databaseName: '', - serverName: '', - authenticationType: '', - getOptionsKey: () => '', - matches: () => false, - groupFullName: '', - groupId: '', - id: '', - options: {}, - password: '', - providerName: providerName, - savePassword: true, - saveProfile: true, - userName: '' - }; - - setup(() => { - telemetryService = TypeMoq.Mock.ofType(TelemetryService, TypeMoq.MockBehavior.Strict, Object.create(null)); - telemetryService.setup(x => x.publicLog(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(x => Promise.resolve(none)); - }); - - test('addTelemetry should add provider id using the connection', (done) => { - let data: TelemetryUtils.IConnectionTelemetryData = { - }; - const logService = new NullLogService(); - TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { - telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b!.provider === providerName)), TypeMoq.Times.once()); - done(); - }).catch(err => { - assert.fail(err); - done(err); - }); - }); - - test('addTelemetry should pass the telemetry data to telemetry service', (done) => { - let data: TelemetryUtils.IConnectionTelemetryData = { - target: 'target', - from: 'from' - }; - data.test1 = '1'; - - const logService = new NullLogService(); - TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { - telemetryService.verify(x => x.publicLog( - TypeMoq.It.is(a => a === telemetryKey), - TypeMoq.It.is(b => b!.provider === providerName - && b!.from === data.from - && b!.target === data.target - && b!.test1 === data.test1 - && b!.connection === undefined)), TypeMoq.Times.once()); - done(); - }).catch(err => { - assert.fail(err); - done(err); - }); - }); - - test('addTelemetry should not crash not given data', (done) => { - - const logService = new NullLogService(); - TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey).then(() => { - telemetryService.verify(x => x.publicLog( - TypeMoq.It.is(a => a === telemetryKey), - TypeMoq.It.is(b => b !== undefined)), TypeMoq.Times.once()); - done(); - }).catch(err => { - assert.fail(err); - done(err); - }); - }); - - test('addTelemetry should try to get the provider name from data first', (done) => { - let data: TelemetryUtils.IConnectionTelemetryData = { - connection: connectionProfile - }; - data.provider = providerName + '1'; - - const logService = new NullLogService(); - TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { - telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b!.provider === data.provider)), TypeMoq.Times.once()); - done(); - }).catch(err => { - assert.fail(err); - done(err); - }); - }); -}); diff --git a/src/sql/workbench/browser/modal/modal.ts b/src/sql/workbench/browser/modal/modal.ts index dd710fa064..bcf57826f7 100644 --- a/src/sql/workbench/browser/modal/modal.ts +++ b/src/sql/workbench/browser/modal/modal.ts @@ -8,7 +8,6 @@ import { Color } from 'vs/base/common/color'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { mixin } from 'vs/base/common/objects'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import * as DOM from 'vs/base/browser/dom'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { generateUuid } from 'vs/base/common/uuid'; @@ -16,7 +15,6 @@ import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/cont import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { Button } from 'sql/base/browser/ui/button/button'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { localize } from 'vs/nls'; import { MessageLevel } from 'sql/workbench/api/common/sqlExtHostTypes'; @@ -28,6 +26,7 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/resour import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; import { find, firstIndex } from 'vs/base/common/arrays'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export const MODAL_SHOWING_KEY = 'modalShowing'; export const MODAL_SHOWING_CONTEXT = new RawContextKey>(MODAL_SHOWING_KEY, []); @@ -140,7 +139,7 @@ export abstract class Modal extends Disposable implements IThemable { constructor( private _title: string, private _name: string, - private readonly _telemetryService: ITelemetryService, + private readonly _telemetryService: IAdsTelemetryService, protected readonly layoutService: IWorkbenchLayoutService, protected readonly _clipboardService: IClipboardService, protected readonly _themeService: IThemeService, @@ -373,7 +372,9 @@ export abstract class Modal extends Disposable implements IThemable { }); this.layout(DOM.getTotalHeight(this._modalBodySection)); - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ModalDialogOpened, { name: this._name }); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.ModalDialogOpened) + .withAdditionalProperties({ name: this._name }) + .send(); } /** @@ -392,7 +393,9 @@ export abstract class Modal extends Disposable implements IThemable { } this._keydownListener.dispose(); this._resizeListener.dispose(); - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ModalDialogClosed, { name: this._name }); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.ModalDialogClosed) + .withAdditionalProperties({ name: this._name }) + .send(); } /** diff --git a/src/sql/workbench/browser/modal/optionsDialog.ts b/src/sql/workbench/browser/modal/optionsDialog.ts index dbc6084427..f6faee774c 100644 --- a/src/sql/workbench/browser/modal/optionsDialog.ts +++ b/src/sql/workbench/browser/modal/optionsDialog.ts @@ -17,7 +17,6 @@ import * as azdata from 'azdata'; import { Event, Emitter } from 'vs/base/common/event'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { localize } from 'vs/nls'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { contrastBorder } from 'vs/platform/theme/common/colorRegistry'; @@ -34,6 +33,7 @@ import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class CategoryView extends ViewletPanel { @@ -93,7 +93,7 @@ export class OptionsDialog extends Modal { @IThemeService themeService: IThemeService, @IContextViewService private _contextViewService: IContextViewService, @IInstantiationService private _instantiationService: IInstantiationService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/parts/accounts/browser/accountDialog.ts b/src/sql/workbench/parts/accounts/browser/accountDialog.ts index 47d93a0bcc..63465f28e3 100644 --- a/src/sql/workbench/parts/accounts/browser/accountDialog.ts +++ b/src/sql/workbench/parts/accounts/browser/accountDialog.ts @@ -15,7 +15,6 @@ import { IAction } from 'vs/base/common/actions'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { SplitView, Sizing } from 'vs/base/browser/ui/splitview/splitview'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet'; @@ -36,6 +35,7 @@ import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; class AccountPanel extends ViewletPanel { public index: number; @@ -122,7 +122,7 @@ export class AccountDialog extends Modal { @IContextMenuService private _contextMenuService: IContextMenuService, @IKeybindingService private _keybindingService: IKeybindingService, @IConfigurationService private _configurationService: IConfigurationService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService private readonly contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/parts/accounts/browser/autoOAuthDialog.ts b/src/sql/workbench/parts/accounts/browser/autoOAuthDialog.ts index 7af2c0c55c..00cdde1cd3 100644 --- a/src/sql/workbench/parts/accounts/browser/autoOAuthDialog.ts +++ b/src/sql/workbench/parts/accounts/browser/autoOAuthDialog.ts @@ -18,12 +18,12 @@ import { Button } from 'sql/base/browser/ui/button/button'; import { Modal } from 'sql/workbench/browser/modal/modal'; import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox'; import { attachModalDialogStyler, attachButtonStyler } from 'sql/platform/theme/common/styler'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class AutoOAuthDialog extends Modal { private _copyAndOpenButton: Button; @@ -47,7 +47,7 @@ export class AutoOAuthDialog extends Modal { @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IThemeService themeService: IThemeService, @IContextViewService private _contextViewService: IContextViewService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/parts/accounts/browser/firewallRuleDialog.ts b/src/sql/workbench/parts/accounts/browser/firewallRuleDialog.ts index 3751dee8d2..6a73b0878f 100644 --- a/src/sql/workbench/parts/accounts/browser/firewallRuleDialog.ts +++ b/src/sql/workbench/parts/accounts/browser/firewallRuleDialog.ts @@ -12,7 +12,6 @@ import { localize } from 'vs/nls'; import { buttonBackground } from 'vs/platform/theme/common/colorRegistry'; import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; @@ -31,6 +30,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; import { IOpenerService } from 'vs/platform/opener/common/opener'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; // TODO: Make the help link 1) extensible (01/08/2018, https://github.com/Microsoft/azuredatastudio/issues/450) // in case that other non-Azure sign in is to be used @@ -69,7 +69,7 @@ export class FirewallRuleDialog extends Modal { @IThemeService themeService: IThemeService, @IInstantiationService private _instantiationService: IInstantiationService, @IContextViewService private _contextViewService: IContextViewService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/parts/backup/browser/backupDialog.ts b/src/sql/workbench/parts/backup/browser/backupDialog.ts index 989283c0ea..168e7f8bd4 100644 --- a/src/sql/workbench/parts/backup/browser/backupDialog.ts +++ b/src/sql/workbench/parts/backup/browser/backupDialog.ts @@ -11,7 +11,6 @@ import { attachModalDialogStyler } from 'sql/platform/theme/common/styler'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { bootstrapAngular } from 'sql/workbench/services/bootstrap/browser/bootstrapService'; @@ -20,6 +19,7 @@ import { append, $ } from 'vs/base/browser/dom'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class BackupDialog extends Modal { private _body: HTMLElement; @@ -29,7 +29,7 @@ export class BackupDialog extends Modal { constructor( @IThemeService themeService: IThemeService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IInstantiationService private _instantiationService: IInstantiationService, @IClipboardService clipboardService: IClipboardService, diff --git a/src/sql/workbench/parts/dashboard/browser/dashboard.module.ts b/src/sql/workbench/parts/dashboard/browser/dashboard.module.ts index 7ce4f250cc..3b79fbaad6 100644 --- a/src/sql/workbench/parts/dashboard/browser/dashboard.module.ts +++ b/src/sql/workbench/parts/dashboard/browser/dashboard.module.ts @@ -20,8 +20,6 @@ import { IBootstrapParams, ISelector } from 'sql/workbench/services/bootstrap/co import { Registry } from 'vs/platform/registry/common/platform'; /* Telemetry */ -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; /* Services */ @@ -89,7 +87,7 @@ import { InsightsWidget } from 'sql/workbench/parts/dashboard/browser/widgets/in import { WebviewWidget } from 'sql/workbench/parts/dashboard/browser/widgets/webview/webviewWidget.component'; import { JobStepsViewComponent } from 'sql/workbench/parts/jobManagement/browser/jobStepsView.component'; import { IInstantiationService, _util } from 'vs/platform/instantiation/common/instantiation'; -import { ILogService } from 'vs/platform/log/common/log'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; const widgetComponents = [ @@ -161,8 +159,7 @@ export const DashboardModule = (params, selector: string, instantiationService: constructor( @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => Router)) private _router: Router, - @Inject(ITelemetryService) private telemetryService: ITelemetryService, - @Inject(ILogService) private readonly logService: ILogService, + @Inject(IAdsTelemetryService) private _telemetryService: IAdsTelemetryService, @Inject(ISelector) private selector: string ) { } @@ -175,9 +172,9 @@ export const DashboardModule = (params, selector: string, instantiationService: this._router.events.subscribe(e => { if (e instanceof NavigationEnd) { this.navigations++; - TelemetryUtils.addTelemetry(this.telemetryService, this.logService, TelemetryKeys.DashboardNavigated, { - numberOfNavigations: this.navigations - }); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.DashboardNavigated) + .withAdditionalProperties({ numberOfNavigations: this.navigations }) + .send(); } }); } diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/chartInsight.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/chartInsight.component.ts index 558df58557..7cc8789b0d 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/chartInsight.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/chartInsight.component.ts @@ -8,7 +8,6 @@ import { BaseChartDirective } from 'ng2-charts'; import * as chartjs from 'chart.js'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; import { mixin } from 'sql/base/common/objects'; import { defaultChartConfig, IChartConfig, IDataSet } from 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/interfaces'; @@ -16,13 +15,12 @@ import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as types from 'vs/base/common/types'; import { Disposable } from 'vs/base/common/lifecycle'; import * as nls from 'vs/nls'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { IInsightData, IPointDataSet } from 'sql/workbench/parts/charts/browser/interfaces'; import { IInsightsView } from 'sql/platform/dashboard/browser/insightRegistry'; import { ChartType, LegendPosition } from 'sql/workbench/parts/charts/common/interfaces'; import { createMemoizer } from 'vs/base/common/decorators'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; @Component({ template: `
@@ -57,8 +55,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(IThemeService) private themeService: IThemeService, - @Inject(ITelemetryService) private telemetryService: ITelemetryService, - @Inject(ILogService) private readonly logService: ILogService + @Inject(IAdsTelemetryService) private _telemetryService: IAdsTelemetryService ) { super(); } @@ -79,7 +76,9 @@ export abstract class ChartInsight extends Disposable implements IInsightsView { this._hasError = true; this._changeRef.detectChanges(); } - TelemetryUtils.addTelemetry(this.telemetryService, this.logService, TelemetryKeys.ChartCreated, { type: this.chartType }); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.ChartCreated) + .withAdditionalProperties({ type: this.chartType }) + .send(); } /** diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/barChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/barChart.component.ts index 59b3e78066..8a41282e92 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/barChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/barChart.component.ts @@ -10,11 +10,10 @@ import { IChartConfig } from 'sql/workbench/parts/dashboard/browser/widgets/insi import * as colors from 'vs/platform/theme/common/colorRegistry'; import { editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry'; import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { customMixin } from 'sql/workbench/parts/charts/browser/interfaces'; import { ChartType } from 'sql/workbench/parts/charts/common/interfaces'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export interface IBarChartConfig extends IChartConfig { yAxisMin: number; @@ -31,10 +30,9 @@ export default class BarChart extends ChartInsight { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } public setConfig(config: IBarChartConfig): void { diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/doughnutChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/doughnutChart.component.ts index 6251c1353c..cc5581e1e1 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/doughnutChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/doughnutChart.component.ts @@ -5,10 +5,9 @@ import PieChart from './pieChart.component'; import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { ILogService } from 'vs/platform/log/common/log'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ChartType } from 'sql/workbench/parts/charts/common/interfaces'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export default class DoughnutChart extends PieChart { protected readonly chartType: ChartType = ChartType.Doughnut; @@ -16,9 +15,8 @@ export default class DoughnutChart extends PieChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } } diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/horizontalBarChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/horizontalBarChart.component.ts index 490dcf7d44..3a7dc5adad 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/horizontalBarChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/horizontalBarChart.component.ts @@ -5,10 +5,9 @@ import BarChart from './barChart.component'; import { forwardRef, Inject, ChangeDetectorRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { ChartType } from 'sql/workbench/parts/charts/common/interfaces'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export default class HorizontalBarChart extends BarChart { protected readonly chartType: ChartType = ChartType.HorizontalBar; @@ -16,9 +15,8 @@ export default class HorizontalBarChart extends BarChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } } diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/lineChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/lineChart.component.ts index 4c740d0d7e..3a65c8ec42 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/lineChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/lineChart.component.ts @@ -8,12 +8,11 @@ import { mixin, deepClone } from 'vs/base/common/objects'; import BarChart, { IBarChartConfig } from './barChart.component'; import { defaultChartConfig, IDataSet } from 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/interfaces'; import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { IPointDataSet } from 'sql/workbench/parts/charts/browser/interfaces'; import { DataType, ChartType } from 'sql/workbench/parts/charts/common/interfaces'; import { values } from 'vs/base/common/collections'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export interface ILineConfig extends IBarChartConfig { dataType?: DataType; @@ -29,10 +28,9 @@ export default class LineChart extends BarChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } public init() { diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/pieChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/pieChart.component.ts index 26e0646b9f..d173733a63 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/pieChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/pieChart.component.ts @@ -5,10 +5,9 @@ import { ChartInsight } from 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/chartInsight.component'; import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { ChartType } from 'sql/workbench/parts/charts/common/interfaces'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export default class PieChart extends ChartInsight { protected readonly chartType: ChartType = ChartType.Pie; @@ -16,9 +15,8 @@ export default class PieChart extends ChartInsight { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } } diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/scatterChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/scatterChart.component.ts index 0300c861e7..264f416115 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/scatterChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/scatterChart.component.ts @@ -8,10 +8,9 @@ import { defaultChartConfig } from 'sql/workbench/parts/dashboard/browser/widget import { mixin, deepClone } from 'vs/base/common/objects'; import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { ChartType } from 'sql/workbench/parts/charts/common/interfaces'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; const defaultScatterConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig; @@ -22,9 +21,8 @@ export default class ScatterChart extends LineChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } } diff --git a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/timeSeriesChart.component.ts b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/timeSeriesChart.component.ts index 0440aaf5cc..2c7c586d09 100644 --- a/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/timeSeriesChart.component.ts +++ b/src/sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/types/timeSeriesChart.component.ts @@ -9,12 +9,11 @@ import { defaultChartConfig } from 'sql/workbench/parts/dashboard/browser/widget import { mixin, deepClone, assign } from 'vs/base/common/objects'; import { Color } from 'vs/base/common/color'; import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ILogService } from 'vs/platform/log/common/log'; import { IPointDataSet } from 'sql/workbench/parts/charts/browser/interfaces'; import { ChartType } from 'sql/workbench/parts/charts/common/interfaces'; import { values } from 'vs/base/common/collections'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; const defaultTimeSeriesConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig; @@ -24,10 +23,9 @@ export default class TimeSeriesChart extends LineChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, @Inject(IThemeService) themeService: IThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService, - @Inject(ILogService) logService: ILogService + @Inject(IAdsTelemetryService) telemetryService: IAdsTelemetryService ) { - super(_changeRef, themeService, telemetryService, logService); + super(_changeRef, themeService, telemetryService); } protected addAxisLabels(): void { diff --git a/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts b/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts index 4cbf055a7f..59b12e63fd 100644 --- a/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts +++ b/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts @@ -16,7 +16,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { localize } from 'vs/nls'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { Button } from 'sql/base/browser/ui/button/button'; import { Modal } from 'sql/workbench/browser/modal/modal'; @@ -29,6 +28,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { Color } from 'vs/base/common/color'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class ServerGroupDialog extends Modal { private _addServerButton: Button; @@ -54,7 +54,7 @@ export class ServerGroupDialog extends Modal { @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IThemeService themeService: IThemeService, @IContextViewService private _contextViewService: IContextViewService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts b/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts index 61bd8717d4..bd45eb4a34 100644 --- a/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts +++ b/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts @@ -21,12 +21,12 @@ import * as DOM from 'vs/base/browser/dom'; import { IDataSource, ITree, IRenderer } from 'vs/base/parts/tree/browser/tree'; import { attachListStyler } from 'vs/platform/theme/common/styler'; import { Event, Emitter } from 'vs/base/common/event'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; class EventItem { @@ -313,7 +313,7 @@ export class ProfilerColumnEditorDialog extends Modal { constructor( @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IThemeService themeService: IThemeService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IContextViewService private _contextViewService: IContextViewService, @IClipboardService clipboardService: IClipboardService, diff --git a/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts b/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts index a3b9a47d18..9110b48571 100644 --- a/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts +++ b/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts @@ -10,7 +10,6 @@ import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { attachButtonStyler, attachModalDialogStyler, attachInputBoxStyler } from 'sql/platform/theme/common/styler'; import { KeyCode } from 'vs/base/common/keyCodes'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { localize } from 'vs/nls'; @@ -27,6 +26,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; import { find, firstIndex } from 'vs/base/common/arrays'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; const ClearText: string = localize('profilerFilterDialog.clear', "Clear all"); @@ -75,7 +75,7 @@ export class ProfilerFilterDialog extends Modal { @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @ILogService logService: ILogService, @IContextViewService private contextViewService: IContextViewService, diff --git a/src/sql/workbench/parts/restore/browser/restoreDialog.ts b/src/sql/workbench/parts/restore/browser/restoreDialog.ts index 84e5a674e0..e2d36b27be 100644 --- a/src/sql/workbench/parts/restore/browser/restoreDialog.ts +++ b/src/sql/workbench/parts/restore/browser/restoreDialog.ts @@ -12,7 +12,6 @@ import { Widget } from 'vs/base/browser/ui/widget'; import { MessageType, IInputOptions } from 'vs/base/browser/ui/inputbox/inputBox'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { localize } from 'vs/nls'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { mixin } from 'vs/base/common/objects'; @@ -44,6 +43,7 @@ import { IFileBrowserDialogController } from 'sql/workbench/services/fileBrowser import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; interface FileListElement { logicalFileName: string; @@ -133,7 +133,7 @@ export class RestoreDialog extends Modal { @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IThemeService themeService: IThemeService, @IContextViewService private _contextViewService: IContextViewService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IFileBrowserDialogController private fileBrowserDialogService: IFileBrowserDialogController, @IClipboardService clipboardService: IClipboardService, diff --git a/src/sql/workbench/parts/webview/browser/webViewDialog.ts b/src/sql/workbench/parts/webview/browser/webViewDialog.ts index 003cb25ec6..1890536964 100644 --- a/src/sql/workbench/parts/webview/browser/webViewDialog.ts +++ b/src/sql/workbench/parts/webview/browser/webViewDialog.ts @@ -10,7 +10,6 @@ import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { attachButtonStyler, attachModalDialogStyler } from 'sql/platform/theme/common/styler'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { Event, Emitter } from 'vs/base/common/event'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { localize } from 'vs/nls'; @@ -21,6 +20,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IWebviewService, WebviewElement } from 'vs/workbench/contrib/webview/browser/webview'; import { generateUuid } from 'vs/base/common/uuid'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class WebViewDialog extends Modal { @@ -44,7 +44,7 @@ export class WebViewDialog extends Modal { @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @ILogService logService: ILogService, @IWebviewService private readonly webviewService: IWebviewService, diff --git a/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts b/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts index 1ffe2947c7..4c08119f8e 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts @@ -23,7 +23,6 @@ import { contrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { Event, Emitter } from 'vs/base/common/event'; import { ICancelableEvent } from 'vs/base/parts/tree/browser/treeDefaults'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { localize } from 'vs/nls'; import { ITree } from 'vs/base/parts/tree/browser/tree'; import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView'; @@ -37,6 +36,7 @@ import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export interface OnShowUIResponse { selectedProviderDisplayName: string; @@ -92,7 +92,7 @@ export class ConnectionDialogWidget extends Modal { @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IThemeService themeService: IThemeService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IContextMenuService private _contextMenuService: IContextMenuService, @IContextViewService private _contextViewService: IContextViewService, diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index be1363ad9f..faa9e5b050 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -20,7 +20,6 @@ import { ConnectionStatusManager } from 'sql/platform/connection/common/connecti import { DashboardInput } from 'sql/workbench/parts/dashboard/browser/dashboardInput'; import { ConnectionGlobalStatus } from 'sql/workbench/parts/connection/common/connectionGlobalStatus'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; import { IResourceProviderService } from 'sql/workbench/services/resourceProvider/common/resourceProviderService'; import { IAngularEventingService, AngularEventType } from 'sql/platform/angularEventing/browser/angularEventingService'; import * as QueryConstants from 'sql/workbench/parts/query/common/constants'; @@ -37,7 +36,6 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import * as platform from 'vs/platform/registry/common/platform'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup'; import { Event, Emitter } from 'vs/base/common/event'; import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; @@ -53,6 +51,7 @@ import { entries } from 'sql/base/common/collections'; import { find } from 'vs/base/common/arrays'; import { values } from 'vs/base/common/collections'; import { assign } from 'vs/base/common/objects'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class ConnectionManagementService extends Disposable implements IConnectionManagementService { @@ -80,7 +79,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti @IConnectionDialogService private _connectionDialogService: IConnectionDialogService, @IInstantiationService private _instantiationService: IInstantiationService, @IEditorService private _editorService: IEditorService, - @ITelemetryService private _telemetryService: ITelemetryService, + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService, @IConfigurationService private _configurationService: IConfigurationService, @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, @IQuickInputService private _quickInputService: IQuickInputService, @@ -590,7 +589,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti } public saveProfileGroup(profile: IConnectionProfileGroup): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.AddServerGroup).catch((e) => this._logService.error(e)); + this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.AddServerGroup); return this._connectionStore.saveProfileGroup(profile).then(groupId => { this._onAddConnectionProfile.fire(undefined); return groupId; @@ -829,21 +828,25 @@ export class ConnectionManagementService extends Disposable implements IConnecti } private addTelemetryForConnection(connection: ConnectionManagementInfo): void { - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.DatabaseConnected, { - connectionType: connection.serverInfo ? (connection.serverInfo.isCloud ? 'Azure' : 'Standalone') : '', - provider: connection.connectionProfile.providerName, - serverVersion: connection.serverInfo ? connection.serverInfo.serverVersion : '', - serverEdition: connection.serverInfo ? connection.serverInfo.serverEdition : '', + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.DatabaseConnected) + .withAdditionalProperties({ + connectionType: connection.serverInfo ? (connection.serverInfo.isCloud ? 'Azure' : 'Standalone') : '', + provider: connection.connectionProfile.providerName, + serverVersion: connection.serverInfo ? connection.serverInfo.serverVersion : '', + serverEdition: connection.serverInfo ? connection.serverInfo.serverEdition : '', - extensionConnectionTime: connection.extensionTimer.elapsed() - connection.serviceTimer.elapsed(), - serviceConnectionTime: connection.serviceTimer.elapsed() - }).catch((e) => this._logService.error(e)); + extensionConnectionTime: connection.extensionTimer.elapsed() - connection.serviceTimer.elapsed(), + serviceConnectionTime: connection.serviceTimer.elapsed() + }) + .send(); } private addTelemetryForConnectionDisconnected(connection: interfaces.IConnectionProfile): void { - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.DatabaseDisconnected, { - provider: connection.providerName - }).catch((e) => this._logService.error(e)); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.DatabaseDisconnected) + .withAdditionalProperties({ + provider: connection.providerName + }) + .send(); } public onConnectionComplete(handle: number, info: azdata.ConnectionInfoSummary): void { @@ -885,13 +888,13 @@ export class ConnectionManagementService extends Disposable implements IConnecti } public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.MoveServerConnection).catch((e) => this._logService.error(e)); + this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.MoveServerConnection); return this._connectionStore.changeGroupIdForConnectionGroup(source, target); } public changeGroupIdForConnection(source: ConnectionProfile, targetGroupId: string): Promise { let id = Utils.generateUri(source); - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.MoveServerGroup).catch((e) => this._logService.error(e)); + this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.MoveServerGroup); return this._connectionStore.changeGroupIdForConnection(source, targetGroupId).then(result => { if (id && targetGroupId) { source.groupId = targetGroupId; @@ -1146,8 +1149,10 @@ export class ConnectionManagementService extends Disposable implements IConnecti * Disconnects a connection before removing from settings. */ public deleteConnection(connection: ConnectionProfile): Promise { - - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.DeleteConnection, {}, connection).catch((e) => this._logService.error(e)); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.DeleteConnection) + .withAdditionalProperties({ + provider: connection.providerName + }).send(); // Disconnect if connected let uri = Utils.generateUri(connection); if (this.isConnected(uri) || this.isConnecting(uri)) { @@ -1177,7 +1182,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti * Disconnects a connection before removing from config. If disconnect fails, settings is not modified. */ public deleteConnectionGroup(group: ConnectionProfileGroup): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, this._logService, TelemetryKeys.DeleteServerGroup).catch((e) => this._logService.error(e)); + this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.DeleteServerGroup); // Get all connections for this group let connections = ConnectionProfileGroup.getConnectionsInGroup(group); diff --git a/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts b/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts index 751572d376..bdf574757b 100644 --- a/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts +++ b/src/sql/workbench/services/connection/test/browser/connectionManagementService.test.ts @@ -33,6 +33,7 @@ import { TestNotificationService } from 'vs/platform/notification/test/common/te import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { NullLogService } from 'vs/platform/log/common/log'; import { assign } from 'vs/base/common/objects'; +import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService'; suite('SQL ConnectionManagementService tests', () => { @@ -152,7 +153,7 @@ suite('SQL ConnectionManagementService tests', () => { connectionDialogService.object, undefined, // IInstantiationService workbenchEditorService.object, - undefined, // ITelemetryService + new NullAdsTelemetryService(), // ITelemetryService workspaceConfigurationServiceMock.object, capabilitiesService, undefined, // IQuickInputService diff --git a/src/sql/workbench/services/dashboard/browser/newDashboardTabDialogImpl.ts b/src/sql/workbench/services/dashboard/browser/newDashboardTabDialogImpl.ts index 8d406d5203..6bd064dafa 100644 --- a/src/sql/workbench/services/dashboard/browser/newDashboardTabDialogImpl.ts +++ b/src/sql/workbench/services/dashboard/browser/newDashboardTabDialogImpl.ts @@ -12,7 +12,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import { localize } from 'vs/nls'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { attachListStyler } from 'vs/platform/theme/common/styler'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IListVirtualDelegate, IListRenderer } from 'vs/base/browser/ui/list/list'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; @@ -28,6 +27,7 @@ import { IClipboardService } from 'sql/platform/clipboard/common/clipboardServic import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; class ExtensionListDelegate implements IListVirtualDelegate { @@ -110,7 +110,7 @@ export class NewDashboardTabDialog extends Modal { constructor( @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IThemeService themeService: IThemeService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/services/dialog/browser/dialogModal.ts b/src/sql/workbench/services/dialog/browser/dialogModal.ts index e2c3598c8f..04ef5788c5 100644 --- a/src/sql/workbench/services/dialog/browser/dialogModal.ts +++ b/src/sql/workbench/services/dialog/browser/dialogModal.ts @@ -10,7 +10,6 @@ import { Dialog, DialogButton } from 'sql/workbench/services/dialog/common/dialo import { DialogPane } from 'sql/workbench/services/dialog/browser/dialogPane'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { attachButtonStyler } from 'vs/platform/theme/common/styler'; import { Button } from 'vs/base/browser/ui/button/button'; @@ -24,6 +23,7 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la import { append, $ } from 'vs/base/browser/dom'; import { ILogService } from 'vs/platform/log/common/log'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class DialogModal extends Modal { private _dialogPane: DialogPane; @@ -39,7 +39,7 @@ export class DialogModal extends Modal { options: IModalOptions, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IWorkbenchThemeService themeService: IWorkbenchThemeService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/services/dialog/browser/wizardModal.ts b/src/sql/workbench/services/dialog/browser/wizardModal.ts index 4115553011..8a90968e7e 100644 --- a/src/sql/workbench/services/dialog/browser/wizardModal.ts +++ b/src/sql/workbench/services/dialog/browser/wizardModal.ts @@ -13,7 +13,6 @@ import { DialogMessage } from 'sql/workbench/api/common/sqlExtHostTypes'; import { DialogModule } from 'sql/workbench/services/dialog/browser/dialog.module'; import { Button } from 'vs/base/browser/ui/button/button'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { attachButtonStyler } from 'vs/platform/theme/common/styler'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; @@ -25,6 +24,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class WizardModal extends Modal { private _dialogPanes = new Map(); @@ -47,7 +47,7 @@ export class WizardModal extends Modal { options: IModalOptions, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IThemeService themeService: IThemeService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IInstantiationService private _instantiationService: IInstantiationService, @IClipboardService clipboardService: IClipboardService, diff --git a/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts b/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts index 1ab52253aa..ee22166cbc 100644 --- a/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts +++ b/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts @@ -14,7 +14,6 @@ import Severity from 'vs/base/common/severity'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { SIDE_BAR_BACKGROUND, SIDE_BAR_FOREGROUND } from 'vs/workbench/common/theme'; import { Event, Emitter } from 'vs/base/common/event'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { localize } from 'vs/nls'; @@ -23,6 +22,7 @@ import * as DOM from 'vs/base/browser/dom'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; const maxActions = 1; @@ -46,7 +46,7 @@ export class ErrorMessageDialog extends Modal { @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @ILogService logService: ILogService, @ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService diff --git a/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts b/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts index 1cda6b5353..d82430339b 100644 --- a/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts +++ b/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts @@ -22,7 +22,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import { localize } from 'vs/nls'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { attachInputBoxStyler, attachSelectBoxStyler } from 'vs/platform/theme/common/styler'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import * as DOM from 'vs/base/browser/dom'; @@ -32,6 +31,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ILogService } from 'vs/platform/log/common/log'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class FileBrowserDialog extends Modal { private _viewModel: FileBrowserViewModel; @@ -53,7 +53,7 @@ export class FileBrowserDialog extends Modal { @IThemeService themeService: IThemeService, @IInstantiationService private _instantiationService: IInstantiationService, @IContextViewService private _contextViewService: IContextViewService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, @ILogService logService: ILogService, diff --git a/src/sql/workbench/services/insights/browser/insightsDialogView.ts b/src/sql/workbench/services/insights/browser/insightsDialogView.ts index d5d9f305e3..4cb56bd922 100644 --- a/src/sql/workbench/services/insights/browser/insightsDialogView.ts +++ b/src/sql/workbench/services/insights/browser/insightsDialogView.ts @@ -26,7 +26,6 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import * as nls from 'vs/nls'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IAction } from 'vs/base/common/actions'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import * as types from 'vs/base/common/types'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; @@ -42,6 +41,7 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la import { IInsightsConfigDetails } from 'sql/platform/dashboard/browser/insightRegistry'; import { TaskRegistry } from 'sql/platform/tasks/browser/tasksRegistry'; import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; const labelDisplay = nls.localize("insights.item", "Item"); const valueDisplay = nls.localize("insights.value", "Value"); @@ -162,7 +162,7 @@ export class InsightsDialogView extends Modal { @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @ITelemetryService telemetryService: ITelemetryService, + @IAdsTelemetryService telemetryService: IAdsTelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @ILogService logService: ILogService, @IInstantiationService private readonly _instantiationService: IInstantiationService, diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts index ff57e312b0..dd9d970283 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts @@ -13,8 +13,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import * as azdata from 'azdata'; import * as nls from 'vs/nls'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ServerTreeView } from 'sql/workbench/parts/objectExplorer/browser/serverTreeView'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import * as Utils from 'sql/platform/connection/common/utils'; @@ -22,6 +20,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { entries } from 'sql/base/common/collections'; import { values } from 'vs/base/common/collections'; import { startsWith } from 'vs/base/common/strings'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export const SERVICE_ID = 'ObjectExplorerService'; @@ -146,7 +145,7 @@ export class ObjectExplorerService implements IObjectExplorerService { constructor( @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService, + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService, @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, @ILogService private logService: ILogService ) { @@ -348,7 +347,11 @@ export class ObjectExplorerService implements IObjectExplorerService { return new Promise((resolve, reject) => { let provider = this._providers[providerId]; if (provider) { - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ObjectExplorerExpand, { refresh: 0, provider: providerId }).catch((e) => this.logService.error(e)); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.ObjectExplorerExpand) + .withAdditionalProperties({ + refresh: false, + provider: providerId + }).send(); this.expandOrRefreshNode(providerId, session, nodePath).then(result => { resolve(result); }, error => { @@ -486,7 +489,11 @@ export class ObjectExplorerService implements IObjectExplorerService { public refreshNode(providerId: string, session: azdata.ObjectExplorerSession, nodePath: string): Thenable { let provider = this._providers[providerId]; if (provider) { - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ObjectExplorerExpand, { refresh: 1, provider: providerId }).catch((e) => this.logService.error(e)); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.ObjectExplorerExpand) + .withAdditionalProperties({ + refresh: true, + provider: providerId + }).send(); return this.expandOrRefreshNode(providerId, session, nodePath, true); } return Promise.resolve(undefined); diff --git a/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts b/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts index f74d15092f..2824603fef 100644 --- a/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts +++ b/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts @@ -21,6 +21,7 @@ import { TestObjectExplorerProvider } from 'sql/workbench/services/objectExplore import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService'; import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService'; import { find } from 'vs/base/common/arrays'; +import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService'; suite('SQL Object Explorer Service tests', () => { let sqlOEProvider: TypeMoq.Mock; @@ -265,7 +266,7 @@ suite('SQL Object Explorer Service tests', () => { connectionManagementService.setup(x => x.getCapabilities(mssqlProviderName)).returns(() => undefined); const logService = new NullLogService(); - objectExplorerService = new ObjectExplorerService(connectionManagementService.object, undefined, capabilitiesService, logService); + objectExplorerService = new ObjectExplorerService(connectionManagementService.object, new NullAdsTelemetryService(), capabilitiesService, logService); objectExplorerService.registerProvider(mssqlProviderName, sqlOEProvider.object); sqlOEProvider.setup(x => x.createNewSession(TypeMoq.It.is(x => x.options['serverName'] === connection.serverName))).returns(() => new Promise((resolve) => { resolve(response); diff --git a/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts b/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts index 022a175d65..ac5f174321 100644 --- a/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts +++ b/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts @@ -3,18 +3,16 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { IResourceProviderService, IHandleFirewallRuleResult } from 'sql/workbench/services/resourceProvider/common/resourceProviderService'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; -import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities'; import { FirewallRuleDialogController } from 'sql/workbench/parts/accounts/browser/firewallRuleDialogController'; import * as azdata from 'azdata'; import { invalidProvider } from 'sql/base/common/errors'; -import { ILogService } from 'vs/platform/log/common/log'; +import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry'; export class ResourceProviderService implements IResourceProviderService { @@ -23,9 +21,8 @@ export class ResourceProviderService implements IResourceProviderService { private _firewallRuleDialogController: FirewallRuleDialogController; constructor( - @ITelemetryService private _telemetryService: ITelemetryService, - @IInstantiationService private _instantiationService: IInstantiationService, - @ILogService private readonly logService: ILogService + @IAdsTelemetryService private _telemetryService: IAdsTelemetryService, + @IInstantiationService private _instantiationService: IInstantiationService ) { } @@ -49,7 +46,10 @@ export class ResourceProviderService implements IResourceProviderService { return new Promise((resolve, reject) => { const provider = this._providers[resourceProviderId]; if (provider) { - TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.FirewallRuleRequested, { provider: resourceProviderId }); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.FirewallRuleRequested) + .withAdditionalProperties({ + provider: resourceProviderId + }).send(); provider.createFirewallRule(selectedAccount, firewallruleInfo).then(result => { resolve(result); }, error => {