{"version":3,"file":"Log-DRMM6-wg.js","sources":["../../node_modules/@hejdoktor/resx-compiler/format.mjs","../../Client/shared/bootstrapped.ts","../../Client/shared/Log.ts"],"sourcesContent":["export function format(translation, ...args) {\n\tfor (let i = 0; i < args.length; i++) {\n\t\ttranslation = translation.replace(new RegExp('\\\\{' + i + '}', 'g'), args[i]);\n\t}\n\n\treturn translation;\n};\n","import { setLocale } from '@hejdoktor/resx-compiler';\nimport { IBootstrappedData } from './interfaces';\n\ndeclare let bootstrapped: IBootstrappedData;\n\nsetLocale(bootstrapped.CurrentLocale);\n\nexport default bootstrapped;\n","/* eslint no-console: \"off\" */\n\nimport { AzureLogger, setLogLevel } from '@azure/logger';\nimport bootstrapped from './bootstrapped';\n\ntype LogLevel = 'info' | 'warn' | 'error' | 'debug';\n\n// Sentry and R7Insight are included globally\ndeclare const Sentry: any;\ndeclare const R7Insight: any;\n\nexport class Log {\n public static info(msg: string, additionalData?: unknown): void {\n Log.emitLogMessage('info', msg, additionalData);\n }\n\n public static warn(msg: string, additionalData?: unknown): void {\n Log.emitLogMessage('warn', msg, additionalData);\n }\n\n public static debug(msg: string, additionalData?: unknown): void {\n Log.emitLogMessage('debug', msg, additionalData);\n }\n\n public static error(\n msg: string,\n additionalData?: unknown,\n error?: Error,\n ): void {\n Log.emitLogMessage('error', msg, additionalData, error);\n }\n\n private static isR7Initialized = false;\n\n private static emitLogMessage(\n msgType: LogLevel,\n msg: string,\n additionalData: unknown,\n error?: Error,\n ): void {\n if (console && console[msgType]) {\n if (additionalData != null || error != null) {\n const data = this.mapData({}, additionalData, error);\n console[msgType](msg, data);\n } else {\n console[msgType](msg);\n }\n }\n\n try {\n Log.logToR7Insight(msgType, msg, additionalData, error);\n } catch (e) {\n console.error('Error logging to R7Insight', e);\n }\n\n try {\n Log.logToSentry(msgType, msg, additionalData, error);\n } catch (e) {\n console.error('Error logging to Sentry', e);\n }\n }\n\n private static logToR7Insight(\n msgType: LogLevel,\n msg: string,\n additionalData: unknown,\n error?: Error,\n ): void {\n if (typeof R7Insight === 'undefined') {\n return;\n }\n if (msgType === 'debug') {\n return;\n }\n if (!bootstrapped.LeToken) {\n return;\n }\n\n if (!Log.isR7Initialized) {\n R7Insight.init({\n token: bootstrapped.LeToken,\n ['page_info']: 'per-page',\n region: 'eu',\n });\n Log.isR7Initialized = true;\n }\n\n const basicData: { [key: string]: any } = {\n user: bootstrapped.UserId,\n message: msg,\n };\n\n const data = this.mapData(basicData, additionalData, error);\n\n // Normalizing log level so we can search the same way across all log channels\n data['level'] = msgType;\n\n R7Insight[msgType](data);\n }\n\n private static logToSentry(\n msgType: LogLevel,\n msg: string,\n additionalData: unknown,\n error?: Error,\n ): void {\n if (msgType === 'info' || msgType === 'debug') {\n return;\n }\n if (typeof Sentry === 'undefined') {\n return;\n }\n\n const basicData: { [key: string]: any } = {\n user: bootstrapped.UserId,\n message: msg,\n };\n\n const data = this.mapData(basicData, additionalData, error);\n\n Sentry.setContext('data', data);\n\n if (additionalData instanceof Error) {\n Sentry.captureException(additionalData, { level: msgType });\n } else if (error instanceof Error) {\n Sentry.captureException(error, { level: msgType });\n } else {\n Sentry.captureMessage(msg, { level: msgType });\n }\n }\n\n private static mapData(\n basicData: { [key: string]: any },\n additionalData?: unknown,\n error?: Error,\n ): { [key: string]: any } {\n const xData = basicData ? basicData : {};\n\n if (additionalData && additionalData instanceof Error) {\n xData['error-name'] = additionalData.name;\n xData['error-message'] = additionalData.message;\n xData['error-stack'] = additionalData.stack;\n } else if (additionalData != null) {\n if (\n additionalData instanceof Object &&\n !Array.isArray(additionalData)\n ) {\n Object.keys(additionalData).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n xData[key] = additionalData[key];\n });\n } else {\n xData['data'] = additionalData;\n }\n }\n\n if (error && error instanceof Error) {\n xData['error-name'] = error.name;\n xData['error-message'] = error.message;\n xData['error-stack'] = error.stack;\n }\n\n return xData;\n }\n}\n\n// Configuring @azure/logger\nsetLogLevel('warning');\nAzureLogger.log = (message) => {\n const level = getLogLevel(message);\n\n switch (level) {\n case 'info':\n Log.info(message);\n break;\n case 'warn':\n Log.warn(message);\n break;\n case 'error':\n Log.error(message);\n break;\n case 'debug':\n Log.debug(message);\n break;\n }\n};\n\nconst downgradedErrorLogs = [\n 'Disconnecting Call end reason=Success',\n 'resultCategories=Success',\n 'Failed to set media metrics device events telemetry',\n ':SenderV2 Not setting up audio mixer for non-audio stream',\n 'ACS-calling:.*\\\\(Failed to dispose calling stack',\n 'Unable to receive incoming calls',\n 'CallClient1:CallStack:Trouter \\\\[Connection\\\\] onSocketDisconnect, reason: disconnect',\n 'CallClient1:CallStack:MA:DeviceManager Error updating renderers:.*audio requested undefined, video requested: true',\n 'CallClient1:CallStack:MA:DeviceManager:videorenderer:local:.*:rendererQueue.*Error from promiseQueue.*type.*noDeviceSelected.*detail.*audio requested undefined.*video requested.*',\n];\n\nconst downgradedErrorLogsRegex = new RegExp(downgradedErrorLogs.join('|'));\n\nfunction getLogLevel(message: string): LogLevel {\n if (message.includes(':error')) {\n if (downgradedErrorLogsRegex.test(message)) {\n return 'info';\n }\n\n return 'error';\n } else if (message.includes(':warning')) {\n return 'warn';\n } else if (message.includes(':info')) {\n return 'info';\n } else {\n // :verbose\n return 'debug';\n }\n}\n"],"names":["format","translation","args","i","setLocale","bootstrapped$1","_Log","msg","additionalData","error","msgType","data","e","bootstrapped","basicData","xData","key","Log","setLogLevel","AzureLogger","message","getLogLevel","downgradedErrorLogs","downgradedErrorLogsRegex"],"mappings":"gGAAO,SAASA,EAAOC,KAAgBC,EAAM,CAC5C,QAASC,EAAI,EAAGA,EAAID,EAAK,OAAQC,IAChCF,EAAcA,EAAY,QAAQ,IAAI,OAAO,MAAQE,EAAI,IAAK,GAAG,EAAGD,EAAKC,CAAC,CAAC,EAG5E,OAAOF,CACR,CCDAG,EAAU,aAAa,aAAa,EAEpC,MAAAC,EAAe,aCIFC,EAAN,MAAMA,CAAI,CACb,OAAc,KAAKC,E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