mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Update ads-extension-telemetry to 1.3.1 (#20724)
* Update ads-extension-telemetry to 1.3.0 * fix
This commit is contained in:
@@ -209,7 +209,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/ads-extension-telemetry": "1.2.0",
|
||||
"@microsoft/ads-extension-telemetry": "^1.3.1",
|
||||
"vscode-nls": "^4.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -12,7 +12,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as crypto from 'crypto';
|
||||
import * as loc from './localizedConstants';
|
||||
import { sendSettingChangedEvent, TelemetryActions, TelemetryReporter, TelemetryViews, TimedAction } from './telemetry';
|
||||
import { sendSettingChangedEvent, TelemetryActions, TelemetryReporter, TelemetryViews } from './telemetry';
|
||||
|
||||
const STORAGE_IV_KEY = 'queryHistory.storage-iv';
|
||||
const STORAGE_KEY_KEY = 'queryHistory.storage-key';
|
||||
@@ -51,7 +51,7 @@ export class QueryHistoryProvider implements vscode.TreeDataProvider<QueryHistor
|
||||
constructor(private _context: vscode.ExtensionContext, storageUri: vscode.Uri) {
|
||||
this._historyStorageFile = path.join(storageUri.fsPath, HISTORY_STORAGE_FILE_NAME);
|
||||
// Kick off initialization but then continue on since that may take a while and we don't want to block extension activation
|
||||
const initializeAction = new TimedAction(TelemetryViews.QueryHistoryProvider, TelemetryActions.Initialize);
|
||||
const initializeAction = TelemetryReporter.createTimedAction(TelemetryViews.QueryHistoryProvider, TelemetryActions.Initialize);
|
||||
this._initPromise = this.initialize().then(() => initializeAction.send());
|
||||
this._disposables.push(vscode.workspace.onDidChangeConfiguration(async e => {
|
||||
if (e.affectsConfiguration(QUERY_HISTORY_CONFIG_SECTION) || e.affectsConfiguration(MAX_ENTRIES_CONFIG_SECTION)) {
|
||||
@@ -147,12 +147,10 @@ export class QueryHistoryProvider implements vscode.TreeDataProvider<QueryHistor
|
||||
const cipher = crypto.createCipheriv(STORAGE_ENCRYPTION_ALGORITHM, key!, iv!);
|
||||
const stringifiedItems = JSON.stringify(this._queryHistoryItems);
|
||||
const encryptedText = Buffer.concat([cipher.update(Buffer.from(stringifiedItems)), cipher.final()]);
|
||||
const writeStorageFileAction = new TimedAction(TelemetryViews.QueryHistoryProvider, TelemetryActions.WriteStorageFile,
|
||||
{},
|
||||
{
|
||||
ItemCount: this._queryHistoryItems.length,
|
||||
ItemLengthChars: stringifiedItems.length
|
||||
});
|
||||
const writeStorageFileAction = TelemetryReporter.createTimedAction(TelemetryViews.QueryHistoryProvider, TelemetryActions.WriteStorageFile).withAdditionalMeasures({
|
||||
ItemCount: this._queryHistoryItems.length,
|
||||
ItemLengthChars: stringifiedItems.length
|
||||
});
|
||||
// Use sync here so that we can write this out when the object is disposed
|
||||
fs.writeFileSync(this._historyStorageFile, encryptedText);
|
||||
writeStorageFileAction.send();
|
||||
@@ -171,7 +169,7 @@ export class QueryHistoryProvider implements vscode.TreeDataProvider<QueryHistor
|
||||
|
||||
|
||||
try {
|
||||
const readStorageFileAction = new TimedAction(TelemetryViews.QueryHistoryProvider, TelemetryActions.ReadStorageFile);
|
||||
const readStorageFileAction = TelemetryReporter.createTimedAction(TelemetryViews.QueryHistoryProvider, TelemetryActions.ReadStorageFile);
|
||||
// Read and decrypt any previous history items
|
||||
const encryptedItems = await fs.promises.readFile(this._historyStorageFile);
|
||||
readStorageFileAction.send();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 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 AdsTelemetryReporter from '@microsoft/ads-extension-telemetry';
|
||||
|
||||
export interface PackageInfo {
|
||||
name: string;
|
||||
@@ -13,49 +13,7 @@ export interface PackageInfo {
|
||||
|
||||
const packageInfo = require('../package.json') as PackageInfo;
|
||||
|
||||
export const TelemetryReporter = new AdsTelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
||||
|
||||
/**
|
||||
* A helper class to send an Action event with a duration, timer starts on construction and ends when send() is called.
|
||||
*/
|
||||
export class TimedAction {
|
||||
/**
|
||||
* Additional properties to send along with the final message once send is called.
|
||||
*/
|
||||
public readonly additionalProperties: TelemetryEventProperties = {};
|
||||
/**
|
||||
* Additional measures to send along with the final message once send is called.
|
||||
*/
|
||||
public readonly additionalMeasures: TelemetryEventMeasures = {};
|
||||
|
||||
private _start: number = Date.now();
|
||||
|
||||
/**
|
||||
* Creates a new TimedAction and sets the start time to Date.now().
|
||||
* @param _view The view this action originates from
|
||||
* @param _action The name of the action
|
||||
* @param properties Additional properties to send along with the final message once send is called
|
||||
* @param measures Additional measures to send along with the final message once send is called
|
||||
*/
|
||||
constructor(private _view: TelemetryViews, private _action: TelemetryActions, properties: TelemetryEventProperties = {}, measures: TelemetryEventMeasures = {}) {
|
||||
Object.assign(this.additionalProperties, properties);
|
||||
Object.assign(this.additionalMeasures, measures);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the event with the duration being the difference between when this TimedAction was created and now.
|
||||
* @param properties Additional properties to send along with the event
|
||||
* @param measures Additional measures to send along with the event
|
||||
*/
|
||||
public send(properties: TelemetryEventProperties = {}, measures: TelemetryEventMeasures = {}): void {
|
||||
Object.assign(this.additionalProperties, properties);
|
||||
Object.assign(this.additionalMeasures, measures);
|
||||
TelemetryReporter.createActionEvent(this._view, this._action, undefined, undefined, Date.now() - this._start)
|
||||
.withAdditionalProperties(this.additionalProperties)
|
||||
.withAdditionalMeasurements(this.additionalMeasures)
|
||||
.send();
|
||||
}
|
||||
}
|
||||
export const TelemetryReporter = new AdsTelemetryReporter<TelemetryViews, TelemetryActions>(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
||||
|
||||
/**
|
||||
* Send an event indicating that a setting changed along with the new and old values. Core has a setting changed
|
||||
|
||||
@@ -246,10 +246,10 @@
|
||||
"@microsoft/applicationinsights-shims" "^2.0.1"
|
||||
"@microsoft/dynamicproto-js" "^1.1.6"
|
||||
|
||||
"@microsoft/ads-extension-telemetry@1.2.0":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@microsoft/ads-extension-telemetry/-/ads-extension-telemetry-1.2.0.tgz#f54e464ac887440727fe9862f8ff32be17aeab3a"
|
||||
integrity sha512-dEp+RVJYo4uebMLvBJqJF8IABufJRp+PWHZx+3xe6SgAC37oYhcwR/glExhp3Nj3A2v3vjso6YQ/Wd5TG27FPQ==
|
||||
"@microsoft/ads-extension-telemetry@^1.3.1":
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@microsoft/ads-extension-telemetry/-/ads-extension-telemetry-1.3.1.tgz#fa757ee88eac91b21c3a68562da6441c2ad15c39"
|
||||
integrity sha512-8Zd7RwwN7ZufMoWFmc1bwzmQc1RV7/jf/Ua33YL1+P0ZwHoWFOhf/b0lwvAVzi9TB/7oD5zA5yv7A/i2sSTn6Q==
|
||||
dependencies:
|
||||
"@vscode/extension-telemetry" "^0.6.2"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user