private removePropertiesWithPossibleUserInfo()

in src/common/baseTelemetryReporter.ts [236:267]


	private removePropertiesWithPossibleUserInfo(properties: TelemetryEventProperties | undefined): TelemetryEventProperties | undefined {
		if (typeof properties !== "object") {
			return;
		}
		const cleanedObject = Object.create(null);
		// Loop through key and values of the properties object
		for (const key of Object.keys(properties)) {
			const value = properties[key];
			// If for some reason it is undefined we skip it (this shouldn't be possible);
			if (!value) {
				continue;
			}

			// Regex which matches @*.site
			const emailRegex = /@[a-zA-Z0-9-.]+/;
			const secretRegex = /(key|token|sig|signature|password|passwd|pwd|android:value)[^a-zA-Z0-9]/;
			// last +? is lazy as a microoptimization since we don't care about the full value
			const tokenRegex = /xox[pbaors]-[a-zA-Z0-9]+-[a-zA-Z0-9-]+?/;

			// Check for common user data in the telemetry events
			if (secretRegex.test(value.toLowerCase())) {
				cleanedObject[key] = "<REDACTED: secret>";
			} else if (emailRegex.test(value)) {
				cleanedObject[key] = "<REDACTED: email>";
			} else if (tokenRegex.test(value)) {
				cleanedObject[key] = "<REDACTED: token>";
			} else {
				cleanedObject[key] = value;
			}
		}
		return cleanedObject;
	}