From bfe78eba9aeda9c68a83b57e75a8b560f9e7cd06 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 8 Feb 2024 11:42:03 +0000 Subject: [PATCH 1/3] Use string index notation instead of as any --- extensions/ql-vscode/src/common/vscode/telemetry.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/common/vscode/telemetry.ts b/extensions/ql-vscode/src/common/vscode/telemetry.ts index ebad18a885f..3ab30059bc6 100644 --- a/extensions/ql-vscode/src/common/vscode/telemetry.ts +++ b/extensions/ql-vscode/src/common/vscode/telemetry.ts @@ -128,7 +128,8 @@ export class ExtensionTelemetryListener ); this.push(this.reporter); - const client = (this.reporter as any).appInsightsClient as TelemetryClient; + // The appInsightsClient field is private but we want to access it anyway + const client = this.reporter["appInsightsClient"] as TelemetryClient; if (client) { // add a telemetry processor to delete unwanted properties client.addTelemetryProcessor((envelope: any) => { From 939616372c881704d5768a9570aa189eb08a0312 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 8 Feb 2024 11:42:28 +0000 Subject: [PATCH 2/3] Use correct type for envelope argument --- extensions/ql-vscode/src/common/vscode/telemetry.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/ql-vscode/src/common/vscode/telemetry.ts b/extensions/ql-vscode/src/common/vscode/telemetry.ts index 3ab30059bc6..5c7d8dfb433 100644 --- a/extensions/ql-vscode/src/common/vscode/telemetry.ts +++ b/extensions/ql-vscode/src/common/vscode/telemetry.ts @@ -20,6 +20,7 @@ import { showBinaryChoiceWithUrlDialog } from "./dialog"; import type { RedactableError } from "../errors"; import type { SemVer } from "semver"; import type { AppTelemetry } from "../telemetry"; +import { EnvelopeTelemetry } from "applicationinsights/out/Declarations/Contracts"; // Key is injected at build time through the APP_INSIGHTS_KEY environment variable. const key = "REPLACE-APP-INSIGHTS-KEY"; @@ -132,9 +133,9 @@ export class ExtensionTelemetryListener const client = this.reporter["appInsightsClient"] as TelemetryClient; if (client) { // add a telemetry processor to delete unwanted properties - client.addTelemetryProcessor((envelope: any) => { + client.addTelemetryProcessor((envelope: EnvelopeTelemetry) => { tagsToRemove.forEach((tag) => delete envelope.tags[tag]); - const baseDataProperties = (envelope.data as any)?.baseData?.properties; + const baseDataProperties = envelope.data.baseData?.properties; if (baseDataProperties) { baseDataPropertiesToRemove.forEach( (prop) => delete baseDataProperties[prop], From 0f6afac222b71902b0ee333cd6958853fe1dcdad Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 12 Feb 2024 17:16:34 +0000 Subject: [PATCH 3/3] Use type import --- extensions/ql-vscode/src/common/vscode/telemetry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/common/vscode/telemetry.ts b/extensions/ql-vscode/src/common/vscode/telemetry.ts index 5c7d8dfb433..567ea2b8cce 100644 --- a/extensions/ql-vscode/src/common/vscode/telemetry.ts +++ b/extensions/ql-vscode/src/common/vscode/telemetry.ts @@ -20,7 +20,7 @@ import { showBinaryChoiceWithUrlDialog } from "./dialog"; import type { RedactableError } from "../errors"; import type { SemVer } from "semver"; import type { AppTelemetry } from "../telemetry"; -import { EnvelopeTelemetry } from "applicationinsights/out/Declarations/Contracts"; +import type { EnvelopeTelemetry } from "applicationinsights/out/Declarations/Contracts"; // Key is injected at build time through the APP_INSIGHTS_KEY environment variable. const key = "REPLACE-APP-INSIGHTS-KEY";