mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -05:00
Remove sql/common (#4990)
* remove sql/common/ * formatting * fix cyclic dependency
This commit is contained in:
62
src/sql/platform/telemetry/telemetryKeys.ts
Normal file
62
src/sql/platform/telemetry/telemetryKeys.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Telemetry Event Names
|
||||
|
||||
export const DatabaseConnected = 'DatabaseConnected';
|
||||
export const DatabaseDisconnected = 'DatabaseDisconnected';
|
||||
export const DeleteConnection = 'DeleteConnection';
|
||||
export const AddServerGroup = 'AddServerGroup';
|
||||
export const MoveServerGroup = 'MoveServerGroup';
|
||||
export const MoveServerConnection = 'MoveServerConnection';
|
||||
export const DeleteServerGroup = 'DeleteServerGroup';
|
||||
export const ModalDialogClosed = 'ModalDialogClosed';
|
||||
export const ModalDialogOpened = 'ModalDialogOpened';
|
||||
export const BackupCreated = 'BackupCreated';
|
||||
export const RestoreRequested = 'RestoreRequested';
|
||||
export const ChartCreated = 'ChartCreated';
|
||||
export const ObjectExplorerExpand = 'ObjectExplorerExpand';
|
||||
export const RunQuery = 'RunQuery';
|
||||
export const RunQueryStatement = 'RunQueryStatement';
|
||||
export const CancelQuery = 'CancelQuery';
|
||||
export const NewQuery = 'NewQuery';
|
||||
export const FirewallRuleRequested = 'FirewallRuleCreated';
|
||||
export const DashboardNavigated = 'DashboardNavigated';
|
||||
|
||||
// Telemetry Properties
|
||||
|
||||
// Modal Dialogs:
|
||||
export const ErrorMessage = 'ErrorMessage';
|
||||
export const WebView = 'WebView';
|
||||
export const ConnectionAdvancedProperties = 'ConnectionAdvancedProperties';
|
||||
export const Connection = 'Connection';
|
||||
export const Backup = 'Backup';
|
||||
export const Restore = 'Restore';
|
||||
export const Insights = 'Insights';
|
||||
export const Profiler = 'Profiler';
|
||||
export const ServerGroups = 'ServerGroups';
|
||||
export const Accounts = 'Accounts';
|
||||
export const FireWallRule = 'FirewallRule';
|
||||
export const AutoOAuth = 'AutoOAuth';
|
||||
export const AddNewDashboardTab = 'AddNewDashboardTab';
|
||||
export const ProfilerFilter = 'ProfilerFilter';
|
||||
|
||||
// SQL Agent Events:
|
||||
|
||||
// Views
|
||||
export const JobsView = 'JobsViewOpened';
|
||||
export const JobHistoryView = 'JobHistoryViewOpened';
|
||||
export const JobStepsView = 'JobStepsViewOpened';
|
||||
|
||||
// Actions
|
||||
export const RunAgentJob = 'RunAgentJob';
|
||||
export const StopAgentJob = 'StopAgentJob';
|
||||
export const DeleteAgentJob = 'DeleteAgentJob';
|
||||
export const DeleteAgentJobStep = 'DeleteAgentJobStep';
|
||||
export const DeleteAgentAlert = 'DeleteAgentAlert';
|
||||
export const DeleteAgentOperator = 'DeleteAgentOperator';
|
||||
export const DeleteAgentProxy = 'DeleteAgentProxy';
|
||||
|
||||
|
||||
57
src/sql/platform/telemetry/telemetryUtilities.ts
Normal file
57
src/sql/platform/telemetry/telemetryUtilities.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { ITelemetryService, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { warn } from 'sql/base/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,
|
||||
telemetryEventName: string,
|
||||
data?: IConnectionTelemetryData,
|
||||
connection?: IConnectionProfile): Promise<void> {
|
||||
return new Promise<void>(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 => {
|
||||
warn(`Failed to add telemetry. error: ${telemetryServiceError}`);
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
} catch (error) {
|
||||
warn(`Failed to add telemetry. error: ${error}`);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user