@cloudcare/browser-logs 3.1.23 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/bundle/dataflux-logs.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/logsPublicApi.js +35 -62
  4. package/cjs/boot/logsPublicApi.js.map +1 -1
  5. package/cjs/boot/preStartLogs.js +72 -0
  6. package/cjs/boot/preStartLogs.js.map +1 -0
  7. package/cjs/boot/startLogs.js +57 -38
  8. package/cjs/boot/startLogs.js.map +1 -1
  9. package/cjs/domain/assembly.js +5 -7
  10. package/cjs/domain/assembly.js.map +1 -1
  11. package/cjs/domain/contexts/commonContext.js +17 -0
  12. package/cjs/domain/contexts/commonContext.js.map +1 -0
  13. package/cjs/domain/contexts/internalContext.js.map +1 -0
  14. package/cjs/domain/createErrorFieldFromRawError.js +20 -0
  15. package/cjs/domain/createErrorFieldFromRawError.js.map +1 -0
  16. package/cjs/domain/logger.js +61 -54
  17. package/cjs/domain/logger.js.map +1 -1
  18. package/cjs/domain/logsCollection/console/consoleCollection.js +5 -5
  19. package/cjs/domain/logsCollection/console/consoleCollection.js.map +1 -1
  20. package/cjs/domain/logsCollection/logger/loggerCollection.js +37 -20
  21. package/cjs/domain/logsCollection/logger/loggerCollection.js.map +1 -1
  22. package/cjs/domain/logsCollection/networkError/networkErrorCollection.js +11 -6
  23. package/cjs/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -1
  24. package/cjs/domain/logsCollection/report/reportCollection.js +6 -15
  25. package/cjs/domain/logsCollection/report/reportCollection.js.map +1 -1
  26. package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
  27. package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -1
  28. package/cjs/domain/reportError.js +24 -0
  29. package/cjs/domain/reportError.js.map +1 -0
  30. package/cjs/transport/startLogsBatch.js +6 -2
  31. package/cjs/transport/startLogsBatch.js.map +1 -1
  32. package/esm/boot/buildEnv.js +1 -1
  33. package/esm/boot/logsPublicApi.js +36 -63
  34. package/esm/boot/logsPublicApi.js.map +1 -1
  35. package/esm/boot/preStartLogs.js +66 -0
  36. package/esm/boot/preStartLogs.js.map +1 -0
  37. package/esm/boot/startLogs.js +57 -38
  38. package/esm/boot/startLogs.js.map +1 -1
  39. package/esm/domain/assembly.js +6 -8
  40. package/esm/domain/assembly.js.map +1 -1
  41. package/esm/domain/contexts/commonContext.js +11 -0
  42. package/esm/domain/contexts/commonContext.js.map +1 -0
  43. package/esm/domain/contexts/internalContext.js.map +1 -0
  44. package/esm/domain/createErrorFieldFromRawError.js +14 -0
  45. package/esm/domain/createErrorFieldFromRawError.js.map +1 -0
  46. package/esm/domain/logger.js +62 -55
  47. package/esm/domain/logger.js.map +1 -1
  48. package/esm/domain/logsCollection/console/consoleCollection.js +5 -5
  49. package/esm/domain/logsCollection/console/consoleCollection.js.map +1 -1
  50. package/esm/domain/logsCollection/logger/loggerCollection.js +39 -22
  51. package/esm/domain/logsCollection/logger/loggerCollection.js.map +1 -1
  52. package/esm/domain/logsCollection/networkError/networkErrorCollection.js +12 -7
  53. package/esm/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -1
  54. package/esm/domain/logsCollection/report/reportCollection.js +7 -16
  55. package/esm/domain/logsCollection/report/reportCollection.js.map +1 -1
  56. package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
  57. package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -1
  58. package/esm/domain/reportError.js +18 -0
  59. package/esm/domain/reportError.js.map +1 -0
  60. package/esm/transport/startLogsBatch.js +7 -3
  61. package/esm/transport/startLogsBatch.js.map +1 -1
  62. package/package.json +4 -3
  63. package/src/boot/logsPublicApi.js +52 -86
  64. package/src/boot/preStartLogs.js +94 -0
  65. package/src/boot/startLogs.js +83 -60
  66. package/src/domain/assembly.js +7 -12
  67. package/src/domain/contexts/commonContext.js +10 -0
  68. package/src/domain/createErrorFieldFromRawError.js +13 -0
  69. package/src/domain/logger.js +89 -63
  70. package/src/domain/logsCollection/console/consoleCollection.js +5 -9
  71. package/src/domain/logsCollection/logger/loggerCollection.js +46 -25
  72. package/src/domain/logsCollection/networkError/networkErrorCollection.js +11 -7
  73. package/src/domain/logsCollection/report/reportCollection.js +9 -16
  74. package/src/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -6
  75. package/src/domain/reportError.js +21 -0
  76. package/src/transport/startLogsBatch.js +6 -4
  77. package/types/configuration.d.ts +2 -2
  78. package/types/logger.d.ts +3 -22
  79. package/cjs/domain/internalContext.js.map +0 -1
  80. package/esm/domain/internalContext.js.map +0 -1
  81. /package/cjs/domain/{internalContext.js → contexts/internalContext.js} +0 -0
  82. /package/esm/domain/{internalContext.js → contexts/internalContext.js} +0 -0
  83. /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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E,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":[]}
@@ -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 _startLogsBatch = require("../transport/startLogsBatch");
16
- var _logger = require("../domain/logger");
17
- var _internalContext = require("../domain/internalContext");
18
- function startLogs(configuration, buildCommonContext, mainLogger) {
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 reportError = function reportError(error) {
21
- lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_LOG_COLLECTED, {
22
- rawLogsEvent: {
23
- message: error.message,
24
- date: error.startClocks.timeStamp,
25
- error: {
26
- origin: _browserCore.ErrorSource.AGENT
27
- },
28
- origin: _browserCore.ErrorSource.AGENT,
29
- status: _logger.StatusType.error
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
- var pageExitObservable = (0, _browserCore.createPageExitObservable)();
34
- var session = (0, _browserCore.areCookiesAuthorized)(configuration.cookieOptions) ? (0, _logsSessionManager.startLogsSessionManager)(configuration) : (0, _logsSessionManager.startLogsSessionManagerStub)(configuration);
35
- var telemetry = startLogsTelemetry(configuration, reportError, pageExitObservable, session.expireObservable);
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
- (0, _networkErrorCollection.startNetworkErrorCollection)(configuration, lifeCycle);
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, configuration.rumEndpoint, reportError, pageExitObservable, sessionExpireObservable);
72
- telemetry.observable.subscribe(function (event) {
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
- return telemetry;
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","_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\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;QAC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s.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,CAAC,IAAAC,oCAAuB,EAAC,CAAC,GACtB,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S,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":[]}
@@ -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
- var _loggerCollection = require("./logsCollection/logger/loggerCollection");
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 logger = data.logger || mainLogger;
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 || buildCommonContext();
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, logger.getContext(), messageContext);
45
- if (!(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()) {
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","_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","_gc","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 _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 logger.getContext(),\n messageContext\n )\n\n if (\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;AAEO,SAASG,iBAAiBA,CAC/BC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,UAAU,EACVC,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,EACNV,aAAa,CAACY,yBAAyB,EACvCR,WACF,CAAC;EACH,CAAC,CAAC;EACFH,SAAS,CAACY,SAAS,CAACC,+BAAkB,CAACC,iBAAiB,EAAE,UAAUC,IAAI,EAAE;IACxE;IACA,IAAIC,YAAY,GAAGD,IAAI,CAACC,YAAY;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ACC,IAAI,EAAE7B,MAAM,CAAC,IAC3DrB,aAAa,CAACmD,UAAU,IAAInD,aAAa,CAACmD,UAAU,CAACvB,GAAG,CAAC,KAAK,KAAM,IACpEA,GAAG,CAACwB,KAAK,IACRxB,GAAG,CAACwB,KAAK,CAACC,MAAM,KAAKC,wBAAW,CAACC,KAAK,IACtC,IAAAC,wCAA2B,EACzBhD,eAAe,CAACoB,GAAG,CAAClB,MAAM,CAAC,EAC3BF,eAAe,CAAC,QAAQ,CAC1B,CAAC,CAACiD,cAAc,CAAC,CAAE,EACrB;MACA;IACF;IAEAxD,SAAS,CAACyD,MAAM,CAAC5C,+BAAkB,CAAC6C,aAAa,EAAE,IAAAC,8BAAiB,EAAChC,GAAG,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ;AAEO,SAASkB,qBAAqBA,CAACxB,SAAS,EAAE;EAC/C,OAAOuC,+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,CAAC3C,SAAS,CAAC;IAChD;EACF;AACF","ignoreList":[]}
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,IAAIE,aAAa,GAAGL,IAAI,CAACK,aAAa;IACtC,IAAIC,SAAS,GAAG,IAAAC,4BAAe,EAACN,YAAY,CAACO,IAAI,CAAC;IAClD,IAAIC,OAAO,GAAGzB,cAAc,CAAC0B,kBAAkB,CAACJ,SAAS,CAAC;IAE1D,IAAI,CAACG,OAAO,EAAE;MACZ;IACF;IACA,IAAIE,aAAa,GAAGP,kBAAkB,IAAIjB,gBAAgB,CAAC,CAAC;IAC5D,IAAIyB,GAAG,GAAG,IAAAC,uBAAU,EAClB;MACEC,OAAO,EAAE7B,aAAa,CAAC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AAkB,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":[]}
@@ -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
- critical: 'critical'
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.set((0, _browserCore.assign)({}, loggerContext, name ? {
42
- logger: {
47
+ this.contextManager.setContext(loggerContext);
48
+ if (name) {
49
+ this.contextManager.setContextProperty('logger', {
43
50
  name: name
44
- }
45
- } : undefined));
51
+ });
52
+ }
46
53
  }
47
54
  Logger.prototype = {
48
- log: (0, _browserCore.monitor)(function (message, messageContext, status, error) {
49
- if (typeof status === 'undefined') {
55
+ logImplementation: (0, _browserCore.monitor)(function (message, messageContext, status, error, handlingStack) {
56
+ if (status === undefined) {
50
57
  status = StatusType.info;
51
58
  }
52
- var errorContext;
53
- if (status === StatusType.error) {
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: 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
- errorContext = {
70
- origin: _browserCore.ErrorSource.LOGGER,
71
- // Remove in next major
72
- stack: rawError.stack,
73
- kind: rawError.type,
74
- message: rawError.message,
75
- causes: rawError.causes
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
- debug: function debug(message, messageContext, error) {
89
- this.log(message, messageContext, StatusType.debug, error);
90
- },
91
- info: function info(message, messageContext, error) {
92
- this.log(message, messageContext, StatusType.info, error);
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.set(context);
92
+ this.contextManager.setContext(context);
110
93
  },
111
94
  getContext: function getContext() {
112
- return this.contextManager.get();
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.add(key, value);
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
@@ -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,GAAAA,WAAA;AAEM,IAAII,QAAQ,GAAG,IAAAC,iBAAI,EAACZ,UAAU,CAAC;AACtC;AAAAM,OAAA,CAAAK,QAAA,GAAAA,QAAA;AACO,SAASE,MAAMA,CACpBC,iBAAiB,EACjBC,IAAI,EACJC,WAAW,EACXC,KAAK,EACLC,aAAa,EACb;EACA,IAAI,CAACC,cAAc,GAAG,IAAAC,iCAAoB,EAACC,6BAAgB,CAACC,aAAa,CAAC;EAC1E,IAAI,OAAON,WAAW,KAAK,WAAW,EAAE;IACtCA,WAAW,GAAGT,WAAW,CAACE,IAAI;EAChC;EACA,IAAI,OAAOQ,KAAK,KAAK,WAAW,EAAE;IAChCA,KA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,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(key) {\n this.contextManager.removeContextProperty(key)\n },\n removeContext: function (key) {\n this.contextManager.remove(key)\n },\n clearContext() {\n this.contextManager.clearContext()\n },\n setHandler: function (handler) {\n this.handlerType = handler\n },\n\n getHandler: function () {\n return this.handlerType\n },\n setLevel: function (level) {\n this.level = level\n },\n getLevel: function () {\n return this.level\n }\n}\nLogger.prototype.ok = createLoggerMethod(StatusType.ok)\nLogger.prototype.debug = createLoggerMethod(StatusType.debug)\nLogger.prototype.info = createLoggerMethod(StatusType.info)\nLogger.prototype.notice = createLoggerMethod(StatusType.notice)\nLogger.prototype.warn = createLoggerMethod(StatusType.warn)\nLogger.prototype.error = createLoggerMethod(StatusType.error)\nLogger.prototype.critical = createLoggerMethod(StatusType.critical)\nLogger.prototype.alert = createLoggerMethod(StatusType.alert)\nLogger.prototype.emerg = createLoggerMethod(StatusType.emerg)\nfunction createLoggerMethod(status) {\n return function (message, messageContext, error) {\n var handlingStack\n\n if (isAuthorized(status, HandlerType.http, this)) {\n handlingStack = createHandlingStack()\n }\n this.logImplementation(\n message,\n messageContext,\n status,\n error,\n handlingStack\n )\n }\n}\n"],"mappings":";;;;;;;;AAAA,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,QAAQ;EAChBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE;AACT,CAAC;AAAAC,OAAA,CAAAV,UAAA,GAAAA,UAAA;AAEM,IAAIW,WAAW,GAAG;EACvBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACV,CAAC;AAAAJ,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAEM,IAAII,QAAQ,GAAG,IAAAC,iBAAI,EAAChB,UAAU,CAAC;AACtC;AAAAU,OAAA,CAAAK,QAAA,GAAAA,QAAA;AACO,SAASE,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