Skip to content

Commit

Permalink
Merge pull request #110 from microsoft/lramos15/reluctant-shark
Browse files Browse the repository at this point in the history
Remove error props
  • Loading branch information
lramos15 authored Jun 15, 2022
2 parents c095592 + 842ffc7 commit c77fda6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
9 changes: 4 additions & 5 deletions lib/telemetryReporter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,23 @@ export default class TelemetryReporter {
sendDangerousTelemetryEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, sanitize?: boolean): void;

/**
* Sends a telemetry error event with the given properties, measurements, and errorProps
* Sends a telemetry error event with the given properties, measurements.
* **Note**: The errorProps parameter has been removed since v0.6, if you would like to remove a property please use the replacementOptions parameter in the constructor.
* @param eventName The name of the event
* @param properties The set of properties to add to the event in the form of a string key value pair
* @param measurements The set of measurements to add to the event in the form of a string key number value pair
* @param errorProps A list of case sensitive properties to drop, if excluded we drop all properties but still send the event
*/
sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, errorProps?: string[]): void;
sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void;

/**
* **DANGEROUS** Given an event name, some properties, and measurements sends a telemetry error event without checking telemetry setting
* Do not use unless in a controlled environment i.e. sending telmetry from a CI pipeline or testing during development
* @param eventName The name of the event
* @param properties The properties to send with the event
* @param measurements The measurements (numeric values) to send with the event
* @param errorProps If not present then we assume all properties belong to the error prop and will be anonymized
* @param sanitize Whether or not to run the properties and measures through sanitiziation, defaults to true
*/
sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, errorProps?: string[], sanitize?: boolean): void;
sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, sanitize?: boolean): void;

/**
* Sends an exception which includes the error stack, properties, and measurements
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vscode/extension-telemetry",
"description": "A module for first party microsoft extensions to report consistent telemetry.",
"version": "0.5.2",
"version": "0.6.0",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
23 changes: 6 additions & 17 deletions src/common/baseTelemetryReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,31 +349,22 @@ export class BaseTelemetryReporter {
* @param eventName The name of the event
* @param properties The properties of the event
* @param measurements The measurements (numeric values) to send with the event
* @param errorProps Properties to readct. If undefined then we assume all properties belong to the error prop and will be anonymized
* @param sanitize Whether or not to sanitize to the properties and measures
* @param dangerous Whether or not to ignore telemetry level
*/
private internalSendTelemetryErrorEvent(
eventName: string,
properties: TelemetryEventProperties | undefined,
measurements: TelemetryEventMeasurements | undefined,
errorProps: string[] | undefined,
sanitize: boolean,
dangerous: boolean
): void {
if ((this.shouldSendErrorTelemetry() || dangerous) && eventName !== "") {

properties = { ...properties, ...this.getCommonProperties() };
if (sanitize) {
// always clean the properties if first party
// do not send any error properties if we shouldn't send error telemetry
// if we have no errorProps, assume all are error props
const cleanProperties = this.cloneAndChange(properties, (key: string, prop: string) => {

if (errorProps === undefined || errorProps.indexOf(key) !== -1) {
return "REDACTED";
}

// Anonymize the file paths
const cleanProperties = this.cloneAndChange(properties, (_: string, prop: string) => {
return this.anonymizeFilePaths(prop, this.firstParty);
});
properties = this.removePropertiesWithPossibleUserInfo(cleanProperties);
Expand All @@ -388,10 +379,9 @@ export class BaseTelemetryReporter {
* @param eventName The name of the event
* @param properties The properties to send with the event
* @param measurements The measurements (numeric values) to send with the event
* @param errorProps If not present then we assume all properties belong to the error prop and will be anonymized
*/
public sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, errorProps?: string[]): void {
this.internalSendTelemetryErrorEvent(eventName, properties, measurements, errorProps, true, false);
public sendTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements): void {
this.internalSendTelemetryErrorEvent(eventName, properties, measurements, true, false);
}

/**
Expand All @@ -400,13 +390,12 @@ export class BaseTelemetryReporter {
* @param eventName The name of the event
* @param properties The properties to send with the event
* @param measurements The measurements (numeric values) to send with the event
* @param errorProps If not present then we assume all properties belong to the error prop and will be anonymized
* @param sanitize Whether or not to run the properties and measures through sanitiziation, defaults to true
*/
public sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, errorProps?: string[], sanitize = true): void {
public sendDangerousTelemetryErrorEvent(eventName: string, properties?: TelemetryEventProperties, measurements?: TelemetryEventMeasurements, sanitize = true): void {
// Since telemetry is probably off when sending dangerously, we must start the appender
this.telemetryAppender.instantiateAppender();
this.internalSendTelemetryErrorEvent(eventName, properties, measurements, errorProps, sanitize, true);
this.internalSendTelemetryErrorEvent(eventName, properties, measurements, sanitize, true);
}

/**
Expand Down

0 comments on commit c77fda6

Please sign in to comment.