Skip to content

Commit

Permalink
Allow undefined for measurements (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 authored Mar 20, 2024
1 parent de8e93a commit 2ad7b6e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion dist/telemetryReporter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface TelemetryEventProperties {
}

export interface TelemetryEventMeasurements {
readonly [key: string]: number;
readonly [key: string]: number | undefined;
}

/**
Expand Down
62 changes: 31 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/common/1dsClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions test/baseTelemetrySender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
);
});
})
});
});

0 comments on commit 2ad7b6e

Please sign in to comment.