Skip to content

Commit 0c4e706

Browse files
authored
Fix send raw telemetry (#172)
1 parent 725f2ed commit 0c4e706

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

dist/telemetryReporter.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*--------------------------------------------------------*/
44

55
export interface TelemetryEventProperties {
6-
readonly [key: string]: string | undefined;
6+
readonly [key: string]: string | import("vscode").TelemetryTrustedValue<string> | undefined;
77
}
88

99
export interface TelemetryEventMeasurements {

src/common/baseTelemetryReporter.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,16 @@ export class BaseTelemetryReporter {
114114
* @param measurements The set of measurements to add to the event in the form of a string key number value pair
115115
*/
116116
public sendRawTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void {
117-
// Check level then send off dangerously which skips the API as the API sanitizes everything.
118-
if (this.telemetryLevel === "all") {
119-
this.internalSendTelemetryEvent(eventName, properties, measurements, true);
117+
const modifiedProperties = { ...properties };
118+
for (const property of Object.keys(modifiedProperties ?? {})) {
119+
if (typeof property === "string") {
120+
// Trusted values are not sanitized, which is what we want for raw telemetry
121+
modifiedProperties[property] = new this.vscodeAPI.TelemetryTrustedValue<string>(property);
122+
}
120123
}
124+
125+
this.sendTelemetryEvent(eventName, modifiedProperties, measurements);
126+
121127
}
122128

123129
/**

0 commit comments

Comments
 (0)