public static sendTelemetryEventForException()

in src/telemetry.ts [102:122]


	public static sendTelemetryEventForException(
		err: any, methodName: string, extensionConfigName: string): void {
		try {
			let stackArray: string[];
			let firstLine: string = '';
			if (err !== undefined && err.stack !== undefined) {
				stackArray = err.stack.split('\n');
				if (stackArray !== undefined && stackArray.length >= 2) {
					firstLine = stackArray[1]; // The fist line is the error message and we don't want to send that telemetry event
					firstLine = FilterErrorPath(firstLine);
				}
			}

			// Only adding the method name and the fist line of the stack trace. We don't add the error message because it might have PII
			this.sendTelemetryEvent('Exception', { methodName: methodName, errorLine: firstLine });
			// Utils.logDebug('Unhandled Exception occurred. error: ' + err + ' method: ' + methodName, extensionConfigName);
		} catch (telemetryErr) {
			// If sending telemetry event fails ignore it so it won't break the extension
			// Utils.logDebug('Failed to send telemetry event. error: ' + telemetryErr, extensionConfigName);
		}
	}