Merge pull request #3346 from github/robertbrignull/telemetry-unknown

Avoid use of any in TelemetryListener
This commit is contained in:
Robert
2024-02-13 09:37:34 +00:00
committed by GitHub

View File

@@ -20,6 +20,7 @@ import { showBinaryChoiceWithUrlDialog } from "./dialog";
import type { RedactableError } from "../errors";
import type { SemVer } from "semver";
import type { AppTelemetry } from "../telemetry";
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";
@@ -128,12 +129,13 @@ 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) => {
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],