From 2ad7b6e9bb0f2b65b867782517c457698dbe0508 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Wed, 20 Mar 2024 09:16:50 -0700 Subject: [PATCH] Allow undefined for measurements (#203) --- dist/telemetryReporter.d.ts | 2 +- package-lock.json | 62 ++++++++++++++++---------------- package.json | 8 ++--- src/common/1dsClientFactory.ts | 2 +- test/baseTelemetrySender.test.ts | 14 ++++---- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/dist/telemetryReporter.d.ts b/dist/telemetryReporter.d.ts index 7b9165e..9c628d7 100644 --- a/dist/telemetryReporter.d.ts +++ b/dist/telemetryReporter.d.ts @@ -7,7 +7,7 @@ export interface TelemetryEventProperties { } export interface TelemetryEventMeasurements { - readonly [key: string]: number; + readonly [key: string]: number | undefined; } /** diff --git a/package-lock.json b/package-lock.json index dff1650..4bbd189 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "@vscode/extension-telemetry", - "version": "0.9.3", + "version": "0.9.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@vscode/extension-telemetry", - "version": "0.9.3", + "version": "0.9.4", "license": "MIT", "dependencies": { - "@microsoft/1ds-core-js": "^4.1.0", - "@microsoft/1ds-post-js": "^4.1.0", - "@microsoft/applicationinsights-web-basic": "^3.1.0" + "@microsoft/1ds-core-js": "^4.1.1", + "@microsoft/1ds-post-js": "^4.1.1", + "@microsoft/applicationinsights-web-basic": "^3.1.1" }, "devDependencies": { "@types/mocha": "^10.0.3", @@ -129,11 +129,11 @@ "dev": true }, "node_modules/@microsoft/1ds-core-js": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/1ds-core-js/-/1ds-core-js-4.1.0.tgz", - "integrity": "sha512-pZstuGzxrmyKaVoXrBvRjPYLE6/hR/wMN0qBJyAdq+APLLDO73QL2re3+8SM/J24e6ykieQ3mjUPgs8POjNZWA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/1ds-core-js/-/1ds-core-js-4.1.1.tgz", + "integrity": "sha512-xCIWuvyAmCCW7qZofnLKXjz6KInrtBfm21jjOXFTDq3UT9MrdWij1XwsWnK2Up3XOpDzJrNLkpn4A8H6Okls/g==", "dependencies": { - "@microsoft/applicationinsights-core-js": "3.1.0", + "@microsoft/applicationinsights-core-js": "3.1.1", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/ts-async": ">= 0.3.0 < 2.x", @@ -141,11 +141,11 @@ } }, "node_modules/@microsoft/1ds-post-js": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/1ds-post-js/-/1ds-post-js-4.1.0.tgz", - "integrity": "sha512-I82QeHMT8DamsgZ78RdNT0cSde8zGb+uwMTFzd9wE6M52q50oTF6sBRhoaVbsU+RvVxiS4vk9py3AWY/g8EDVA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/1ds-post-js/-/1ds-post-js-4.1.1.tgz", + "integrity": "sha512-yC7MOxJNibzMAyPr9TnBIS1+OLzqYj54Tr8p6Zje7tu9nb7cKh1a8KNyaIyxnuwPXKkWb+2YzTWLkC3clZCKiA==", "dependencies": { - "@microsoft/1ds-core-js": "4.1.0", + "@microsoft/1ds-core-js": "4.1.1", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/ts-async": ">= 0.3.0 < 2.x", @@ -153,12 +153,12 @@ } }, "node_modules/@microsoft/applicationinsights-channel-js": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-3.1.0.tgz", - "integrity": "sha512-VJUZT1FpQ5+XV3t4/AKprWiyH0gEEPDoJr6E8ZVopKoVVX/AjorkhPcZ4oDlpeEWpBeMxg+PeZOdTMKyY0atOw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-3.1.1.tgz", + "integrity": "sha512-HhEkcGAkXLoCCcNcpAomZiHYSjl6Y33l3oVqVRvwNj3E9T8e6zNFFtO3/iuqfuAOgDO3/adBFm5Tb5nIGPgu2g==", "dependencies": { - "@microsoft/applicationinsights-common": "3.1.0", - "@microsoft/applicationinsights-core-js": "3.1.0", + "@microsoft/applicationinsights-common": "3.1.1", + "@microsoft/applicationinsights-core-js": "3.1.1", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/ts-async": ">= 0.3.0 < 2.x", @@ -169,11 +169,11 @@ } }, "node_modules/@microsoft/applicationinsights-common": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-common/-/applicationinsights-common-3.1.0.tgz", - "integrity": "sha512-PpWdCbTPsH5MSDIkHKaIBpEJcsnPcnAjlTCk+ls0DOfIB/T6bTn3TuKsDfSu/sxdLhDQiJeUXu8G3qOQ3L0nBA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-common/-/applicationinsights-common-3.1.1.tgz", + "integrity": "sha512-rhLP+l+y1b7K3fjIf9wUHOPjouzMdyOpFdQHntDiHewU7YMUOEzco5c5UUAnTGixOUh9cE/Xnf7F3/PWTtGyuw==", "dependencies": { - "@microsoft/applicationinsights-core-js": "3.1.0", + "@microsoft/applicationinsights-core-js": "3.1.1", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/ts-utils": ">= 0.10.5 < 2.x" @@ -183,9 +183,9 @@ } }, "node_modules/@microsoft/applicationinsights-core-js": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-3.1.0.tgz", - "integrity": "sha512-pHaZ3CQx+KdfRV3yV/xuMEvIEJ1KxlK6klnFcuz4AMXOOPeuvWy1FsUIQ/sVA97TXEDl87LqV6QDnH99bLZpMg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-3.1.1.tgz", + "integrity": "sha512-vLuTrqUgXmmNBWqrLsbhp9rdc9WZrJ1jInswA0ozPomKt32WIPO1WJ8OrG3qY8FQ+rJDsrjTIy4naHP0qZpDEA==", "dependencies": { "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", @@ -205,13 +205,13 @@ } }, "node_modules/@microsoft/applicationinsights-web-basic": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-web-basic/-/applicationinsights-web-basic-3.1.0.tgz", - "integrity": "sha512-H2pDmc9YNTk+aoJ+1nkxSoYo/o2c/YLBO8+n3wdDAKuEpKio0HvMbsiKbGczGpLGixA/yYrd9b9vIikjSwGtUA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-web-basic/-/applicationinsights-web-basic-3.1.1.tgz", + "integrity": "sha512-/3D0ggfrFEMzI8dw+qEHlAhDH9vT5Mdv655ztNgvX3aSn/TsRpYJmN23zvP7azCioBfhD8T9zWcotkDN2lvtDQ==", "dependencies": { - "@microsoft/applicationinsights-channel-js": "3.1.0", - "@microsoft/applicationinsights-common": "3.1.0", - "@microsoft/applicationinsights-core-js": "3.1.0", + "@microsoft/applicationinsights-channel-js": "3.1.1", + "@microsoft/applicationinsights-common": "3.1.1", + "@microsoft/applicationinsights-core-js": "3.1.1", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/ts-async": ">= 0.3.0 < 2.x", diff --git a/package.json b/package.json index 57ea0c7..e0b42da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@vscode/extension-telemetry", "description": "A module for Visual Studio Code extensions to report consistent telemetry.", - "version": "0.9.3", + "version": "0.9.4", "author": { "name": "Microsoft Corporation" }, @@ -20,9 +20,9 @@ "compile": "tsc -p src/browser/tsconfig.json && tsc -p src/node/tsconfig.json" }, "dependencies": { - "@microsoft/1ds-core-js": "^4.1.0", - "@microsoft/1ds-post-js": "^4.1.0", - "@microsoft/applicationinsights-web-basic": "^3.1.0" + "@microsoft/1ds-core-js": "^4.1.1", + "@microsoft/1ds-post-js": "^4.1.1", + "@microsoft/applicationinsights-web-basic": "^3.1.1" }, "devDependencies": { "@types/mocha": "^10.0.3", diff --git a/src/common/1dsClientFactory.ts b/src/common/1dsClientFactory.ts index fad56ce..3b5df6c 100644 --- a/src/common/1dsClientFactory.ts +++ b/src/common/1dsClientFactory.ts @@ -52,7 +52,7 @@ const getAICore = async (key: string, vscodeAPI: typeof vscode, xhrOverride?: IX appInsightsCore.addTelemetryInitializer((envelope: any) => { envelope["ext"] = envelope["ext"] ?? {}; envelope["ext"]["web"] = envelope["ext"]["web"] ?? {}; - envelope["ext"]["web"]["consentDetails"] = '{"GPC_DataSharingOptIn":false}'; + envelope["ext"]["web"]["consentDetails"] = "{\"GPC_DataSharingOptIn\":false}"; // Only add the remaining flags when `telemetry.internalTesting` is enabled if (!internalTesting) { diff --git a/test/baseTelemetrySender.test.ts b/test/baseTelemetrySender.test.ts index 33b83d6..535cfa9 100644 --- a/test/baseTelemetrySender.test.ts +++ b/test/baseTelemetrySender.test.ts @@ -75,28 +75,28 @@ describe("Base telemetry sender test suite", () => { assert.strictEqual((telemetryClient.logEvent as sinon.SinonSpy).callCount, 1); sinon.assert.calledWithMatch( telemetryClient.logEvent as sinon.SinonSpy, "unhandlederror", - {properties: {name: error.name, message: error.message, stack: error.stack}} + { properties: { name: error.name, message: error.message, stack: error.stack } } ); - }) + }); it("Error properties are correctly created for a data without properties field", () => { const error = new Error("test"); - sender.sendErrorData(error, {prop1: 1, prop2: "two"}); + sender.sendErrorData(error, { prop1: 1, prop2: "two" }); assert.strictEqual((telemetryClient.logEvent as sinon.SinonSpy).callCount, 1); sinon.assert.calledWithMatch( telemetryClient.logEvent as sinon.SinonSpy, "unhandlederror", - {properties: {prop1: 1, prop2: "two", name: error.name, message: error.message, stack: error.stack}} + { properties: { prop1: 1, prop2: "two", name: error.name, message: error.message, stack: error.stack } } ); }); it("Error properties are correctly created for a data with properties field", () => { const error = new Error("uh oh"); - sender.sendErrorData(error, {properties: {prop1: 1, prop2: "two"}}); + sender.sendErrorData(error, { properties: { prop1: 1, prop2: "two" } }); assert.strictEqual((telemetryClient.logEvent as sinon.SinonSpy).callCount, 1); sinon.assert.calledWithMatch( telemetryClient.logEvent as sinon.SinonSpy, "unhandlederror", - {properties: {prop1: 1, prop2: "two", name: error.name, message: error.message, stack: error.stack}} + { properties: { prop1: 1, prop2: "two", name: error.name, message: error.message, stack: error.stack } } ); }); - }) + }); });