@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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPreStartStrategy = createPreStartStrategy;
|
|
7
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
8
|
+
var _configuration = require("../domain/configuration");
|
|
9
|
+
function createPreStartStrategy(getCommonContext, doStartLogs) {
|
|
10
|
+
var bufferApiCalls = (0, _browserCore.createBoundedBuffer)();
|
|
11
|
+
var cachedInitConfiguration;
|
|
12
|
+
var cachedConfiguration;
|
|
13
|
+
function tryStartLogs() {
|
|
14
|
+
if (!cachedConfiguration || !cachedInitConfiguration) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
var startLogsResult = doStartLogs(cachedInitConfiguration, cachedConfiguration);
|
|
18
|
+
bufferApiCalls.drain(startLogsResult);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
init: function init(initConfiguration) {
|
|
22
|
+
if (!initConfiguration) {
|
|
23
|
+
_browserCore.display.error('Missing configuration');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Set the experimental feature flags as early as possible, so we can use them in most places
|
|
27
|
+
|
|
28
|
+
if ((0, _browserCore.canUseEventBridge)()) {
|
|
29
|
+
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Expose the initial configuration regardless of initialization success.
|
|
33
|
+
cachedInitConfiguration = initConfiguration;
|
|
34
|
+
if (cachedConfiguration) {
|
|
35
|
+
(0, _browserCore.displayAlreadyInitializedError)('DATAFLUX_LOGS', initConfiguration);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var configuration = (0, _configuration.validateAndBuildLogsConfiguration)(initConfiguration);
|
|
39
|
+
if (!configuration) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
cachedConfiguration = configuration;
|
|
43
|
+
// Instrumuent fetch to track network requests
|
|
44
|
+
// This is needed in case the consent is not granted and some cutsomer
|
|
45
|
+
// library (Apollo Client) is storing uninstrumented fetch to be used later
|
|
46
|
+
// The subscrption is needed so that the instrumentation process is completed
|
|
47
|
+
(0, _browserCore.initFetchObservable)().subscribe(_browserCore.noop);
|
|
48
|
+
tryStartLogs();
|
|
49
|
+
},
|
|
50
|
+
getInitConfiguration: function getInitConfiguration() {
|
|
51
|
+
return cachedInitConfiguration;
|
|
52
|
+
},
|
|
53
|
+
getInternalContext: _browserCore.noop,
|
|
54
|
+
handleLog: function handleLog(message, statusType, handlingStack, context, date) {
|
|
55
|
+
if (context === undefined) {
|
|
56
|
+
context = getCommonContext();
|
|
57
|
+
}
|
|
58
|
+
if (date === undefined) {
|
|
59
|
+
date = (0, _browserCore.timeStampNow)();
|
|
60
|
+
}
|
|
61
|
+
bufferApiCalls.add(function (startLogsResult) {
|
|
62
|
+
startLogsResult.handleLog(message, statusType, handlingStack, context, date);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function overrideInitConfigurationForBridge(initConfiguration) {
|
|
68
|
+
return (0, _browserCore.assign)({}, initConfiguration, {
|
|
69
|
+
clientToken: 'empty'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=preStartLogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preStartLogs.js","names":["_browserCore","require","_configuration","createPreStartStrategy","getCommonContext","doStartLogs","bufferApiCalls","createBoundedBuffer","cachedInitConfiguration","cachedConfiguration","tryStartLogs","startLogsResult","drain","init","initConfiguration","display","error","canUseEventBridge","overrideInitConfigurationForBridge","displayAlreadyInitializedError","configuration","validateAndBuildLogsConfiguration","initFetchObservable","subscribe","noop","getInitConfiguration","getInternalContext","handleLog","message","statusType","handlingStack","context","date","undefined","timeStampNow","add","assign","clientToken"],"sources":["../../src/boot/preStartLogs.js"],"sourcesContent":["import {\n createBoundedBuffer,\n assign,\n canUseEventBridge,\n display,\n displayAlreadyInitializedError,\n initFetchObservable,\n noop,\n timeStampNow\n} from '@cloudcare/browser-core'\nimport { validateAndBuildLogsConfiguration } from '../domain/configuration'\n\nexport function createPreStartStrategy(getCommonContext, doStartLogs) {\n const bufferApiCalls = createBoundedBuffer()\n let cachedInitConfiguration\n let cachedConfiguration\n\n function tryStartLogs() {\n if (!cachedConfiguration || !cachedInitConfiguration) {\n return\n }\n\n var startLogsResult = doStartLogs(\n cachedInitConfiguration,\n cachedConfiguration\n )\n bufferApiCalls.drain(startLogsResult)\n }\n\n return {\n init: function (initConfiguration) {\n if (!initConfiguration) {\n display.error('Missing configuration')\n return\n }\n // Set the experimental feature flags as early as possible, so we can use them in most places\n\n if (canUseEventBridge()) {\n initConfiguration =\n overrideInitConfigurationForBridge(initConfiguration)\n }\n\n // Expose the initial configuration regardless of initialization success.\n cachedInitConfiguration = initConfiguration\n\n if (cachedConfiguration) {\n displayAlreadyInitializedError('DATAFLUX_LOGS', initConfiguration)\n return\n }\n\n const configuration = validateAndBuildLogsConfiguration(initConfiguration)\n if (!configuration) {\n return\n }\n\n cachedConfiguration = configuration\n // Instrumuent fetch to track network requests\n // This is needed in case the consent is not granted and some cutsomer\n // library (Apollo Client) is storing uninstrumented fetch to be used later\n // The subscrption is needed so that the instrumentation process is completed\n initFetchObservable().subscribe(noop)\n\n tryStartLogs()\n },\n\n getInitConfiguration: function () {\n return cachedInitConfiguration\n },\n\n getInternalContext: noop,\n\n handleLog: function (message, statusType, handlingStack, context, date) {\n if (context === undefined) {\n context = getCommonContext()\n }\n if (date === undefined) {\n date = timeStampNow()\n }\n bufferApiCalls.add(function (startLogsResult) {\n startLogsResult.handleLog(\n message,\n statusType,\n handlingStack,\n context,\n date\n )\n })\n }\n }\n}\n\nfunction overrideInitConfigurationForBridge(initConfiguration) {\n return assign({}, initConfiguration, { clientToken: 'empty' })\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAUA,IAAAC,cAAA,GAAAD,OAAA;AAEO,SAASE,sBAAsBA,CAACC,gBAAgB,EAAEC,WAAW,EAAE;EACpE,IAAMC,cAAc,GAAG,IAAAC,gCAAmB,EAAC,CAAC;EAC5C,IAAIC,uBAAuB;EAC3B,IAAIC,mBAAmB;EAEvB,SAASC,YAAYA,CAAA,EAAG;IACtB,IAAI,CAACD,mBAAmB,IAAI,CAACD,uBAAuB,EAAE;MACpD;IACF;IAEA,IAAIG,eAAe,GAAGN,WAAW,CAC/BG,uBAAuB,EACvBC,mBACF,CAAC;IACDH,cAAc,CAACM,KAAK,CAACD,eAAe,CAAC;EACvC;EAEA,OAAO;IACLE,IAAI,EAAE,SAAAA,KAAUC,iBAAiB,EAAE;MACjC,IAAI,CAACA,iBAAiB,EAAE;QACtBC,oBAAO,CAACC,KAAK,CAAC,uBAAuB,CAAC;QACtC;MACF;MACA;;MAEA,IAAI,IAAAC,8BAAiB,EAAC,CAAC,EAAE;QACvBH,iBAAiB,GACfI,kCAAkC,CAACJ,iBAAiB,CAAC;MACzD;;MAEA;MACAN,uBAAuB,GAAGM,iBAAiB;MAE3C,IAAIL,mBAAmB,EAAE;QACvB,IAAAU,2CAA8B,EAAC,eAAe,EAAEL,iBAAiB,CAAC;QAClE;MACF;MAEA,IAAMM,aAAa,GAAG,IAAAC,gDAAiC,EAACP,iBAAiB,CAAC;MAC1E,IAAI,CAACM,aAAa,EAAE;QAClB;MACF;MAEAX,mBAAmB,GAAGW,aAAa;MACnC;MACA;MACA;MACA;MACA,IAAAE,gCAAmB,EAAC,CAAC,CAACC,SAAS,CAACC,iBAAI,CAAC;MAErCd,YAAY,CAAC,CAAC;IAChB,CAAC;IAEDe,oBAAoB,EAAE,SAAAA,qBAAA,EAAY;MAChC,OAAOjB,uBAAuB;IAChC,CAAC;IAEDkB,kBAAkB,EAAEF,iBAAI;IAExBG,SAAS,EAAE,SAAAA,UAAUC,OAAO,EAAEC,UAAU,EAAEC,aAAa,EAAEC,OAAO,EAAEC,IAAI,EAAE;MACtE,IAAID,OAAO,KAAKE,SAAS,EAAE;QACzBF,OAAO,GAAG3B,gBAAgB,CAAC,CAAC;MAC9B;MACA,IAAI4B,IAAI,KAAKC,SAAS,EAAE;QACtBD,IAAI,GAAG,IAAAE,yBAAY,EAAC,CAAC;MACvB;MACA5B,cAAc,CAAC6B,GAAG,CAAC,UAAUxB,eAAe,EAAE;QAC5CA,eAAe,CAACgB,SAAS,CACvBC,OAAO,EACPC,UAAU,EACVC,aAAa,EACbC,OAAO,EACPC,IACF,CAAC;MACH,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAEA,SAASd,kCAAkCA,CAACJ,iBAAiB,EAAE;EAC7D,OAAO,IAAAsB,mBAAM,EAAC,CAAC,CAAC,EAAEtB,iBAAiB,EAAE;IAAEuB,WAAW,EAAE;EAAQ,CAAC,CAAC;AAChE","ignoreList":[]}
|
package/cjs/boot/startLogs.js
CHANGED
|
@@ -12,27 +12,44 @@ var _reportCollection = require("../domain/logsCollection/report/reportCollectio
|
|
|
12
12
|
var _networkErrorCollection = require("../domain/logsCollection/networkError/networkErrorCollection");
|
|
13
13
|
var _runtimeErrorCollection = require("../domain/logsCollection/rumtimeError/runtimeErrorCollection");
|
|
14
14
|
var _loggerCollection = require("../domain/logsCollection/logger/loggerCollection");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
function startLogs(
|
|
15
|
+
var _startLogsBatch2 = require("../transport/startLogsBatch");
|
|
16
|
+
var _internalContext = require("../domain/contexts/internalContext");
|
|
17
|
+
var _reportError = require("../domain/reportError");
|
|
18
|
+
function startLogs(initConfiguration, configuration, getCommonContext) {
|
|
19
19
|
var lifeCycle = new _browserCore.LifeCycle();
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
var cleanupTasks = [];
|
|
21
|
+
var reportError = (0, _reportError.startReportError)(lifeCycle);
|
|
22
|
+
var pageExitObservable = (0, _browserCore.createPageExitObservable)();
|
|
23
|
+
var session = (0, _browserCore.areCookiesAuthorized)(configuration.cookieOptions) && !(0, _browserCore.canUseEventBridge)() && !(0, _browserCore.willSyntheticsInjectRum)() ? (0, _logsSessionManager.startLogsSessionManager)(configuration) : (0, _logsSessionManager.startLogsSessionManagerStub)(configuration);
|
|
24
|
+
var telemetry = startLogsTelemetry(initConfiguration, configuration, reportError, pageExitObservable, session);
|
|
25
|
+
cleanupTasks.push(function () {
|
|
26
|
+
telemetry.stop();
|
|
27
|
+
});
|
|
28
|
+
(0, _networkErrorCollection.startNetworkErrorCollection)(configuration, lifeCycle);
|
|
29
|
+
(0, _runtimeErrorCollection.startRuntimeErrorCollection)(configuration, lifeCycle);
|
|
30
|
+
(0, _consoleCollection.startConsoleCollection)(configuration, lifeCycle);
|
|
31
|
+
(0, _reportCollection.startReportCollection)(configuration, lifeCycle);
|
|
32
|
+
var _startLoggerCollection = (0, _loggerCollection.startLoggerCollection)(lifeCycle);
|
|
33
|
+
(0, _assembly.startLogsAssembly)(session, configuration, lifeCycle, getCommonContext, reportError);
|
|
34
|
+
if (!(0, _browserCore.canUseEventBridge)()) {
|
|
35
|
+
var _startLogsBatch = (0, _startLogsBatch2.startLogsBatch)(configuration, lifeCycle, reportError, pageExitObservable, session);
|
|
36
|
+
cleanupTasks.push(function () {
|
|
37
|
+
_startLogsBatch.stop();
|
|
31
38
|
});
|
|
39
|
+
}
|
|
40
|
+
var internalContext = (0, _internalContext.startInternalContext)(session);
|
|
41
|
+
return {
|
|
42
|
+
handleLog: _startLoggerCollection.handleLog,
|
|
43
|
+
getInternalContext: internalContext.get,
|
|
44
|
+
stop: function stop() {
|
|
45
|
+
cleanupTasks.forEach(function (task) {
|
|
46
|
+
task();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
32
49
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var telemetry =
|
|
50
|
+
}
|
|
51
|
+
function startLogsTelemetry(initConfiguration, configuration, reportError, pageExitObservable, session) {
|
|
52
|
+
var telemetry = (0, _browserCore.startTelemetry)(_browserCore.TelemetryService.LOGS, configuration);
|
|
36
53
|
telemetry.setContextProvider(function () {
|
|
37
54
|
var RUMInternalContext = (0, _assembly.getRUMInternalContext)();
|
|
38
55
|
return {
|
|
@@ -50,29 +67,31 @@ function startLogs(configuration, buildCommonContext, mainLogger) {
|
|
|
50
67
|
}
|
|
51
68
|
};
|
|
52
69
|
});
|
|
53
|
-
|
|
54
|
-
(0, _runtimeErrorCollection.startRuntimeErrorCollection)(configuration, lifeCycle);
|
|
55
|
-
(0, _consoleCollection.startConsoleCollection)(configuration, lifeCycle);
|
|
56
|
-
(0, _reportCollection.startReportCollection)(configuration, lifeCycle);
|
|
57
|
-
var _startLoggerCollection = (0, _loggerCollection.startLoggerCollection)(lifeCycle);
|
|
58
|
-
(0, _assembly.startLogsAssembly)(session, configuration, lifeCycle, buildCommonContext, mainLogger, reportError);
|
|
59
|
-
if (!(0, _browserCore.canUseEventBridge)()) {
|
|
60
|
-
(0, _startLogsBatch.startLogsBatch)(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable);
|
|
61
|
-
}
|
|
62
|
-
var internalContext = (0, _internalContext.startInternalContext)(session);
|
|
63
|
-
return {
|
|
64
|
-
handleLog: _startLoggerCollection.handleLog,
|
|
65
|
-
getInternalContext: internalContext.get
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function startLogsTelemetry(configuration, reportError, pageExitObservable, sessionExpireObservable) {
|
|
69
|
-
var telemetry = (0, _browserCore.startTelemetry)(_browserCore.TelemetryService.LOGS, configuration);
|
|
70
|
+
var cleanupTasks = [];
|
|
70
71
|
if (!(0, _browserCore.canUseEventBridge)()) {
|
|
71
|
-
var telemetryBatch = (0, _browserCore.startBatchWithReplica)(configuration,
|
|
72
|
-
|
|
72
|
+
var telemetryBatch = (0, _browserCore.startBatchWithReplica)(configuration, {
|
|
73
|
+
endpoint: configuration.rumEndpoint,
|
|
74
|
+
encoder: (0, _browserCore.createIdentityEncoder)()
|
|
75
|
+
}, reportError, pageExitObservable, session.expireObservable);
|
|
76
|
+
cleanupTasks.push(function () {
|
|
77
|
+
telemetryBatch.stop();
|
|
78
|
+
});
|
|
79
|
+
var telemetrySubscription = telemetry.observable.subscribe(function (event) {
|
|
73
80
|
telemetryBatch.add(event);
|
|
74
81
|
});
|
|
82
|
+
cleanupTasks.push(function () {
|
|
83
|
+
telemetrySubscription.unsubscribe();
|
|
84
|
+
});
|
|
75
85
|
}
|
|
76
|
-
|
|
86
|
+
(0, _browserCore.drainPreStartTelemetry)();
|
|
87
|
+
(0, _browserCore.addTelemetryConfiguration)((0, _browserCore.deepClone)(initConfiguration));
|
|
88
|
+
return {
|
|
89
|
+
telemetry: telemetry,
|
|
90
|
+
stop: function stop() {
|
|
91
|
+
cleanupTasks.forEach(function (task) {
|
|
92
|
+
task();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
77
96
|
}
|
|
78
97
|
//# sourceMappingURL=startLogs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startLogs.js","names":["_browserCore","require","_logsSessionManager","_assembly","_consoleCollection","_reportCollection","_networkErrorCollection","_runtimeErrorCollection","_loggerCollection","
|
|
1
|
+
{"version":3,"file":"startLogs.js","names":["_browserCore","require","_logsSessionManager","_assembly","_consoleCollection","_reportCollection","_networkErrorCollection","_runtimeErrorCollection","_loggerCollection","_startLogsBatch2","_internalContext","_reportError","startLogs","initConfiguration","configuration","getCommonContext","lifeCycle","LifeCycle","cleanupTasks","reportError","startReportError","pageExitObservable","createPageExitObservable","session","areCookiesAuthorized","cookieOptions","canUseEventBridge","willSyntheticsInjectRum","startLogsSessionManager","startLogsSessionManagerStub","telemetry","startLogsTelemetry","push","stop","startNetworkErrorCollection","startRuntimeErrorCollection","startConsoleCollection","startReportCollection","_startLoggerCollection","startLoggerCollection","startLogsAssembly","_startLogsBatch","startLogsBatch","internalContext","startInternalContext","handleLog","getInternalContext","get","forEach","task","startTelemetry","TelemetryService","LOGS","setContextProvider","RUMInternalContext","getRUMInternalContext","application","id","findTrackedSession","view","action","userAction","telemetryBatch","startBatchWithReplica","endpoint","rumEndpoint","encoder","createIdentityEncoder","expireObservable","telemetrySubscription","observable","subscribe","event","add","unsubscribe","drainPreStartTelemetry","addTelemetryConfiguration","deepClone"],"sources":["../../src/boot/startLogs.js"],"sourcesContent":["import {\n LifeCycle,\n createPageExitObservable,\n areCookiesAuthorized,\n willSyntheticsInjectRum,\n startTelemetry,\n startBatchWithReplica,\n canUseEventBridge,\n TelemetryService,\n drainPreStartTelemetry,\n createIdentityEncoder,\n addTelemetryConfiguration,\n deepClone\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 { startInternalContext } from '../domain/contexts/internalContext'\nimport { startReportError } from '../domain/reportError'\nexport function startLogs(initConfiguration, configuration, getCommonContext) {\n var lifeCycle = new LifeCycle()\n var cleanupTasks = []\n var reportError = startReportError(lifeCycle)\n var pageExitObservable = createPageExitObservable()\n var session =\n areCookiesAuthorized(configuration.cookieOptions) &&\n !canUseEventBridge() &&\n !willSyntheticsInjectRum()\n ? startLogsSessionManager(configuration)\n : startLogsSessionManagerStub(configuration)\n const telemetry = startLogsTelemetry(\n initConfiguration,\n configuration,\n reportError,\n pageExitObservable,\n session\n )\n cleanupTasks.push(function () {\n telemetry.stop()\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 getCommonContext,\n reportError\n )\n if (!canUseEventBridge()) {\n var _startLogsBatch = startLogsBatch(\n configuration,\n lifeCycle,\n reportError,\n pageExitObservable,\n session\n )\n cleanupTasks.push(function () {\n _startLogsBatch.stop()\n })\n }\n\n var internalContext = startInternalContext(session)\n\n return {\n handleLog: _startLoggerCollection.handleLog,\n getInternalContext: internalContext.get,\n stop: function () {\n cleanupTasks.forEach(function (task) {\n task()\n })\n }\n }\n}\nfunction startLogsTelemetry(\n initConfiguration,\n configuration,\n reportError,\n pageExitObservable,\n session\n) {\n const telemetry = startTelemetry(TelemetryService.LOGS, configuration)\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 var cleanupTasks = []\n if (!canUseEventBridge()) {\n var telemetryBatch = startBatchWithReplica(\n configuration,\n { endpoint: configuration.rumEndpoint, encoder: createIdentityEncoder() },\n reportError,\n pageExitObservable,\n session.expireObservable\n )\n cleanupTasks.push(function () {\n telemetryBatch.stop()\n })\n var telemetrySubscription = telemetry.observable.subscribe(function (\n event\n ) {\n telemetryBatch.add(event)\n })\n cleanupTasks.push(function () {\n telemetrySubscription.unsubscribe()\n })\n }\n drainPreStartTelemetry()\n addTelemetryConfiguration(deepClone(initConfiguration))\n return {\n telemetry: telemetry,\n stop: function () {\n cleanupTasks.forEach(function (task) {\n task()\n })\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAcA,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,gBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACO,SAASW,SAASA,CAACC,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE;EAC5E,IAAIC,SAAS,GAAG,IAAIC,sBAAS,CAAC,CAAC;EAC/B,IAAIC,YAAY,GAAG,EAAE;EACrB,IAAIC,WAAW,GAAG,IAAAC,6BAAgB,EAACJ,SAAS,CAAC;EAC7C,IAAIK,kBAAkB,GAAG,IAAAC,qCAAwB,EAAC,CAAC;EACnD,IAAIC,OAAO,GACT,IAAAC,iCAAoB,EAACV,aAAa,CAACW,aAAa,CAAC,IACjD,CAAC,IAAAC,8BAAiB,EAAC,CAAC,IACpB,CA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AC;IACF,IAAIoC,qBAAqB,GAAGvC,SAAS,CAACwC,UAAU,CAACC,SAAS,CAAC,UACzDC,KAAK,EACL;MACAV,cAAc,CAACW,GAAG,CAACD,KAAK,CAAC;IAC3B,CAAC,CAAC;IACFtD,YAAY,CAACc,IAAI,CAAC,YAAY;MAC5BqC,qBAAqB,CAACK,WAAW,CAAC,CAAC;IACrC,CAAC,CAAC;EACJ;EACA,IAAAC,mCAAsB,EAAC,CAAC;EACxB,IAAAC,sCAAyB,EAAC,IAAAC,sBAAS,EAAChE,iBAAiB,CAAC,CAAC;EACvD,OAAO;IACLiB,SAAS,EAAEA,SAAS;IACpBG,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBf,YAAY,CAAC8B,OAAO,CAAC,UAAUC,IAAI,EAAE;QACnCA,IAAI,CAAC,CAAC;MACR,CAAC,CAAC;IACJ;EACF,CAAC;AACH","ignoreList":[]}
|
package/cjs/domain/assembly.js
CHANGED
|
@@ -7,25 +7,23 @@ exports.getRUMInternalContext = getRUMInternalContext;
|
|
|
7
7
|
exports.startLogsAssembly = startLogsAssembly;
|
|
8
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
9
|
var _logger = require("./logger");
|
|
10
|
-
|
|
11
|
-
function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommonContext, mainLogger, reportError) {
|
|
10
|
+
function startLogsAssembly(sessionManager, configuration, lifeCycle, getCommonContext, reportError) {
|
|
12
11
|
var statusWithCustom = _logger.STATUSES.concat(['custom']);
|
|
13
12
|
var logRateLimiters = {};
|
|
14
13
|
(0, _browserCore.each)(statusWithCustom, function (status) {
|
|
15
14
|
logRateLimiters[status] = (0, _browserCore.createEventRateLimiter)(status, configuration.eventRateLimiterThreshold, reportError);
|
|
16
15
|
});
|
|
17
16
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, function (data) {
|
|
18
|
-
// { rawLogsEvent, messageContext = undefined, savedCommonContext = undefined, logger = mainLogger }
|
|
19
17
|
var rawLogsEvent = data.rawLogsEvent;
|
|
20
18
|
var messageContext = data.messageContext || undefined;
|
|
21
19
|
var savedCommonContext = data.savedCommonContext || undefined;
|
|
22
|
-
var
|
|
20
|
+
var domainContext = data.domainContext;
|
|
23
21
|
var startTime = (0, _browserCore.getRelativeTime)(rawLogsEvent.date);
|
|
24
22
|
var session = sessionManager.findTrackedSession(startTime);
|
|
25
23
|
if (!session) {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
|
-
var commonContext = savedCommonContext ||
|
|
26
|
+
var commonContext = savedCommonContext || getCommonContext();
|
|
29
27
|
var log = (0, _browserCore.extend2Lev)({
|
|
30
28
|
service: configuration.service || 'browser',
|
|
31
29
|
env: configuration.env || '',
|
|
@@ -41,8 +39,8 @@ function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommon
|
|
|
41
39
|
user: !(0, _browserCore.isEmptyObject)(commonContext.user) ? commonContext.user : undefined,
|
|
42
40
|
device: _browserCore.deviceInfo,
|
|
43
41
|
type: _browserCore.RumEventType.LOGGER
|
|
44
|
-
}, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent,
|
|
45
|
-
if (
|
|
42
|
+
}, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, messageContext);
|
|
43
|
+
if (configuration.beforeSend && configuration.beforeSend(log, domainContext) === false || log.origin !== _browserCore.ErrorSource.AGENT && (0, _browserCore.isNullUndefinedDefaultValue)(logRateLimiters[log.status], logRateLimiters['custom']).isLimitReached()) {
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
48
46
|
lifeCycle.notify(_browserCore.LifeCycleEventType.LOG_COLLECTED, (0, _browserCore.withSnakeCaseKeys)(log));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assembly.js","names":["_browserCore","require","_logger","
|
|
1
|
+
{"version":3,"file":"assembly.js","names":["_browserCore","require","_logger","startLogsAssembly","sessionManager","configuration","lifeCycle","getCommonContext","reportError","statusWithCustom","STATUSES","concat","logRateLimiters","each","status","createEventRateLimiter","eventRateLimiterThreshold","subscribe","LifeCycleEventType","RAW_LOG_COLLECTED","data","rawLogsEvent","messageContext","undefined","savedCommonContext","domainContext","startTime","getRelativeTime","date","session","findTrackedSession","commonContext","log","extend2Lev","service","env","version","_gc","sdkName","sdkVersion","id","view","user","isEmptyObject","device","deviceInfo","type","RumEventType","LOGGER","context","getRUMInternalContext","beforeSend","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 } from './logger'\n\nexport function startLogsAssembly(\n sessionManager,\n configuration,\n lifeCycle,\n getCommonContext,\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 var rawLogsEvent = data.rawLogsEvent\n var messageContext = data.messageContext || undefined\n var savedCommonContext = data.savedCommonContext || undefined\n var domainContext = data.domainContext\n var startTime = getRelativeTime(rawLogsEvent.date)\n var session = sessionManager.findTrackedSession(startTime)\n\n if (!session) {\n return\n }\n var commonContext = savedCommonContext || getCommonContext()\n var log = extend2Lev(\n {\n service: configuration.service || 'browser',\n env: configuration.env || '',\n version: configuration.version || '',\n _gc: {\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 messageContext\n )\n\n if (\n (configuration.beforeSend &&\n configuration.beforeSend(log, domainContext) === false) ||\n (log.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;AAEO,SAASE,iBAAiBA,CAC/BC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,WAAW,EACX;EACA,IAAIC,gBAAgB,GAAGC,gBAAQ,CAACC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;EAClD,IAAIC,eAAe,GAAG,CAAC,CAAC;EACxB,IAAAC,iBAAI,EAACJ,gBAAgB,EAAE,UAAUK,MAAM,EAAE;IACvCF,eAAe,CAACE,MAAM,CAAC,GAAG,IAAAC,mCAAsB,EAC9CD,MAAM,EACNT,aAAa,CAACW,yBAAyB,EACvCR,WACF,CAAC;EACH,CAAC,CAAC;EACFF,SAAS,CAACW,SAAS,CAACC,+BAAkB,CAACC,iBAAiB,EAAE,UAAUC,IAAI,EAAE;IACxE,IAAIC,YAAY,GAAGD,IAAI,CAACC,YAAY;IACpC,IAAIC,cAAc,GAAGF,IAAI,CAACE,cAAc,IAAIC,SAAS;IACrD,IAAIC,kBAAkB,GAAGJ,IAAI,CAACI,kBAAkB,IAAID,SAAS;IAC7D,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AC1B,CAAC,CAAC4C,cAAc,CAAC,CAAE,EACrB;MACA;IACF;IAEAlD,SAAS,CAACmD,MAAM,CAACvC,+BAAkB,CAACwC,aAAa,EAAE,IAAAC,8BAAiB,EAAC3B,GAAG,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ;AAEO,SAASkB,qBAAqBA,CAACxB,SAAS,EAAE;EAC/C,OAAOkC,+BAA+B,CAACC,MAAM,CAACC,YAAY,CAAC;EAE3D,SAASF,+BAA+BA,CAACG,SAAS,EAAE;IAClD,IAAIA,SAAS,IAAIA,SAAS,CAACC,kBAAkB,EAAE;MAC7C,OAAOD,SAAS,CAACC,kBAAkB,CAACtC,SAAS,CAAC;IAChD;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildCommonContext = buildCommonContext;
|
|
7
|
+
function buildCommonContext(globalContextManager, userContextManager) {
|
|
8
|
+
return {
|
|
9
|
+
view: {
|
|
10
|
+
referrer: document.referrer,
|
|
11
|
+
url: window.location.href
|
|
12
|
+
},
|
|
13
|
+
context: globalContextManager.getContext(),
|
|
14
|
+
user: userContextManager.getContext()
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=commonContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonContext.js","names":["buildCommonContext","globalContextManager","userContextManager","view","referrer","document","url","window","location","href","context","getContext","user"],"sources":["../../../src/domain/contexts/commonContext.js"],"sourcesContent":["export function buildCommonContext(globalContextManager, userContextManager) {\n return {\n view: {\n referrer: document.referrer,\n url: window.location.href\n },\n context: globalContextManager.getContext(),\n user: userContextManager.getContext()\n }\n}\n"],"mappings":";;;;;;AAAO,SAASA,kBAAkBA,CAACC,oBAAoB,EAAEC,kBAAkB,EAAE;EAC3E,OAAO;IACLC,IAAI,EAAE;MACJC,QAAQ,EAAEC,QAAQ,CAACD,QAAQ;MAC3BE,GAAG,EAAEC,MAAM,CAACC,QAAQ,CAACC;IACvB,CAAC;IACDC,OAAO,EAAET,oBAAoB,CAACU,UAAU,CAAC,CAAC;IAC1CC,IAAI,EAAEV,kBAAkB,CAACS,UAAU,CAAC;EACtC,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalContext.js","names":["startInternalContext","sessionManager","get","startTime","trackedSession","findTrackedSession","session","id"],"sources":["../../../src/domain/contexts/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","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createErrorFieldFromRawError = createErrorFieldFromRawError;
|
|
7
|
+
function createErrorFieldFromRawError(rawError, options) {
|
|
8
|
+
if (options === undefined) {
|
|
9
|
+
options = {};
|
|
10
|
+
}
|
|
11
|
+
var includeMessage = options.includeMessage || false;
|
|
12
|
+
return {
|
|
13
|
+
stack: rawError.stack,
|
|
14
|
+
kind: rawError.type,
|
|
15
|
+
message: includeMessage ? rawError.message : undefined,
|
|
16
|
+
causes: rawError.causes,
|
|
17
|
+
handling: rawError.handling
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=createErrorFieldFromRawError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createErrorFieldFromRawError.js","names":["createErrorFieldFromRawError","rawError","options","undefined","includeMessage","stack","kind","type","message","causes","handling"],"sources":["../../src/domain/createErrorFieldFromRawError.js"],"sourcesContent":["export function createErrorFieldFromRawError(rawError, options) {\n if (options === undefined) {\n options = {}\n }\n var includeMessage = options.includeMessage || false\n return {\n stack: rawError.stack,\n kind: rawError.type,\n message: includeMessage ? rawError.message : undefined,\n causes: rawError.causes,\n handling: rawError.handling\n }\n}\n"],"mappings":";;;;;;AAAO,SAASA,4BAA4BA,CAACC,QAAQ,EAAEC,OAAO,EAAE;EAC9D,IAAIA,OAAO,KAAKC,SAAS,EAAE;IACzBD,OAAO,GAAG,CAAC,CAAC;EACd;EACA,IAAIE,cAAc,GAAGF,OAAO,CAACE,cAAc,IAAI,KAAK;EACpD,OAAO;IACLC,KAAK,EAAEJ,QAAQ,CAACI,KAAK;IACrBC,IAAI,EAAEL,QAAQ,CAACM,IAAI;IACnBC,OAAO,EAAEJ,cAAc,GAAGH,QAAQ,CAACO,OAAO,GAAGL,SAAS;IACtDM,MAAM,EAAER,QAAQ,CAACQ,MAAM;IACvBC,QAAQ,EAAET,QAAQ,CAACS;EACrB,CAAC;AACH","ignoreList":[]}
|
package/cjs/domain/logger.js
CHANGED
|
@@ -7,12 +7,18 @@ exports.HandlerType = void 0;
|
|
|
7
7
|
exports.Logger = Logger;
|
|
8
8
|
exports.StatusType = exports.STATUSES = void 0;
|
|
9
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
+
var _loggerCollection = require("./logsCollection/logger/loggerCollection");
|
|
11
|
+
var _createErrorFieldFromRawError = require("./createErrorFieldFromRawError");
|
|
10
12
|
var StatusType = {
|
|
13
|
+
ok: 'ok',
|
|
11
14
|
debug: 'debug',
|
|
12
|
-
error: 'error',
|
|
13
15
|
info: 'info',
|
|
16
|
+
notice: 'notice',
|
|
14
17
|
warn: 'warn',
|
|
15
|
-
|
|
18
|
+
error: 'error',
|
|
19
|
+
critical: 'critical',
|
|
20
|
+
alert: 'alert',
|
|
21
|
+
emerg: 'emerg'
|
|
16
22
|
};
|
|
17
23
|
exports.StatusType = StatusType;
|
|
18
24
|
var HandlerType = {
|
|
@@ -25,7 +31,6 @@ var STATUSES = (0, _browserCore.keys)(StatusType);
|
|
|
25
31
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
26
32
|
exports.STATUSES = STATUSES;
|
|
27
33
|
function Logger(handleLogStrategy, name, handlerType, level, loggerContext) {
|
|
28
|
-
this.contextManager = (0, _browserCore.createContextManager)(_browserCore.CustomerDataType.LoggerContext);
|
|
29
34
|
if (typeof handlerType === 'undefined') {
|
|
30
35
|
handlerType = HandlerType.http;
|
|
31
36
|
}
|
|
@@ -35,84 +40,68 @@ function Logger(handleLogStrategy, name, handlerType, level, loggerContext) {
|
|
|
35
40
|
if (typeof loggerContext === 'undefined') {
|
|
36
41
|
loggerContext = {};
|
|
37
42
|
}
|
|
43
|
+
this.contextManager = (0, _browserCore.createContextManager)(_browserCore.CustomerDataType.LoggerContext);
|
|
38
44
|
this.handleLogStrategy = handleLogStrategy;
|
|
39
45
|
this.handlerType = handlerType;
|
|
40
46
|
this.level = level;
|
|
41
|
-
this.contextManager.
|
|
42
|
-
|
|
47
|
+
this.contextManager.setContext(loggerContext);
|
|
48
|
+
if (name) {
|
|
49
|
+
this.contextManager.setContextProperty('logger', {
|
|
43
50
|
name: name
|
|
44
|
-
}
|
|
45
|
-
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
Logger.prototype = {
|
|
48
|
-
|
|
49
|
-
if (
|
|
55
|
+
logImplementation: (0, _browserCore.monitor)(function (message, messageContext, status, error, handlingStack) {
|
|
56
|
+
if (status === undefined) {
|
|
50
57
|
status = StatusType.info;
|
|
51
58
|
}
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
// Always add origin if status is error (backward compatibility - Remove in next major)
|
|
55
|
-
errorContext = {
|
|
56
|
-
origin: _browserCore.ErrorSource.LOGGER
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
+
var sanitizedMessageContext = (0, _browserCore.sanitize)(messageContext);
|
|
60
|
+
var context;
|
|
59
61
|
if (error !== undefined && error !== null) {
|
|
60
|
-
var stackTrace = error instanceof Error ? (0, _browserCore.computeStackTrace)(error) : undefined;
|
|
61
62
|
var rawError = (0, _browserCore.computeRawError)({
|
|
62
|
-
stackTrace:
|
|
63
|
+
stackTrace: error instanceof Error ? (0, _browserCore.computeStackTrace)(error) : undefined,
|
|
63
64
|
originalError: error,
|
|
64
65
|
nonErrorPrefix: _browserCore.NonErrorPrefix.PROVIDED,
|
|
65
66
|
source: _browserCore.ErrorSource.LOGGER,
|
|
66
67
|
handling: _browserCore.ErrorHandling.HANDLED,
|
|
67
68
|
startClocks: (0, _browserCore.clocksNow)()
|
|
68
69
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
70
|
+
context = (0, _browserCore.extend2Lev)({
|
|
71
|
+
error: (0, _createErrorFieldFromRawError.createErrorFieldFromRawError)(rawError, {
|
|
72
|
+
includeMessage: true
|
|
73
|
+
})
|
|
74
|
+
}, sanitizedMessageContext);
|
|
75
|
+
} else {
|
|
76
|
+
context = sanitizedMessageContext;
|
|
77
77
|
}
|
|
78
|
-
var sanitizedMessageContext = (0, _browserCore.sanitize)(messageContext);
|
|
79
|
-
var context = errorContext ? (0, _browserCore.extend2Lev)({
|
|
80
|
-
error: errorContext
|
|
81
|
-
}, sanitizedMessageContext) : sanitizedMessageContext;
|
|
82
78
|
this.handleLogStrategy({
|
|
83
|
-
message: message,
|
|
79
|
+
message: (0, _browserCore.sanitize)(message),
|
|
84
80
|
context: context,
|
|
85
81
|
status: status
|
|
86
|
-
}, this);
|
|
82
|
+
}, this, handlingStack);
|
|
87
83
|
}),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
warn: function warn(message, messageContext, error) {
|
|
95
|
-
this.log(message, messageContext, StatusType.warn, error);
|
|
96
|
-
},
|
|
97
|
-
critical: function critical(message, messageContext, error) {
|
|
98
|
-
this.log(message, messageContext, StatusType.critical, error);
|
|
99
|
-
},
|
|
100
|
-
error: function error(message, messageContext, _error) {
|
|
101
|
-
var errorOrigin = {
|
|
102
|
-
error: {
|
|
103
|
-
origin: _browserCore.ErrorSource.LOGGER
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
this.log(message, (0, _browserCore.extend2Lev)(errorOrigin, messageContext), StatusType.error, _error);
|
|
84
|
+
log: function log(message, messageContext, status, error) {
|
|
85
|
+
var handlingStack;
|
|
86
|
+
if ((0, _loggerCollection.isAuthorized)(status, HandlerType.http, this)) {
|
|
87
|
+
handlingStack = (0, _browserCore.createHandlingStack)();
|
|
88
|
+
}
|
|
89
|
+
this.logImplementation(message, messageContext, status, error, handlingStack);
|
|
107
90
|
},
|
|
108
91
|
setContext: function setContext(context) {
|
|
109
|
-
this.contextManager.
|
|
92
|
+
this.contextManager.setContext(context);
|
|
110
93
|
},
|
|
111
94
|
getContext: function getContext() {
|
|
112
|
-
return this.contextManager.
|
|
95
|
+
return this.contextManager.getContext();
|
|
96
|
+
},
|
|
97
|
+
setContextProperty: function setContextProperty(key, value) {
|
|
98
|
+
this.contextManager.setContextProperty(key, value);
|
|
113
99
|
},
|
|
114
100
|
addContext: function addContext(key, value) {
|
|
115
|
-
this.contextManager.
|
|
101
|
+
this.contextManager.setContextProperty(key, value);
|
|
102
|
+
},
|
|
103
|
+
removeContextProperty: function removeContextProperty(key) {
|
|
104
|
+
this.contextManager.removeContextProperty(key);
|
|
116
105
|
},
|
|
117
106
|
removeContext: function removeContext(key) {
|
|
118
107
|
this.contextManager.remove(key);
|
|
@@ -133,4 +122,22 @@ Logger.prototype = {
|
|
|
133
122
|
return this.level;
|
|
134
123
|
}
|
|
135
124
|
};
|
|
125
|
+
Logger.prototype.ok = createLoggerMethod(StatusType.ok);
|
|
126
|
+
Logger.prototype.debug = createLoggerMethod(StatusType.debug);
|
|
127
|
+
Logger.prototype.info = createLoggerMethod(StatusType.info);
|
|
128
|
+
Logger.prototype.notice = createLoggerMethod(StatusType.notice);
|
|
129
|
+
Logger.prototype.warn = createLoggerMethod(StatusType.warn);
|
|
130
|
+
Logger.prototype.error = createLoggerMethod(StatusType.error);
|
|
131
|
+
Logger.prototype.critical = createLoggerMethod(StatusType.critical);
|
|
132
|
+
Logger.prototype.alert = createLoggerMethod(StatusType.alert);
|
|
133
|
+
Logger.prototype.emerg = createLoggerMethod(StatusType.emerg);
|
|
134
|
+
function createLoggerMethod(status) {
|
|
135
|
+
return function (message, messageContext, error) {
|
|
136
|
+
var handlingStack;
|
|
137
|
+
if ((0, _loggerCollection.isAuthorized)(status, HandlerType.http, this)) {
|
|
138
|
+
handlingStack = (0, _browserCore.createHandlingStack)();
|
|
139
|
+
}
|
|
140
|
+
this.logImplementation(message, messageContext, status, error, handlingStack);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
136
143
|
//# sourceMappingURL=logger.js.map
|
package/cjs/domain/logger.js.map
CHANGED
|
@@ -1 +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","causes","sanitizedMessageContext","sanitize","context","extend2Lev","errorOrigin","setContext","getContext","get","addContext","key","value","add","removeContext","remove","clearContext","setHandler","handler","getHandler","setLevel","getLevel"],"sources":["../../src/domain/logger.js"],"sourcesContent":["import {\n assign,\n extend2Lev,\n createContextManager,\n ErrorSource,\n keys,\n CustomerDataType,\n sanitize,\n computeStackTrace,\n computeRawError,\n clocksNow,\n ErrorHandling,\n monitor,\n NonErrorPrefix\n} from '@cloudcare/browser-core'\n\nexport var StatusType = {\n debug: 'debug',\n error: 'error',\n info: 'info',\n warn: 'warn',\n critical: 'critical'\n}\n\nexport var HandlerType = {\n console: 'console',\n http: 'http',\n silent: 'silent'\n}\n\nexport var STATUSES = keys(StatusType)\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport function Logger(\n handleLogStrategy,\n name,\n handlerType,\n level,\n loggerContext\n) {\n this.contextManager = createContextManager(CustomerDataType.LoggerContext)\n if (typeof handlerType === 'undefined') {\n handlerType = HandlerType.http\n }\n if (typeof level === 'undefined') {\n level = StatusType.debug\n }\n if (typeof loggerContext === 'undefined') {\n loggerContext = {}\n }\n this.handleLogStrategy = handleLogStrategy\n this.handlerType = handlerType\n this.level = level\n this.contextManager.set(\n assign({}, loggerContext, name ? { logger: { name: name } } : undefined)\n )\n}\nLogger.prototype = {\n log: monitor(function (message, messageContext, status, error) {\n if (typeof status === 'undefined') {\n status = StatusType.info\n }\n var errorContext\n if (status === StatusType.error) {\n // Always add origin if status is error (backward compatibility - Remove in next major)\n errorContext = { origin: ErrorSource.LOGGER }\n }\n if (error !== undefined && error !== null) {\n var stackTrace =\n error instanceof Error ? computeStackTrace(error) : undefined\n var rawError = computeRawError({\n stackTrace: stackTrace,\n originalError: error,\n nonErrorPrefix: NonErrorPrefix.PROVIDED,\n source: ErrorSource.LOGGER,\n handling: ErrorHandling.HANDLED,\n startClocks: clocksNow()\n })\n\n errorContext = {\n origin: ErrorSource.LOGGER, // Remove in next major\n stack: rawError.stack,\n kind: rawError.type,\n message: rawError.message,\n causes: rawError.causes\n }\n }\n\n var sanitizedMessageContext = sanitize(messageContext)\n\n var context = errorContext\n ? extend2Lev({ error: errorContext }, sanitizedMessageContext)\n : sanitizedMessageContext\n\n this.handleLogStrategy(\n { message: message, context: context, status: status },\n this\n )\n }),\n\n debug: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.debug, error)\n },\n\n info: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.info, error)\n },\n\n warn: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.warn, error)\n },\n critical: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.critical, error)\n },\n error: function (message, messageContext, error) {\n var errorOrigin = {\n error: {\n origin: ErrorSource.LOGGER\n }\n }\n this.log(\n message,\n extend2Lev(errorOrigin, messageContext),\n StatusType.error,\n error\n )\n },\n\n setContext: function (context) {\n this.contextManager.set(context)\n },\n\n getContext: function () {\n return this.contextManager.get()\n },\n\n addContext: function (key, value) {\n this.contextManager.add(key, value)\n },\n\n removeContext: function (key) {\n this.contextManager.remove(key)\n },\n clearContext() {\n this.contextManager.clearContext()\n },\n setHandler: function (handler) {\n this.handlerType = handler\n },\n\n getHandler: function () {\n return this.handlerType\n },\n setLevel: function (level) {\n this.level = level\n },\n getLevel: function () {\n return this.level\n }\n}\n"],"mappings":";;;;;;;;AAAA,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,MAAM,EAAE;AACV,CAAC;AAAAJ,OAAA,CAAAC,WAAA,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;EACrC,CAAC;EAEDE,aAAa,EAAE,SAAAA,cAAUH,GAAG,EAAE;IAC5B,IAAI,CAAC9C,cAAc,CAACkD,MAAM,CAACJ,GAAG,CAAC;EACjC,CAAC;EACDK,YAAY,WAAAA,aAAA,EAAG;IACb,IAAI,CAACnD,cAAc,CAACmD,YAAY,CAAC,CAAC;EACpC,CAAC;EACDC,UAAU,EAAE,SAAAA,WAAUC,OAAO,EAAE;IAC7B,IAAI,CAACxD,WAAW,GAAGwD,OAAO;EAC5B,CAAC;EAEDC,UAAU,EAAE,SAAAA,WAAA,EAAY;IACtB,OAAO,IAAI,CAACzD,WAAW;EACzB,CAAC;EACD0D,QAAQ,EAAE,SAAAA,SAAUzD,KAAK,EAAE;IACzB,IAAI,CAACA,KAAK,GAAGA,KAAK;EACpB,CAAC;EACD0D,QAAQ,EAAE,SAAAA,SAAA,EAAY;IACpB,OAAO,IAAI,CAAC1D,KAAK;EACnB;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"logger.js","names":["_browserCore","require","_loggerCollection","_createErrorFieldFromRawError","StatusType","ok","debug","info","notice","warn","error","critical","alert","emerg","exports","HandlerType","console","http","silent","STATUSES","keys","Logger","handleLogStrategy","name","handlerType","level","loggerContext","contextManager","createContextManager","CustomerDataType","LoggerContext","setContext","setContextProperty","prototype","logImplementation","monitor","message","messageContext","status","handlingStack","undefined","sanitizedMessageContext","sanitize","context","rawError","computeRawError","stackTrace","Error","computeStackTrace","originalError","nonErrorPrefix","NonErrorPrefix","PROVIDED","source","ErrorSource","LOGGER","handling","ErrorHandling","HANDLED","startClocks","clocksNow","extend2Lev","createErrorFieldFromRawError","includeMessage","log","isAuthorized","createHandlingStack","getContext","key","value","addContext","removeContextProperty","removeContext","remove","clearContext","setHandler","handler","getHandler","setLevel","getLevel","createLoggerMethod"],"sources":["../../src/domain/logger.js"],"sourcesContent":["import {\n extend2Lev,\n createContextManager,\n ErrorSource,\n keys,\n CustomerDataType,\n sanitize,\n computeStackTrace,\n computeRawError,\n clocksNow,\n ErrorHandling,\n monitor,\n NonErrorPrefix,\n createHandlingStack\n} from '@cloudcare/browser-core'\nimport { isAuthorized } from './logsCollection/logger/loggerCollection'\nimport { createErrorFieldFromRawError } from './createErrorFieldFromRawError'\nexport var StatusType = {\n ok: 'ok',\n debug: 'debug',\n info: 'info',\n notice: 'notice',\n warn: 'warn',\n error: 'error',\n critical: 'critical',\n alert: 'alert',\n emerg: 'emerg'\n}\n\nexport var HandlerType = {\n console: 'console',\n http: 'http',\n silent: 'silent'\n}\n\nexport var STATUSES = keys(StatusType)\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport function Logger(\n handleLogStrategy,\n name,\n handlerType,\n level,\n loggerContext\n) {\n if (typeof handlerType === 'undefined') {\n handlerType = HandlerType.http\n }\n if (typeof level === 'undefined') {\n level = StatusType.debug\n }\n if (typeof loggerContext === 'undefined') {\n loggerContext = {}\n }\n this.contextManager = createContextManager(CustomerDataType.LoggerContext)\n this.handleLogStrategy = handleLogStrategy\n this.handlerType = handlerType\n this.level = level\n this.contextManager.setContext(loggerContext)\n if (name) {\n this.contextManager.setContextProperty('logger', { name: name })\n }\n}\nLogger.prototype = {\n logImplementation: monitor(function (\n message,\n messageContext,\n status,\n error,\n handlingStack\n ) {\n if (status === undefined) {\n status = StatusType.info\n }\n var sanitizedMessageContext = sanitize(messageContext)\n var context\n\n if (error !== undefined && error !== null) {\n var rawError = computeRawError({\n stackTrace:\n error instanceof Error ? computeStackTrace(error) : undefined,\n originalError: error,\n nonErrorPrefix: NonErrorPrefix.PROVIDED,\n source: ErrorSource.LOGGER,\n handling: ErrorHandling.HANDLED,\n startClocks: clocksNow()\n })\n context = extend2Lev(\n {\n error: createErrorFieldFromRawError(rawError, {\n includeMessage: true\n })\n },\n sanitizedMessageContext\n )\n } else {\n context = sanitizedMessageContext\n }\n\n this.handleLogStrategy(\n {\n message: sanitize(message),\n context: context,\n status: status\n },\n this,\n handlingStack\n )\n }),\n log: function (message, messageContext, status, error) {\n var handlingStack\n\n if (isAuthorized(status, HandlerType.http, this)) {\n handlingStack = createHandlingStack()\n }\n\n this.logImplementation(\n message,\n messageContext,\n status,\n error,\n handlingStack\n )\n },\n\n setContext: function (context) {\n this.contextManager.setContext(context)\n },\n\n getContext: function () {\n return this.contextManager.getContext()\n },\n setContextProperty: function (key, value) {\n this.contextManager.setContextProperty(key, value)\n },\n addContext: function (key, value) {\n this.contextManager.setContextProperty(key, value)\n },\n removeContextProperty: function (key) {\n this.contextManager.removeContextProperty(key)\n },\n removeContext: function (key) {\n this.contextManager.remove(key)\n },\n clearContext: function () {\n this.contextManager.clearContext()\n },\n setHandler: function (handler) {\n this.handlerType = handler\n },\n\n getHandler: function () {\n return this.handlerType\n },\n setLevel: function (level) {\n this.level = level\n },\n getLevel: function () {\n return this.level\n }\n}\nLogger.prototype.ok = createLoggerMethod(StatusType.ok)\nLogger.prototype.debug = createLoggerMethod(StatusType.debug)\nLogger.prototype.info = createLoggerMethod(StatusType.info)\nLogger.prototype.notice = createLoggerMethod(StatusType.notice)\nLogger.prototype.warn = createLoggerMethod(StatusType.warn)\nLogger.prototype.error = createLoggerMethod(StatusType.error)\nLogger.prototype.critical = createLoggerMethod(StatusType.critical)\nLogger.prototype.alert = createLoggerMethod(StatusType.alert)\nLogger.prototype.emerg = createLoggerMethod(StatusType.emerg)\nfunction createLoggerMethod(status) {\n return function (message, messageContext, error) {\n var handlingStack\n\n if (isAuthorized(status, HandlerType.http, this)) {\n handlingStack = createHandlingStack()\n }\n this.logImplementation(\n message,\n messageContext,\n status,\n error,\n handlingStack\n )\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAeA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACO,IAAIG,UAAU,GAAG;EACtBC,EAAE,EAAE,IAAI;EACRC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,Q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