diff --git a/package-lock.json b/package-lock.json
index c6a86fdb..59c2a9cf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15,8 +15,8 @@
"@microsoft/generator-powerpages": "1.21.19",
"@types/jwt-decode": "2.2.0",
"@types/node-fetch": "^2.6.2",
- "@types/xmldom": "^0.1.34",
"@vscode/extension-telemetry": "^0.6.2",
+ "@xmldom/xmldom": "^0.8.10",
"cockatiel": "^3.1.1",
"command-exists": "^1.2.9",
"find-process": "^1.4.7",
@@ -36,7 +36,6 @@
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"worker-loader": "^3.0.8",
- "xmldom": "^0.6.0",
"yaml": "^2.2.2"
},
"devDependencies": {
@@ -3442,11 +3441,6 @@
"integrity": "sha512-56/MAlX5WMsPVbOg7tAxnYvNYMMWr/QJiIp6BxVSW3JJXUVzzOn64qW8TzQyMSqSUFM2+PVI4aUHcHOzIz/1tg==",
"dev": true
},
- "node_modules/@types/xmldom": {
- "version": "0.1.34",
- "resolved": "https://registry.npmjs.org/@types/xmldom/-/xmldom-0.1.34.tgz",
- "integrity": "sha512-7eZFfxI9XHYjJJuugddV6N5YNeXgQE1lArWOcd1eCOKWb/FGs5SIjacSYuEJuwhsGS3gy4RuZ5EUIcqYscuPDA=="
- },
"node_modules/@types/yauzl": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz",
@@ -4211,6 +4205,14 @@
}
}
},
+ "node_modules/@xmldom/xmldom": {
+ "version": "0.8.10",
+ "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.10.tgz",
+ "integrity": "sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==",
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
"node_modules/@xtuc/ieee754": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz",
@@ -8836,9 +8838,9 @@
}
},
"node_modules/follow-redirects": {
- "version": "1.15.4",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
- "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
+ "version": "1.15.6",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
@@ -21421,14 +21423,6 @@
"node": ">=4.0"
}
},
- "node_modules/xmldom": {
- "version": "0.6.0",
- "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.6.0.tgz",
- "integrity": "sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg==",
- "engines": {
- "node": ">=10.0.0"
- }
- },
"node_modules/xmlhttprequest-ssl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz",
diff --git a/package.json b/package.json
index aa9cd1da..1ddf0c51 100644
--- a/package.json
+++ b/package.json
@@ -1091,8 +1091,8 @@
"@microsoft/generator-powerpages": "1.21.19",
"@types/jwt-decode": "2.2.0",
"@types/node-fetch": "^2.6.2",
- "@types/xmldom": "^0.1.34",
"@vscode/extension-telemetry": "^0.6.2",
+ "@xmldom/xmldom": "^0.8.10",
"cockatiel": "^3.1.1",
"command-exists": "^1.2.9",
"find-process": "^1.4.7",
@@ -1112,7 +1112,6 @@
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"worker-loader": "^3.0.8",
- "xmldom": "^0.6.0",
"yaml": "^2.2.2"
},
"__metadata": {
diff --git a/src/common/OneDSLoggerTelemetry/oneDSLogger.ts b/src/common/OneDSLoggerTelemetry/oneDSLogger.ts
index 242bb241..c603840b 100644
--- a/src/common/OneDSLoggerTelemetry/oneDSLogger.ts
+++ b/src/common/OneDSLoggerTelemetry/oneDSLogger.ts
@@ -11,9 +11,9 @@ import { ITelemetryLogger } from "./ITelemetryLogger";
import { IContextInfo, IUserInfo } from "./IEventTypes";
import { EventType, Severity } from "./telemetryConstants";
import * as vscode from "vscode";
-import {getExtensionType, getExtensionVersion} from "../../common/Utils";
+import { getExtensionType, getExtensionVersion } from "../../common/Utils";
import { EXTENSION_ID } from "../../client/constants";
-import {OneDSCollectorEventName} from "./EventContants";
+import { OneDSCollectorEventName } from "./EventContants";
import { telemetryEventNames } from "../../web/client/telemetry/constants";
import { region } from "../telemetry-generated/buildRegionConfiguration";
import { telemetryEventNames as desktopExtTelemetryEventNames } from "../../client/telemetry/TelemetryEventNames";
@@ -24,14 +24,14 @@ interface IInstrumentationSettings {
instrumentationKey: string;
}
-export class OneDSLogger implements ITelemetryLogger{
+export class OneDSLogger implements ITelemetryLogger {
- private readonly appInsightsCore :AppInsightsCore;
- private readonly postChannel: PostChannel;
+ private readonly appInsightsCore: AppInsightsCore;
+ private readonly postChannel: PostChannel;
- private static userInfo: IUserInfo = {oid: "", tid: "", puid: ""};
- private static contextInfo: IContextInfo ;
- private static userRegion : string = "";
+ private static userInfo: IUserInfo = { oid: "", tid: "", puid: "" };
+ private static contextInfo: IContextInfo;
+ private static userRegion: string = "";
private readonly regexPatternsToRedact = [
/key["\\ ']*[:=]+["\\ ']*([a-zA-Z0-9]*)/igm,
@@ -83,44 +83,44 @@ export class OneDSLogger implements ITelemetryLogger{
},
};
- public constructor(geo?:string ) {
+ public constructor(geo?: string) {
this.appInsightsCore = new AppInsightsCore();
this.postChannel = new PostChannel();
const channelConfig: IChannelConfiguration = {
- alwaysUseXhrOverride: true,
- httpXHROverride: this.fetchHttpXHROverride,
- };
-
- const instrumentationSetting : IInstrumentationSettings= OneDSLogger.getInstrumentationSettings(geo); // Need to replace with actual data
-
- // Configure App insights core to send to collector
- const coreConfig: IExtendedConfiguration = {
- instrumentationKey: instrumentationSetting.instrumentationKey,
- loggingLevelConsole: 0, // Do not log to console
- disableDbgExt: true, // Small perf optimization
- extensions: [
- // Passing no channels here when the user opts out of telemetry would be ideal, completely ensuring telemetry
- // could not be sent out at all.
- this.postChannel,
- ],
+ alwaysUseXhrOverride: true,
+ httpXHROverride: this.fetchHttpXHROverride,
+ };
+
+ const instrumentationSetting: IInstrumentationSettings = OneDSLogger.getInstrumentationSettings(geo); // Need to replace with actual data
+
+ // Configure App insights core to send to collector
+ const coreConfig: IExtendedConfiguration = {
+ instrumentationKey: instrumentationSetting.instrumentationKey,
+ loggingLevelConsole: 0, // Do not log to console
+ disableDbgExt: true, // Small perf optimization
+ extensions: [
+ // Passing no channels here when the user opts out of telemetry would be ideal, completely ensuring telemetry
+ // could not be sent out at all.
+ this.postChannel,
+ ],
endpointUrl: instrumentationSetting.endpointURL,
- extensionConfig: {
- [this.postChannel.identifier]: channelConfig,
- },
+ extensionConfig: {
+ [this.postChannel.identifier]: channelConfig,
+ },
- };
+ };
- if ((coreConfig.instrumentationKey ?? "") !== "") {
- this.appInsightsCore.initialize(coreConfig, []);
- }
+ if ((coreConfig.instrumentationKey ?? "") !== "") {
+ this.appInsightsCore.initialize(coreConfig, []);
+ }
this.intitializeContextInfo();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.appInsightsCore.addTelemetryInitializer(this.populateCommonAttributes());
- }
+ }
- private intitializeContextInfo(){
+ private intitializeContextInfo() {
OneDSLogger.contextInfo = {
orgId: "",
portalId: "",
@@ -136,9 +136,9 @@ export class OneDSLogger implements ITelemetryLogger{
}
}
- private static getInstrumentationSettings(geo?:string): IInstrumentationSettings {
- const buildRegion:string = region;
- const instrumentationSettings:IInstrumentationSettings = {
+ private static getInstrumentationSettings(geo?: string): IInstrumentationSettings {
+ const buildRegion: string = region;
+ const instrumentationSettings: IInstrumentationSettings = {
endpointURL: 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/',
instrumentationKey: 'ffdb4c99ca3a4ad5b8e9ffb08bf7da0d-65357ff3-efcd-47fc-b2fd-ad95a52373f4-7402'
};
@@ -149,187 +149,185 @@ export class OneDSLogger implements ITelemetryLogger{
break;
case 'prod':
case 'preview':
- switch (geo) {
- case 'us':
- case 'br':
- case 'jp':
- case 'in':
- case 'au':
- case 'ca':
- case 'as':
- case 'za':
- case 'ae':
- case 'kr':
- instrumentationSettings.endpointURL ='https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
- instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
- break;
- case 'eu':
- case 'uk':
- case 'de':
- case 'fr':
- case 'no':
- case 'ch':
- instrumentationSettings.endpointURL ='https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/',
- instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
- break;
- default:
- instrumentationSettings.endpointURL ='https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
- instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
- break;
- }
- break;
+ switch (geo) {
+ case 'us':
+ case 'br':
+ case 'jp':
+ case 'in':
+ case 'au':
+ case 'ca':
+ case 'as':
+ case 'za':
+ case 'ae':
+ case 'kr':
+ instrumentationSettings.endpointURL = 'https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
+ instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
+ break;
+ case 'eu':
+ case 'uk':
+ case 'de':
+ case 'fr':
+ case 'no':
+ case 'ch':
+ instrumentationSettings.endpointURL = 'https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/',
+ instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
+ break;
+ default:
+ instrumentationSettings.endpointURL = 'https://us-mobile.events.data.microsoft.com/OneCollector/1.0/',
+ instrumentationSettings.instrumentationKey = '197418c5cb8c4426b201f9db2e87b914-87887378-2790-49b0-9295-51f43b6204b1-7172'
+ break;
+ }
+ break;
case 'gov':
case 'high':
case 'dod':
case 'mooncake':
instrumentationSettings.endpointURL = '',
- instrumentationSettings.instrumentationKey = '' //prod key;
- break;
+ instrumentationSettings.instrumentationKey = '' //prod key;
+ break;
case 'ex':
case 'rx':
default:
- break;
- }
+ break;
+ }
return instrumentationSettings;
- }
+ }
- /// Trace info log
- public traceInfo(eventName:string, eventInfo?:object, measurement?: object) {
- const event = {
- name: OneDSCollectorEventName.VSCODE_EVENT,
- data: {
+ /// Trace info log
+ public traceInfo(eventName: string, eventInfo?: object, measurement?: object) {
+ const event = {
+ name: OneDSCollectorEventName.VSCODE_EVENT,
+ data: {
eventName: eventName,
eventType: EventType.TRACE,
severity: Severity.INFO,
eventInfo: JSON.stringify(eventInfo!),
- measurement: JSON.stringify(measurement!)
- }
- };
-
- this.appInsightsCore.track(event);
- }
-
- /// Trace warning log
- public traceWarning(eventName:string, eventInfo?: object, measurement?: object) {
- const event = {
- name: OneDSCollectorEventName.VSCODE_EVENT,
- data: {
+ measurement: JSON.stringify(measurement!)
+ }
+ };
+
+ this.appInsightsCore.track(event);
+ }
+
+ /// Trace warning log
+ public traceWarning(eventName: string, eventInfo?: object, measurement?: object) {
+ const event = {
+ name: OneDSCollectorEventName.VSCODE_EVENT,
+ data: {
eventName: eventName,
- eventType: EventType.TRACE,
+ eventType: EventType.TRACE,
severity: Severity.WARN,
eventInfo: JSON.stringify(eventInfo!),
- measurement: JSON.stringify(measurement!)
- }
- };
+ measurement: JSON.stringify(measurement!)
+ }
+ };
- this.appInsightsCore.track(event);
- }
+ this.appInsightsCore.track(event);
+ }
// Trace error log
- public traceError(eventName: string, errorMessage: string, exception: Error, eventInfo?:object, measurement?: object) {
- const event = {
- name: OneDSCollectorEventName.VSCODE_EVENT,
- data: {
+ public traceError(eventName: string, errorMessage: string, exception: Error, eventInfo?: object, measurement?: object) {
+ const event = {
+ name: OneDSCollectorEventName.VSCODE_EVENT,
+ data: {
eventName: eventName,
- eventType: EventType.TRACE,
+ eventType: EventType.TRACE,
severity: Severity.ERROR,
- message: errorMessage!,
+ message: errorMessage!,
errorName: exception ? exception.name : "",
errorStack: JSON.stringify(exception!),
eventInfo: JSON.stringify(eventInfo!),
- measurement: JSON.stringify(measurement!)
- }
- };
+ measurement: JSON.stringify(measurement!)
+ }
+ };
this.appInsightsCore.track(event);
}
- public featureUsage(
+ public featureUsage(
featureName: string,
eventName: string,
customDimensions?: object
- ) {
+ ) {
const event = {
- name: OneDSCollectorEventName.VSCODE_EVENT,
- data: {
+ name: OneDSCollectorEventName.VSCODE_EVENT,
+ data: {
eventName: 'Portal_Metrics_Event',
- eventType: EventType.TRACE,
+ eventType: EventType.TRACE,
severity: Severity.INFO,
eventInfo: JSON.stringify({
featureName: featureName,
customDimensions: customDimensions,
eventName: eventName
})
- }
- };
+ }
+ };
this.appInsightsCore.track(event);
}
/// Populate attributes that are common to all events
- private populateCommonAttributes() {
+ private populateCommonAttributes() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (envelope:any) => {
- try {
- envelope.data = envelope.data || {}; // create data nested object if doesn't exist already'
-
- envelope.data.clientSessionId = vscode.env.sessionId;
- envelope.data.vscodeSurface = getExtensionType();
- envelope.data.vscodeExtensionName = EXTENSION_ID;
- envelope.data.vscodeExtensionVersion = getExtensionVersion();
- envelope.data.vscodeVersion = vscode.version;
- envelope.data.domain = vscode.env.appHost;
- envelope.data.measurements = envelope.data.measurement;
- // Adding below attributes so they get populated in Geneva.
- // TODO: It needs implementation for populating the actual value
- envelope.data.eventSubType = "";
- envelope.data.scenarioId = "";
- envelope.data.eventModifier = "";
- envelope.data.country = "";
- envelope.data.userLocale = "";
- envelope.data.userDataBoundary = "";
- envelope.data.appLocale = "";
- envelope.data.userLocale = "";
- envelope.data.webBrowser = "";
- envelope.data.browserVersion = "";
- envelope.data.browserLanguage = "";
- envelope.data.screenResolution = "";
- envelope.data.osName = "";
- envelope.data.osVersion = "";
- envelope.data.timestamp = new Date();
- if (getExtensionType() == 'Web'){
- this.populateVscodeWebAttributes(envelope);
- }else{
- this.populateVscodeDesktopAttributes(envelope);
- }
- envelope.data.tenantId = OneDSLogger.userInfo?.tid;
- envelope.data.principalObjectId = OneDSLogger.userInfo?.oid;
- envelope.data.puid = OneDSLogger.userInfo?.puid;
- envelope.data.context = JSON.stringify(OneDSLogger.contextInfo);
- envelope.data.userRegion = OneDSLogger.userRegion;
- envelope.data.orgGeo = OneDSLogger.contextInfo.orgGeo;
- // At the end of event enrichment, redact the sensitive data for all the applicable fields
- // envelope = this.redactSensitiveDataFromEvent(envelope);
+ return (envelope: any) => {
+ try {
+ envelope.data = envelope.data || {}; // create data nested object if doesn't exist already'
+
+ envelope.data.clientSessionId = vscode.env.sessionId;
+ envelope.data.vscodeSurface = getExtensionType();
+ envelope.data.vscodeExtensionName = EXTENSION_ID;
+ envelope.data.vscodeExtensionVersion = getExtensionVersion();
+ envelope.data.vscodeVersion = vscode.version;
+ envelope.data.domain = vscode.env.appHost;
+ envelope.data.measurements = envelope.data.measurement;
+ // Adding below attributes so they get populated in Geneva.
+ // TODO: It needs implementation for populating the actual value
+ envelope.data.eventSubType = "";
+ envelope.data.scenarioId = "";
+ envelope.data.eventModifier = "";
+ envelope.data.country = "";
+ envelope.data.userLocale = "";
+ envelope.data.userDataBoundary = "";
+ envelope.data.appLocale = "";
+ envelope.data.userLocale = "";
+ envelope.data.webBrowser = "";
+ envelope.data.browserVersion = "";
+ envelope.data.browserLanguage = "";
+ envelope.data.screenResolution = "";
+ envelope.data.osName = "";
+ envelope.data.osVersion = "";
+ envelope.data.timestamp = new Date();
+ if (getExtensionType() == 'Web') {
+ this.populateVscodeWebAttributes(envelope);
+ } else {
+ this.populateVscodeDesktopAttributes(envelope);
+ }
+ envelope.data.tenantId = OneDSLogger.userInfo?.tid;
+ envelope.data.principalObjectId = OneDSLogger.userInfo?.oid;
+ envelope.data.puid = OneDSLogger.userInfo?.puid;
+ envelope.data.context = JSON.stringify(OneDSLogger.contextInfo);
+ envelope.data.userRegion = OneDSLogger.userRegion;
+ envelope.data.orgGeo = OneDSLogger.contextInfo.orgGeo;
+ // At the end of event enrichment, redact the sensitive data for all the applicable fields
+ // envelope = this.redactSensitiveDataFromEvent(envelope);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- catch (exception:any)
- {
- // Such exceptions are likely if we are trying to process event attributes which don't exist
- // In such cases, only add common attributes and current exception details, and avoid processing the event attributes further
- // However, do log the baseData of the event along with its name in the exception event that gets sent out in this scenario
- console.warn("Caught exception processing the telemetry event: " + envelope.name);
- console.warn(exception.message);
-
- this.traceExceptionInEventProcessing();
- return false;
- }
+ catch (exception: any) {
+ // Such exceptions are likely if we are trying to process event attributes which don't exist
+ // In such cases, only add common attributes and current exception details, and avoid processing the event attributes further
+ // However, do log the baseData of the event along with its name in the exception event that gets sent out in this scenario
+ console.warn("Caught exception processing the telemetry event: " + envelope.name);
+ console.warn(exception.message);
+
+ this.traceExceptionInEventProcessing();
+ return false;
+ }
}
- }
+ }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private populateVscodeWebAttributes(envelope: any) {
if (envelope.data.eventName == telemetryEventNames.WEB_EXTENSION_INIT_QUERY_PARAMETERS) {
const eventInfo = JSON.parse(envelope.data.eventInfo);
-
OneDSLogger.userInfo.tid = eventInfo.tenantId ?? '';
OneDSLogger.userRegion = eventInfo.geo ? geoMappingsToAzureRegion[eventInfo.geo.toLowerCase()].geoName ?? eventInfo.geo : '';
OneDSLogger.contextInfo.orgId = eventInfo.orgId ?? '';
@@ -344,16 +342,17 @@ export class OneDSLogger implements ITelemetryLogger{
OneDSLogger.contextInfo.orgGeo = eventInfo.orgGeo ?? '';
OneDSLogger.contextInfo.sku = eventInfo.sku ?? '';
}
+
if (envelope.data.eventName == telemetryEventNames.WEB_EXTENSION_DATAVERSE_AUTHENTICATION_COMPLETED) {
OneDSLogger.userInfo.oid = JSON.parse(envelope.data.eventInfo).userId;
}
- if (envelope.data.eventName == telemetryEventNames.WEB_EXTENSION_ORG_GEO){
+ if (envelope.data.eventName == telemetryEventNames.WEB_EXTENSION_ORG_GEO) {
OneDSLogger.contextInfo.orgGeo = JSON.parse(envelope.data.eventInfo).orgGeo;
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- private populateVscodeDesktopAttributes(envelope: any){
+ private populateVscodeDesktopAttributes(envelope: any) {
if (envelope.data.eventName == desktopExtTelemetryEventNames.DESKTOP_EXTENSION_INIT_CONTEXT) {
OneDSLogger.contextInfo.orgId = JSON.parse(envelope.data.eventInfo).OrgId;
OneDSLogger.contextInfo.envId = JSON.parse(envelope.data.eventInfo).EnvironmentId;
@@ -363,54 +362,54 @@ export class OneDSLogger implements ITelemetryLogger{
}
//// Redact Sensitive data for the fields susceptible to contain codes/tokens/keys/secrets etc.
- //// This is done post event enrichment is complete to not impact the dependencies (if any) on actual values like Uri etc.
+ //// This is done post event enrichment is complete to not impact the dependencies (if any) on actual values like Uri etc.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- private redactSensitiveDataFromEvent(envelope:any) {
- //Redact sensitive information from suseptible fields
- envelope.data.errorStack = this.getAllSensitiveRedactedFromField(envelope.data.errorStack);
- return envelope;
- }
+ private redactSensitiveDataFromEvent(envelope: any) {
+ //Redact sensitive information from suseptible fields
+ envelope.data.errorStack = this.getAllSensitiveRedactedFromField(envelope.data.errorStack);
+ return envelope;
+ }
//// Get redacted value after all sensitive information is redacted
- getAllSensitiveRedactedFromField(value:string) {
- try {
- // Ensure the value is of type string
- if (value && typeof value === 'string') {
- this.regexPatternsToRedact.forEach((pattern: RegExp) => {
- value = this.getRedactedValueViaRegexMatch(value, pattern);
- });
- }
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- } catch (exception:any) {
- console.warn("Caught exception while processing telemetry data for redaction (if any): " + value);
- console.warn(exception.message);
- }
- return value;
- }
-
- //// Get redacted value
- getRedactedValueViaRegexMatch(value:string, regexPattern:RegExp) {
- let matches;
-
- while ((matches = regexPattern.exec(value)) !== null) {
- // This is necessary to avoid infinite loops with zero-width matches
- if (matches.index === regexPattern.lastIndex) {
- regexPattern.lastIndex++;
- }
-
- matches.forEach((match, groupIndex) => {
- if (groupIndex == 0) { // Redact the entire matched string
- value = value.replace(match, OneDSCollectorEventName.REDACTED); //Replace with string REDACTED
- }
- });
- }
- return value;
- }
+ getAllSensitiveRedactedFromField(value: string) {
+ try {
+ // Ensure the value is of type string
+ if (value && typeof value === 'string') {
+ this.regexPatternsToRedact.forEach((pattern: RegExp) => {
+ value = this.getRedactedValueViaRegexMatch(value, pattern);
+ });
+ }
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ } catch (exception: any) {
+ console.warn("Caught exception while processing telemetry data for redaction (if any): " + value);
+ console.warn(exception.message);
+ }
+ return value;
+ }
+
+ //// Get redacted value
+ getRedactedValueViaRegexMatch(value: string, regexPattern: RegExp) {
+ let matches;
+
+ while ((matches = regexPattern.exec(value)) !== null) {
+ // This is necessary to avoid infinite loops with zero-width matches
+ if (matches.index === regexPattern.lastIndex) {
+ regexPattern.lastIndex++;
+ }
+
+ matches.forEach((match, groupIndex) => {
+ if (groupIndex == 0) { // Redact the entire matched string
+ value = value.replace(match, OneDSCollectorEventName.REDACTED); //Replace with string REDACTED
+ }
+ });
+ }
+ return value;
+ }
/// Trace exceptions in processing event attributes
- private traceExceptionInEventProcessing() {
- // TODO : Add exception handling
- }
+ private traceExceptionInEventProcessing() {
+ // TODO : Add exception handling
+ }
public flushAndTeardown(): void {
this.appInsightsCore.flush();
diff --git a/src/common/OneDSLoggerTelemetry/oneDSLoggerWrapper.ts b/src/common/OneDSLoggerTelemetry/oneDSLoggerWrapper.ts
index e508a114..6a85c269 100644
--- a/src/common/OneDSLoggerTelemetry/oneDSLoggerWrapper.ts
+++ b/src/common/OneDSLoggerTelemetry/oneDSLoggerWrapper.ts
@@ -7,65 +7,65 @@ import { isCustomTelemetryEnabled } from "../Utils";
import { OneDSLogger } from "./oneDSLogger";
//// Wrapper class of oneDSLogger for below purposes
-//// 1. Abstracting code from manual trace log APIs.
+//// 1. Abstracting code from manual trace log APIs.
//// 2. Constrolling instantiation of 1ds SDK framework code in oneDSLogger.ts
export class oneDSLoggerWrapper {
private static instance: oneDSLoggerWrapper;
- private static oneDSLoggerIntance : OneDSLogger;
+ private static oneDSLoggerIntance: OneDSLogger;
private constructor(geo?: string) {
oneDSLoggerWrapper.oneDSLoggerIntance = new OneDSLogger(geo);
}
- static getLogger(){
+ static getLogger() {
return this.instance;
}
- static instantiate(geo?:string){
+ static instantiate(geo?: string) {
oneDSLoggerWrapper.instance = new oneDSLoggerWrapper(geo);
}
- /// Trace info log
- public traceInfo(eventName:string, eventInfo?: object, measurement?: object) {
- try{
+ /// Trace info log
+ public traceInfo(eventName: string, eventInfo?: object, measurement?: object) {
+ try {
if (!isCustomTelemetryEnabled()) return;
oneDSLoggerWrapper.oneDSLoggerIntance.traceInfo(eventName, eventInfo, measurement);
- }catch (exception) {
- console.warn(exception);
- }
- }
+ } catch (exception) {
+ console.warn(exception);
+ }
+ }
/// Trace warning log
- public traceWarning(eventName:string, eventInfo?: object, measurement?: object) {
- try{
+ public traceWarning(eventName: string, eventInfo?: object, measurement?: object) {
+ try {
if (!isCustomTelemetryEnabled()) return;
oneDSLoggerWrapper.oneDSLoggerIntance.traceWarning(eventName, eventInfo, measurement);
- }catch (exception) {
- console.warn(exception);
- }
- }
+ } catch (exception) {
+ console.warn(exception);
+ }
+ }
/// Trace exception log
- public traceError(eventName: string, errorMessage: string, exception: Error, eventInfo?:object, measurement?: object) {
- try{
+ public traceError(eventName: string, errorMessage: string, exception: Error, eventInfo?: object, measurement?: object) {
+ try {
if (!isCustomTelemetryEnabled()) return;
oneDSLoggerWrapper.oneDSLoggerIntance.traceError(eventName, errorMessage, exception, eventInfo, measurement);
- }catch (exception) {
+ } catch (exception) {
console.warn("Caught exception processing the telemetry event: " + exception);
console.warn(exception);
- }
- }
+ }
+ }
/// Trace featureName
- public featureUsage( featureName: string,eventName: string,customDimensions?: object) {
- try{
+ public featureUsage(featureName: string, eventName: string, customDimensions?: object) {
+ try {
if (!isCustomTelemetryEnabled()) return;
oneDSLoggerWrapper.oneDSLoggerIntance.featureUsage(featureName, eventName, customDimensions);
- }catch (exception) {
- console.warn(exception);
- }
- }
-
-}
\ No newline at end of file
+ } catch (exception) {
+ console.warn(exception);
+ }
+ }
+
+}
diff --git a/src/common/OneDSLoggerTelemetry/shortNameMappingToAzureRegion.ts b/src/common/OneDSLoggerTelemetry/shortNameMappingToAzureRegion.ts
index 2102d19c..0c71e976 100644
--- a/src/common/OneDSLoggerTelemetry/shortNameMappingToAzureRegion.ts
+++ b/src/common/OneDSLoggerTelemetry/shortNameMappingToAzureRegion.ts
@@ -16,7 +16,7 @@ export const azureRegions = {
CanadaCentral: 'canadacentral',
CanadaEast: 'canadaeast',
BrazilSouth: 'brazilsouth',
-
+
// Europe
EuropeNorth: 'northeurope',
EuropeWest: 'westeurope',
@@ -30,7 +30,7 @@ export const azureRegions = {
GermanyWestCentral: 'germanywestcentral',
NorwayWest: 'norwaywest',
NorwayEast: 'norwayeast',
-
+
// Asia
AsiaEast: 'eastasia',
AsiaSouthEast: 'southeastasia',
@@ -45,44 +45,44 @@ export const azureRegions = {
IndiaWest: 'westindia',
KoreaSouth: 'koreasouth',
KoreaCentral: 'koreacentral',
-
+
// UAE
UAECentral: 'uaecentral',
UAENorth: 'uaenorth',
SouthAfricaNorth: 'southafricanorth',
SouthAfricaWest: 'southafricawest',
-
+
// Germany
GermanyCentral: 'germanycentral',
GermanyNorthEast: 'germanynortheast',
-
+
// Singapore
SingaporeSouthEast: 'southeastasia',
-
+
///
/// U.S. government cloud in Virginia.
///
-
+
GovernmentUSVirginia: 'usgovvirginia',
-
+
///
/// U.S. government cloud in Iowa.
///
GovernmentUSIowa: 'usgoviowa',
-
+
///
/// U.S. government cloud in Arizona.
///
GovernmentUSArizona: 'usgovarizona',
-
+
///
/// U.S. government cloud in Texas.
///
GovernmentUSTexas: 'usgovtexas',
-
+
GovernmentUSDodEast: 'usdodeast',
GovernmentUSDodCentral: 'usdodcentral',
-
+
///
/// China Environment
///
@@ -92,9 +92,9 @@ export const azureRegions = {
ChinaEast: 'chinaeast',
ChinaEast2: 'chinaeast2',
ChinaEast3: 'chinaeast3',
- };
-
- export const regionShortName = {
+};
+
+export const regionShortName = {
wus: 'wus',
cus: 'cus',
eus: 'eus',
@@ -141,8 +141,8 @@ export const azureRegions = {
cnn: 'cnn',
cnn2: 'cnn2',
cnn3: 'cnn3'
- };
-
+};
+
export const geoMappingsToAzureRegion = {
// Public
[regionShortName.wus]: { geoName: 'us', azureRegion: azureRegions.USWest },
@@ -178,7 +178,7 @@ export const geoMappingsToAzureRegion = {
[regionShortName.nch]: { geoName: 'ch', azureRegion: azureRegions.SwitzerlandNorth },
[regionShortName.wch]: { geoName: 'ch', azureRegion: azureRegions.SwitzerlandWest },
[regionShortName.eno]: { geoName: 'no', azureRegion: azureRegions.NorwayEast },
- [regionShortName.wno]: { geoName: 'no', azureRegion: azureRegions.NorwayWest },
+ [regionShortName.wno]: { geoName: 'no', azureRegion: azureRegions.NorwayWest },
[regionShortName.ckr]: { geoName: 'kr', azureRegion: azureRegions.KoreaCentral },
[regionShortName.skr]: { geoName: 'kr', azureRegion: azureRegions.KoreaSouth },
// Government US.
@@ -193,5 +193,4 @@ export const geoMappingsToAzureRegion = {
[regionShortName.cnn]: { geoName: 'cn', azureRegion: azureRegions.ChinaNorth },
[regionShortName.cnn2]: { geoName: 'cn', azureRegion: azureRegions.ChinaNorth2 },
[regionShortName.cnn3]: { geoName: 'cn', azureRegion: azureRegions.ChinaNorth3 },
- };
-
\ No newline at end of file
+};
diff --git a/src/common/copilot/dataverseMetadata.ts b/src/common/copilot/dataverseMetadata.ts
index e3563f5b..f4ee4469 100644
--- a/src/common/copilot/dataverseMetadata.ts
+++ b/src/common/copilot/dataverseMetadata.ts
@@ -11,7 +11,7 @@ import { ITelemetry } from "../../client/telemetry/ITelemetry";
import { sendTelemetryEvent } from "./telemetry/copilotTelemetry";
import { CopilotDataverseMetadataFailureEvent, CopilotDataverseMetadataSuccessEvent, CopilotGetEntityFailureEvent, CopilotYamlParsingFailureEvent } from "./telemetry/telemetryConstants";
import { getEntityMetadata } from "../../web/client/utilities/fileAndEntityUtil";
-import { DOMParser } from "xmldom";
+import { DOMParser } from "@xmldom/xmldom";
import { ATTRIBUTE_CLASSID, ATTRIBUTE_DATAFIELD_NAME, ATTRIBUTE_DESCRIPTION, ControlClassIdMap, SYSTEFORMS_API_PATH } from "./constants";