@cloudcare/browser-logs 3.1.23 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dataflux-logs.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/logsPublicApi.js +35 -62
- package/cjs/boot/logsPublicApi.js.map +1 -1
- package/cjs/boot/preStartLogs.js +72 -0
- package/cjs/boot/preStartLogs.js.map +1 -0
- package/cjs/boot/startLogs.js +57 -38
- package/cjs/boot/startLogs.js.map +1 -1
- package/cjs/domain/assembly.js +5 -7
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/contexts/commonContext.js +17 -0
- package/cjs/domain/contexts/commonContext.js.map +1 -0
- package/cjs/domain/contexts/internalContext.js.map +1 -0
- package/cjs/domain/createErrorFieldFromRawError.js +20 -0
- package/cjs/domain/createErrorFieldFromRawError.js.map +1 -0
- package/cjs/domain/logger.js +61 -54
- package/cjs/domain/logger.js.map +1 -1
- package/cjs/domain/logsCollection/console/consoleCollection.js +5 -5
- package/cjs/domain/logsCollection/console/consoleCollection.js.map +1 -1
- package/cjs/domain/logsCollection/logger/loggerCollection.js +37 -20
- package/cjs/domain/logsCollection/logger/loggerCollection.js.map +1 -1
- package/cjs/domain/logsCollection/networkError/networkErrorCollection.js +11 -6
- package/cjs/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -1
- package/cjs/domain/logsCollection/report/reportCollection.js +6 -15
- package/cjs/domain/logsCollection/report/reportCollection.js.map +1 -1
- package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
- package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -1
- package/cjs/domain/reportError.js +24 -0
- package/cjs/domain/reportError.js.map +1 -0
- package/cjs/transport/startLogsBatch.js +6 -2
- package/cjs/transport/startLogsBatch.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/logsPublicApi.js +36 -63
- package/esm/boot/logsPublicApi.js.map +1 -1
- package/esm/boot/preStartLogs.js +66 -0
- package/esm/boot/preStartLogs.js.map +1 -0
- package/esm/boot/startLogs.js +57 -38
- package/esm/boot/startLogs.js.map +1 -1
- package/esm/domain/assembly.js +6 -8
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/contexts/commonContext.js +11 -0
- package/esm/domain/contexts/commonContext.js.map +1 -0
- package/esm/domain/contexts/internalContext.js.map +1 -0
- package/esm/domain/createErrorFieldFromRawError.js +14 -0
- package/esm/domain/createErrorFieldFromRawError.js.map +1 -0
- package/esm/domain/logger.js +62 -55
- package/esm/domain/logger.js.map +1 -1
- package/esm/domain/logsCollection/console/consoleCollection.js +5 -5
- package/esm/domain/logsCollection/console/consoleCollection.js.map +1 -1
- package/esm/domain/logsCollection/logger/loggerCollection.js +39 -22
- package/esm/domain/logsCollection/logger/loggerCollection.js.map +1 -1
- package/esm/domain/logsCollection/networkError/networkErrorCollection.js +12 -7
- package/esm/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -1
- package/esm/domain/logsCollection/report/reportCollection.js +7 -16
- package/esm/domain/logsCollection/report/reportCollection.js.map +1 -1
- package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
- package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -1
- package/esm/domain/reportError.js +18 -0
- package/esm/domain/reportError.js.map +1 -0
- package/esm/transport/startLogsBatch.js +7 -3
- package/esm/transport/startLogsBatch.js.map +1 -1
- package/package.json +4 -3
- package/src/boot/logsPublicApi.js +52 -86
- package/src/boot/preStartLogs.js +94 -0
- package/src/boot/startLogs.js +83 -60
- package/src/domain/assembly.js +7 -12
- package/src/domain/contexts/commonContext.js +10 -0
- package/src/domain/createErrorFieldFromRawError.js +13 -0
- package/src/domain/logger.js +89 -63
- package/src/domain/logsCollection/console/consoleCollection.js +5 -9
- package/src/domain/logsCollection/logger/loggerCollection.js +46 -25
- package/src/domain/logsCollection/networkError/networkErrorCollection.js +11 -7
- package/src/domain/logsCollection/report/reportCollection.js +9 -16
- package/src/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -6
- package/src/domain/reportError.js +21 -0
- package/src/transport/startLogsBatch.js +6 -4
- package/types/configuration.d.ts +2 -2
- package/types/logger.d.ts +3 -22
- package/cjs/domain/internalContext.js.map +0 -1
- package/esm/domain/internalContext.js.map +0 -1
- /package/cjs/domain/{internalContext.js → contexts/internalContext.js} +0 -0
- /package/esm/domain/{internalContext.js → contexts/internalContext.js} +0 -0
- /package/src/domain/{internalContext.js → contexts/internalContext.js} +0 -0
package/esm/domain/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":["assign","extend2Lev","createContextManager","ErrorSource","keys","CustomerDataType","sanitize","computeStackTrace","computeRawError","clocksNow","ErrorHandling","monitor","NonErrorPrefix","StatusType","debug","error","info","warn","critical","HandlerType","console","http","silent","STATUSES","Logger","handleLogStrategy","name","handlerType","level","loggerContext","contextManager","LoggerContext","set","logger","undefined","prototype","log","message","messageContext","status","errorContext","origin","LOGGER","stackTrace","Error","rawError","originalError","nonErrorPrefix","PROVIDED","source","handling","HANDLED","startClocks","stack","kind","type","causes","sanitizedMessageContext","context","errorOrigin","setContext","getContext","get","addContext","key","value","add","removeContext","remove","clearContext","setHandler","handler","getHandler","setLevel","getLevel"],"sources":["../../src/domain/logger.js"],"sourcesContent":["import {\n assign,\n extend2Lev,\n createContextManager,\n ErrorSource,\n keys,\n CustomerDataType,\n sanitize,\n computeStackTrace,\n computeRawError,\n clocksNow,\n ErrorHandling,\n monitor,\n NonErrorPrefix\n} from '@cloudcare/browser-core'\n\nexport var StatusType = {\n debug: 'debug',\n error: 'error',\n info: 'info',\n warn: 'warn',\n critical: 'critical'\n}\n\nexport var HandlerType = {\n console: 'console',\n http: 'http',\n silent: 'silent'\n}\n\nexport var STATUSES = keys(StatusType)\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport function Logger(\n handleLogStrategy,\n name,\n handlerType,\n level,\n loggerContext\n) {\n this.contextManager = createContextManager(CustomerDataType.LoggerContext)\n if (typeof handlerType === 'undefined') {\n handlerType = HandlerType.http\n }\n if (typeof level === 'undefined') {\n level = StatusType.debug\n }\n if (typeof loggerContext === 'undefined') {\n loggerContext = {}\n }\n this.handleLogStrategy = handleLogStrategy\n this.handlerType = handlerType\n this.level = level\n this.contextManager.set(\n assign({}, loggerContext, name ? { logger: { name: name } } : undefined)\n )\n}\nLogger.prototype = {\n log: monitor(function (message, messageContext, status, error) {\n if (typeof status === 'undefined') {\n status = StatusType.info\n }\n var errorContext\n if (status === StatusType.error) {\n // Always add origin if status is error (backward compatibility - Remove in next major)\n errorContext = { origin: ErrorSource.LOGGER }\n }\n if (error !== undefined && error !== null) {\n var stackTrace =\n error instanceof Error ? computeStackTrace(error) : undefined\n var rawError = computeRawError({\n stackTrace: stackTrace,\n originalError: error,\n nonErrorPrefix: NonErrorPrefix.PROVIDED,\n source: ErrorSource.LOGGER,\n handling: ErrorHandling.HANDLED,\n startClocks: clocksNow()\n })\n\n errorContext = {\n origin: ErrorSource.LOGGER, // Remove in next major\n stack: rawError.stack,\n kind: rawError.type,\n message: rawError.message,\n causes: rawError.causes\n }\n }\n\n var sanitizedMessageContext = sanitize(messageContext)\n\n var context = errorContext\n ? extend2Lev({ error: errorContext }, sanitizedMessageContext)\n : sanitizedMessageContext\n\n this.handleLogStrategy(\n { message: message, context: context, status: status },\n this\n )\n }),\n\n debug: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.debug, error)\n },\n\n info: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.info, error)\n },\n\n warn: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.warn, error)\n },\n critical: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.critical, error)\n },\n error: function (message, messageContext, error) {\n var errorOrigin = {\n error: {\n origin: ErrorSource.LOGGER\n }\n }\n this.log(\n message,\n extend2Lev(errorOrigin, messageContext),\n StatusType.error,\n error\n )\n },\n\n setContext: function (context) {\n this.contextManager.set(context)\n },\n\n getContext: function () {\n return this.contextManager.get()\n },\n\n addContext: function (key, value) {\n this.contextManager.add(key, value)\n },\n\n removeContext: function (key) {\n this.contextManager.remove(key)\n },\n clearContext() {\n this.contextManager.clearContext()\n },\n setHandler: function (handler) {\n this.handlerType = handler\n },\n\n getHandler: function () {\n return this.handlerType\n },\n setLevel: function (level) {\n this.level = level\n },\n getLevel: function () {\n return this.level\n }\n}\n"],"mappings":"AAAA,SACEA,MAAM,EACNC,UAAU,EACVC,oBAAoB,EACpBC,WAAW,EACXC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,SAAS,EACTC,aAAa,EACbC,OAAO,EACPC,cAAc,QACT,yBAAyB;AAEhC,OAAO,IAAIC,UAAU,GAAG;EACtBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,IAAIC,WAAW,GAAG;EACvBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,IAAIC,QAAQ,GAAGnB,IAAI,CAACS,UAAU,CAAC;AACtC;AACA,OAAO,SAASW,MAAMA,CACpBC,iBAAiB,EACjBC,IAAI,EACJC,WAAW,EACXC,KAAK,EACLC,aAAa,EACb;EACA,IAAI,CAACC,cAAc,GAAG5B,oBAAoB,CAACG,gBAAgB,CAAC0B,aAAa,CAAC;EAC1E,IAAI,OAAOJ,WAAW,KAAK,WAAW,EAAE;IACtCA,WAAW,GAAGR,WAAW,CAACE,IAAI;EAChC;EACA,IAAI,OAAOO,KAAK,KAAK,WAAW,EAAE;IAChCA,KAAK,GAAGf,UAAU,CAACC,KAAK;EAC1B;EACA,IAAI,OAAOe,aAAa,KAAK,WAAW,EAAE;I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AO,IAAI,CAAC9C,KAAK;EACnB;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"logger.js","names":["extend2Lev","createContextManager","ErrorSource","keys","CustomerDataType","sanitize","computeStackTrace","computeRawError","clocksNow","ErrorHandling","monitor","NonErrorPrefix","createHandlingStack","isAuthorized","createErrorFieldFromRawError","StatusType","ok","debug","info","notice","warn","error","critical","alert","emerg","HandlerType","console","http","silent","STATUSES","Logger","handleLogStrategy","name","handlerType","level","loggerContext","contextManager","LoggerContext","setContext","setContextProperty","prototype","logImplementation","message","messageContext","status","handlingStack","undefined","sanitizedMessageContext","context","rawError","stackTrace","Error","originalError","nonErrorPrefix","PROVIDED","source","LOGGER","handling","HANDLED","startClocks","includeMessage","log","getContext","key","value","addContext","removeContextProperty","removeContext","remove","clearContext","setHandler","handler","getHandler","setLevel","getLevel","createLoggerMethod"],"sources":["../../src/domain/logger.js"],"sourcesContent":["import {\n extend2Lev,\n createContextManager,\n ErrorSource,\n keys,\n CustomerDataType,\n sanitize,\n computeStackTrace,\n computeRawError,\n clocksNow,\n ErrorHandling,\n monitor,\n NonErrorPrefix,\n createHandlingStack\n} from '@cloudcare/browser-core'\nimport { isAuthorized } from './logsCollection/logger/loggerCollection'\nimport { createErrorFieldFromRawError } from './createErrorFieldFromRawError'\nexport var StatusType = {\n ok: 'ok',\n debug: 'debug',\n info: 'info',\n notice: 'notice',\n warn: 'warn',\n error: 'error',\n critical: 'critical',\n alert: 'alert',\n emerg: 'emerg'\n}\n\nexport var HandlerType = {\n console: 'console',\n http: 'http',\n silent: 'silent'\n}\n\nexport var STATUSES = keys(StatusType)\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport function Logger(\n handleLogStrategy,\n name,\n handlerType,\n level,\n loggerContext\n) {\n if (typeof handlerType === 'undefined') {\n handlerType = HandlerType.http\n }\n if (typeof level === 'undefined') {\n level = StatusType.debug\n }\n if (typeof loggerContext === 'undefined') {\n loggerContext = {}\n }\n this.contextManager = createContextManager(CustomerDataType.LoggerContext)\n this.handleLogStrategy = handleLogStrategy\n this.handlerType = handlerType\n this.level = level\n this.contextManager.setContext(loggerContext)\n if (name) {\n this.contextManager.setContextProperty('logger', { name: name })\n }\n}\nLogger.prototype = {\n logImplementation: monitor(function (\n message,\n messageContext,\n status,\n error,\n handlingStack\n ) {\n if (status === undefined) {\n status = StatusType.info\n }\n var sanitizedMessageContext = sanitize(messageContext)\n var context\n\n if (error !== undefined && error !== null) {\n var rawError = computeRawError({\n stackTrace:\n error instanceof Error ? computeStackTrace(error) : undefined,\n originalError: error,\n nonErrorPrefix: NonErrorPrefix.PROVIDED,\n source: ErrorSource.LOGGER,\n handling: ErrorHandling.HANDLED,\n startClocks: clocksNow()\n })\n context = extend2Lev(\n {\n error: createErrorFieldFromRawError(rawError, {\n includeMessage: true\n })\n },\n sanitizedMessageContext\n )\n } else {\n context = sanitizedMessageContext\n }\n\n this.handleLogStrategy(\n {\n message: sanitize(message),\n context: context,\n status: status\n },\n this,\n handlingStack\n )\n }),\n log: function (message, messageContext, status, error) {\n var handlingStack\n\n if (isAuthorized(status, HandlerType.http, this)) {\n handlingStack = createHandlingStack()\n }\n\n this.logImplementation(\n message,\n messageContext,\n status,\n error,\n handlingStack\n )\n },\n\n setContext: function (context) {\n this.contextManager.setContext(context)\n },\n\n getContext: function () {\n return this.contextManager.getContext()\n },\n setContextProperty: function (key, value) {\n this.contextManager.setContextProperty(key, value)\n },\n addContext: function (key, value) {\n this.contextManager.setContextProperty(key, value)\n },\n removeContextProperty(key) {\n this.contextManager.removeContextProperty(key)\n },\n removeContext: function (key) {\n this.contextManager.remove(key)\n },\n clearContext() {\n this.contextManager.clearContext()\n },\n setHandler: function (handler) {\n this.handlerType = handler\n },\n\n getHandler: function () {\n return this.handlerType\n },\n setLevel: function (level) {\n this.level = level\n },\n getLevel: function () {\n return this.level\n }\n}\nLogger.prototype.ok = createLoggerMethod(StatusType.ok)\nLogger.prototype.debug = createLoggerMethod(StatusType.debug)\nLogger.prototype.info = createLoggerMethod(StatusType.info)\nLogger.prototype.notice = createLoggerMethod(StatusType.notice)\nLogger.prototype.warn = createLoggerMethod(StatusType.warn)\nLogger.prototype.error = createLoggerMethod(StatusType.error)\nLogger.prototype.critical = createLoggerMethod(StatusType.critical)\nLogger.prototype.alert = createLoggerMethod(StatusType.alert)\nLogger.prototype.emerg = createLoggerMethod(StatusType.emerg)\nfunction createLoggerMethod(status) {\n return function (message, messageContext, error) {\n var handlingStack\n\n if (isAuthorized(status, HandlerType.http, this)) {\n handlingStack = createHandlingStack()\n }\n this.logImplementation(\n message,\n messageContext,\n status,\n error,\n handlingStack\n )\n }\n}\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,WAAW,EACXC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,SAAS,EACTC,aAAa,EACbC,OAAO,EACPC,cAAc,EACdC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,YAAY,QAAQ,0CAA0C;AACvE,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,OAAO,IAAIC,UAAU,GAAG;EACtBC,EAAE,EAAE,IAAI;EACRC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE;AACT,CAAC;AAED,OAAO,IAAIC,WAAW,GAAG;EACvBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,IAAIC,QAAQ,GAAG1B,IAAI,CAACY,UAAU,CAAC;AACtC;AACA,OAAO,SAASe,MAAMA,CACpBC,iBAAiB,EACjBC,IAAI,EACJC,WAAW,EACXC,KAAK,EACLC,aAAa,EACb;EACA,IAAI,OAAOF,WAAW,KAAK,W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DU,MAAM,CAACU,SAAS,CAACnB,KAAK,GAAGsD,kBAAkB,CAAC5D,UAAU,CAACM,KAAK,CAAC;AAC7DS,MAAM,CAACU,SAAS,CAAClB,QAAQ,GAAGqD,kBAAkB,CAAC5D,UAAU,CAACO,QAAQ,CAAC;AACnEQ,MAAM,CAACU,SAAS,CAACjB,KAAK,GAAGoD,kBAAkB,CAAC5D,UAAU,CAACQ,KAAK,CAAC;AAC7DO,MAAM,CAACU,SAAS,CAAChB,KAAK,GAAGmD,kBAAkB,CAAC5D,UAAU,CAACS,KAAK,CAAC;AAC7D,SAASmD,kBAAkBA,CAAC/B,MAAM,EAAE;EAClC,OAAO,UAAUF,OAAO,EAAEC,cAAc,EAAEtB,KAAK,EAAE;IAC/C,IAAIwB,aAAa;IAEjB,IAAIhC,YAAY,CAAC+B,MAAM,EAAEnB,WAAW,CAACE,IAAI,EAAE,IAAI,CAAC,EAAE;MAChDkB,aAAa,GAAGjC,mBAAmB,CAAC,CAAC;IACvC;IACA,IAAI,CAAC6B,iBAAiB,CACpBC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNvB,KAAK,EACLwB,aACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
5
5
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
6
|
import { timeStampNow, ConsoleApiName, ErrorSource, initConsoleObservable, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
7
7
|
import { StatusType } from '../../logger';
|
|
8
|
+
import { createErrorFieldFromRawError } from '../../createErrorFieldFromRawError';
|
|
8
9
|
var LogStatusForApi = (_LogStatusForApi = {}, _defineProperty(_LogStatusForApi, ConsoleApiName.log, StatusType.info), _defineProperty(_LogStatusForApi, ConsoleApiName.debug, StatusType.debug), _defineProperty(_LogStatusForApi, ConsoleApiName.info, StatusType.info), _defineProperty(_LogStatusForApi, ConsoleApiName.warn, StatusType.warn), _defineProperty(_LogStatusForApi, ConsoleApiName.error, StatusType.error), _LogStatusForApi);
|
|
9
10
|
export function startConsoleCollection(configuration, lifeCycle) {
|
|
10
11
|
var consoleSubscription = initConsoleObservable(configuration.forwardConsoleLogs).subscribe(function (log) {
|
|
@@ -13,12 +14,11 @@ export function startConsoleCollection(configuration, lifeCycle) {
|
|
|
13
14
|
date: timeStampNow(),
|
|
14
15
|
message: log.message,
|
|
15
16
|
origin: ErrorSource.CONSOLE,
|
|
16
|
-
error: log.
|
|
17
|
-
origin: ErrorSource.CONSOLE,
|
|
18
|
-
stack: log.stack,
|
|
19
|
-
causes: log.causes
|
|
20
|
-
} : undefined,
|
|
17
|
+
error: log.error && createErrorFieldFromRawError(log.error),
|
|
21
18
|
status: LogStatusForApi[log.api]
|
|
19
|
+
},
|
|
20
|
+
domainContext: {
|
|
21
|
+
handlingStack: log.handlingStack
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleCollection.js","names":["timeStampNow","ConsoleApiName","ErrorSource","initConsoleObservable","LifeCycleEventType","StatusType","LogStatusForApi","_LogStatusForApi","_defineProperty","log","info","debug","warn","error","startConsoleCollection","configuration","lifeCycle","consoleSubscription","forwardConsoleLogs","subscribe","notify","RAW_LOG_COLLECTED","rawLogsEvent","date","message","origin","CONSOLE","
|
|
1
|
+
{"version":3,"file":"consoleCollection.js","names":["timeStampNow","ConsoleApiName","ErrorSource","initConsoleObservable","LifeCycleEventType","StatusType","createErrorFieldFromRawError","LogStatusForApi","_LogStatusForApi","_defineProperty","log","info","debug","warn","error","startConsoleCollection","configuration","lifeCycle","consoleSubscription","forwardConsoleLogs","subscribe","notify","RAW_LOG_COLLECTED","rawLogsEvent","date","message","origin","CONSOLE","status","api","domainContext","handlingStack","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/console/consoleCollection.js"],"sourcesContent":["import {\n timeStampNow,\n ConsoleApiName,\n ErrorSource,\n initConsoleObservable,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\nimport { createErrorFieldFromRawError } from '../../createErrorFieldFromRawError'\nvar LogStatusForApi = {\n [ConsoleApiName.log]: StatusType.info,\n [ConsoleApiName.debug]: StatusType.debug,\n [ConsoleApiName.info]: StatusType.info,\n [ConsoleApiName.warn]: StatusType.warn,\n [ConsoleApiName.error]: StatusType.error\n}\nexport function startConsoleCollection(configuration, lifeCycle) {\n var consoleSubscription = initConsoleObservable(\n configuration.forwardConsoleLogs\n ).subscribe(function (log) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: timeStampNow(),\n message: log.message,\n origin: ErrorSource.CONSOLE,\n error: log.error && createErrorFieldFromRawError(log.error),\n status: LogStatusForApi[log.api]\n },\n domainContext: {\n handlingStack: log.handlingStack\n }\n })\n })\n\n return {\n stop: function () {\n consoleSubscription.unsubscribe()\n }\n }\n}\n"],"mappings":";;;;;AAAA,SACEA,YAAY,EACZC,cAAc,EACdC,WAAW,EACXC,qBAAqB,EACrBC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,4BAA4B,QAAQ,oCAAoC;AACjF,IAAIC,eAAe,IAAAC,gBAAA,OAAAC,eAAA,CAAAD,gBAAA,EAChBP,cAAc,CAACS,GAAG,EAAGL,UAAU,CAACM,IAAI,GAAAF,eAAA,CAAAD,gBAAA,EACpCP,cAAc,CAACW,KAAK,EAAGP,UAAU,CAACO,KAAK,GAAAH,eAAA,CAAAD,gBAAA,EACvCP,cAAc,CAACU,IAAI,EAAGN,UAAU,CAACM,IAAI,GAAAF,eAAA,CAAAD,gBAAA,EACrCP,cAAc,CAACY,IAAI,EAAGR,UAAU,CAACQ,IAAI,GAAAJ,eAAA,CAAAD,gBAAA,EACrCP,cAAc,CAACa,KAAK,EAAGT,UAAU,CAACS,KAAK,GAAAN,gBAAA,CACzC;AACD,OAAO,SAASO,sBAAsBA,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC/D,IAAIC,mBAAmB,GAAGf,qBAAqB,CAC7Ca,aAAa,CAACG,kBAChB,CAAC,CAACC,SAAS,CAAC,UAAUV,GAAG,EAAE;IACzBO,SAAS,CAACI,MAAM,CAACjB,kBAAkB,CAACkB,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAExB,YAAY,CAAC,CAAC;QACpByB,OAAO,EAAEf,GAAG,CAACe,OAAO;QACpBC,MAAM,EAAExB,WAAW,CAACyB,OAAO;QAC3Bb,KAAK,EAAEJ,GAAG,CAACI,KAAK,IAAIR,4BAA4B,CAACI,GAAG,CAACI,KAAK,CAAC;QAC3Dc,MAAM,EAAErB,eAAe,CAACG,GAAG,CAACmB,GAAG;MACjC,CAAC;MACDC,aAAa,EAAE;QACbC,aAAa,EAAErB,GAAG,CAACqB;MACrB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBd,mBAAmB,CAACe,WAAW,CAAC,CAAC;IACnC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,28 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { includes, extend2Lev, ErrorSource, timeStampNow, LifeCycleEventType, isArray, originalConsoleMethods } from '@cloudcare/browser-core';
|
|
2
|
+
import { HandlerType } from '../../logger';
|
|
3
|
+
export var STATUS_PRIORITIES = {
|
|
4
|
+
ok: 0,
|
|
5
|
+
debug: 1,
|
|
6
|
+
info: 2,
|
|
7
|
+
notice: 4,
|
|
8
|
+
warn: 5,
|
|
9
|
+
error: 6,
|
|
10
|
+
critical: 7,
|
|
11
|
+
alert: 8,
|
|
12
|
+
emerg: 9
|
|
13
|
+
};
|
|
9
14
|
export function startLoggerCollection(lifeCycle) {
|
|
10
|
-
function handleLog(logsMessage, logger, savedCommonContext, savedDate) {
|
|
11
|
-
var messageContext = logsMessage.context;
|
|
15
|
+
function handleLog(logsMessage, logger, handlingStack, savedCommonContext, savedDate) {
|
|
16
|
+
var messageContext = extend2Lev(logger.getContext(), logsMessage.context);
|
|
12
17
|
if (isAuthorized(logsMessage.status, HandlerType.console, logger)) {
|
|
13
|
-
|
|
18
|
+
displayInConsole(logsMessage, messageContext);
|
|
19
|
+
}
|
|
20
|
+
if (isAuthorized(logsMessage.status, HandlerType.http, logger)) {
|
|
21
|
+
var rawLogEventData = {
|
|
22
|
+
rawLogsEvent: {
|
|
23
|
+
date: savedDate || timeStampNow(),
|
|
24
|
+
message: logsMessage.message,
|
|
25
|
+
status: logsMessage.status,
|
|
26
|
+
origin: ErrorSource.LOGGER
|
|
27
|
+
},
|
|
28
|
+
messageContext: messageContext,
|
|
29
|
+
savedCommonContext: savedCommonContext
|
|
30
|
+
};
|
|
31
|
+
if (handlingStack) {
|
|
32
|
+
rawLogEventData.domainContext = {
|
|
33
|
+
handlingStack: handlingStack
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, rawLogEventData);
|
|
14
37
|
}
|
|
15
|
-
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
16
|
-
rawLogsEvent: {
|
|
17
|
-
date: savedDate || timeStampNow(),
|
|
18
|
-
message: logsMessage.message,
|
|
19
|
-
status: logsMessage.status,
|
|
20
|
-
origin: ErrorSource.LOGGER
|
|
21
|
-
},
|
|
22
|
-
messageContext: messageContext,
|
|
23
|
-
savedCommonContext: savedCommonContext,
|
|
24
|
-
logger: logger
|
|
25
|
-
});
|
|
26
38
|
}
|
|
27
39
|
return {
|
|
28
40
|
handleLog: handleLog
|
|
@@ -33,4 +45,9 @@ export function isAuthorized(status, handlerType, logger) {
|
|
|
33
45
|
var sanitizedHandlerType = isArray(loggerHandler) ? loggerHandler : [loggerHandler];
|
|
34
46
|
return STATUS_PRIORITIES[status] >= STATUS_PRIORITIES[logger.getLevel()] && includes(sanitizedHandlerType, handlerType);
|
|
35
47
|
}
|
|
48
|
+
function displayInConsole(data, messageContext) {
|
|
49
|
+
var status = data.status;
|
|
50
|
+
var message = data.message;
|
|
51
|
+
originalConsoleMethods[loggerToConsoleApiName[status]].call(globalConsole, message, messageContext);
|
|
52
|
+
}
|
|
36
53
|
//# sourceMappingURL=loggerCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerCollection.js","names":["includes","
|
|
1
|
+
{"version":3,"file":"loggerCollection.js","names":["includes","extend2Lev","ErrorSource","timeStampNow","LifeCycleEventType","isArray","originalConsoleMethods","HandlerType","STATUS_PRIORITIES","ok","debug","info","notice","warn","error","critical","alert","emerg","startLoggerCollection","lifeCycle","handleLog","logsMessage","logger","handlingStack","savedCommonContext","savedDate","messageContext","getContext","context","isAuthorized","status","console","displayInConsole","http","rawLogEventData","rawLogsEvent","date","message","origin","LOGGER","domainContext","notify","RAW_LOG_COLLECTED","handlerType","loggerHandler","getHandler","sanitizedHandlerType","getLevel","data","loggerToConsoleApiName","call","globalConsole"],"sources":["../../../../src/domain/logsCollection/logger/loggerCollection.js"],"sourcesContent":["import {\n includes,\n extend2Lev,\n ErrorSource,\n timeStampNow,\n LifeCycleEventType,\n isArray,\n originalConsoleMethods\n} from '@cloudcare/browser-core'\nimport { HandlerType } from '../../logger'\n\nexport var STATUS_PRIORITIES = {\n ok: 0,\n debug: 1,\n info: 2,\n notice: 4,\n warn: 5,\n error: 6,\n critical: 7,\n alert: 8,\n emerg: 9\n}\n\nexport function startLoggerCollection(lifeCycle) {\n function handleLog(\n logsMessage,\n logger,\n handlingStack,\n savedCommonContext,\n savedDate\n ) {\n var messageContext = extend2Lev(logger.getContext(), logsMessage.context)\n if (isAuthorized(logsMessage.status, HandlerType.console, logger)) {\n displayInConsole(logsMessage, messageContext)\n }\n if (isAuthorized(logsMessage.status, HandlerType.http, logger)) {\n var rawLogEventData = {\n rawLogsEvent: {\n date: savedDate || timeStampNow(),\n message: logsMessage.message,\n status: logsMessage.status,\n origin: ErrorSource.LOGGER\n },\n messageContext: messageContext,\n savedCommonContext: savedCommonContext\n }\n if (handlingStack) {\n rawLogEventData.domainContext = { handlingStack }\n }\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, rawLogEventData)\n }\n }\n\n return {\n handleLog: handleLog\n }\n}\n\nexport function isAuthorized(status, handlerType, logger) {\n var loggerHandler = logger.getHandler()\n var sanitizedHandlerType = isArray(loggerHandler)\n ? loggerHandler\n : [loggerHandler]\n return (\n STATUS_PRIORITIES[status] >= STATUS_PRIORITIES[logger.getLevel()] &&\n includes(sanitizedHandlerType, handlerType)\n )\n}\nfunction displayInConsole(data, messageContext) {\n var status = data.status\n var message = data.message\n originalConsoleMethods[loggerToConsoleApiName[status]].call(\n globalConsole,\n message,\n messageContext\n )\n}\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,kBAAkB,EAClBC,OAAO,EACPC,sBAAsB,QACjB,yBAAyB;AAChC,SAASC,WAAW,QAAQ,cAAc;AAE1C,OAAO,IAAIC,iBAAiB,GAAG;EAC7BC,EAAE,EAAE,CAAC;EACLC,KAAK,EAAE,CAAC;EACRC,IAAI,EAAE,CAAC;EACPC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,QAAQ,EAAE,CAAC;EACXC,KAAK,EAAE,CAAC;EACRC,KAAK,EAAE;AACT,CAAC;AAED,OAAO,SAASC,qBAAqBA,CAACC,SAAS,EAAE;EAC/C,SAASC,SAAS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QAAQ,CAAC,CAAC,CAAC,IACjE/C,QAAQ,CAAC8C,oBAAoB,EAAEH,WAAW,CAAC;AAE/C;AACA,SAASX,gBAAgBA,CAACgB,IAAI,EAAEtB,cAAc,EAAE;EAC9C,IAAII,MAAM,GAAGkB,IAAI,CAAClB,MAAM;EACxB,IAAIO,OAAO,GAAGW,IAAI,CAACX,OAAO;EAC1B/B,sBAAsB,CAAC2C,sBAAsB,CAACnB,MAAM,CAAC,CAAC,CAACoB,IAAI,CACzDC,aAAa,EACbd,OAAO,EACPX,cACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSource, initXhrObservable, RequestType, initFetchObservable, computeStackTrace, toStackTraceString, noop,
|
|
1
|
+
import { ErrorSource, initXhrObservable, RequestType, initFetchObservable, computeStackTrace, toStackTraceString, noop, LifeCycleEventType, getStatusGroup, urlParse, replaceNumberCharByPath, tryToClone, readBytesFromStream, monitor, isIntakeRequest } from '@cloudcare/browser-core';
|
|
2
2
|
import { StatusType } from '../../logger';
|
|
3
3
|
export function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
4
4
|
if (!configuration.forwardErrorsToLogs) {
|
|
@@ -8,15 +8,15 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
8
8
|
}
|
|
9
9
|
var xhrSubscription = initXhrObservable().subscribe(function (context) {
|
|
10
10
|
if (context.state === 'complete') {
|
|
11
|
-
|
|
11
|
+
handleResponse(RequestType.XHR, context);
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
var fetchSubscription = initFetchObservable().subscribe(function (context) {
|
|
15
15
|
if (context.state === 'resolve') {
|
|
16
|
-
|
|
16
|
+
handleResponse(RequestType.FETCH, context);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
function
|
|
19
|
+
function handleResponse(type, request) {
|
|
20
20
|
if (!isIntakeRequest(request.url, configuration) && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
|
|
21
21
|
if ('xhr' in request) {
|
|
22
22
|
computeXhrResponseData(request.xhr, configuration, onResponseDataAvailable);
|
|
@@ -27,14 +27,18 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function onResponseDataAvailable(responseData) {
|
|
30
|
+
var domainContext = {
|
|
31
|
+
isAborted: request.isAborted,
|
|
32
|
+
handlingStack: request.handlingStack
|
|
33
|
+
};
|
|
30
34
|
var urlObj = urlParse(request.url).getParse();
|
|
31
35
|
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
32
36
|
rawLogsEvent: {
|
|
33
37
|
message: format(type) + ' error ' + request.method + ' ' + request.url,
|
|
34
38
|
date: request.startClocks.timeStamp,
|
|
35
39
|
error: {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
stack: responseData || 'Failed to load',
|
|
41
|
+
handing: undefined
|
|
38
42
|
},
|
|
39
43
|
http: {
|
|
40
44
|
method: request.method,
|
|
@@ -47,7 +51,8 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
47
51
|
},
|
|
48
52
|
status: StatusType.error,
|
|
49
53
|
origin: ErrorSource.NETWORK
|
|
50
|
-
}
|
|
54
|
+
},
|
|
55
|
+
domainContext: domainContext
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networkErrorCollection.js","names":["ErrorSource","initXhrObservable","RequestType","initFetchObservable","computeStackTrace","toStackTraceString","noop","each","LifeCycleEventType","getStatusGroup","urlParse","replaceNumberCharByPath","tryToClone","readBytesFromStream","monitor","isIntakeRequest","StatusType","startNetworkErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","xhrSubscription","subscribe","context","state","handleCompleteRequest","XHR","fetchSubscription","FETCH","type","request","url","isRejected","isServerError","computeXhrResponseData","xhr","onResponseDataAvailable","response","computeFetchResponseText","error","computeFetchErrorText","responseData","urlObj","getParse","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","format","method","date","startClocks","timeStamp","origin","NETWORK","stack","http","status_code","status","statusGroup","urlHost","Host","urlPath","Path","urlPathGroup","unsubscribe","callback","truncateResponseText","clonedResponse","body","window","TextDecoder","text","then","truncateResponseStream","requestErrorResponseLengthLimit","responseText","responseType","length","substring","stream","bytesLimit","bytes","limitExceeded","decode","undefined","collectStreamBody"],"sources":["../../../../src/domain/logsCollection/networkError/networkErrorCollection.js"],"sourcesContent":["import {\n ErrorSource,\n initXhrObservable,\n RequestType,\n initFetchObservable,\n computeStackTrace,\n toStackTraceString,\n noop,\n each,\n LifeCycleEventType,\n getStatusGroup,\n urlParse,\n replaceNumberCharByPath,\n tryToClone,\n readBytesFromStream,\n monitor,\n isIntakeRequest\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nexport function startNetworkErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var xhrSubscription = initXhrObservable().subscribe(function (context) {\n if (context.state === 'complete') {\n handleCompleteRequest(RequestType.XHR, context)\n }\n })\n var fetchSubscription = initFetchObservable().subscribe(function (context) {\n if (context.state === 'resolve') {\n handleCompleteRequest(RequestType.FETCH, context)\n }\n })\n\n function handleCompleteRequest(type, request) {\n if (\n !isIntakeRequest(request.url, configuration) &&\n (isRejected(request) ||\n isServerError(request) ||\n configuration.isServerError(request))\n ) {\n if ('xhr' in request) {\n computeXhrResponseData(\n request.xhr,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.response) {\n computeFetchResponseText(\n request.response,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.error) {\n computeFetchErrorText(\n request.error,\n configuration,\n onResponseDataAvailable\n )\n }\n }\n\n function onResponseDataAvailable(responseData) {\n var urlObj = urlParse(request.url).getParse()\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message:\n format(type) + ' error ' + request.method + ' ' + request.url,\n date: request.startClocks.timeStamp,\n error: {\n origin: ErrorSource.NETWORK,\n stack: responseData || 'Failed to load'\n },\n http: {\n method: request.method,\n status_code: request.status,\n url: request.url,\n statusGroup: getStatusGroup(request.status),\n urlHost: urlObj.Host,\n urlPath: urlObj.Path,\n urlPathGroup: replaceNumberCharByPath(urlObj.Path)\n },\n status: StatusType.error,\n origin: ErrorSource.NETWORK\n }\n })\n }\n }\n\n return {\n stop: function () {\n xhrSubscription.unsubscribe()\n fetchSubscription.unsubscribe()\n }\n }\n}\n\nexport function computeXhrResponseData(xhr, configuration, callback) {\n if (typeof xhr.response === 'string') {\n callback(truncateResponseText(xhr.response, configuration))\n } else {\n callback(xhr.response)\n }\n}\n\nexport function computeFetchErrorText(error, configuration, callback) {\n callback(\n truncateResponseText(\n toStackTraceString(computeStackTrace(error)),\n configuration\n )\n )\n}\n\nexport function computeFetchResponseText(response, configuration, callback) {\n var clonedResponse = tryToClone(response)\n if (!clonedResponse || !clonedResponse.body) {\n // if the clone failed or if the body is null, let's not try to read it.\n callback()\n } else if (!window.TextDecoder) {\n // If the browser doesn't support TextDecoder, let's read the whole response then truncate it.\n //\n // This should only be the case on early versions of Edge (before they migrated to Chromium).\n // Even if it could be possible to implement a workaround for the missing TextDecoder API (using\n // a Blob and FileReader), we found another issue preventing us from reading only the first\n // bytes from the response: contrary to other browsers, when reading from the cloned response,\n // if the original response gets canceled, the cloned response is also canceled and we can't\n // know about it. In the following illustration, the promise returned by `reader.read()` may\n // never be fulfilled:\n //\n // fetch('/').then((response) => {\n // const reader = response.clone().body.getReader()\n // readMore()\n // function readMore() {\n // reader.read().then(\n // (result) => {\n // if (result.done) {\n // console.log('done')\n // } else {\n // readMore()\n // }\n // },\n // () => console.log('error')\n // )\n // }\n // response.body.getReader().cancel()\n // })\n clonedResponse.text().then(\n monitor(function (text) {\n return callback(truncateResponseText(text, configuration))\n }),\n monitor(function (error) {\n return callback('Unable to retrieve response: ' + error)\n })\n )\n } else {\n truncateResponseStream(\n clonedResponse.body,\n configuration.requestErrorResponseLengthLimit,\n function (error, responseText) {\n if (error) {\n callback('Unable to retrieve response: ' + error)\n } else {\n callback(responseText)\n }\n }\n )\n }\n}\n\nfunction isRejected(request) {\n return request.status === 0 && request.responseType !== 'opaque'\n}\n\nfunction isServerError(request) {\n return request.status >= 500\n}\n\nfunction truncateResponseText(responseText, configuration) {\n if (responseText.length > configuration.requestErrorResponseLengthLimit) {\n return (\n responseText.substring(0, configuration.requestErrorResponseLengthLimit) +\n '...'\n )\n }\n return responseText\n}\n\nfunction format(type) {\n if (RequestType.XHR === type) {\n return 'XHR'\n }\n return 'Fetch'\n}\n\nfunction truncateResponseStream(stream, bytesLimit, callback) {\n readBytesFromStream(\n stream,\n function (error, bytes, limitExceeded) {\n if (error) {\n callback(error)\n } else {\n var responseText = new TextDecoder().decode(bytes)\n if (limitExceeded) {\n responseText += '...'\n }\n callback(undefined, responseText)\n }\n },\n {\n bytesLimit: bytesLimit,\n collectStreamBody: true\n }\n )\n}\n"],"mappings":"AAAA,SACEA,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,IAAI,EACJC,IAAI,EACJC,kBAAkB,EAClBC,cAAc,EACdC,QAAQ,EACRC,uBAAuB,EACvBC,UAAU,EACVC,mBAAmB,EACnBC,OAAO,EACPC,eAAe,QACV,yBAAyB;AAChC,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,SAASC,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEf;IAAK,CAAC;EACvB;EAEA,IAAIgB,eAAe,GAAGrB,iBAAiB,CAAC,CAAC,CAACsB,SAAS,CAAC,UAAUC,OAAO,EAAE;IACrE,IAAIA,OAAO,CAACC,KAAK,KAAK,UAAU,EAAE;MAChCC,qBAAqB,CAACxB,WAAW,CAACy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C4B,MAAM,IAAI,GAAG;AAC9B;AAEA,SAASS,oBAAoBA,CAACS,YAAY,EAAE3D,aAAa,EAAE;EACzD,IAAI2D,YAAY,CAACE,MAAM,GAAG7D,aAAa,CAAC0D,+BAA+B,EAAE;IACvE,OACEC,YAAY,CAACG,SAAS,CAAC,CAAC,EAAE9D,aAAa,CAAC0D,+BAA+B,CAAC,GACxE,KAAK;EAET;EACA,OAAOC,YAAY;AACrB;AAEA,SAAS5B,MAAMA,CAACnB,IAAI,EAAE;EACpB,IAAI5B,WAAW,CAACyB,GAAG,KAAKG,IAAI,EAAE;IAC5B,OAAO,KAAK;EACd;EACA,OAAO,OAAO;AAChB;AAEA,SAAS6C,sBAAsBA,CAACM,MAAM,EAAEC,UAAU,EAAEf,QAAQ,EAAE;EAC5DtD,mBAAmB,CACjBoE,MAAM,EACN,UAAUzC,KAAK,EAAE2C,KAAK,EAAEC,aAAa,EAAE;IACrC,IAAI5C,KAAK,EAAE;MACT2B,QAAQ,CAAC3B,KAAK,CAAC;IACjB,CAAC,MAAM;MACL,IAAIqC,YAAY,GAAG,IAAIL,WAAW,CAAC,CAAC,CAACa,MAAM,CAACF,KAAK,CAAC;MAClD,IAAIC,aAAa,EAAE;QACjBP,YAAY,IAAI,KAAK;MACvB;MACAV,QAAQ,CAACmB,SAAS,EAAET,YAAY,CAAC;IACnC;EACF,CAAC,EACD;IACEK,UAAU,EAAEA,UAAU;IACtBK,iBAAiB,EAAE;EACrB,CACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"networkErrorCollection.js","names":["ErrorSource","initXhrObservable","RequestType","initFetchObservable","computeStackTrace","toStackTraceString","noop","LifeCycleEventType","getStatusGroup","urlParse","replaceNumberCharByPath","tryToClone","readBytesFromStream","monitor","isIntakeRequest","StatusType","startNetworkErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","xhrSubscription","subscribe","context","state","handleResponse","XHR","fetchSubscription","FETCH","type","request","url","isRejected","isServerError","computeXhrResponseData","xhr","onResponseDataAvailable","response","computeFetchResponseText","error","computeFetchErrorText","responseData","domainContext","isAborted","handlingStack","urlObj","getParse","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","format","method","date","startClocks","timeStamp","stack","handing","undefined","http","status_code","status","statusGroup","urlHost","Host","urlPath","Path","urlPathGroup","origin","NETWORK","unsubscribe","callback","truncateResponseText","clonedResponse","body","window","TextDecoder","text","then","truncateResponseStream","requestErrorResponseLengthLimit","responseText","responseType","length","substring","stream","bytesLimit","bytes","limitExceeded","decode","collectStreamBody"],"sources":["../../../../src/domain/logsCollection/networkError/networkErrorCollection.js"],"sourcesContent":["import {\n ErrorSource,\n initXhrObservable,\n RequestType,\n initFetchObservable,\n computeStackTrace,\n toStackTraceString,\n noop,\n LifeCycleEventType,\n getStatusGroup,\n urlParse,\n replaceNumberCharByPath,\n tryToClone,\n readBytesFromStream,\n monitor,\n isIntakeRequest\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nexport function startNetworkErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var xhrSubscription = initXhrObservable().subscribe(function (context) {\n if (context.state === 'complete') {\n handleResponse(RequestType.XHR, context)\n }\n })\n var fetchSubscription = initFetchObservable().subscribe(function (context) {\n if (context.state === 'resolve') {\n handleResponse(RequestType.FETCH, context)\n }\n })\n\n function handleResponse(type, request) {\n if (\n !isIntakeRequest(request.url, configuration) &&\n (isRejected(request) ||\n isServerError(request) ||\n configuration.isServerError(request))\n ) {\n if ('xhr' in request) {\n computeXhrResponseData(\n request.xhr,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.response) {\n computeFetchResponseText(\n request.response,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.error) {\n computeFetchErrorText(\n request.error,\n configuration,\n onResponseDataAvailable\n )\n }\n }\n\n function onResponseDataAvailable(responseData) {\n var domainContext = {\n isAborted: request.isAborted,\n handlingStack: request.handlingStack\n }\n var urlObj = urlParse(request.url).getParse()\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message:\n format(type) + ' error ' + request.method + ' ' + request.url,\n date: request.startClocks.timeStamp,\n error: {\n stack: responseData || 'Failed to load',\n handing: undefined\n },\n http: {\n method: request.method,\n status_code: request.status,\n url: request.url,\n statusGroup: getStatusGroup(request.status),\n urlHost: urlObj.Host,\n urlPath: urlObj.Path,\n urlPathGroup: replaceNumberCharByPath(urlObj.Path)\n },\n status: StatusType.error,\n origin: ErrorSource.NETWORK\n },\n domainContext: domainContext\n })\n }\n }\n\n return {\n stop: function () {\n xhrSubscription.unsubscribe()\n fetchSubscription.unsubscribe()\n }\n }\n}\n\nexport function computeXhrResponseData(xhr, configuration, callback) {\n if (typeof xhr.response === 'string') {\n callback(truncateResponseText(xhr.response, configuration))\n } else {\n callback(xhr.response)\n }\n}\n\nexport function computeFetchErrorText(error, configuration, callback) {\n callback(\n truncateResponseText(\n toStackTraceString(computeStackTrace(error)),\n configuration\n )\n )\n}\n\nexport function computeFetchResponseText(response, configuration, callback) {\n var clonedResponse = tryToClone(response)\n if (!clonedResponse || !clonedResponse.body) {\n // if the clone failed or if the body is null, let's not try to read it.\n callback()\n } else if (!window.TextDecoder) {\n // If the browser doesn't support TextDecoder, let's read the whole response then truncate it.\n //\n // This should only be the case on early versions of Edge (before they migrated to Chromium).\n // Even if it could be possible to implement a workaround for the missing TextDecoder API (using\n // a Blob and FileReader), we found another issue preventing us from reading only the first\n // bytes from the response: contrary to other browsers, when reading from the cloned response,\n // if the original response gets canceled, the cloned response is also canceled and we can't\n // know about it. In the following illustration, the promise returned by `reader.read()` may\n // never be fulfilled:\n //\n // fetch('/').then((response) => {\n // const reader = response.clone().body.getReader()\n // readMore()\n // function readMore() {\n // reader.read().then(\n // (result) => {\n // if (result.done) {\n // console.log('done')\n // } else {\n // readMore()\n // }\n // },\n // () => console.log('error')\n // )\n // }\n // response.body.getReader().cancel()\n // })\n clonedResponse.text().then(\n monitor(function (text) {\n return callback(truncateResponseText(text, configuration))\n }),\n monitor(function (error) {\n return callback('Unable to retrieve response: ' + error)\n })\n )\n } else {\n truncateResponseStream(\n clonedResponse.body,\n configuration.requestErrorResponseLengthLimit,\n function (error, responseText) {\n if (error) {\n callback('Unable to retrieve response: ' + error)\n } else {\n callback(responseText)\n }\n }\n )\n }\n}\n\nfunction isRejected(request) {\n return request.status === 0 && request.responseType !== 'opaque'\n}\n\nfunction isServerError(request) {\n return request.status >= 500\n}\n\nfunction truncateResponseText(responseText, configuration) {\n if (responseText.length > configuration.requestErrorResponseLengthLimit) {\n return (\n responseText.substring(0, configuration.requestErrorResponseLengthLimit) +\n '...'\n )\n }\n return responseText\n}\n\nfunction format(type) {\n if (RequestType.XHR === type) {\n return 'XHR'\n }\n return 'Fetch'\n}\n\nfunction truncateResponseStream(stream, bytesLimit, callback) {\n readBytesFromStream(\n stream,\n function (error, bytes, limitExceeded) {\n if (error) {\n callback(error)\n } else {\n var responseText = new TextDecoder().decode(bytes)\n if (limitExceeded) {\n responseText += '...'\n }\n callback(undefined, responseText)\n }\n },\n {\n bytesLimit: bytesLimit,\n collectStreamBody: true\n }\n )\n}\n"],"mappings":"AAAA,SACEA,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,IAAI,EACJC,kBAAkB,EAClBC,cAAc,EACdC,QAAQ,EACRC,uBAAuB,EACvBC,UAAU,EACVC,mBAAmB,EACnBC,OAAO,EACPC,eAAe,QACV,yBAAyB;AAChC,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,SAASC,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEd;IAAK,CAAC;EACvB;EAEA,IAAIe,eAAe,GAAGpB,iBAAiB,CAAC,CAAC,CAACqB,SAAS,CAAC,UAAU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AAC;EACH;AACF;AAEA,SAASjD,UAAUA,CAACF,OAAO,EAAE;EAC3B,OAAOA,OAAO,CAAC+B,MAAM,KAAK,CAAC,IAAI/B,OAAO,CAACoD,YAAY,KAAK,QAAQ;AAClE;AAEA,SAASjD,aAAaA,CAACH,OAAO,EAAE;EAC9B,OAAOA,OAAO,CAAC+B,MAAM,IAAI,GAAG;AAC9B;AAEA,SAASW,oBAAoBA,CAACS,YAAY,EAAEhE,aAAa,EAAE;EACzD,IAAIgE,YAAY,CAACE,MAAM,GAAGlE,aAAa,CAAC+D,+BAA+B,EAAE;IACvE,OACEC,YAAY,CAACG,SAAS,CAAC,CAAC,EAAEnE,aAAa,CAAC+D,+BAA+B,CAAC,GACxE,KAAK;EAET;EACA,OAAOC,YAAY;AACrB;AAEA,SAAS9B,MAAMA,CAACtB,IAAI,EAAE;EACpB,IAAI3B,WAAW,CAACwB,GAAG,KAAKG,IAAI,EAAE;IAC5B,OAAO,KAAK;EACd;EACA,OAAO,OAAO;AAChB;AAEA,SAASkD,sBAAsBA,CAACM,MAAM,EAAEC,UAAU,EAAEf,QAAQ,EAAE;EAC5D3D,mBAAmB,CACjByE,MAAM,EACN,UAAU9C,KAAK,EAAEgD,KAAK,EAAEC,aAAa,EAAE;IACrC,IAAIjD,KAAK,EAAE;MACTgC,QAAQ,CAAChC,KAAK,CAAC;IACjB,CAAC,MAAM;MACL,IAAI0C,YAAY,GAAG,IAAIL,WAAW,CAAC,CAAC,CAACa,MAAM,CAACF,KAAK,CAAC;MAClD,IAAIC,aAAa,EAAE;QACjBP,YAAY,IAAI,KAAK;MACvB;MACAV,QAAQ,CAACb,SAAS,EAAEuB,YAAY,CAAC;IACnC;EACF,CAAC,EACD;IACEK,UAAU,EAAEA,UAAU;IACtBI,iBAAiB,EAAE;EACrB,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
-
import { timeStampNow, ErrorSource, RawReportType, getFileFromStackTraceString, initReportObservable, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
1
|
+
import { timeStampNow, ErrorSource, getFileFromStackTraceString, initReportObservable, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
7
2
|
import { StatusType } from '../../logger';
|
|
8
|
-
|
|
3
|
+
import { createErrorFieldFromRawError } from '../../createErrorFieldFromRawError';
|
|
9
4
|
export function startReportCollection(configuration, lifeCycle) {
|
|
10
|
-
var reportSubscription = initReportObservable(configuration, configuration.forwardReports).subscribe(function (
|
|
11
|
-
var message =
|
|
12
|
-
var status =
|
|
5
|
+
var reportSubscription = initReportObservable(configuration, configuration.forwardReports).subscribe(function (rawError) {
|
|
6
|
+
var message = rawError.message;
|
|
7
|
+
var status = rawError.originalError.type === 'deprecation' ? StatusType.warn : StatusType.error;
|
|
13
8
|
var error;
|
|
14
9
|
if (status === StatusType.error) {
|
|
15
|
-
error =
|
|
16
|
-
kind: report.subtype,
|
|
17
|
-
origin: ErrorSource.REPORT,
|
|
18
|
-
stack: report.stack
|
|
19
|
-
};
|
|
10
|
+
error = createErrorFieldFromRawError(rawError);
|
|
20
11
|
} else if (report.stack) {
|
|
21
|
-
message += ' Found in ' + getFileFromStackTraceString(
|
|
12
|
+
message += ' Found in ' + getFileFromStackTraceString(rawError.stack);
|
|
22
13
|
}
|
|
23
14
|
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
24
15
|
rawLogsEvent: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportCollection.js","names":["timeStampNow","ErrorSource","
|
|
1
|
+
{"version":3,"file":"reportCollection.js","names":["timeStampNow","ErrorSource","getFileFromStackTraceString","initReportObservable","LifeCycleEventType","StatusType","createErrorFieldFromRawError","startReportCollection","configuration","lifeCycle","reportSubscription","forwardReports","subscribe","rawError","message","status","originalError","type","warn","error","report","stack","notify","RAW_LOG_COLLECTED","rawLogsEvent","date","origin","REPORT","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/report/reportCollection.js"],"sourcesContent":["import {\n timeStampNow,\n ErrorSource,\n getFileFromStackTraceString,\n initReportObservable,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\nimport { createErrorFieldFromRawError } from '../../createErrorFieldFromRawError'\n\nexport function startReportCollection(configuration, lifeCycle) {\n var reportSubscription = initReportObservable(\n configuration,\n configuration.forwardReports\n ).subscribe(function (rawError) {\n var message = rawError.message\n var status =\n rawError.originalError.type === 'deprecation'\n ? StatusType.warn\n : StatusType.error\n var error\n if (status === StatusType.error) {\n error = createErrorFieldFromRawError(rawError)\n } else if (report.stack) {\n message += ' Found in ' + getFileFromStackTraceString(rawError.stack)\n }\n\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: timeStampNow(),\n message: message,\n origin: ErrorSource.REPORT,\n error: error,\n status: status\n }\n })\n })\n\n return {\n stop: function () {\n reportSubscription.unsubscribe()\n }\n }\n}\n"],"mappings":"AAAA,SACEA,YAAY,EACZC,WAAW,EACXC,2BAA2B,EAC3BC,oBAAoB,EACpBC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,4BAA4B,QAAQ,oCAAoC;AAEjF,OAAO,SAASC,qBAAqBA,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC9D,IAAIC,kBAAkB,GAAGP,oBAAoB,CAC3CK,aAAa,EACbA,aAAa,CAACG,cAChB,CAAC,CAACC,SAAS,CAAC,UAAUC,QAAQ,EAAE;IAC9B,IAAIC,OAAO,GAAGD,QAAQ,CAACC,OAAO;IAC9B,IAAIC,MAAM,GACRF,QAAQ,CAACG,aAAa,CAACC,IAAI,KAAK,aAAa,GACzCZ,UAAU,CAACa,IAAI,GACfb,UAAU,CAACc,KAAK;IACtB,IAAIA,KAAK;IACT,IAAIJ,MAAM,KAAKV,UAAU,CAACc,KAAK,EAAE;MAC/BA,KAAK,GAAGb,4BAA4B,CAACO,QAAQ,CAAC;IAChD,CAAC,MAAM,IAAIO,MAAM,CAACC,KAAK,EAAE;MACvBP,OAAO,IAAI,YAAY,GAAGZ,2BAA2B,CAACW,QAAQ,CAACQ,KAAK,CAAC;IACvE;IAEAZ,SAAS,CAACa,MAAM,CAAClB,kBAAkB,CAACmB,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAEzB,YAAY,CAAC,CAAC;QACpBc,OAAO,EAAEA,OAAO;QAChBY,MAAM,EAAEzB,WAAW,CAAC0B,MAAM;QAC1BR,KAAK,EAAEA,KAAK;QACZJ,MAAM,EAAEA;MACV;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLa,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBlB,kBAAkB,CAACmB,WAAW,CAAC,CAAC;IAClC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { noop, ErrorSource, trackRuntimeError, Observable, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
2
2
|
import { StatusType } from '../../logger';
|
|
3
|
+
import { createErrorFieldFromRawError } from '../../createErrorFieldFromRawError';
|
|
3
4
|
export function startRuntimeErrorCollection(configuration, lifeCycle) {
|
|
4
5
|
if (!configuration.forwardErrorsToLogs) {
|
|
5
6
|
return {
|
|
@@ -13,11 +14,7 @@ export function startRuntimeErrorCollection(configuration, lifeCycle) {
|
|
|
13
14
|
rawLogsEvent: {
|
|
14
15
|
message: rawError.message,
|
|
15
16
|
date: rawError.startClocks.timeStamp,
|
|
16
|
-
error:
|
|
17
|
-
kind: rawError.type,
|
|
18
|
-
stack: rawError.stack,
|
|
19
|
-
causes: rawError.causes
|
|
20
|
-
},
|
|
17
|
+
error: createErrorFieldFromRawError(rawError),
|
|
21
18
|
origin: ErrorSource.SOURCE,
|
|
22
19
|
status: StatusType.error
|
|
23
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeErrorCollection.js","names":["noop","ErrorSource","trackRuntimeError","Observable","LifeCycleEventType","StatusType","startRuntimeErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","rawErrorObservable","_trackRuntimeError","rawErrorSubscription","subscribe","rawError","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","error","
|
|
1
|
+
{"version":3,"file":"runtimeErrorCollection.js","names":["noop","ErrorSource","trackRuntimeError","Observable","LifeCycleEventType","StatusType","createErrorFieldFromRawError","startRuntimeErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","rawErrorObservable","_trackRuntimeError","rawErrorSubscription","subscribe","rawError","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","error","origin","SOURCE","status","unsubscribe"],"sources":["../../../../src/domain/logsCollection/rumtimeError/runtimeErrorCollection.js"],"sourcesContent":["import {\n noop,\n ErrorSource,\n trackRuntimeError,\n Observable,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\nimport { createErrorFieldFromRawError } from '../../createErrorFieldFromRawError'\nexport function startRuntimeErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var rawErrorObservable = new Observable()\n\n var _trackRuntimeError = trackRuntimeError(rawErrorObservable)\n\n var rawErrorSubscription = rawErrorObservable.subscribe(function (rawError) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message: rawError.message,\n date: rawError.startClocks.timeStamp,\n error: createErrorFieldFromRawError(rawError),\n origin: ErrorSource.SOURCE,\n status: StatusType.error\n }\n })\n })\n\n return {\n stop: function () {\n _trackRuntimeError.stop()\n rawErrorSubscription.unsubscribe()\n }\n }\n}\n"],"mappings":"AAAA,SACEA,IAAI,EACJC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,EACVC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,4BAA4B,QAAQ,oCAAoC;AACjF,OAAO,SAASC,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEX;IAAK,CAAC;EACvB;EAEA,IAAIY,kBAAkB,GAAG,IAAIT,UAAU,CAAC,CAAC;EAEzC,IAAIU,kBAAkB,GAAGX,iBAAiB,CAACU,kBAAkB,CAAC;EAE9D,IAAIE,oBAAoB,GAAGF,kBAAkB,CAACG,SAAS,CAAC,UAAUC,QAAQ,EAAE;IAC1EP,SAAS,CAACQ,MAAM,CAACb,kBAAkB,CAACc,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEJ,QAAQ,CAACI,OAAO;QACzBC,IAAI,EAAEL,QAAQ,CAACM,WAAW,CAACC,SAAS;QACpCC,KAAK,EAAElB,4BAA4B,CAACU,QAAQ,CAAC;QAC7CS,MAAM,EAAExB,WAAW,CAACyB,MAAM;QAC1BC,MAAM,EAAEtB,UAAU,CAACmB;MACrB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLb,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBE,kBAAkB,CAACF,IAAI,CAAC,CAAC;MACzBG,oBAAoB,CAACc,WAAW,CAAC,CAAC;IACpC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ErrorSource, LifeCycleEventType, addTelemetryDebug } from '@cloudcare/browser-core';
|
|
2
|
+
import { StatusType } from './logger';
|
|
3
|
+
export function startReportError(lifeCycle) {
|
|
4
|
+
return function (error) {
|
|
5
|
+
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
6
|
+
rawLogsEvent: {
|
|
7
|
+
message: error.message,
|
|
8
|
+
date: error.startClocks.timeStamp,
|
|
9
|
+
origin: ErrorSource.AGENT,
|
|
10
|
+
status: StatusType.error
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
addTelemetryDebug('Error reported to customer', {
|
|
14
|
+
'error.message': error.message
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=reportError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportError.js","names":["ErrorSource","LifeCycleEventType","addTelemetryDebug","StatusType","startReportError","lifeCycle","error","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","origin","AGENT","status"],"sources":["../../src/domain/reportError.js"],"sourcesContent":["import {\n ErrorSource,\n LifeCycleEventType,\n addTelemetryDebug\n} from '@cloudcare/browser-core'\nimport { StatusType } from './logger'\nexport function startReportError(lifeCycle) {\n return function (error) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message: error.message,\n date: error.startClocks.timeStamp,\n origin: ErrorSource.AGENT,\n status: StatusType.error\n }\n })\n addTelemetryDebug('Error reported to customer', {\n 'error.message': error.message\n })\n }\n}\n"],"mappings":"AAAA,SACEA,WAAW,EACXC,kBAAkB,EAClBC,iBAAiB,QACZ,yBAAyB;AAChC,SAASC,UAAU,QAAQ,UAAU;AACrC,OAAO,SAASC,gBAAgBA,CAACC,SAAS,EAAE;EAC1C,OAAO,UAAUC,KAAK,EAAE;IACtBD,SAAS,CAACE,MAAM,CAACN,kBAAkB,CAACO,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEJ,KAAK,CAACI,OAAO;QACtBC,IAAI,EAAEL,KAAK,CAACM,WAAW,CAACC,SAAS;QACjCC,MAAM,EAAEd,WAAW,CAACe,KAAK;QACzBC,MAAM,EAAEb,UAAU,CAACG;MACrB;IACF,CAAC,CAAC;IACFJ,iBAAiB,CAAC,4BAA4B,EAAE;MAC9C,eAAe,EAAEI,KAAK,CAACI;IACzB,CAAC,CAAC;EACJ,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { startBatchWithReplica, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
2
|
-
export function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable,
|
|
3
|
-
var batch = startBatchWithReplica(configuration,
|
|
1
|
+
import { startBatchWithReplica, LifeCycleEventType, createIdentityEncoder } from '@cloudcare/browser-core';
|
|
2
|
+
export function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session) {
|
|
3
|
+
var batch = startBatchWithReplica(configuration, {
|
|
4
|
+
endpoint: configuration.logsEndpoint,
|
|
5
|
+
encoder: createIdentityEncoder()
|
|
6
|
+
}, reportError, pageExitObservable, session.expireObservable);
|
|
4
7
|
lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, function (serverLogsEvent) {
|
|
5
8
|
batch.add(serverLogsEvent);
|
|
6
9
|
});
|
|
10
|
+
return batch;
|
|
7
11
|
}
|
|
8
12
|
//# sourceMappingURL=startLogsBatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startLogsBatch.js","names":["startBatchWithReplica","LifeCycleEventType","startLogsBatch","configuration","lifeCycle","reportError","pageExitObservable","
|
|
1
|
+
{"version":3,"file":"startLogsBatch.js","names":["startBatchWithReplica","LifeCycleEventType","createIdentityEncoder","startLogsBatch","configuration","lifeCycle","reportError","pageExitObservable","session","batch","endpoint","logsEndpoint","encoder","expireObservable","subscribe","LOG_COLLECTED","serverLogsEvent","add"],"sources":["../../src/transport/startLogsBatch.js"],"sourcesContent":["import {\n startBatchWithReplica,\n LifeCycleEventType,\n createIdentityEncoder\n} from '@cloudcare/browser-core'\n\nexport function startLogsBatch(\n configuration,\n lifeCycle,\n reportError,\n pageExitObservable,\n session\n) {\n var batch = startBatchWithReplica(\n configuration,\n { endpoint: configuration.logsEndpoint, encoder: createIdentityEncoder() },\n reportError,\n pageExitObservable,\n session.expireObservable\n )\n\n lifeCycle.subscribe(\n LifeCycleEventType.LOG_COLLECTED,\n function (serverLogsEvent) {\n batch.add(serverLogsEvent)\n }\n )\n return batch\n}\n"],"mappings":"AAAA,SACEA,qBAAqB,EACrBC,kBAAkB,EAClBC,qBAAqB,QAChB,yBAAyB;AAEhC,OAAO,SAASC,cAAcA,CAC5BC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,kBAAkB,EAClBC,OAAO,EACP;EACA,IAAIC,KAAK,GAAGT,qBAAqB,CAC/BI,aAAa,EACb;IAAEM,QAAQ,EAAEN,aAAa,CAACO,YAAY;IAAEC,OAAO,EAAEV,qBAAqB,CAAC;EAAE,CAAC,EAC1EI,WAAW,EACXC,kBAAkB,EAClBC,OAAO,CAACK,gBACV,CAAC;EAEDR,SAAS,CAACS,SAAS,CACjBb,kBAAkB,CAACc,aAAa,EAChC,UAAUC,eAAe,EAAE;IACzBP,KAAK,CAACQ,GAAG,CAACD,eAAe,CAAC;EAC5B,CACF,CAAC;EACD,OAAOP,KAAK;AACd","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
"name": "@cloudcare/browser-logs",
|
|
3
3
|
"main": "cjs/index.js",
|
|
4
4
|
"module": "esm/index.js",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.2.0",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"@cloudcare/browser-core": "3.
|
|
8
|
+
"@cloudcare/browser-core": "3.2.0"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"dev": "webpack serve --open --mode=development",
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"author": "dataflux",
|
|
31
32
|
"license": "MIT",
|
|
32
33
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "81a7f878553edc3a3fe9eb57779cad505c55d4de"
|
|
34
35
|
}
|