Allow undefined for measurements (#203)

This commit is contained in:
Logan Ramos 2024-03-20 09:16:50 -07:00 коммит произвёл GitHub
Родитель de8e93a869
Коммит 2ad7b6e9bb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 44 добавлений и 44 удалений

2
dist/telemetryReporter.d.ts поставляемый
Просмотреть файл

@ -7,7 +7,7 @@ export interface TelemetryEventProperties {
}
export interface TelemetryEventMeasurements {
readonly [key: string]: number;
readonly [key: string]: number | undefined;
}
/**

62
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",

Просмотреть файл

@ -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",

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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 } }
);
});
})
});
});