@cloudcare/browser-logs 3.0.29 → 3.1.1
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 +3 -2
- package/cjs/boot/buildEnv.js.map +1 -0
- package/cjs/boot/logsPublicApi.js +2 -30
- package/cjs/boot/logsPublicApi.js.map +1 -0
- package/cjs/boot/startLogs.js +34 -19
- package/cjs/boot/startLogs.js.map +1 -0
- package/cjs/domain/assembly.js +4 -13
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration.js +2 -12
- package/cjs/domain/configuration.js.map +1 -0
- package/cjs/domain/internalContext.js +2 -3
- package/cjs/domain/internalContext.js.map +1 -0
- package/cjs/domain/logger.js +5 -16
- package/cjs/domain/logger.js.map +1 -0
- package/cjs/domain/logsCollection/console/consoleCollection.js +6 -8
- package/cjs/domain/logsCollection/console/consoleCollection.js.map +1 -0
- package/cjs/domain/logsCollection/logger/loggerCollection.js +6 -12
- package/cjs/domain/logsCollection/logger/loggerCollection.js.map +1 -0
- package/cjs/domain/logsCollection/networkError/networkErrorCollection.js +5 -23
- package/cjs/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -0
- package/cjs/domain/logsCollection/report/reportCollection.js +7 -11
- package/cjs/domain/logsCollection/report/reportCollection.js.map +1 -0
- package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -8
- package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -0
- package/cjs/domain/logsSessionManager.js +2 -9
- package/cjs/domain/logsSessionManager.js.map +1 -0
- package/cjs/entries/main.js +2 -5
- package/cjs/entries/main.js.map +1 -0
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -0
- package/cjs/transport/startLogsBatch.js +2 -3
- package/cjs/transport/startLogsBatch.js.map +1 -0
- package/cjs/transport/startLogsBridge.js +14 -0
- package/cjs/transport/startLogsBridge.js.map +1 -0
- package/esm/boot/buildEnv.js +3 -2
- package/esm/boot/buildEnv.js.map +1 -0
- package/esm/boot/logsPublicApi.js +2 -25
- package/esm/boot/logsPublicApi.js.map +1 -0
- package/esm/boot/startLogs.js +36 -9
- package/esm/boot/startLogs.js.map +1 -0
- package/esm/domain/assembly.js +4 -7
- package/esm/domain/assembly.js.map +1 -0
- package/esm/domain/configuration.js +2 -7
- package/esm/domain/configuration.js.map +1 -0
- package/esm/domain/internalContext.js +2 -2
- package/esm/domain/internalContext.js.map +1 -0
- package/esm/domain/logger.js +6 -13
- package/esm/domain/logger.js.map +1 -0
- package/esm/domain/logsCollection/console/consoleCollection.js +6 -4
- package/esm/domain/logsCollection/console/consoleCollection.js.map +1 -0
- package/esm/domain/logsCollection/logger/loggerCollection.js +6 -7
- package/esm/domain/logsCollection/logger/loggerCollection.js.map +1 -0
- package/esm/domain/logsCollection/networkError/networkErrorCollection.js +5 -17
- package/esm/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -0
- package/esm/domain/logsCollection/report/reportCollection.js +7 -7
- package/esm/domain/logsCollection/report/reportCollection.js.map +1 -0
- package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
- package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -0
- package/esm/domain/logsSessionManager.js +2 -5
- package/esm/domain/logsSessionManager.js.map +1 -0
- package/esm/entries/main.js +2 -1
- package/esm/entries/main.js.map +1 -0
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -0
- package/esm/transport/startLogsBatch.js +2 -1
- package/esm/transport/startLogsBatch.js.map +1 -0
- package/esm/transport/startLogsBridge.js +8 -0
- package/esm/transport/startLogsBridge.js.map +1 -0
- package/package.json +5 -4
- package/src/boot/startLogs.js +68 -10
- package/src/domain/logger.js +3 -2
- package/src/domain/logsCollection/logger/loggerCollection.js +24 -16
- package/src/domain/logsCollection/report/reportCollection.js +10 -8
- package/src/transport/startLogsBridge.js +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startLogs.js","names":["_browserCore","require","_logsSessionManager","_assembly","_consoleCollection","_reportCollection","_networkErrorCollection","_runtimeErrorCollection","_loggerCollection","_startLogsBatch","_logger","_internalContext","startLogs","configuration","buildCommonContext","mainLogger","lifeCycle","LifeCycle","reportError","error","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","origin","ErrorSource","AGENT","status","StatusType","pageExitObservable","createPageExitObservable","session","areCookiesAuthorized","cookieOptions","startLogsSessionManager","startLogsSessionManagerStub","telemetry","startLogsTelemetry","expireObservable","setContextProvider","RUMInternalContext","getRUMInternalContext","application","id","findTrackedSession","view","action","userAction","startNetworkErrorCollection","startRuntimeErrorCollection","startConsoleCollection","startReportCollection","_startLoggerCollection","startLoggerCollection","startLogsAssembly","canUseEventBridge","startLogsBatch","internalContext","startInternalContext","handleLog","getInternalContext","get","sessionExpireObservable","startTelemetry","TelemetryService","LOGS","telemetryBatch","startBatchWithReplica","rumEndpoint","observable","subscribe","event","add"],"sources":["../../src/boot/startLogs.js"],"sourcesContent":["import {\n ErrorSource,\n LifeCycle,\n LifeCycleEventType,\n createPageExitObservable,\n areCookiesAuthorized,\n startTelemetry,\n startBatchWithReplica,\n canUseEventBridge,\n TelemetryService\n} from '@cloudcare/browser-core'\nimport {\n startLogsSessionManager,\n startLogsSessionManagerStub\n} from '../domain/logsSessionManager'\nimport { startLogsAssembly, getRUMInternalContext } from '../domain/assembly'\nimport { startConsoleCollection } from '../domain/logsCollection/console/consoleCollection'\nimport { startReportCollection } from '../domain/logsCollection/report/reportCollection'\nimport { startNetworkErrorCollection } from '../domain/logsCollection/networkError/networkErrorCollection'\nimport { startRuntimeErrorCollection } from '../domain/logsCollection/rumtimeError/runtimeErrorCollection'\nimport { startLoggerCollection } from '../domain/logsCollection/logger/loggerCollection'\nimport { startLogsBatch } from '../transport/startLogsBatch'\nimport { StatusType } from '../domain/logger'\nimport { startInternalContext } from '../domain/internalContext'\n\nexport function startLogs(configuration, buildCommonContext, mainLogger) {\n var lifeCycle = new LifeCycle()\n\n var reportError = function (error) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message: error.message,\n date: error.startClocks.timeStamp,\n error: {\n origin: ErrorSource.AGENT // Todo: Remove in the next major release\n },\n origin: ErrorSource.AGENT,\n status: StatusType.error\n }\n })\n }\n var pageExitObservable = createPageExitObservable()\n var session = areCookiesAuthorized(configuration.cookieOptions)\n ? startLogsSessionManager(configuration)\n : startLogsSessionManagerStub(configuration)\n const telemetry = startLogsTelemetry(\n configuration,\n reportError,\n pageExitObservable,\n session.expireObservable\n )\n telemetry.setContextProvider(function () {\n var RUMInternalContext = getRUMInternalContext()\n return {\n application: {\n id:\n RUMInternalContext &&\n RUMInternalContext.application &&\n RUMInternalContext.application.id\n },\n session: {\n id: session.findTrackedSession() && session.findTrackedSession().id\n },\n view: {\n id:\n RUMInternalContext &&\n RUMInternalContext.view &&\n RUMInternalContext.view.id\n },\n action: {\n id:\n RUMInternalContext &&\n RUMInternalContext.userAction &&\n RUMInternalContext.userAction.id\n }\n }\n })\n startNetworkErrorCollection(configuration, lifeCycle)\n startRuntimeErrorCollection(configuration, lifeCycle)\n startConsoleCollection(configuration, lifeCycle)\n startReportCollection(configuration, lifeCycle)\n var _startLoggerCollection = startLoggerCollection(lifeCycle)\n\n startLogsAssembly(\n session,\n configuration,\n lifeCycle,\n buildCommonContext,\n mainLogger,\n reportError\n )\n if (!canUseEventBridge()) {\n startLogsBatch(\n configuration,\n lifeCycle,\n reportError,\n pageExitObservable,\n session.expireObservable\n )\n }\n\n var internalContext = startInternalContext(session)\n\n return {\n handleLog: _startLoggerCollection.handleLog,\n getInternalContext: internalContext.get\n }\n}\nfunction startLogsTelemetry(\n configuration,\n reportError,\n pageExitObservable,\n sessionExpireObservable\n) {\n const telemetry = startTelemetry(TelemetryService.LOGS, configuration)\n if (!canUseEventBridge()) {\n var telemetryBatch = startBatchWithReplica(\n configuration,\n configuration.rumEndpoint,\n reportError,\n pageExitObservable,\n sessionExpireObservable\n )\n telemetry.observable.subscribe(function (event) {\n telemetryBatch.add(event)\n })\n }\n return telemetry\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,mBAAA,GAAAD,OAAA;AAIA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,uBAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AAEO,SAASW,SAASA,CAACC,aAAa,EAAEC,kBAAkB,EAAEC,UAAU,EAAE;EACvE,IAAIC,SAAS,GAAG,IAAIC,sBAAS,CAAC,CAAC;EAE/B,IAAIC,WAAW,GAAG,SAAdA,WAAWA,CAAaC,KAAK,EAAE;IACjCH,SAAS,CAACI,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEL,KAAK,CAACK,OAAO;QACtBC,IAAI,EAAEN,KAAK,CAACO,WAAW,CAACC,SAAS;QACjCR,KAAK,EAAE;UACLS,MAAM,EAAEC,wBAAW,CAACC,KAAK,CAAC;QAC5B,CAAC;;QACDF,MAAM,EAAEC,wBAAW,CAACC,KAAK;QACzBC,MAAM,EAAEC,kBAAU,CAACb;MACrB;IACF,CAAC,CAAC;EACJ,CAAC;EACD,IAAIc,kBAAkB,GAAG,IAAAC,qCAAwB,EAAC,CAAC;EACnD,IAAIC,OAAO,GAAG,IAAAC,iCAAoB,EAACvB,aAAa,CAACwB,aAAa,CAAC,GAC3D,IAAAC,2CAAuB,EAACzB,aAAa,CAAC,GACtC,IAAA0B,+CAA2B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SAAS,EACTE,WAAW,EACXe,kBAAkB,EAClBE,OAAO,CAACO,gBACV,CAAC;EACH;EAEA,IAAImB,eAAe,GAAG,IAAAC,qCAAoB,EAAC3B,OAAO,CAAC;EAEnD,OAAO;IACL4B,SAAS,EAAEP,sBAAsB,CAACO,SAAS;IAC3CC,kBAAkB,EAAEH,eAAe,CAACI;EACtC,CAAC;AACH;AACA,SAASxB,kBAAkBA,CACzB5B,aAAa,EACbK,WAAW,EACXe,kBAAkB,EAClBiC,uBAAuB,EACvB;EACA,IAAM1B,SAAS,GAAG,IAAA2B,2BAAc,EAACC,6BAAgB,CAACC,IAAI,EAAExD,aAAa,CAAC;EACtE,IAAI,CAAC,IAAA8C,8BAAiB,EAAC,CAAC,EAAE;IACxB,IAAIW,cAAc,GAAG,IAAAC,kCAAqB,EACxC1D,aAAa,EACbA,aAAa,CAAC2D,WAAW,EACzBtD,WAAW,EACXe,kBAAkB,EAClBiC,uBACF,CAAC;IACD1B,SAAS,CAACiC,UAAU,CAACC,SAAS,CAAC,UAAUC,KAAK,EAAE;MAC9CL,cAAc,CAACM,GAAG,CAACD,KAAK,CAAC;IAC3B,CAAC,CAAC;EACJ;EACA,OAAOnC,SAAS;AAClB"}
|
package/cjs/domain/assembly.js
CHANGED
|
@@ -5,16 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getRUMInternalContext = getRUMInternalContext;
|
|
7
7
|
exports.startLogsAssembly = startLogsAssembly;
|
|
8
|
-
|
|
9
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
-
|
|
11
9
|
var _logger = require("./logger");
|
|
12
|
-
|
|
13
10
|
var _loggerCollection = require("./logsCollection/logger/loggerCollection");
|
|
14
|
-
|
|
15
11
|
function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommonContext, mainLogger, reportError) {
|
|
16
12
|
var statusWithCustom = _logger.STATUSES.concat(['custom']);
|
|
17
|
-
|
|
18
13
|
var logRateLimiters = {};
|
|
19
14
|
(0, _browserCore.each)(statusWithCustom, function (status) {
|
|
20
15
|
logRateLimiters[status] = (0, _browserCore.createEventRateLimiter)(status, configuration.eventRateLimiterThreshold, reportError);
|
|
@@ -27,11 +22,9 @@ function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommon
|
|
|
27
22
|
var logger = data.logger || mainLogger;
|
|
28
23
|
var startTime = (0, _browserCore.getRelativeTime)(rawLogsEvent.date);
|
|
29
24
|
var session = sessionManager.findTrackedSession(startTime);
|
|
30
|
-
|
|
31
25
|
if (!session) {
|
|
32
26
|
return;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
var commonContext = savedCommonContext || buildCommonContext();
|
|
36
29
|
var log = (0, _browserCore.extend2Lev)({
|
|
37
30
|
service: configuration.service || 'browser',
|
|
@@ -49,22 +42,20 @@ function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommon
|
|
|
49
42
|
device: _browserCore.deviceInfo,
|
|
50
43
|
type: _browserCore.RumEventType.LOGGER
|
|
51
44
|
}, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, logger.getContext(), messageContext);
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
if (
|
|
46
|
+
// Todo: [RUMF-1230] Move this check to the logger collection in the next major release
|
|
54
47
|
!(0, _loggerCollection.isAuthorized)(rawLogsEvent.status, _logger.HandlerType.http, logger) || configuration.beforeSend && configuration.beforeSend(log) === false || log.error && log.error.origin !== _browserCore.ErrorSource.AGENT && (0, _browserCore.isNullUndefinedDefaultValue)(logRateLimiters[log.status], logRateLimiters['custom']).isLimitReached()) {
|
|
55
48
|
return;
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
lifeCycle.notify(_browserCore.LifeCycleEventType.LOG_COLLECTED, (0, _browserCore.withSnakeCaseKeys)(log));
|
|
59
51
|
});
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
function getRUMInternalContext(startTime) {
|
|
63
54
|
return getInternalContextFromRumGlobal(window.DATAFLUX_RUM);
|
|
64
|
-
|
|
65
55
|
function getInternalContextFromRumGlobal(rumGlobal) {
|
|
66
56
|
if (rumGlobal && rumGlobal.getInternalContext) {
|
|
67
57
|
return rumGlobal.getInternalContext(startTime);
|
|
68
58
|
}
|
|
69
59
|
}
|
|
70
|
-
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=assembly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assembly.js","names":["_browserCore","require","_logger","_loggerCollection","startLogsAssembly","sessionManager","configuration","lifeCycle","buildCommonContext","mainLogger","reportError","statusWithCustom","STATUSES","concat","logRateLimiters","each","status","createEventRateLimiter","eventRateLimiterThreshold","subscribe","LifeCycleEventType","RAW_LOG_COLLECTED","data","rawLogsEvent","messageContext","undefined","savedCommonContext","logger","startTime","getRelativeTime","date","session","findTrackedSession","commonContext","log","extend2Lev","service","env","version","_dd","sdkName","sdkVersion","id","view","user","isEmptyObject","device","deviceInfo","type","RumEventType","LOGGER","context","getRUMInternalContext","getContext","isAuthorized","HandlerType","http","beforeSend","error","origin","ErrorSource","AGENT","isNullUndefinedDefaultValue","isLimitReached","notify","LOG_COLLECTED","withSnakeCaseKeys","getInternalContextFromRumGlobal","window","DATAFLUX_RUM","rumGlobal","getInternalContext"],"sources":["../../src/domain/assembly.js"],"sourcesContent":["import {\n ErrorSource,\n extend2Lev,\n createEventRateLimiter,\n getRelativeTime,\n withSnakeCaseKeys,\n LifeCycleEventType,\n deviceInfo,\n each,\n RumEventType,\n isEmptyObject,\n isNullUndefinedDefaultValue\n} from '@cloudcare/browser-core'\n\nimport { STATUSES, HandlerType } from './logger'\nimport { isAuthorized } from './logsCollection/logger/loggerCollection'\n\nexport function startLogsAssembly(\n sessionManager,\n configuration,\n lifeCycle,\n buildCommonContext,\n mainLogger,\n reportError\n) {\n var statusWithCustom = STATUSES.concat(['custom'])\n var logRateLimiters = {}\n each(statusWithCustom, function (status) {\n logRateLimiters[status] = createEventRateLimiter(\n status,\n configuration.eventRateLimiterThreshold,\n reportError\n )\n })\n lifeCycle.subscribe(LifeCycleEventType.RAW_LOG_COLLECTED, function (data) {\n // { rawLogsEvent, messageContext = undefined, savedCommonContext = undefined, logger = mainLogger }\n var rawLogsEvent = data.rawLogsEvent\n var messageContext = data.messageContext || undefined\n var savedCommonContext = data.savedCommonContext || undefined\n var logger = data.logger || mainLogger\n var startTime = getRelativeTime(rawLogsEvent.date)\n var session = sessionManager.findTrackedSession(startTime)\n\n if (!session) {\n return\n }\n var commonContext = savedCommonContext || buildCommonContext()\n var log = extend2Lev(\n {\n service: configuration.service || 'browser',\n env: configuration.env || '',\n version: configuration.version || '',\n _dd: {\n sdkName: configuration.sdkName,\n sdkVersion: configuration.sdkVersion\n },\n session: {\n id: session.id\n },\n view: commonContext.view,\n user: !isEmptyObject(commonContext.user)\n ? commonContext.user\n : undefined,\n device: deviceInfo,\n type: RumEventType.LOGGER\n },\n commonContext.context,\n getRUMInternalContext(startTime),\n rawLogsEvent,\n logger.getContext(),\n messageContext\n )\n\n if (\n // Todo: [RUMF-1230] Move this check to the logger collection in the next major release\n !isAuthorized(rawLogsEvent.status, HandlerType.http, logger) ||\n (configuration.beforeSend && configuration.beforeSend(log) === false) ||\n (log.error &&\n log.error.origin !== ErrorSource.AGENT &&\n isNullUndefinedDefaultValue(\n logRateLimiters[log.status],\n logRateLimiters['custom']\n ).isLimitReached())\n ) {\n return\n }\n\n lifeCycle.notify(LifeCycleEventType.LOG_COLLECTED, withSnakeCaseKeys(log))\n })\n}\n\nexport function getRUMInternalContext(startTime) {\n return getInternalContextFromRumGlobal(window.DATAFLUX_RUM)\n\n function getInternalContextFromRumGlobal(rumGlobal) {\n if (rumGlobal && rumGlobal.getInternalContext) {\n return rumGlobal.getInternalContext(startTime)\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAcA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;A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AOD,SAAS,CAACC,kBAAkB,CAAC3C,SAAS,CAAC;IAChD;EACF;AACF"}
|
|
@@ -6,30 +6,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT = void 0;
|
|
7
7
|
exports.validateAndBuildForwardOption = validateAndBuildForwardOption;
|
|
8
8
|
exports.validateAndBuildLogsConfiguration = validateAndBuildLogsConfiguration;
|
|
9
|
-
|
|
10
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
-
|
|
12
10
|
var _buildEnv = require("../boot/buildEnv");
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* arbitrary value, byte precision not needed
|
|
16
13
|
*/
|
|
17
14
|
var DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT = 32 * _browserCore.ONE_KIBI_BYTE;
|
|
18
15
|
exports.DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT = DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT;
|
|
19
|
-
|
|
20
16
|
function validateAndBuildLogsConfiguration(initConfiguration) {
|
|
21
17
|
var baseConfiguration = (0, _browserCore.validateAndBuildConfiguration)(initConfiguration);
|
|
22
18
|
var forwardConsoleLogs = validateAndBuildForwardOption(initConfiguration.forwardConsoleLogs, (0, _browserCore.values)(_browserCore.ConsoleApiName), 'Forward Console Logs');
|
|
23
19
|
var forwardReports = validateAndBuildForwardOption(initConfiguration.forwardReports, (0, _browserCore.values)(_browserCore.RawReportType), 'Forward Reports');
|
|
24
|
-
|
|
25
20
|
if (!baseConfiguration || !forwardConsoleLogs || !forwardReports) {
|
|
26
21
|
return;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
if (initConfiguration.forwardErrorsToLogs && !(0, _browserCore.includes)(forwardConsoleLogs, _browserCore.ConsoleApiName.error)) {
|
|
30
24
|
forwardConsoleLogs.push(_browserCore.ConsoleApiName.error);
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
return (0, _browserCore.assign)({
|
|
34
27
|
forwardErrorsToLogs: initConfiguration.forwardErrorsToLogs !== false,
|
|
35
28
|
forwardConsoleLogs: forwardConsoleLogs,
|
|
@@ -37,19 +30,16 @@ function validateAndBuildLogsConfiguration(initConfiguration) {
|
|
|
37
30
|
requestErrorResponseLengthLimit: DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT
|
|
38
31
|
}, baseConfiguration, _buildEnv.buildEnv);
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
function validateAndBuildForwardOption(option, allowedValues, label) {
|
|
42
34
|
if (option === undefined) {
|
|
43
35
|
return [];
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
if (!(option === 'all' || (0, _browserCore.isArray)(option) && (0, _browserCore.every)(option, function (api) {
|
|
47
38
|
return (0, _browserCore.includes)(allowedValues, api);
|
|
48
39
|
}))) {
|
|
49
40
|
_browserCore.display.error(label + ' should be "all" or an array with allowed values "' + allowedValues.join('", "') + '"');
|
|
50
|
-
|
|
51
41
|
return;
|
|
52
42
|
}
|
|
53
|
-
|
|
54
43
|
return option === 'all' ? allowedValues : (0, _browserCore.unique)(option);
|
|
55
|
-
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","names":["_browserCore","require","_buildEnv","DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT","ONE_KIBI_BYTE","exports","validateAndBuildLogsConfiguration","initConfiguration","baseConfiguration","validateAndBuildConfiguration","forwardConsoleLogs","validateAndBuildForwardOption","values","ConsoleApiName","forwardReports","RawReportType","forwardErrorsToLogs","includes","error","push","assign","requestErrorResponseLengthLimit","buildEnv","option","allowedValues","label","undefined","isArray","every","api","display","join","unique"],"sources":["../../src/domain/configuration.js"],"sourcesContent":["import {\n assign,\n ONE_KIBI_BYTE,\n validateAndBuildConfiguration,\n display,\n unique,\n RawReportType,\n isArray,\n every,\n ConsoleApiName,\n includes,\n values,\n} from '@cloudcare/browser-core'\nimport { buildEnv } from '../boot/buildEnv'\n/**\n * arbitrary value, byte precision not needed\n */\nexport var DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT = 32 * ONE_KIBI_BYTE\n\nexport function validateAndBuildLogsConfiguration(\n initConfiguration\n){\n var baseConfiguration = validateAndBuildConfiguration(initConfiguration)\n\n var forwardConsoleLogs = validateAndBuildForwardOption(\n initConfiguration.forwardConsoleLogs,\n values(ConsoleApiName),\n 'Forward Console Logs'\n )\n\n var forwardReports = validateAndBuildForwardOption(\n initConfiguration.forwardReports,\n values(RawReportType),\n 'Forward Reports'\n )\n\n if (!baseConfiguration || !forwardConsoleLogs || !forwardReports) {\n return\n }\n\n if (initConfiguration.forwardErrorsToLogs && !includes(forwardConsoleLogs, ConsoleApiName.error)) {\n forwardConsoleLogs.push(ConsoleApiName.error)\n }\n return assign(\n {\n forwardErrorsToLogs: initConfiguration.forwardErrorsToLogs !== false,\n forwardConsoleLogs: forwardConsoleLogs,\n forwardReports: forwardReports,\n requestErrorResponseLengthLimit: DEFAULT_REQUEST_ERROR_RESPONSE_LENGTH_LIMIT,\n },\n baseConfiguration,\n buildEnv\n )\n}\n\nexport function validateAndBuildForwardOption(\n option,\n allowedValues,\n label\n) {\n if (option === undefined) {\n return []\n }\n\n if (!(option === 'all' || (isArray(option) && every(option, function(api) { return includes(allowedValues, api) })))) {\n display.error(label + ' should be \"all\" or an array with allowed values \"' + allowedValues.join('\", \"') + '\"')\n return\n }\n return option === 'all' ? allowedValues : unique(option)\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAaA,IAAAC,SAAA,GAAAD,OAAA;AACA;AACA;AACA;AACO,IAAIE,2CAA2C,GAAG,EAAE,GAAGC,0BAAa;AAAAC,OAAA,CAAAF,2CAAA,GAAAA,2CAAA;AAEpE,SAASG,iCAAiCA,CAC/CC,i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,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;IAC9G;EACF;EACA,OAAOR,MAAM,KAAK,KAAK,GAAGC,aAAa,GAAG,IAAAQ,mBAAM,EAACT,MAAM,CAAC;AAC1D"}
|
|
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startInternalContext = startInternalContext;
|
|
7
|
-
|
|
8
7
|
function startInternalContext(sessionManager) {
|
|
9
8
|
return {
|
|
10
9
|
get: function get(startTime) {
|
|
11
10
|
var trackedSession = sessionManager.findTrackedSession(startTime);
|
|
12
|
-
|
|
13
11
|
if (trackedSession) {
|
|
14
12
|
return {
|
|
15
13
|
session: {
|
|
@@ -19,4 +17,5 @@ function startInternalContext(sessionManager) {
|
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
};
|
|
22
|
-
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=internalContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalContext.js","names":["startInternalContext","sessionManager","get","startTime","trackedSession","findTrackedSession","session","id"],"sources":["../../src/domain/internalContext.js"],"sourcesContent":["\nexport function startInternalContext(sessionManager) {\n return {\n get: function(startTime) {\n var trackedSession = sessionManager.findTrackedSession(startTime)\n if (trackedSession) {\n return {\n session: {\n id: trackedSession.id\n },\n }\n }\n },\n }\n}\n"],"mappings":";;;;;;AACO,SAASA,oBAAoBA,CAACC,cAAc,EAAE;EACnD,OAAO;IACLC,GAAG,EAAE,SAAAA,IAASC,SAAS,EAAE;MACvB,IAAIC,cAAc,GAAGH,cAAc,CAACI,kBAAkB,CAACF,SAAS,CAAC;MACjE,IAAIC,cAAc,EAAE;QAClB,OAAO;UACLE,OAAO,EAAE;YACPC,EAAE,EAAEH,cAAc,CAACG;UACrB;QACF,CAAC;MACH;IACF;EACF,CAAC;AACH"}
|
package/cjs/domain/logger.js
CHANGED
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.HandlerType = void 0;
|
|
7
7
|
exports.Logger = Logger;
|
|
8
8
|
exports.StatusType = exports.STATUSES = void 0;
|
|
9
|
-
|
|
10
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
-
|
|
12
10
|
var StatusType = {
|
|
13
11
|
debug: 'debug',
|
|
14
12
|
error: 'error',
|
|
@@ -23,25 +21,20 @@ var HandlerType = {
|
|
|
23
21
|
silent: 'silent'
|
|
24
22
|
};
|
|
25
23
|
exports.HandlerType = HandlerType;
|
|
26
|
-
var STATUSES = (0, _browserCore.keys)(StatusType);
|
|
27
|
-
|
|
24
|
+
var STATUSES = (0, _browserCore.keys)(StatusType);
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
28
26
|
exports.STATUSES = STATUSES;
|
|
29
|
-
|
|
30
27
|
function Logger(handleLogStrategy, name, handlerType, level, loggerContext) {
|
|
31
28
|
this.contextManager = (0, _browserCore.createContextManager)(_browserCore.CustomerDataType.LoggerContext);
|
|
32
|
-
|
|
33
29
|
if (typeof handlerType === 'undefined') {
|
|
34
30
|
handlerType = HandlerType.http;
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
if (typeof level === 'undefined') {
|
|
38
33
|
level = StatusType.debug;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
if (typeof loggerContext === 'undefined') {
|
|
42
36
|
loggerContext = {};
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
this.handleLogStrategy = handleLogStrategy;
|
|
46
39
|
this.handlerType = handlerType;
|
|
47
40
|
this.level = level;
|
|
@@ -51,28 +44,24 @@ function Logger(handleLogStrategy, name, handlerType, level, loggerContext) {
|
|
|
51
44
|
}
|
|
52
45
|
} : undefined));
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
Logger.prototype = {
|
|
56
48
|
log: (0, _browserCore.monitor)(function (message, messageContext, status, error) {
|
|
57
49
|
if (typeof status === 'undefined') {
|
|
58
50
|
status = StatusType.info;
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
var errorContext;
|
|
62
|
-
|
|
63
53
|
if (status === StatusType.error) {
|
|
64
54
|
// Always add origin if status is error (backward compatibility - Remove in next major)
|
|
65
55
|
errorContext = {
|
|
66
56
|
origin: _browserCore.ErrorSource.LOGGER
|
|
67
57
|
};
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
if (error !== undefined && error !== null) {
|
|
71
60
|
var stackTrace = error instanceof Error ? (0, _browserCore.computeStackTrace)(error) : undefined;
|
|
72
61
|
var rawError = (0, _browserCore.computeRawError)({
|
|
73
62
|
stackTrace: stackTrace,
|
|
74
63
|
originalError: error,
|
|
75
|
-
nonErrorPrefix:
|
|
64
|
+
nonErrorPrefix: _browserCore.NonErrorPrefix.PROVIDED,
|
|
76
65
|
source: _browserCore.ErrorSource.LOGGER,
|
|
77
66
|
handling: _browserCore.ErrorHandling.HANDLED,
|
|
78
67
|
startClocks: (0, _browserCore.clocksNow)()
|
|
@@ -85,7 +74,6 @@ Logger.prototype = {
|
|
|
85
74
|
message: rawError.message
|
|
86
75
|
};
|
|
87
76
|
}
|
|
88
|
-
|
|
89
77
|
var sanitizedMessageContext = (0, _browserCore.sanitize)(messageContext);
|
|
90
78
|
var context = errorContext ? (0, _browserCore.extend2Lev)({
|
|
91
79
|
error: errorContext
|
|
@@ -140,4 +128,5 @@ Logger.prototype = {
|
|
|
140
128
|
getLevel: function getLevel() {
|
|
141
129
|
return this.level;
|
|
142
130
|
}
|
|
143
|
-
};
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","names":["_browserCore","require","StatusType","debug","error","info","warn","critical","exports","HandlerType","console","http","silent","STATUSES","keys","Logger","handleLogStrategy","name","handlerType","level","loggerContext","contextManager","createContextManager","CustomerDataType","LoggerContext","set","assign","logger","undefined","prototype","log","monitor","message","messageContext","status","errorContext","origin","ErrorSource","LOGGER","stackTrace","Error","computeStackTrace","rawError","computeRawError","originalError","nonErrorPrefix","NonErrorPrefix","PROVIDED","source","handling","ErrorHandling","HANDLED","startClocks","clocksNow","stack","kind","type","sanitizedMessageContext","sanitize","context","extend2Lev","errorOrigin","setContext","getContext","get","addContext","key","value","add","removeContext","remove","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 }\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\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,IAAAA,YAAA,GAAAC,OAAA;AAgBO,IAAIC,UAAU,GAAG;EACtBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE;AACZ,CAAC;AAAAC,OAAA,CAAAN,UAAA,GAAAA,UAAA;AAEM,IAAIO,WAAW,GAAG;EACvBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,M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AK,CAAC;EACrC,CAAC;EAEDE,aAAa,EAAE,SAAAA,cAAUH,GAAG,EAAE;IAC5B,IAAI,CAAC7C,cAAc,CAACiD,MAAM,CAACJ,GAAG,CAAC;EACjC,CAAC;EAEDK,UAAU,EAAE,SAAAA,WAAUC,OAAO,EAAE;IAC7B,IAAI,CAACtD,WAAW,GAAGsD,OAAO;EAC5B,CAAC;EAEDC,UAAU,EAAE,SAAAA,WAAA,EAAY;IACtB,OAAO,IAAI,CAACvD,WAAW;EACzB,CAAC;EACDwD,QAAQ,EAAE,SAAAA,SAAUvD,KAAK,EAAE;IACzB,IAAI,CAACA,KAAK,GAAGA,KAAK;EACpB,CAAC;EACDwD,QAAQ,EAAE,SAAAA,SAAA,EAAY;IACpB,OAAO,IAAI,CAACxD,KAAK;EACnB;AACF,CAAC"}
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startConsoleCollection = startConsoleCollection;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
var _logger = require("../../logger");
|
|
11
|
-
|
|
12
9
|
var _LogStatusForApi;
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
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); }
|
|
16
14
|
var LogStatusForApi = (_LogStatusForApi = {}, _defineProperty(_LogStatusForApi, _browserCore.ConsoleApiName.log, _logger.StatusType.info), _defineProperty(_LogStatusForApi, _browserCore.ConsoleApiName.debug, _logger.StatusType.debug), _defineProperty(_LogStatusForApi, _browserCore.ConsoleApiName.info, _logger.StatusType.info), _defineProperty(_LogStatusForApi, _browserCore.ConsoleApiName.warn, _logger.StatusType.warn), _defineProperty(_LogStatusForApi, _browserCore.ConsoleApiName.error, _logger.StatusType.error), _LogStatusForApi);
|
|
17
|
-
|
|
18
15
|
function startConsoleCollection(configuration, lifeCycle) {
|
|
19
16
|
var consoleSubscription = (0, _browserCore.initConsoleObservable)(configuration.forwardConsoleLogs).subscribe(function (log) {
|
|
20
17
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
@@ -36,4 +33,5 @@ function startConsoleCollection(configuration, lifeCycle) {
|
|
|
36
33
|
consoleSubscription.unsubscribe();
|
|
37
34
|
}
|
|
38
35
|
};
|
|
39
|
-
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=consoleCollection.js.map
|
|
@@ -0,0 +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","api","stack","status","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/console/consoleCollection.js"],"sourcesContent":["import { timeStampNow, ConsoleApiName, ErrorSource, initConsoleObservable, LifeCycleEventType } from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\n\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(configuration.forwardConsoleLogs).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:\n log.api === ConsoleApiName.error\n ? {\n origin: ErrorSource.CONSOLE, // Todo: Remove in the next major release\n stack: log.stack,\n }\n : undefined,\n status: LogStatusForApi[log.api],\n },\n })\n })\n\n return {\n stop: function(){\n consoleSubscription.unsubscribe()\n },\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAyC,IAAAE,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,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A,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC/D,IAAIC,mBAAmB,GAAG,IAAAC,kCAAqB,EAACH,aAAa,CAACI,kBAAkB,CAAC,CAACC,SAAS,CAAC,UAASZ,GAAG,EAAE;IACxGQ,SAAS,CAACK,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAE,IAAAC,yBAAY,EAAC,CAAC;QACpBC,OAAO,EAAEnB,GAAG,CAACmB,OAAO;QACpBC,MAAM,EAAEC,wBAAW,CAACC,OAAO;QAC3BjB,KAAK,EACHL,GAAG,CAACuB,GAAG,KAAKxB,2BAAc,CAACM,KAAK,GAC5B;UACEe,MAAM,EAAEC,wBAAW,CAACC,OAAO;UAAE;UAC7BE,KAAK,EAAExB,GAAG,CAACwB;QACb,CAAC,GACD/B,SAAS;QACfgC,MAAM,EAAE3B,eAAe,CAACE,GAAG,CAACuB,GAAG;MACjC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLG,IAAI,EAAE,SAAAA,KAAA,EAAU;MACdjB,mBAAmB,CAACkB,WAAW,CAAC,CAAC;IACnC;EACF,CAAC;AACH"}
|
|
@@ -6,26 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.STATUS_PRIORITIES = void 0;
|
|
7
7
|
exports.isAuthorized = isAuthorized;
|
|
8
8
|
exports.startLoggerCollection = startLoggerCollection;
|
|
9
|
-
|
|
10
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
-
|
|
12
10
|
var _logger = require("../../logger");
|
|
13
|
-
|
|
14
11
|
var _STATUS_PRIORITIES;
|
|
15
|
-
|
|
16
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
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); }
|
|
18
16
|
var STATUS_PRIORITIES = (_STATUS_PRIORITIES = {}, _defineProperty(_STATUS_PRIORITIES, _logger.StatusType.debug, 0), _defineProperty(_STATUS_PRIORITIES, _logger.StatusType.info, 1), _defineProperty(_STATUS_PRIORITIES, _logger.StatusType.warn, 2), _defineProperty(_STATUS_PRIORITIES, _logger.StatusType.error, 3), _STATUS_PRIORITIES);
|
|
19
17
|
exports.STATUS_PRIORITIES = STATUS_PRIORITIES;
|
|
20
|
-
|
|
21
18
|
function startLoggerCollection(lifeCycle) {
|
|
22
19
|
function handleLog(logsMessage, logger, savedCommonContext, savedDate) {
|
|
23
20
|
var messageContext = logsMessage.context;
|
|
24
|
-
|
|
25
21
|
if (isAuthorized(logsMessage.status, _logger.HandlerType.console, logger)) {
|
|
26
22
|
(0, _browserCore.display)(logsMessage.status, logsMessage.message, (0, _browserCore.extend2Lev)(logger.getContext(), messageContext));
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
30
25
|
rawLogsEvent: {
|
|
31
26
|
date: savedDate || (0, _browserCore.timeStampNow)(),
|
|
@@ -38,14 +33,13 @@ function startLoggerCollection(lifeCycle) {
|
|
|
38
33
|
logger: logger
|
|
39
34
|
});
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
return {
|
|
43
37
|
handleLog: handleLog
|
|
44
38
|
};
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
function isAuthorized(status, handlerType, logger) {
|
|
48
41
|
var loggerHandler = logger.getHandler();
|
|
49
42
|
var sanitizedHandlerType = (0, _browserCore.isArray)(loggerHandler) ? loggerHandler : [loggerHandler];
|
|
50
43
|
return STATUS_PRIORITIES[status] >= STATUS_PRIORITIES[logger.getLevel()] && (0, _browserCore.includes)(sanitizedHandlerType, handlerType);
|
|
51
|
-
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=loggerCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggerCollection.js","names":["_browserCore","require","_logger","_STATUS_PRIORITIES","_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","STATUS_PRIORITIES","StatusType","debug","info","warn","error","exports","startLoggerCollection","lifeCycle","handleLog","logsMessage","logger","savedCommonContext","savedDate","messageContext","context","isAuthorized","status","HandlerType","console","display","message","extend2Lev","getContext","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","date","timeStampNow","origin","ErrorSource","LOGGER","handlerType","loggerHandler","getHandler","sanitizedHandlerType","isArray","getLevel","includes"],"sources":["../../../../src/domain/logsCollection/logger/loggerCollection.js"],"sourcesContent":["import {\n includes,\n display,\n extend2Lev,\n ErrorSource,\n timeStampNow,\n LifeCycleEventType,\n isArray\n} from '@cloudcare/browser-core'\nimport { StatusType, HandlerType } from '../../logger'\n\nexport var STATUS_PRIORITIES = {\n [StatusType.debug]: 0,\n [StatusType.info]: 1,\n [StatusType.warn]: 2,\n [StatusType.error]: 3\n}\n\nexport function startLoggerCollection(lifeCycle) {\n function handleLog(logsMessage, logger, savedCommonContext, savedDate) {\n var messageContext = logsMessage.context\n if (isAuthorized(logsMessage.status, HandlerType.console, logger)) {\n display(\n logsMessage.status,\n logsMessage.message,\n extend2Lev(logger.getContext(), messageContext)\n )\n }\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\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 logger: logger\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}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,OAAA,GAAAD,OAAA;AAAsD,IAAAE,kBAAA;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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ClBP,WAAW,CAACW,OAAO,EACnB,IAAAC,uBAAU,EAACX,MAAM,CAACY,UAAU,CAAC,CAAC,EAAET,cAAc,CAChD,CAAC;IACH;IACAN,SAAS,CAACgB,MAAM,CAACC,+BAAkB,CAACC,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAEf,SAAS,IAAI,IAAAgB,yBAAY,EAAC,CAAC;QACjCR,OAAO,EAAEX,WAAW,CAACW,OAAO;QAC5BJ,MAAM,EAAEP,WAAW,CAACO,MAAM;QAC1Ba,MAAM,EAAEC,wBAAW,CAACC;MACtB,CAAC;MACDlB,cAAc,EAAEA,cAAc;MAC9BF,kBAAkB,EAAEA,kBAAkB;MACtCD,MAAM,EAAEA;IACV,CAAC,CAAC;EACJ;EAEA,OAAO;IACLF,SAAS,EAAEA;EACb,CAAC;AACH;AAEO,SAASO,YAAYA,CAACC,MAAM,EAAEgB,WAAW,EAAEtB,MAAM,EAAE;EACxD,IAAIuB,aAAa,GAAGvB,MAAM,CAACwB,UAAU,CAAC,CAAC;EACvC,IAAIC,oBAAoB,GAAG,IAAAC,oBAAO,EAACH,aAAa,CAAC,GAC7CA,aAAa,GACb,CAACA,aAAa,CAAC;EACnB,OACElC,iBAAiB,CAACiB,MAAM,CAAC,IAAIjB,iBAAiB,CAACW,MAAM,CAAC2B,QAAQ,CAAC,CAAC,CAAC,IACjE,IAAAC,qBAAQ,EAACH,oBAAoB,EAAEH,WAAW,CAAC;AAE/C"}
|
|
@@ -7,18 +7,14 @@ exports.computeFetchErrorText = computeFetchErrorText;
|
|
|
7
7
|
exports.computeFetchResponseText = computeFetchResponseText;
|
|
8
8
|
exports.computeXhrResponseData = computeXhrResponseData;
|
|
9
9
|
exports.startNetworkErrorCollection = startNetworkErrorCollection;
|
|
10
|
-
|
|
11
10
|
var _browserCore = require("@cloudcare/browser-core");
|
|
12
|
-
|
|
13
11
|
var _logger = require("../../logger");
|
|
14
|
-
|
|
15
12
|
function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
16
13
|
if (!configuration.forwardErrorsToLogs) {
|
|
17
14
|
return {
|
|
18
15
|
stop: _browserCore.noop
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
var xhrSubscription = (0, _browserCore.initXhrObservable)().subscribe(function (context) {
|
|
23
19
|
if (context.state === 'complete') {
|
|
24
20
|
handleCompleteRequest(_browserCore.RequestType.XHR, context);
|
|
@@ -29,7 +25,6 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
29
25
|
handleCompleteRequest(_browserCore.RequestType.FETCH, context);
|
|
30
26
|
}
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
function handleCompleteRequest(type, request) {
|
|
34
29
|
if (!configuration.isIntakeUrl(request.url) && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
|
|
35
30
|
if ('xhr' in request) {
|
|
@@ -40,7 +35,6 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
40
35
|
computeFetchErrorText(request.error, configuration, onResponseDataAvailable);
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
function onResponseDataAvailable(responseData) {
|
|
45
39
|
var urlObj = (0, _browserCore.urlParse)(request.url).getParse();
|
|
46
40
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
@@ -68,20 +62,19 @@ function startNetworkErrorCollection(configuration, lifeCycle) {
|
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
|
-
|
|
72
65
|
return {
|
|
73
66
|
stop: function stop() {
|
|
74
67
|
xhrSubscription.unsubscribe();
|
|
75
68
|
fetchSubscription.unsubscribe();
|
|
76
69
|
}
|
|
77
70
|
};
|
|
78
|
-
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// TODO: ideally, computeXhrResponseData should always call the callback with a string instead of
|
|
79
74
|
// `unknown`. But to keep backward compatibility, in the case of XHR with a `responseType` different
|
|
80
75
|
// than "text", the response data should be whatever `xhr.response` is. This is a bit confusing as
|
|
81
76
|
// Logs event 'stack' is expected to be a string. This should be changed in a future major version
|
|
82
77
|
// as it could be a breaking change.
|
|
83
|
-
|
|
84
|
-
|
|
85
78
|
function computeXhrResponseData(xhr, configuration, callback) {
|
|
86
79
|
if (typeof xhr.response === 'string') {
|
|
87
80
|
callback(truncateResponseText(xhr.response, configuration));
|
|
@@ -89,14 +82,11 @@ function computeXhrResponseData(xhr, configuration, callback) {
|
|
|
89
82
|
callback(xhr.response);
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
|
-
|
|
93
85
|
function computeFetchErrorText(error, configuration, callback) {
|
|
94
86
|
callback(truncateResponseText((0, _browserCore.toStackTraceString)((0, _browserCore.computeStackTrace)(error)), configuration));
|
|
95
87
|
}
|
|
96
|
-
|
|
97
88
|
function computeFetchResponseText(response, configuration, callback) {
|
|
98
89
|
var clonedResponse = (0, _browserCore.tryToClone)(response);
|
|
99
|
-
|
|
100
90
|
if (!clonedResponse || !clonedResponse.body) {
|
|
101
91
|
// if the clone failed or if the body is null, let's not try to read it.
|
|
102
92
|
callback();
|
|
@@ -143,46 +133,38 @@ function computeFetchResponseText(response, configuration, callback) {
|
|
|
143
133
|
});
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
|
-
|
|
147
136
|
function isRejected(request) {
|
|
148
137
|
return request.status === 0 && request.responseType !== 'opaque';
|
|
149
138
|
}
|
|
150
|
-
|
|
151
139
|
function isServerError(request) {
|
|
152
140
|
return request.status >= 500;
|
|
153
141
|
}
|
|
154
|
-
|
|
155
142
|
function truncateResponseText(responseText, configuration) {
|
|
156
143
|
if (responseText.length > configuration.requestErrorResponseLengthLimit) {
|
|
157
144
|
return responseText.substring(0, configuration.requestErrorResponseLengthLimit) + '...';
|
|
158
145
|
}
|
|
159
|
-
|
|
160
146
|
return responseText;
|
|
161
147
|
}
|
|
162
|
-
|
|
163
148
|
function format(type) {
|
|
164
149
|
if (_browserCore.RequestType.XHR === type) {
|
|
165
150
|
return 'XHR';
|
|
166
151
|
}
|
|
167
|
-
|
|
168
152
|
return 'Fetch';
|
|
169
153
|
}
|
|
170
|
-
|
|
171
154
|
function truncateResponseStream(stream, bytesLimit, callback) {
|
|
172
155
|
(0, _browserCore.readBytesFromStream)(stream, function (error, bytes, limitExceeded) {
|
|
173
156
|
if (error) {
|
|
174
157
|
callback(error);
|
|
175
158
|
} else {
|
|
176
159
|
var responseText = new TextDecoder().decode(bytes);
|
|
177
|
-
|
|
178
160
|
if (limitExceeded) {
|
|
179
161
|
responseText += '...';
|
|
180
162
|
}
|
|
181
|
-
|
|
182
163
|
callback(undefined, responseText);
|
|
183
164
|
}
|
|
184
165
|
}, {
|
|
185
166
|
bytesLimit: bytesLimit,
|
|
186
167
|
collectStreamBody: true
|
|
187
168
|
});
|
|
188
|
-
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=networkErrorCollection.js.map
|
|
@@ -0,0 +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","isIntakeUrl","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} 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 !configuration.isIntakeUrl(request.url) &&\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, // Todo: Remove in the next major release\n stack: responseData || 'Failed to load'\n },\n http: {\n method: request.method, // Cast resource method because of case mismatch cf issue RUMF-1152\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\n// TODO: ideally, computeXhrResponseData should always call the callback with a string instead of\n// `unknown`. But to keep backward compatibility, in the case of XHR with a `responseType` different\n// than \"text\", the response data should be whatever `xhr.response` is. This is a bit confusing as\n// Logs event 'stack' is expected to be a string. This should be changed in a future major version\n// as it could be a breaking change.\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,IAAAA,YAAA,GAAAC,OAAA;AAiBA,IAAAC,OAAA,GAAAD,OAAA;AAEO,SAASE,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEC;IAAK,CAAC;EACvB;EAEA,IAAIC,eAAe,GAAG,IAAAC,8BAAiB,EAAC,CAAC,CAACC,SAAS,CAAC,UAAUC,OAAO,EAAE;IACrE,IAAIA,OAAO,CAACC,KAAK,KAAK,UAAU,EAAE;MAChCC,qBAAqB,CAACC,wBAAW,CAACC,GAAG,EAAEJ,OAAO,CAAC;IACjD;EACF,CAAC,CAAC;EACF,IAAIK,iBAAiB,GAAG,IAAAC,gCAAmB,EAAC,CAAC,CAACP,SAAS,CAAC,UAAUC,OAAO,EAAE;IACzE,IAAIA,OAAO,CAACC,KAAK,KAAK,SAAS,EAAE;MAC/BC,qBAAqB,CAACC,wBAAW,CAACI,KAAK,EAAEP,OAAO,C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,CAAC,EAAE7E,aAAa,CAACyE,+BAA+B,CAAC,GACxE,KAAK;EAET;EACA,OAAOC,YAAY;AACrB;AAEA,SAASpC,MAAMA,CAACtB,IAAI,EAAE;EACpB,IAAIL,wBAAW,CAACC,GAAG,KAAKI,IAAI,EAAE;IAC5B,OAAO,KAAK;EACd;EACA,OAAO,OAAO;AAChB;AAEA,SAASwD,sBAAsBA,CAACM,MAAM,EAAEC,UAAU,EAAEnB,QAAQ,EAAE;EAC5D,IAAAoB,gCAAmB,EACjBF,MAAM,EACN,UAAUnD,KAAK,EAAEsD,KAAK,EAAEC,aAAa,EAAE;IACrC,IAAIvD,KAAK,EAAE;MACTiC,QAAQ,CAACjC,KAAK,CAAC;IACjB,CAAC,MAAM;MACL,IAAI+C,YAAY,GAAG,IAAIN,WAAW,CAAC,CAAC,CAACe,MAAM,CAACF,KAAK,CAAC;MAClD,IAAIC,aAAa,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"}
|
|
@@ -4,23 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startReportCollection = startReportCollection;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
var _logger = require("../../logger");
|
|
11
|
-
|
|
12
9
|
var _LogStatusForReport;
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
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); }
|
|
16
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);
|
|
17
|
-
|
|
18
15
|
function startReportCollection(configuration, lifeCycle) {
|
|
19
|
-
var reportSubscription = (0, _browserCore.initReportObservable)(configuration.forwardReports).subscribe(function (report) {
|
|
16
|
+
var reportSubscription = (0, _browserCore.initReportObservable)(configuration, configuration.forwardReports).subscribe(function (report) {
|
|
20
17
|
var message = report.message;
|
|
21
18
|
var status = LogStatusForReport[report.type];
|
|
22
19
|
var error;
|
|
23
|
-
|
|
24
20
|
if (status === _logger.StatusType.error) {
|
|
25
21
|
error = {
|
|
26
22
|
kind: report.subtype,
|
|
@@ -31,7 +27,6 @@ function startReportCollection(configuration, lifeCycle) {
|
|
|
31
27
|
} else if (report.stack) {
|
|
32
28
|
message += ' Found in ' + (0, _browserCore.getFileFromStackTraceString)(report.stack);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
|
|
36
31
|
rawLogsEvent: {
|
|
37
32
|
date: (0, _browserCore.timeStampNow)(),
|
|
@@ -47,4 +42,5 @@ function startReportCollection(configuration, lifeCycle) {
|
|
|
47
42
|
reportSubscription.unsubscribe();
|
|
48
43
|
}
|
|
49
44
|
};
|
|
50
|
-
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=reportCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportCollection.js","names":["_browserCore","require","_logger","_LogStatusForReport","_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","LogStatusForReport","RawReportType","cspViolation","StatusType","error","intervention","deprecation","warn","startReportCollection","configuration","lifeCycle","reportSubscription","initReportObservable","forwardReports","subscribe","report","message","status","type","kind","subtype","origin","ErrorSource","REPORT","stack","getFileFromStackTraceString","notify","LifeCycleEventType","RAW_LOG_COLLECTED","rawLogsEvent","date","timeStampNow","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/report/reportCollection.js"],"sourcesContent":["import {\n timeStampNow,\n ErrorSource,\n RawReportType,\n getFileFromStackTraceString,\n initReportObservable,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nvar LogStatusForReport = {\n [RawReportType.cspViolation]: StatusType.error,\n [RawReportType.intervention]: StatusType.error,\n [RawReportType.deprecation]: StatusType.warn\n}\n\nexport function startReportCollection(configuration, lifeCycle) {\n var reportSubscription = initReportObservable(\n configuration,\n configuration.forwardReports\n ).subscribe(function (report) {\n var message = report.message\n var status = LogStatusForReport[report.type]\n var error\n if (status === StatusType.error) {\n error = {\n kind: report.subtype,\n origin: ErrorSource.REPORT, // Todo: Remove in the next major release\n stack: report.stack\n }\n } else if (report.stack) {\n message += ' Found in ' + getFileFromStackTraceString(report.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;AAQA,IAAAC,OAAA,GAAAD,OAAA;AAAyC,IAAAE,mBAAA;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,CAAAD,GAAA,oBAAAf,OAAA,CAAAO,GAAA,iBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,QAAAnB,OAAA,CAAAkB,KAAA,kBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAhB,MAAA,CAAAmB,WAAA,OAAAD,IAAA,KAAAE,SAAA,QAAAC,GAAA,GAAAH,IAAA,CAAAI,IAAA,CAAAN,KAAA,EAAAC,IAAA,oB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