Skip to content

Commit 4ed6a7b

Browse files
Merge pull request #3346 from github/robertbrignull/telemetry-unknown
Avoid use of any in TelemetryListener
2 parents 3f02ff4 + 0f6afac commit 4ed6a7b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

extensions/ql-vscode/src/common/vscode/telemetry.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { showBinaryChoiceWithUrlDialog } from "./dialog";
2020
import type { RedactableError } from "../errors";
2121
import type { SemVer } from "semver";
2222
import type { AppTelemetry } from "../telemetry";
23+
import type { EnvelopeTelemetry } from "applicationinsights/out/Declarations/Contracts";
2324

2425
// Key is injected at build time through the APP_INSIGHTS_KEY environment variable.
2526
const key = "REPLACE-APP-INSIGHTS-KEY";
@@ -128,12 +129,13 @@ export class ExtensionTelemetryListener
128129
);
129130
this.push(this.reporter);
130131

131-
const client = (this.reporter as any).appInsightsClient as TelemetryClient;
132+
// The appInsightsClient field is private but we want to access it anyway
133+
const client = this.reporter["appInsightsClient"] as TelemetryClient;
132134
if (client) {
133135
// add a telemetry processor to delete unwanted properties
134-
client.addTelemetryProcessor((envelope: any) => {
136+
client.addTelemetryProcessor((envelope: EnvelopeTelemetry) => {
135137
tagsToRemove.forEach((tag) => delete envelope.tags[tag]);
136-
const baseDataProperties = (envelope.data as any)?.baseData?.properties;
138+
const baseDataProperties = envelope.data.baseData?.properties;
137139
if (baseDataProperties) {
138140
baseDataPropertiesToRemove.forEach(
139141
(prop) => delete baseDataProperties[prop],

0 commit comments

Comments
 (0)