Adding telemetry framework to migration extension (#15284)

* Adding telemetry to sql-migration

* Adding some telemetry helper functions

* removing unncessary telemetry

* removing unncessary imports

* Changing name of telemetry sender methods and removing unused functions.

* Removing extra whitespace

* Fixing a typo
This commit is contained in:
Aasim Khan
2021-04-29 14:00:44 -07:00
committed by GitHub
parent 8d482a06e8
commit e00d48c210
4 changed files with 138 additions and 0 deletions

View File

@@ -43,6 +43,23 @@ export function getSqlServerName(majorVersion: number): string | undefined {
}
}
export interface IPackageInfo {
name: string;
version: string;
aiKey: string;
}
export function getPackageInfo(packageJson: any): IPackageInfo | undefined {
if (packageJson) {
return {
name: packageJson.name,
version: packageJson.version,
aiKey: packageJson.aiKey
};
}
return undefined;
}
/**
* Generates a wordy time difference between start and end time.
* @returns stringified duration like '10.0 days', '12.0 hrs', '1.0 min'

View File

@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import AdsTelemetryReporter, { TelemetryEventMeasures, TelemetryEventProperties } from '@microsoft/ads-extension-telemetry';
import { getPackageInfo } from './api/utils';
const packageJson = require('../package.json');
let packageInfo = getPackageInfo(packageJson)!;
export const TelemetryReporter = new AdsTelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
export enum TelemetryViews {
SqlServerDashboard = 'SqlServerDashboard',
MigrationWizard = 'MigrationWizard',
CreateDataMigrationServiceDialog = 'CreateDataMigrationServiceDialog',
AssessmentsDialog = 'AssessmentsDialog',
MigrationCutoverDialog = 'MigrationCutoverDialog',
MigrationStatusDialog = 'MigrationStatusDialog',
AssessmentsPage = 'AssessmentsPage'
}
export function sendSqlMigrationActionEvent(telemetryView: string, telemetryAction: string, additionalProps: TelemetryEventProperties, additionalMeasurements: TelemetryEventMeasures): void {
TelemetryReporter.createActionEvent(telemetryView, telemetryAction)
.withAdditionalProperties(additionalProps)
.withAdditionalMeasurements(additionalMeasurements)
.send();
}