microsoft / vscode-extension-telemetry

Node module to help VS Code extensions send telemetry using application insights
https://www.npmjs.com/package/@vscode/extension-telemetry
Other
125 stars 46 forks source link

Add support `TelemetryTrustedValue` instead `sendRawTelemetryEvent` method #170

Closed oliversen closed 1 year ago

oliversen commented 1 year ago

To send raw (unsanitized) data there is a special value wrapper TelemetryTrustedValue. Its use would be more correct instead of the sendRawTelemetryEvent method, which will only work if telemetryLevel === "all", and data mixing will not occur with it (vscode will not add parameters such as OS, Platform Version, Extension Version, VS Code Version etc. to the telemetry data).

Usage TelemetryTrustedValue:

import { TelemetryTrustedValue } from "vscode";

const data = {"foo": "bar"};
const trustedData = new TelemetryTrustedValue(data);
telemetryReporter.sendTelemetryEvent("someEvent", {data: trustedData)};
oliversen commented 1 year ago

@microsoft-github-policy-service agree

lramos15 commented 1 year ago

TelemetryTrustedValue would be a better use case for the sendRawTelemetryEvent method, I can't believe I forgot about that :). I think what we should do instead is inside that method automatically map all the values into trusted ones and then send it off to the API, that way the consumer doesn't need to think about it but can still benefit from the common properties and output channel logging.

lramos15 commented 1 year ago

This has been fixed and imlemented