@cloudcare/browser-logs 3.1.24 → 3.2.2
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 +3 -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 +90 -64
- 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
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.startConsoleCollection = startConsoleCollection;
|
|
7
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
8
8
|
var _logger = require("../../logger");
|
|
9
|
+
var _createErrorFieldFromRawError = require("../../createErrorFieldFromRawError");
|
|
9
10
|
var _LogStatusForApi;
|
|
10
11
|
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); }
|
|
11
12
|
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; }
|
|
@@ -19,12 +20,11 @@ function startConsoleCollection(configuration, lifeCycle) {
|
|
|
19
20
|
date: (0, _browserCore.timeStampNow)(),
|
|
20
21
|
message: log.message,
|
|
21
22
|
origin: _browserCore.ErrorSource.CONSOLE,
|
|
22
|
-
error: log.
|
|
23
|
-
origin: _browserCore.ErrorSource.CONSOLE,
|
|
24
|
-
stack: log.stack,
|
|
25
|
-
causes: log.causes
|
|
26
|
-
} : undefined,
|
|
23
|
+
error: log.error && (0, _createErrorFieldFromRawError.createErrorFieldFromRawError)(log.error),
|
|
27
24
|
status: LogStatusForApi[log.api]
|
|
25
|
+
},
|
|
26
|
+
domainContext: {
|
|
27
|
+
handlingStack: log.handlingStack
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleCollection.js","names":["_browserCore","require","_logger","_LogStatusForApi","_typeof","obj","Symbol","iterator","constructor","prototype","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","call","TypeError","Number","LogStatusForApi","ConsoleApiName","log","StatusType","info","debug","warn","error","startConsoleCollection","configuration","lifeCycle","consoleSubscription","initConsoleObservable","forwardConsoleLogs","subscribe","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","date","timeStampNow","message","origin","ErrorSource","CONSOLE","
|
|
1
|
+
{"version":3,"file":"consoleCollection.js","names":["_browserCore","require","_logger","_createErrorFieldFromRawError","_LogStatusForApi","_typeof","obj","Symbol","iterator","constructor","prototype","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","call","TypeError","Number","LogStatusForApi","ConsoleApiName","log","StatusType","info","debug","warn","error","startConsoleCollection","configuration","lifeCycle","consoleSubscription","initConsoleObservable","forwardConsoleLogs","subscribe","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","date","timeStampNow","message","origin","ErrorSource","CONSOLE","createErrorFieldFromRawError","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,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AAAiF,IAAAG,gBAAA;AAAA,SAAAC,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAC,MAAA,IAAAD,GAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,GAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,GAAA,KAAAD,OAAA,CAAAC,GAAA;AAAA,SAAAK,gBAAAL,GAAA,EAAAM,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAN,GAAA,IAAAS,MAAA,CAAAC,cAAA,CAAAV,GAAA,EAAAM,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAb,GAAA,CAAAM,GAAA,IAAAC,KAAA,WAAAP,GAAA;AAAA,SAAAQ,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAA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ACmB,OAAO;QACpBC,MAAM,EAAEC,wBAAW,CAACC,OAAO;QAC3BjB,KAAK,EAAEL,GAAG,CAACK,KAAK,IAAI,IAAAkB,0DAA4B,EAACvB,GAAG,CAACK,KAAK,CAAC;QAC3DmB,MAAM,EAAE1B,eAAe,CAACE,GAAG,CAACyB,GAAG;MACjC,CAAC;MACDC,aAAa,EAAE;QACbC,aAAa,EAAE3B,GAAG,CAAC2B;MACrB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBnB,mBAAmB,CAACoB,WAAW,CAAC,CAAC;IACnC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -8,30 +8,42 @@ exports.isAuthorized = isAuthorized;
|
|
|
8
8
|
exports.startLoggerCollection = startLoggerCollection;
|
|
9
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
10
10
|
var _logger = require("../../logger");
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var STATUS_PRIORITIES = {
|
|
12
|
+
ok: 0,
|
|
13
|
+
debug: 1,
|
|
14
|
+
info: 2,
|
|
15
|
+
notice: 4,
|
|
16
|
+
warn: 5,
|
|
17
|
+
error: 6,
|
|
18
|
+
critical: 7,
|
|
19
|
+
alert: 8,
|
|
20
|
+
emerg: 9
|
|
21
|
+
};
|
|
17
22
|
exports.STATUS_PRIORITIES = STATUS_PRIORITIES;
|
|
18
23
|
function startLoggerCollection(lifeCycle) {
|
|
19
|
-
function handleLog(logsMessage, logger, savedCommonContext, savedDate) {
|
|
20
|
-
var messageContext = logsMessage.context;
|
|
24
|
+
function handleLog(logsMessage, logger, handlingStack, savedCommonContext, savedDate) {
|
|
25
|
+
var messageContext = (0, _browserCore.extend2Lev)(logger.getContext(), logsMessage.context);
|
|
21
26
|
if (isAuthorized(logsMessage.status, _logger.HandlerType.console, logger)) {
|
|
22
|
-
(
|
|
27
|
+
displayInConsole(logsMessage, messageContext);
|
|
28
|
+
}
|
|
29
|
+
if (isAuthorized(logsMessage.status, _logger.HandlerType.http, logger)) {
|
|
30
|
+
var rawLogEventData = {
|
|
31
|
+
rawLogsEvent: {
|
|
32
|
+
date: savedDate || (0, _browserCore.timeStampNow)(),
|
|
33
|
+
message: logsMessage.message,
|
|
34
|
+
status: logsMessage.status,
|
|
35
|
+
origin: _browserCore.ErrorSource.LOGGER
|
|
36
|
+
},
|
|
37
|
+
messageContext: messageContext,
|
|
38
|
+
savedCommonContext: savedCommonContext
|
|
39
|
+
};
|
|
40
|
+
if (handlingStack) {
|
|
41
|
+
rawLogEventData.domainContext = {
|
|
42
|
+
handlingStack: handlingStack
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, rawLogEventData);
|
|
23
46
|
}
|
|
24
|
-
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
25
|
-
rawLogsEvent: {
|
|
26
|
-
date: savedDate || (0, _browserCore.timeStampNow)(),
|
|
27
|
-
message: logsMessage.message,
|
|
28
|
-
status: logsMessage.status,
|
|
29
|
-
origin: _browserCore.ErrorSource.LOGGER
|
|
30
|
-
},
|
|
31
|
-
messageContext: messageContext,
|
|
32
|
-
savedCommonContext: savedCommonContext,
|
|
33
|
-
logger: logger
|
|
34
|
-
});
|
|
35
47
|
}
|
|
36
48
|
return {
|
|
37
49
|
handleLog: handleLog
|
|
@@ -42,4 +54,9 @@ function isAuthorized(status, handlerType, logger) {
|
|
|
42
54
|
var sanitizedHandlerType = (0, _browserCore.isArray)(loggerHandler) ? loggerHandler : [loggerHandler];
|
|
43
55
|
return STATUS_PRIORITIES[status] >= STATUS_PRIORITIES[logger.getLevel()] && (0, _browserCore.includes)(sanitizedHandlerType, handlerType);
|
|
44
56
|
}
|
|
57
|
+
function displayInConsole(data, messageContext) {
|
|
58
|
+
var status = data.status;
|
|
59
|
+
var message = data.message;
|
|
60
|
+
_browserCore.originalConsoleMethods[loggerToConsoleApiName[status]].call(globalConsole, message, messageContext);
|
|
61
|
+
}
|
|
45
62
|
//# sourceMappingURL=loggerCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerCollection.js","names":["_browserCore","require","_logger","
|
|
1
|
+
{"version":3,"file":"loggerCollection.js","names":["_browserCore","require","_logger","STATUS_PRIORITIES","ok","debug","info","notice","warn","error","critical","alert","emerg","exports","startLoggerCollection","lifeCycle","handleLog","logsMessage","logger","handlingStack","savedCommonContext","savedDate","messageContext","extend2Lev","getContext","context","isAuthorized","status","HandlerType","console","displayInConsole","http","rawLogEventData","rawLogsEvent","date","timeStampNow","message","origin","ErrorSource","LOGGER","domainContext","notify","LifeCycleEventType","RAW_LOG_COLLECTED","handlerType","loggerHandler","getHandler","sanitizedHandlerType","isArray","getLevel","includes","data","originalConsoleMethods","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,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,OAAA,GAAAD,OAAA;AAEO,IAAIE,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;AAAAC,OAAA,CAAAV,iBAAA,GAAAA,iBAAA;AAEM,SAASW,qBAAqBA,CAACC,SAAS,EAAE;EAC/C,SAASC,SAASA,CAChBC,WAAW,EACXC,MAAM,EACNC,aAAa,EACbC,kBAAkB,EAClBC,SAAS,EACT;IACA,IAAIC,cAAc,GAAG,IAAAC,uBAAU,EAACL,MAAM,CAACM,UAAU,CAAC,CAAC,EAAEP,WAAW,CAACQ,OAAO,CAAC;IACzE,IAAIC,YAAY,CAACT,WAAW,CAACU,MAAM,EAAEC,mBAAW,CAACC,OAAO,EAAEX,MAAM,CAAC,EAAE;MACjEY,gBAAgB,CAACb,WAAW,EAAEK,cAAc,CA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AAI,CACzDC,aAAa,EACbnB,OAAO,EACPd,cACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -17,15 +17,15 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
17
17
|
}
|
|
18
18
|
var xhrSubscription = (0, _browserCore.initXhrObservable)().subscribe(function (context) {
|
|
19
19
|
if (context.state === 'complete') {
|
|
20
|
-
|
|
20
|
+
handleResponse(_browserCore.RequestType.XHR, context);
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
var fetchSubscription = (0, _browserCore.initFetchObservable)().subscribe(function (context) {
|
|
24
24
|
if (context.state === 'resolve') {
|
|
25
|
-
|
|
25
|
+
handleResponse(_browserCore.RequestType.FETCH, context);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
function
|
|
28
|
+
function handleResponse(type, request) {
|
|
29
29
|
if (!(0, _browserCore.isIntakeRequest)(request.url, configuration) && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
|
|
30
30
|
if ('xhr' in request) {
|
|
31
31
|
computeXhrResponseData(request.xhr, configuration, onResponseDataAvailable);
|
|
@@ -36,14 +36,18 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function onResponseDataAvailable(responseData) {
|
|
39
|
+
var domainContext = {
|
|
40
|
+
isAborted: request.isAborted,
|
|
41
|
+
handlingStack: request.handlingStack
|
|
42
|
+
};
|
|
39
43
|
var urlObj = (0, _browserCore.urlParse)(request.url).getParse();
|
|
40
44
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
41
45
|
rawLogsEvent: {
|
|
42
46
|
message: format(type) + ' error ' + request.method + ' ' + request.url,
|
|
43
47
|
date: request.startClocks.timeStamp,
|
|
44
48
|
error: {
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
stack: responseData || 'Failed to load',
|
|
50
|
+
handing: undefined
|
|
47
51
|
},
|
|
48
52
|
http: {
|
|
49
53
|
method: request.method,
|
|
@@ -56,7 +60,8 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
56
60
|
},
|
|
57
61
|
status: _logger.StatusType.error,
|
|
58
62
|
origin: _browserCore.ErrorSource.NETWORK
|
|
59
|
-
}
|
|
63
|
+
},
|
|
64
|
+
domainContext: domainContext
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networkErrorCollection.js","names":["_browserCore","require","_logger","startNetworkErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","noop","xhrSubscription","initXhrObservable","subscribe","context","state","handleCompleteRequest","RequestType","XHR","fetchSubscription","initFetchObservable","FETCH","type","request","isIntakeRequest","url","isRejected","isServerError","computeXhrResponseData","xhr","onResponseDataAvailable","response","computeFetchResponseText","error","computeFetchErrorText","responseData","urlObj","urlParse","getParse","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","format","method","date","startClocks","timeStamp","origin","ErrorSource","NETWORK","stack","http","status_code","status","statusGroup","getStatusGroup","urlHost","Host","urlPath","Path","urlPathGroup","replaceNumberCharByPath","StatusType","unsubscribe","callback","truncateResponseText","toStackTraceString","computeStackTrace","clonedResponse","tryToClone","body","window","TextDecoder","text","then","monitor","truncateResponseStream","requestErrorResponseLengthLimit","responseText","responseType","length","substring","stream","bytesLimit","readBytesFromStream","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 {\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,EAAE;QACjBR,YAAY,IAAI,KAAK;MACvB;MACAd,QAAQ,CAACwB,SAAS,EAAEV,YAAY,CAAC;IACnC;EACF,CAAC,EACD;IACEK,UAAU,EAAEA,UAAU;IACtBM,iBAAiB,EAAE;EACrB,CACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"networkErrorCollection.js","names":["_browserCore","require","_logger","startNetworkErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","noop","xhrSubscription","initXhrObservable","subscribe","context","state","handleResponse","RequestType","XHR","fetchSubscription","initFetchObservable","FETCH","type","request","isIntakeRequest","url","isRejected","isServerError","computeXhrResponseData","xhr","onResponseDataAvailable","response","computeFetchResponseText","error","computeFetchErrorText","responseData","domainContext","isAborted","handlingStack","urlObj","urlParse","getParse","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","format","method","date","startClocks","timeStamp","stack","handing","undefined","http","status_code","status","statusGroup","getStatusGroup","urlHost","Host","urlPath","Path","urlPathGroup","replaceNumberCharByPath","StatusType","origin","ErrorSource","NETWORK","unsubscribe","callback","truncateResponseText","toStackTraceString","computeStackTrace","clonedResponse","tryToClone","body","window","TextDecoder","text","then","monitor","truncateResponseStream","requestErrorResponseLengthLimit","responseText","responseType","length","substring","stream","bytesLimit","readBytesFromStream","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 )\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IAAIoD,YAAY,GAAG,IAAIN,WAAW,CAAC,CAAC,CAACe,MAAM,CAACF,KAAK,CAAC;MAClD,IAAIC,aAAa,EAAE;QACjBR,YAAY,IAAI,KAAK;MACvB;MACAd,QAAQ,CAACjB,SAAS,EAAE+B,YAAY,CAAC;IACnC;EACF,CAAC,EACD;IACEK,UAAU,EAAEA,UAAU;IACtBK,iBAAiB,EAAE;EACrB,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -6,25 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.startReportCollection = startReportCollection;
|
|
7
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
8
8
|
var _logger = require("../../logger");
|
|
9
|
-
var
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
-
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); }
|
|
14
|
-
var LogStatusForReport = (_LogStatusForReport = {}, _defineProperty(_LogStatusForReport, _browserCore.RawReportType.cspViolation, _logger.StatusType.error), _defineProperty(_LogStatusForReport, _browserCore.RawReportType.intervention, _logger.StatusType.error), _defineProperty(_LogStatusForReport, _browserCore.RawReportType.deprecation, _logger.StatusType.warn), _LogStatusForReport);
|
|
9
|
+
var _createErrorFieldFromRawError = require("../../createErrorFieldFromRawError");
|
|
15
10
|
function startReportCollection(configuration, lifeCycle) {
|
|
16
|
-
var reportSubscription = (0, _browserCore.initReportObservable)(configuration, configuration.forwardReports).subscribe(function (
|
|
17
|
-
var message =
|
|
18
|
-
var status =
|
|
11
|
+
var reportSubscription = (0, _browserCore.initReportObservable)(configuration, configuration.forwardReports).subscribe(function (rawError) {
|
|
12
|
+
var message = rawError.message;
|
|
13
|
+
var status = rawError.originalError.type === 'deprecation' ? _logger.StatusType.warn : _logger.StatusType.error;
|
|
19
14
|
var error;
|
|
20
15
|
if (status === _logger.StatusType.error) {
|
|
21
|
-
error =
|
|
22
|
-
kind: report.subtype,
|
|
23
|
-
origin: _browserCore.ErrorSource.REPORT,
|
|
24
|
-
stack: report.stack
|
|
25
|
-
};
|
|
16
|
+
error = (0, _createErrorFieldFromRawError.createErrorFieldFromRawError)(rawError);
|
|
26
17
|
} else if (report.stack) {
|
|
27
|
-
message += ' Found in ' + (0, _browserCore.getFileFromStackTraceString)(
|
|
18
|
+
message += ' Found in ' + (0, _browserCore.getFileFromStackTraceString)(rawError.stack);
|
|
28
19
|
}
|
|
29
20
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
30
21
|
rawLogsEvent: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportCollection.js","names":["_browserCore","require","_logger","
|
|
1
|
+
{"version":3,"file":"reportCollection.js","names":["_browserCore","require","_logger","_createErrorFieldFromRawError","startReportCollection","configuration","lifeCycle","reportSubscription","initReportObservable","forwardReports","subscribe","rawError","message","status","originalError","type","StatusType","warn","error","createErrorFieldFromRawError","report","stack","getFileFromStackTraceString","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","date","timeStampNow","origin","ErrorSource","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,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AAEO,SAASG,qBAAqBA,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC9D,IAAIC,kBAAkB,GAAG,IAAAC,iCAAoB,EAC3CH,aAAa,EACbA,aAAa,CAACI,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,GACzCC,kBAAU,CAACC,IAAI,GACfD,kBAAU,CAACE,KAAK;IACtB,IAAIA,KAAK;IACT,IAAIL,MAAM,KAAKG,kBAAU,CAACE,KAAK,EAAE;MAC/BA,KAAK,GAAG,IAAAC,0DAA4B,EAACR,QAAQ,CAAC;IAChD,CAAC,MAAM,IAAIS,MAAM,CAACC,KAAK,EAAE;MACvBT,OAAO,IAAI,YAAY,GAAG,IAAAU,wCAA2B,EAACX,QAAQ,CAACU,KAAK,CAAC;IACvE;IAEAf,SAAS,CAACiB,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAE,IAAAC,yBAAY,EAAC,CAAC;QACpBhB,OAAO,EAAEA,OAAO;QAChBiB,MAAM,EAAEC,wBAAW,CAACC,MAAM;QAC1Bb,KAAK,EAAEA,KAAK;QACZL,MAAM,EAAEA;MACV;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLmB,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBzB,kBAAkB,CAAC0B,WAAW,CAAC,CAAC;IAClC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.startRuntimeErrorCollection = startRuntimeErrorCollection;
|
|
7
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
8
8
|
var _logger = require("../../logger");
|
|
9
|
+
var _createErrorFieldFromRawError = require("../../createErrorFieldFromRawError");
|
|
9
10
|
function startRuntimeErrorCollection(configuration, lifeCycle) {
|
|
10
11
|
if (!configuration.forwardErrorsToLogs) {
|
|
11
12
|
return {
|
|
@@ -19,11 +20,7 @@ function startRuntimeErrorCollection(configuration, lifeCycle) {
|
|
|
19
20
|
rawLogsEvent: {
|
|
20
21
|
message: rawError.message,
|
|
21
22
|
date: rawError.startClocks.timeStamp,
|
|
22
|
-
error:
|
|
23
|
-
kind: rawError.type,
|
|
24
|
-
stack: rawError.stack,
|
|
25
|
-
causes: rawError.causes
|
|
26
|
-
},
|
|
23
|
+
error: (0, _createErrorFieldFromRawError.createErrorFieldFromRawError)(rawError),
|
|
27
24
|
origin: _browserCore.ErrorSource.SOURCE,
|
|
28
25
|
status: _logger.StatusType.error
|
|
29
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeErrorCollection.js","names":["_browserCore","require","_logger","startRuntimeErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","noop","rawErrorObservable","Observable","_trackRuntimeError","trackRuntimeError","rawErrorSubscription","subscribe","rawError","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","error","
|
|
1
|
+
{"version":3,"file":"runtimeErrorCollection.js","names":["_browserCore","require","_logger","_createErrorFieldFromRawError","startRuntimeErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","noop","rawErrorObservable","Observable","_trackRuntimeError","trackRuntimeError","rawErrorSubscription","subscribe","rawError","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","error","createErrorFieldFromRawError","origin","ErrorSource","SOURCE","status","StatusType","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,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACO,SAASG,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEC;IAAK,CAAC;EACvB;EAEA,IAAIC,kBAAkB,GAAG,IAAIC,uBAAU,CAAC,CAAC;EAEzC,IAAIC,kBAAkB,GAAG,IAAAC,8BAAiB,EAACH,kBAAkB,CAAC;EAE9D,IAAII,oBAAoB,GAAGJ,kBAAkB,CAACK,SAAS,CAAC,UAAUC,QAAQ,EAAE;IAC1EV,SAAS,CAACW,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEL,QAAQ,CAACK,OAAO;QACzBC,IAAI,EAAEN,QAAQ,CAACO,WAAW,CAACC,SAAS;QACpCC,KAAK,EAAE,IAAAC,0DAA4B,EAACV,QAAQ,CAAC;QAC7CW,MAAM,EAAEC,wBAAW,CAACC,MAAM;QAC1BC,MAAM,EAAEC,kBAAU,CAACN;MACrB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLjB,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBI,kBAAkB,CAACJ,IAAI,CAAC,CAAC;MACzBM,oBAAoB,CAACkB,WAAW,CAAC,CAAC;IACpC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startReportError = startReportError;
|
|
7
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
8
|
+
var _logger = require("./logger");
|
|
9
|
+
function startReportError(lifeCycle) {
|
|
10
|
+
return function (error) {
|
|
11
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
12
|
+
rawLogsEvent: {
|
|
13
|
+
message: error.message,
|
|
14
|
+
date: error.startClocks.timeStamp,
|
|
15
|
+
origin: _browserCore.ErrorSource.AGENT,
|
|
16
|
+
status: _logger.StatusType.error
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
(0, _browserCore.addTelemetryDebug)('Error reported to customer', {
|
|
20
|
+
'error.message': error.message
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=reportError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportError.js","names":["_browserCore","require","_logger","startReportError","lifeCycle","error","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","origin","ErrorSource","AGENT","status","StatusType","addTelemetryDebug"],"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,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACO,SAASE,gBAAgBA,CAACC,SAAS,EAAE;EAC1C,OAAO,UAAUC,KAAK,EAAE;IACtBD,SAAS,CAACE,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEL,KAAK,CAACK,OAAO;QACtBC,IAAI,EAAEN,KAAK,CAACO,WAAW,CAACC,SAAS;QACjCC,MAAM,EAAEC,wBAAW,CAACC,KAAK;QACzBC,MAAM,EAAEC,kBAAU,CAACb;MACrB;IACF,CAAC,CAAC;IACF,IAAAc,8BAAiB,EAAC,4BAA4B,EAAE;MAC9C,eAAe,EAAEd,KAAK,CAACK;IACzB,CAAC,CAAC;EACJ,CAAC;AACH","ignoreList":[]}
|
|
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.startLogsBatch = startLogsBatch;
|
|
7
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
8
|
-
function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable,
|
|
9
|
-
var batch = (0, _browserCore.startBatchWithReplica)(configuration,
|
|
8
|
+
function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session) {
|
|
9
|
+
var batch = (0, _browserCore.startBatchWithReplica)(configuration, {
|
|
10
|
+
endpoint: configuration.logsEndpoint,
|
|
11
|
+
encoder: (0, _browserCore.createIdentityEncoder)()
|
|
12
|
+
}, reportError, pageExitObservable, session.expireObservable);
|
|
10
13
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.LOG_COLLECTED, function (serverLogsEvent) {
|
|
11
14
|
batch.add(serverLogsEvent);
|
|
12
15
|
});
|
|
16
|
+
return batch;
|
|
13
17
|
}
|
|
14
18
|
//# sourceMappingURL=startLogsBatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startLogsBatch.js","names":["_browserCore","require","startLogsBatch","configuration","lifeCycle","reportError","pageExitObservable","
|
|
1
|
+
{"version":3,"file":"startLogsBatch.js","names":["_browserCore","require","startLogsBatch","configuration","lifeCycle","reportError","pageExitObservable","session","batch","startBatchWithReplica","endpoint","logsEndpoint","encoder","createIdentityEncoder","expireObservable","subscribe","LifeCycleEventType","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,IAAAA,YAAA,GAAAC,OAAA;AAMO,SAASC,cAAcA,CAC5BC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,kBAAkB,EAClBC,OAAO,EACP;EACA,IAAIC,KAAK,GAAG,IAAAC,kCAAqB,EAC/BN,aAAa,EACb;IAAEO,QAAQ,EAAEP,aAAa,CAACQ,YAAY;IAAEC,OAAO,EAAE,IAAAC,kCAAqB,EAAC;EAAE,CAAC,EAC1ER,WAAW,EACXC,kBAAkB,EAClBC,OAAO,CAACO,gBACV,CAAC;EAEDV,SAAS,CAACW,SAAS,CACjBC,+BAAkB,CAACC,aAAa,EAChC,UAAUC,eAAe,EAAE;IACzBV,KAAK,CAACW,GAAG,CAACD,eAAe,CAAC;EAC5B,CACF,CAAC;EACD,OAAOV,KAAK;AACd","ignoreList":[]}
|
package/esm/boot/buildEnv.js
CHANGED
|
@@ -1,65 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { validateAndBuildLogsConfiguration } from '../domain/configuration';
|
|
1
|
+
import { createContextManager, makePublicApi, CustomerDataType, checkUser, sanitizeUser, monitor, storeContextManager, displayAlreadyInitializedError, assign } from '@cloudcare/browser-core';
|
|
3
2
|
import { Logger } from '../domain/logger';
|
|
3
|
+
import { buildCommonContext } from '../domain/contexts/commonContext';
|
|
4
|
+
import { createPreStartStrategy } from './preStartLogs';
|
|
4
5
|
var LOGS_STORAGE_KEY = 'logs';
|
|
5
6
|
export function makeLogsPublicApi(startLogsImpl) {
|
|
6
|
-
var isAlreadyInitialized = false;
|
|
7
7
|
var globalContextManager = createContextManager(CustomerDataType.GlobalContext);
|
|
8
8
|
var userContextManager = createContextManager(CustomerDataType.User);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
savedCommonContext = deepClone(buildCommonContext());
|
|
17
|
-
}
|
|
18
|
-
if (typeof date === 'undefined') {
|
|
19
|
-
date = timeStampNow();
|
|
9
|
+
function getCommonContext() {
|
|
10
|
+
return buildCommonContext(globalContextManager, userContextManager);
|
|
11
|
+
}
|
|
12
|
+
var strategy = createPreStartStrategy(getCommonContext, function (initConfiguration, configuration) {
|
|
13
|
+
if (initConfiguration.storeContextsToLocal) {
|
|
14
|
+
storeContextManager(configuration, globalContextManager, LOGS_STORAGE_KEY, CustomerDataType.GlobalContext);
|
|
15
|
+
storeContextManager(configuration, userContextManager, LOGS_STORAGE_KEY, CustomerDataType.User);
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
var
|
|
26
|
-
return undefined;
|
|
27
|
-
};
|
|
17
|
+
var startLogsResult = startLogsImpl(initConfiguration, configuration, getCommonContext);
|
|
18
|
+
strategy = createPostStartStrategy(initConfiguration, startLogsResult);
|
|
19
|
+
return startLogsResult;
|
|
20
|
+
});
|
|
21
|
+
var customLoggers = {};
|
|
28
22
|
var mainLogger = new Logger(function () {
|
|
29
|
-
return
|
|
23
|
+
return strategy.handleLog.apply(this, arguments);
|
|
30
24
|
});
|
|
31
|
-
function buildCommonContext() {
|
|
32
|
-
return {
|
|
33
|
-
view: {
|
|
34
|
-
referrer: document.referrer,
|
|
35
|
-
url: window.location.href
|
|
36
|
-
},
|
|
37
|
-
context: globalContextManager.getContext(),
|
|
38
|
-
user: userContextManager.getContext()
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
25
|
return makePublicApi({
|
|
42
26
|
logger: mainLogger,
|
|
43
27
|
init: monitor(function (initConfiguration) {
|
|
44
|
-
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
var configuration = validateAndBuildLogsConfiguration(initConfiguration);
|
|
48
|
-
if (!configuration) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (initConfiguration.storeContextsToLocal) {
|
|
52
|
-
storeContextManager(configuration, globalContextManager, LOGS_STORAGE_KEY, CustomerDataType.GlobalContext);
|
|
53
|
-
storeContextManager(configuration, userContextManager, LOGS_STORAGE_KEY, CustomerDataType.User);
|
|
54
|
-
}
|
|
55
|
-
var _startLogsImpl = startLogsImpl(configuration, buildCommonContext, mainLogger);
|
|
56
|
-
_handleLogStrategy = _startLogsImpl.handleLog;
|
|
57
|
-
getInternalContextStrategy = _startLogsImpl.getInternalContext;
|
|
58
|
-
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
59
|
-
return deepClone(initConfiguration);
|
|
60
|
-
};
|
|
61
|
-
beforeInitLoggerLog.drain();
|
|
62
|
-
isAlreadyInitialized = true;
|
|
28
|
+
return strategy.init(initConfiguration);
|
|
63
29
|
}),
|
|
64
30
|
getGlobalContext: monitor(function () {
|
|
65
31
|
return globalContextManager.getContext();
|
|
@@ -81,18 +47,18 @@ export function makeLogsPublicApi(startLogsImpl) {
|
|
|
81
47
|
conf = {};
|
|
82
48
|
}
|
|
83
49
|
customLoggers[name] = new Logger(function () {
|
|
84
|
-
return
|
|
85
|
-
}, name, conf.handler, conf.level, conf.context);
|
|
50
|
+
return strategy.handleLog.apply(this, arguments);
|
|
51
|
+
}, sanitize(name), conf.handler, conf.level, sanitize(conf.context));
|
|
86
52
|
return customLoggers[name];
|
|
87
53
|
}),
|
|
88
54
|
getLogger: monitor(function (name) {
|
|
89
55
|
return customLoggers[name];
|
|
90
56
|
}),
|
|
91
57
|
getInitConfiguration: monitor(function () {
|
|
92
|
-
return
|
|
58
|
+
return strategy.getInitConfiguration();
|
|
93
59
|
}),
|
|
94
60
|
getInternalContext: monitor(function (startTime) {
|
|
95
|
-
return
|
|
61
|
+
return strategy.getInternalContext(startTime);
|
|
96
62
|
}),
|
|
97
63
|
setUser: monitor(function (newUser) {
|
|
98
64
|
if (checkUser(newUser)) {
|
|
@@ -105,18 +71,25 @@ export function makeLogsPublicApi(startLogsImpl) {
|
|
|
105
71
|
removeUserProperty: monitor(function (key) {
|
|
106
72
|
return userContextManager.removeContextProperty(key);
|
|
107
73
|
}),
|
|
74
|
+
setUserProperty: monitor(function (key, property) {
|
|
75
|
+
var newUser = {};
|
|
76
|
+
newUser[key] = property;
|
|
77
|
+
var sanitizedProperty = sanitizeUser(newUser)[key];
|
|
78
|
+
userContextManager.setContextProperty(key, sanitizedProperty);
|
|
79
|
+
}),
|
|
108
80
|
clearUser: monitor(function () {
|
|
109
81
|
return userContextManager.clearContext();
|
|
110
82
|
})
|
|
111
83
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
84
|
+
}
|
|
85
|
+
function createPostStartStrategy(initConfiguration, startLogsResult) {
|
|
86
|
+
return assign({
|
|
87
|
+
init: function init(initConfiguration) {
|
|
88
|
+
displayAlreadyInitializedError('DATAFLUX_LOGS', initConfiguration);
|
|
89
|
+
},
|
|
90
|
+
getInitConfiguration: function getInitConfiguration() {
|
|
91
|
+
return initConfiguration;
|
|
118
92
|
}
|
|
119
|
-
|
|
120
|
-
}
|
|
93
|
+
}, startLogsResult);
|
|
121
94
|
}
|
|
122
95
|
//# sourceMappingURL=logsPublicApi.js.map
|