@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
@@ -1 +1 @@
1
- {"version":3,"file":"logsPublicApi.js","names":["BoundedBuffer","createContextManager","makePublicApi","CustomerDataType","display","deepClone","timeStampNow","checkUser","sanitizeUser","monitor","storeContextManager","validateAndBuildLogsConfiguration","Logger","LOGS_STORAGE_KEY","makeLogsPublicApi","startLogsImpl","isAlreadyInitialized","globalContextManager","GlobalContext","userContextManager","User","customLoggers","getInternalContextStrategy","undefined","beforeInitLoggerLog","handleLogStrategy","logsMessage","logger","savedCommonContext","date","buildCommonContext","add","getInitConfigurationStrategy","mainLogger","apply","arguments","view","referrer","document","url","window","location","href","context","getContext","user","init","initConfiguration","canInitLogs","configuration","storeContextsToLocal","_startLogsImpl","handleLog","getInternalContext","drain","getGlobalContext","setGlobalContext","setContext","setGlobalContextProperty","key","value","setContextProperty","removeGlobalContextProperty","removeContextProperty","clearGlobalContext","clearContext","createLogger","name","conf","handler","level","getLogger","getInitConfiguration","startTime","setUser","newUser","getUser","removeUserProperty","clearUser","silentMultipleInit","error"],"sources":["../../src/boot/logsPublicApi.js"],"sourcesContent":["import {\n BoundedBuffer,\n createContextManager,\n makePublicApi,\n CustomerDataType,\n display,\n deepClone,\n timeStampNow,\n checkUser,\n sanitizeUser,\n monitor,\n storeContextManager\n} from '@cloudcare/browser-core'\nimport { validateAndBuildLogsConfiguration } from '../domain/configuration'\nimport { Logger } from '../domain/logger'\nvar LOGS_STORAGE_KEY = 'logs'\nexport function makeLogsPublicApi(startLogsImpl) {\n var isAlreadyInitialized = false\n\n var globalContextManager = createContextManager(\n CustomerDataType.GlobalContext\n )\n var userContextManager = createContextManager(CustomerDataType.User)\n var customLoggers = {}\n var getInternalContextStrategy = function () {\n return undefined\n }\n\n var beforeInitLoggerLog = new BoundedBuffer()\n\n var handleLogStrategy = function (\n logsMessage,\n logger,\n savedCommonContext,\n date\n ) {\n if (typeof savedCommonContext === 'undefined') {\n savedCommonContext = deepClone(buildCommonContext())\n }\n if (typeof date === 'undefined') {\n date = timeStampNow()\n }\n beforeInitLoggerLog.add(function () {\n return handleLogStrategy(logsMessage, logger, savedCommonContext, date)\n })\n }\n\n var getInitConfigurationStrategy = function () {\n return undefined\n }\n\n var mainLogger = new Logger(function () {\n return handleLogStrategy.apply(this, arguments)\n })\n\n function buildCommonContext() {\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\n return makePublicApi({\n logger: mainLogger,\n\n init: monitor(function (initConfiguration) {\n if (!canInitLogs(initConfiguration)) {\n return\n }\n\n var configuration = validateAndBuildLogsConfiguration(initConfiguration)\n if (!configuration) {\n return\n }\n if (initConfiguration.storeContextsToLocal) {\n storeContextManager(\n configuration,\n globalContextManager,\n LOGS_STORAGE_KEY,\n CustomerDataType.GlobalContext\n )\n storeContextManager(\n configuration,\n userContextManager,\n LOGS_STORAGE_KEY,\n CustomerDataType.User\n )\n }\n var _startLogsImpl = startLogsImpl(\n configuration,\n buildCommonContext,\n mainLogger\n )\n handleLogStrategy = _startLogsImpl.handleLog\n getInternalContextStrategy = _startLogsImpl.getInternalContext\n getInitConfigurationStrategy = function () {\n return deepClone(initConfiguration)\n }\n beforeInitLoggerLog.drain()\n\n isAlreadyInitialized = true\n }),\n\n getGlobalContext: monitor(function () {\n return globalContextManager.getContext()\n }),\n\n setGlobalContext: monitor(function (context) {\n return globalContextManager.setContext(context)\n }),\n\n setGlobalContextProperty: monitor(function (key, value) {\n return globalContextManager.setContextProperty(key, value)\n }),\n\n removeGlobalContextProperty: monitor(function (key) {\n return globalContextManager.removeContextProperty(key)\n }),\n\n clearGlobalContext: monitor(function () {\n return globalContextManager.clearContext()\n }),\n\n createLogger: monitor(function (name, conf) {\n if (typeof conf == 'undefined') {\n conf = {}\n }\n customLoggers[name] = new Logger(\n function () {\n return handleLogStrategy(this.arguments)\n },\n name,\n conf.handler,\n conf.level,\n conf.context\n )\n return customLoggers[name]\n }),\n\n getLogger: monitor(function (name) {\n return customLoggers[name]\n }),\n\n getInitConfiguration: monitor(function () {\n return getInitConfigurationStrategy()\n }),\n\n getInternalContext: monitor(function (startTime) {\n return getInternalContextStrategy(startTime)\n }),\n setUser: monitor(function (newUser) {\n if (checkUser(newUser)) {\n userContextManager.setContext(sanitizeUser(newUser))\n }\n }),\n getUser: monitor(function () {\n return userContextManager.getContext()\n }),\n removeUserProperty: monitor(function (key) {\n return userContextManager.removeContextProperty(key)\n }),\n clearUser: monitor(function () {\n return userContextManager.clearContext()\n })\n })\n\n function canInitLogs(initConfiguration) {\n if (isAlreadyInitialized) {\n if (!initConfiguration.silentMultipleInit) {\n display.error('DD_LOGS is already initialized.')\n }\n return false\n }\n\n return true\n }\n}\n"],"mappings":"AAAA,SACEA,aAAa,EACbC,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBC,OAAO,EACPC,SAAS,EACTC,YAAY,EACZC,SAAS,EACTC,YAAY,EACZC,OAAO,EACPC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,iCAAiC,QAAQ,yBAAyB;AAC3E,SAASC,MAAM,QAAQ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AC,UAAUkE,OAAO,EAAE;MAClC,IAAIpE,SAAS,CAACoE,OAAO,CAAC,EAAE;QACtBxD,kBAAkB,CAACsC,UAAU,CAACjD,YAAY,CAACmE,OAAO,CAAC,CAAC;MACtD;IACF,CAAC,CAAC;IACFC,OAAO,EAAEnE,OAAO,CAAC,YAAY;MAC3B,OAAOU,kBAAkB,CAACyB,UAAU,CAAC,CAAC;IACxC,CAAC,CAAC;IACFiC,kBAAkB,EAAEpE,OAAO,CAAC,UAAUkD,GAAG,EAAE;MACzC,OAAOxC,kBAAkB,CAAC4C,qBAAqB,CAACJ,GAAG,CAAC;IACtD,CAAC,CAAC;IACFmB,SAAS,EAAErE,OAAO,CAAC,YAAY;MAC7B,OAAOU,kBAAkB,CAAC8C,YAAY,CAAC,CAAC;IAC1C,CAAC;EACH,CAAC,CAAC;EAEF,SAASjB,WAAWA,CAACD,iBAAiB,EAAE;IACtC,IAAI/B,oBAAoB,EAAE;MACxB,IAAI,CAAC+B,iBAAiB,CAACgC,kBAAkB,EAAE;QACzC3E,OAAO,CAAC4E,KAAK,CAAC,iCAAiC,CAAC;MAClD;MACA,OAAO,KAAK;IACd;IAEA,OAAO,IAAI;EACb;AACF","ignoreList":[]}
1
+ {"version":3,"file":"logsPublicApi.js","names":["createContextManager","makePublicApi","CustomerDataType","checkUser","sanitizeUser","monitor","storeContextManager","displayAlreadyInitializedError","assign","Logger","buildCommonContext","createPreStartStrategy","LOGS_STORAGE_KEY","makeLogsPublicApi","startLogsImpl","globalContextManager","GlobalContext","userContextManager","User","getCommonContext","strategy","initConfiguration","configuration","storeContextsToLocal","startLogsResult","createPostStartStrategy","customLoggers","mainLogger","handleLog","apply","arguments","logger","init","getGlobalContext","getContext","setGlobalContext","context","setContext","setGlobalContextProperty","key","value","setContextProperty","removeGlobalContextProperty","removeContextProperty","clearGlobalContext","clearContext","createLogger","name","conf","sanitize","handler","level","getLogger","getInitConfiguration","getInternalContext","startTime","setUser","newUser","getUser","removeUserProperty","setUserProperty","property","sanitizedProperty","clearUser"],"sources":["../../src/boot/logsPublicApi.js"],"sourcesContent":["import {\n createContextManager,\n makePublicApi,\n CustomerDataType,\n checkUser,\n sanitizeUser,\n monitor,\n storeContextManager,\n displayAlreadyInitializedError,\n assign\n} from '@cloudcare/browser-core'\nimport { Logger } from '../domain/logger'\nimport { buildCommonContext } from '../domain/contexts/commonContext'\nimport { createPreStartStrategy } from './preStartLogs'\nvar LOGS_STORAGE_KEY = 'logs'\nexport function makeLogsPublicApi(startLogsImpl) {\n var globalContextManager = createContextManager(\n CustomerDataType.GlobalContext\n )\n var userContextManager = createContextManager(CustomerDataType.User)\n\n function getCommonContext() {\n return buildCommonContext(globalContextManager, userContextManager)\n }\n var strategy = createPreStartStrategy(\n getCommonContext,\n function (initConfiguration, configuration) {\n if (initConfiguration.storeContextsToLocal) {\n storeContextManager(\n configuration,\n globalContextManager,\n LOGS_STORAGE_KEY,\n CustomerDataType.GlobalContext\n )\n storeContextManager(\n configuration,\n userContextManager,\n LOGS_STORAGE_KEY,\n CustomerDataType.User\n )\n }\n\n var startLogsResult = startLogsImpl(\n initConfiguration,\n configuration,\n getCommonContext\n )\n\n strategy = createPostStartStrategy(initConfiguration, startLogsResult)\n return startLogsResult\n }\n )\n var customLoggers = {}\n\n var mainLogger = new Logger(function () {\n return strategy.handleLog.apply(this, arguments)\n })\n\n return makePublicApi({\n logger: mainLogger,\n\n init: monitor(function (initConfiguration) {\n return strategy.init(initConfiguration)\n }),\n\n getGlobalContext: monitor(function () {\n return globalContextManager.getContext()\n }),\n\n setGlobalContext: monitor(function (context) {\n return globalContextManager.setContext(context)\n }),\n\n setGlobalContextProperty: monitor(function (key, value) {\n return globalContextManager.setContextProperty(key, value)\n }),\n\n removeGlobalContextProperty: monitor(function (key) {\n return globalContextManager.removeContextProperty(key)\n }),\n\n clearGlobalContext: monitor(function () {\n return globalContextManager.clearContext()\n }),\n\n createLogger: monitor(function (name, conf) {\n if (typeof conf == 'undefined') {\n conf = {}\n }\n customLoggers[name] = new Logger(\n function () {\n return strategy.handleLog.apply(this, arguments)\n },\n sanitize(name),\n conf.handler,\n conf.level,\n sanitize(conf.context)\n )\n return customLoggers[name]\n }),\n\n getLogger: monitor(function (name) {\n return customLoggers[name]\n }),\n\n getInitConfiguration: monitor(function () {\n return strategy.getInitConfiguration()\n }),\n\n getInternalContext: monitor(function (startTime) {\n return strategy.getInternalContext(startTime)\n }),\n setUser: monitor(function (newUser) {\n if (checkUser(newUser)) {\n userContextManager.setContext(sanitizeUser(newUser))\n }\n }),\n getUser: monitor(function () {\n return userContextManager.getContext()\n }),\n removeUserProperty: monitor(function (key) {\n return userContextManager.removeContextProperty(key)\n }),\n setUserProperty: monitor(function (key, property) {\n var newUser = {}\n newUser[key] = property\n var sanitizedProperty = sanitizeUser(newUser)[key]\n userContextManager.setContextProperty(key, sanitizedProperty)\n }),\n clearUser: monitor(function () {\n return userContextManager.clearContext()\n })\n })\n}\nfunction createPostStartStrategy(initConfiguration, startLogsResult) {\n return assign(\n {\n init: function (initConfiguration) {\n displayAlreadyInitializedError('DATAFLUX_LOGS', initConfiguration)\n },\n getInitConfiguration: function () {\n return initConfiguration\n }\n },\n startLogsResult\n )\n}\n"],"mappings":"AAAA,SACEA,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBC,SAAS,EACTC,YAAY,EACZC,OAAO,EACPC,mBAAmB,EACnBC,8BAA8B,EAC9BC,MAAM,QACD,yBAAyB;AAChC,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,IAAIC,gBAAgB,GAAG,MAAM;AAC7B,OAAO,SAASC,iBAAiBA,CAACC,aAAa,EAAE;EAC/C,IAAIC,oBAAoB,GAAGf,oBAAoB,CAC7CE,gBAAgB,CAACc,aACnB,CAAC;EACD,IAAIC,kBAAkB,GAAGjB,oBAAoB,CAACE,gBAAgB,CAACgB,IAAI,CAAC;EAEp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itializedError, initFetchObservable, noop, timeStampNow } from '@cloudcare/browser-core';
2
+ import { validateAndBuildLogsConfiguration } from '../domain/configuration';
3
+ export function createPreStartStrategy(getCommonContext, doStartLogs) {
4
+ var bufferApiCalls = createBoundedBuffer();
5
+ var cachedInitConfiguration;
6
+ var cachedConfiguration;
7
+ function tryStartLogs() {
8
+ if (!cachedConfiguration || !cachedInitConfiguration) {
9
+ return;
10
+ }
11
+ var startLogsResult = doStartLogs(cachedInitConfiguration, cachedConfiguration);
12
+ bufferApiCalls.drain(startLogsResult);
13
+ }
14
+ return {
15
+ init: function init(initConfiguration) {
16
+ if (!initConfiguration) {
17
+ display.error('Missing configuration');
18
+ return;
19
+ }
20
+ // Set the experimental feature flags as early as possible, so we can use them in most places
21
+
22
+ if (canUseEventBridge()) {
23
+ initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
24
+ }
25
+
26
+ // Expose the initial configuration regardless of initialization success.
27
+ cachedInitConfiguration = initConfiguration;
28
+ if (cachedConfiguration) {
29
+ displayAlreadyInitializedError('DATAFLUX_LOGS', initConfiguration);
30
+ return;
31
+ }
32
+ var configuration = validateAndBuildLogsConfiguration(initConfiguration);
33
+ if (!configuration) {
34
+ return;
35
+ }
36
+ cachedConfiguration = configuration;
37
+ // Instrumuent fetch to track network requests
38
+ // This is needed in case the consent is not granted and some cutsomer
39
+ // library (Apollo Client) is storing uninstrumented fetch to be used later
40
+ // The subscrption is needed so that the instrumentation process is completed
41
+ initFetchObservable().subscribe(noop);
42
+ tryStartLogs();
43
+ },
44
+ getInitConfiguration: function getInitConfiguration() {
45
+ return cachedInitConfiguration;
46
+ },
47
+ getInternalContext: noop,
48
+ handleLog: function handleLog(message, statusType, handlingStack, context, date) {
49
+ if (context === undefined) {
50
+ context = getCommonContext();
51
+ }
52
+ if (date === undefined) {
53
+ date = timeStampNow();
54
+ }
55
+ bufferApiCalls.add(function (startLogsResult) {
56
+ startLogsResult.handleLog(message, statusType, handlingStack, context, date);
57
+ });
58
+ }
59
+ };
60
+ }
61
+ function overrideInitConfigurationForBridge(initConfiguration) {
62
+ return assign({}, initConfiguration, {
63
+ clientToken: 'empty'
64
+ });
65
+ }
66
+ //# sourceMappingURL=preStartLogs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preStartLogs.js","names":["createBoundedBuffer","assign","canUseEventBridge","display","displayAlreadyInitializedError","initFetchObservable","noop","timeStampNow","validateAndBuildLogsConfiguration","createPreStartStrategy","getCommonContext","doStartLogs","bufferApiCalls","cachedInitConfiguration","cachedConfiguration","tryStartLogs","startLogsResult","drain","init","initConfiguration","error","overrideInitConfigurationForBridge","configuration","subscribe","getInitConfiguration","getInternalContext","handleLog","message","statusType","handlingStack","context","date","undefined","add","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,SACEA,mBAAmB,EACnBC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACPC,8BAA8B,EAC9BC,mBAAmB,EACnBC,IAAI,EACJC,YAAY,QACP,yBAAyB;AAChC,SAASC,iCAAiC,QAAQ,yBAAyB;AAE3E,OAAO,SAASC,sBAAsBA,CAACC,gBAAgB,EAAEC,WAAW,EAAE;EACpE,IAAMC,cAAc,GAAGZ,mBAAmB,CAAC,CAAC;EAC5C,IAAIa,uBAAuB;EAC3B,IAAIC,mBAAmB;EAEvB,SAASC,YAAYA,CAAA,EAAG;IACtB,IAAI,CAACD,mBAAmB,IAAI,CAACD,uBAAuB,EAAE;MACpD;IACF;IAEA,IAAIG,eAAe,GAAGL,WAAW,CAC/BE,uBAAuB,EACvBC,mBACF,CAAC;IACDF,cAAc,CAACK,KAAK,CAACD,eAAe,CAAC;EACvC;EAEA,OAAO;IACLE,IAAI,EAAE,SAAAA,KAAUC,iBAAiB,EAAE;MACjC,IAAI,CAACA,iBAAiB,EAAE;QACtBhB,OAAO,CAACiB,KAAK,CAAC,uBAAuB,CAAC;QACtC;MACF;MACA;;MAEA,IAAIlB,iBAAiB,CAAC,CAAC,EAAE;QACvBiB,iBAAiB,GACfE,kCAAkC,CAACF,iBAAiB,CAAC;MACzD;;MAEA;MACAN,uBAAuB,GAAGM,iBAAiB;MAE3C,IAAIL,mBAAmB,EAAE;QACvBV,8BAA8B,CAAC,eAAe,EAAEe,iBAAiB,CAAC;QAClE;MACF;MAEA,IAAMG,aAAa,GAAGd,iCAAiC,CAACW,iBAAiB,CAAC;MAC1E,IAAI,CAACG,aAAa,EAAE;QAClB;MACF;MAEAR,mBAAmB,GAAGQ,aAAa;MACnC;MACA;MACA;MACA;MACAjB,mBAAmB,CAAC,CAAC,CAACkB,SAAS,CAACjB,IAAI,CAAC;MAErCS,YAAY,CAAC,CAAC;IAChB,CAAC;IAEDS,oBAAoB,EAAE,SAAAA,qBAAA,EAAY;MAChC,OAAOX,uBAAuB;IAChC,CAAC;IAEDY,kBAAkB,EAAEnB,IAAI;IAExBoB,SAAS,EAAE,SAAAA,UAAUC,OAAO,EAAEC,UAAU,EAAEC,aAAa,EAAEC,OAAO,EAAEC,IAAI,EAAE;MACtE,IAAID,OAAO,KAAKE,SAAS,EAAE;QACzBF,OAAO,GAAGpB,gBAAgB,CAAC,CAAC;MAC9B;MACA,IAAIqB,IAAI,KAAKC,SAAS,EAAE;QACtBD,IAAI,GAAGxB,YAAY,CAAC,CAAC;MACvB;MACAK,cAAc,CAACqB,GAAG,CAAC,UAAUjB,eAAe,EAAE;QAC5CA,eAAe,CAACU,SAAS,CACvBC,OAAO,EACPC,UAAU,EACVC,aAAa,EACbC,OAAO,EACPC,IACF,CAAC;MACH,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAEA,SAASV,kCAAkCA,CAACF,iBAAiB,EAAE;EAC7D,OAAOlB,MAAM,CAAC,CAAC,CAAC,EAAEkB,iBAAiB,EAAE;IAAEe,WAAW,EAAE;EAAQ,CAAC,CAAC;AAChE","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ErrorSource, LifeCycle, LifeCycleEventType, createPageExitObservable, areCookiesAuthorized, startTelemetry, startBatchWithReplica, canUseEventBridge, TelemetryService } from '@cloudcare/browser-core';
1
+ import { LifeCycle, createPageExitObservable, areCookiesAuthorized, willSyntheticsInjectRum, startTelemetry, startBatchWithReplica, canUseEventBridge, TelemetryService, drainPreStartTelemetry, createIdentityEncoder, addTelemetryConfiguration, deepClone } from '@cloudcare/browser-core';
2
2
  import { startLogsSessionManager, startLogsSessionManagerStub } from '../domain/logsSessionManager';
3
3
  import { startLogsAssembly, getRUMInternalContext } from '../domain/assembly';
4
4
  import { startConsoleCollection } from '../domain/logsCollection/console/consoleCollection';
@@ -7,26 +7,43 @@ import { startNetworkErrorCollection } from '../domain/logsCollection/networkErr
7
7
  import { startRuntimeErrorCollection } from '../domain/logsCollection/rumtimeError/runtimeErrorCollection';
8
8
  import { startLoggerCollection } from '../domain/logsCollection/logger/loggerCollection';
9
9
  import { startLogsBatch } from '../transport/startLogsBatch';
10
- import { StatusType } from '../domain/logger';
11
- import { startInternalContext } from '../domain/internalContext';
12
- export function startLogs(configuration, buildCommonContext, mainLogger) {
10
+ import { startInternalContext } from '../domain/contexts/internalContext';
11
+ import { startReportError } from '../domain/reportError';
12
+ export function startLogs(initConfiguration, configuration, getCommonContext) {
13
13
  var lifeCycle = new LifeCycle();
14
- var reportError = function reportError(error) {
15
- lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
16
- rawLogsEvent: {
17
- message: error.message,
18
- date: error.startClocks.timeStamp,
19
- error: {
20
- origin: ErrorSource.AGENT
21
- },
22
- origin: ErrorSource.AGENT,
23
- status: StatusType.error
24
- }
14
+ var cleanupTasks = [];
15
+ var reportError = startReportError(lifeCycle);
16
+ var pageExitObservable = createPageExitObservable();
17
+ var session = areCookiesAuthorized(configuration.cookieOptions) && !canUseEventBridge() && !willSyntheticsInjectRum() ? startLogsSessionManager(configuration) : startLogsSessionManagerStub(configuration);
18
+ var telemetry = startLogsTelemetry(initConfiguration, configuration, reportError, pageExitObservable, session);
19
+ cleanupTasks.push(function () {
20
+ telemetry.stop();
21
+ });
22
+ startNetworkErrorCollection(configuration, lifeCycle);
23
+ startRuntimeErrorCollection(configuration, lifeCycle);
24
+ startConsoleCollection(configuration, lifeCycle);
25
+ startReportCollection(configuration, lifeCycle);
26
+ var _startLoggerCollection = startLoggerCollection(lifeCycle);
27
+ startLogsAssembly(session, configuration, lifeCycle, getCommonContext, reportError);
28
+ if (!canUseEventBridge()) {
29
+ var _startLogsBatch = startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session);
30
+ cleanupTasks.push(function () {
31
+ _startLogsBatch.stop();
25
32
  });
33
+ }
34
+ var internalContext = startInternalContext(session);
35
+ return {
36
+ handleLog: _startLoggerCollection.handleLog,
37
+ getInternalContext: internalContext.get,
38
+ stop: function stop() {
39
+ cleanupTasks.forEach(function (task) {
40
+ task();
41
+ });
42
+ }
26
43
  };
27
- var pageExitObservable = createPageExitObservable();
28
- var session = areCookiesAuthorized(configuration.cookieOptions) ? startLogsSessionManager(configuration) : startLogsSessionManagerStub(configuration);
29
- var telemetry = startLogsTelemetry(configuration, reportError, pageExitObservable, session.expireObservable);
44
+ }
45
+ function startLogsTelemetry(initConfiguration, configuration, reportError, pageExitObservable, session) {
46
+ var telemetry = startTelemetry(TelemetryService.LOGS, configuration);
30
47
  telemetry.setContextProvider(function () {
31
48
  var RUMInternalContext = getRUMInternalContext();
32
49
  return {
@@ -44,29 +61,31 @@ export function startLogs(configuration, buildCommonContext, mainLogger) {
44
61
  }
45
62
  };
46
63
  });
47
- startNetworkErrorCollection(configuration, lifeCycle);
48
- startRuntimeErrorCollection(configuration, lifeCycle);
49
- startConsoleCollection(configuration, lifeCycle);
50
- startReportCollection(configuration, lifeCycle);
51
- var _startLoggerCollection = startLoggerCollection(lifeCycle);
52
- startLogsAssembly(session, configuration, lifeCycle, buildCommonContext, mainLogger, reportError);
53
- if (!canUseEventBridge()) {
54
- startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable);
55
- }
56
- var internalContext = startInternalContext(session);
57
- return {
58
- handleLog: _startLoggerCollection.handleLog,
59
- getInternalContext: internalContext.get
60
- };
61
- }
62
- function startLogsTelemetry(configuration, reportError, pageExitObservable, sessionExpireObservable) {
63
- var telemetry = startTelemetry(TelemetryService.LOGS, configuration);
64
+ var cleanupTasks = [];
64
65
  if (!canUseEventBridge()) {
65
- var telemetryBatch = startBatchWithReplica(configuration, configuration.rumEndpoint, reportError, pageExitObservable, sessionExpireObservable);
66
- telemetry.observable.subscribe(function (event) {
66
+ var telemetryBatch = startBatchWithReplica(configuration, {
67
+ endpoint: configuration.rumEndpoint,
68
+ encoder: createIdentityEncoder()
69
+ }, reportError, pageExitObservable, session.expireObservable);
70
+ cleanupTasks.push(function () {
71
+ telemetryBatch.stop();
72
+ });
73
+ var telemetrySubscription = telemetry.observable.subscribe(function (event) {
67
74
  telemetryBatch.add(event);
68
75
  });
76
+ cleanupTasks.push(function () {
77
+ telemetrySubscription.unsubscribe();
78
+ });
69
79
  }
70
- return telemetry;
80
+ drainPreStartTelemetry();
81
+ addTelemetryConfiguration(deepClone(initConfiguration));
82
+ return {
83
+ telemetry: telemetry,
84
+ stop: function stop() {
85
+ cleanupTasks.forEach(function (task) {
86
+ task();
87
+ });
88
+ }
89
+ };
71
90
  }
72
91
  //# sourceMappingURL=startLogs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"startLogs.js","names":["ErrorSource","LifeCycle","LifeCycleEventType","createPageExitObservable","areCookiesAuthorized","startTelemetry","startBatchWithReplica","canUseEventBridge","TelemetryService","startLogsSessionManager","startLogsSessionManagerStub","startLogsAssembly","getRUMInternalContext","startConsoleCollection","startReportCollection","startNetworkErrorCollection","startRuntimeErrorCollection","startLoggerCollection","startLogsBatch","StatusType","startInternalContext","startLogs","configuration","buildCommonContext","mainLogger","lifeCycle","reportError","error","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","origin","AGENT","status","pageExitObservable","session","cookieOptions","telemetry","startLogsTelemetry","expireObservable","setContextProvider","RUMInternalContext","application","id","findTrackedSession","view","action","userAction","_startLoggerCollection","internalContext","handleLog","getInternalContext","get","sessionExpireObservable","LOGS","telemetryBatch","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,SACEA,WAAW,EACXC,SAAS,EACTC,kBAAkB,EAClBC,wBAAwB,EACxBC,oBAAoB,EACpBC,cAAc,EACdC,qBAAqB,EACrBC,iBAAiB,EACjBC,gBAAgB,QACX,yBAAyB;AAChC,SACEC,uBAAuB,EACvBC,2BAA2B,QACtB,8BAA8B;AACrC,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,oBAAoB;AAC7E,SAASC,sBAAsB,QAAQ,oDAAoD;AAC3F,SAASC,qBAAqB,QAAQ,kDAAkD;AACxF,SAASC,2BAA2B,QAAQ,8DAA8D;AAC1G,SAASC,2BAA2B,QAAQ,8DAA8D;AAC1G,SAASC,qBAAq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qBAAqB,CACxCgB,aAAa,EACbA,aAAa,CAACsC,WAAW,EACzBlC,WAAW,EACXY,kBAAkB,EAClBmB,uBACF,CAAC;IACDhB,SAAS,CAACoB,UAAU,CAACC,SAAS,CAAC,UAAUC,KAAK,EAAE;MAC9CJ,cAAc,CAACK,GAAG,CAACD,KAAK,CAAC;IAC3B,CAAC,CAAC;EACJ;EACA,OAAOtB,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"startLogs.js","names":["LifeCycle","createPageExitObservable","areCookiesAuthorized","willSyntheticsInjectRum","startTelemetry","startBatchWithReplica","canUseEventBridge","TelemetryService","drainPreStartTelemetry","createIdentityEncoder","addTelemetryConfiguration","deepClone","startLogsSessionManager","startLogsSessionManagerStub","startLogsAssembly","getRUMInternalContext","startConsoleCollection","startReportCollection","startNetworkErrorCollection","startRuntimeErrorCollection","startLoggerCollection","startLogsBatch","startInternalContext","startReportError","startLogs","initConfiguration","configuration","getCommonContext","lifeCycle","cleanupTasks","reportError","pageExitObservable","session","cookieOptions","telemetry","startLogsTelemetry","push","stop","_startLoggerCollection","_startLogsBatch","internalContext","handleLog","getInternalContext","get","forEach","task","LOGS","setContextProvider","RUMInternalContext","application","id","findTrackedSession","view","action","userAction","telemetryBatch","endpoint","rumEndpoint","encoder","expireObservable","telemetrySubscription","observable","subscribe","event","add","unsubscribe"],"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,SACEA,SAAS,EACTC,wBAAwB,EACxBC,oBAAoB,EACpBC,uBAAuB,EACvBC,cAAc,EACdC,qBAAqB,EACrBC,iBAAiB,EACjBC,gBAAgB,EAChBC,sBAAsB,EACtBC,qBAAqB,EACrBC,yBAAyB,EACzBC,SAAS,QACJ,yBAAyB;AAChC,SACEC,uBAAuB,EACvBC,2BAA2B,QACtB,8BAA8B;AACrC,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,oBAAoB;AAC7E,SAASC,sBAAsB,QAAQ,oDAAoD;AAC3F,SAASC,qBAAqB,QAAQ,kDAAkD;AACxF,SAASC,2BAA2B,QAAQ,8DAA8D;AAC1G,SAASC,2BAA2B,QAAQ,8DAA8D;AAC1G,SAASC,qBAAqB,QAAQ,kDAAkD;AACxF,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,OAAO,S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ACb;MAAE8B,QAAQ,EAAE9B,aAAa,CAAC+B,WAAW;MAAEC,OAAO,EAAEjD,qBAAqB,CAAC;IAAE,CAAC,EACzEqB,WAAW,EACXC,kBAAkB,EAClBC,OAAO,CAAC2B,gBACV,CAAC;IACD9B,YAAY,CAACO,IAAI,CAAC,YAAY;MAC5BmB,cAAc,CAAClB,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,IAAIuB,qBAAqB,GAAG1B,SAAS,CAAC2B,UAAU,CAACC,SAAS,CAAC,UACzDC,KAAK,EACL;MACAR,cAAc,CAACS,GAAG,CAACD,KAAK,CAAC;IAC3B,CAAC,CAAC;IACFlC,YAAY,CAACO,IAAI,CAAC,YAAY;MAC5BwB,qBAAqB,CAACK,WAAW,CAAC,CAAC;IACrC,CAAC,CAAC;EACJ;EACAzD,sBAAsB,CAAC,CAAC;EACxBE,yBAAyB,CAACC,SAAS,CAACc,iBAAiB,CAAC,CAAC;EACvD,OAAO;IACLS,SAAS,EAAEA,SAAS;IACpBG,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBR,YAAY,CAACe,OAAO,CAAC,UAAUC,IAAI,EAAE;QACnCA,IAAI,CAAC,CAAC;MACR,CAAC,CAAC;IACJ;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,24 +1,22 @@
1
1
  import { ErrorSource, extend2Lev, createEventRateLimiter, getRelativeTime, withSnakeCaseKeys, LifeCycleEventType, deviceInfo, each, RumEventType, isEmptyObject, isNullUndefinedDefaultValue } from '@cloudcare/browser-core';
2
- import { STATUSES, HandlerType } from './logger';
3
- import { isAuthorized } from './logsCollection/logger/loggerCollection';
4
- export function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommonContext, mainLogger, reportError) {
2
+ import { STATUSES } from './logger';
3
+ export function startLogsAssembly(sessionManager, configuration, lifeCycle, getCommonContext, reportError) {
5
4
  var statusWithCustom = STATUSES.concat(['custom']);
6
5
  var logRateLimiters = {};
7
6
  each(statusWithCustom, function (status) {
8
7
  logRateLimiters[status] = createEventRateLimiter(status, configuration.eventRateLimiterThreshold, reportError);
9
8
  });
10
9
  lifeCycle.subscribe(LifeCycleEventType.RAW_LOG_COLLECTED, function (data) {
11
- // { rawLogsEvent, messageContext = undefined, savedCommonContext = undefined, logger = mainLogger }
12
10
  var rawLogsEvent = data.rawLogsEvent;
13
11
  var messageContext = data.messageContext || undefined;
14
12
  var savedCommonContext = data.savedCommonContext || undefined;
15
- var logger = data.logger || mainLogger;
13
+ var domainContext = data.domainContext;
16
14
  var startTime = getRelativeTime(rawLogsEvent.date);
17
15
  var session = sessionManager.findTrackedSession(startTime);
18
16
  if (!session) {
19
17
  return;
20
18
  }
21
- var commonContext = savedCommonContext || buildCommonContext();
19
+ var commonContext = savedCommonContext || getCommonContext();
22
20
  var log = extend2Lev({
23
21
  service: configuration.service || 'browser',
24
22
  env: configuration.env || '',
@@ -34,8 +32,8 @@ export function startLogsAssembly(sessionManager, configuration, lifeCycle, buil
34
32
  user: !isEmptyObject(commonContext.user) ? commonContext.user : undefined,
35
33
  device: deviceInfo,
36
34
  type: RumEventType.LOGGER
37
- }, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, logger.getContext(), messageContext);
38
- if (!isAuthorized(rawLogsEvent.status, HandlerType.http, logger) || configuration.beforeSend && configuration.beforeSend(log) === false || log.error && log.error.origin !== ErrorSource.AGENT && isNullUndefinedDefaultValue(logRateLimiters[log.status], logRateLimiters['custom']).isLimitReached()) {
35
+ }, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, messageContext);
36
+ if (configuration.beforeSend && configuration.beforeSend(log, domainContext) === false || log.origin !== ErrorSource.AGENT && isNullUndefinedDefaultValue(logRateLimiters[log.status], logRateLimiters['custom']).isLimitReached()) {
39
37
  return;
40
38
  }
41
39
  lifeCycle.notify(LifeCycleEventType.LOG_COLLECTED, withSnakeCaseKeys(log));
@@ -1 +1 @@
1
- {"version":3,"file":"assembly.js","names":["ErrorSource","extend2Lev","createEventRateLimiter","getRelativeTime","withSnakeCaseKeys","LifeCycleEventType","deviceInfo","each","RumEventType","isEmptyObject","isNullUndefinedDefaultValue","STATUSES","HandlerType","isAuthorized","startLogsAssembly","sessionManager","configuration","lifeCycle","buildCommonContext","mainLogger","reportError","statusWithCustom","concat","logRateLimiters","status","eventRateLimiterThreshold","subscribe","RAW_LOG_COLLECTED","data","rawLogsEvent","messageContext","undefined","savedCommonContext","logger","startTime","date","session","findTrackedSession","commonContext","log","service","env","version","_gc","sdkName","sdkVersion","id","view","user","device","type","LOGGER","context","getRUMInternalContext","getContext","http","beforeSend","error","origin","AGENT","isLimitReached","notify","LOG_COLLECTED","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,SACEA,WAAW,EACXC,UAAU,EACVC,sBAAsB,EACtBC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,aAAa,EACbC,2BAA2B,QACtB,yBAAyB;AAEhC,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU;AAChD,SAASC,YAAY,QAAQ,0CAA0C;AAEvE,OAAO,SAASC,iBAAiBA,CAC/BC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,UAAU,EACVC,WAAW,EACX;EACA,IAAIC,gBAAgB,GAAGV,QAAQ,CAACW,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;EAClD,IAAIC,eAAe,GAAG,CAAC,CAAC;EACxBhB,IAAI,CAACc,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AAE3C,UAAU;MAClB4C,IAAI,EAAE1C,YAAY,CAAC2C;IACrB,CAAC,EACDb,aAAa,CAACc,OAAO,EACrBC,qBAAqB,CAACnB,SAAS,CAAC,EAChCL,YAAY,EACZI,MAAM,CAACqB,UAAU,CAAC,CAAC,EACnBxB,cACF,CAAC;IAED,IACE,CAACjB,YAAY,CAACgB,YAAY,CAACL,MAAM,EAAEZ,WAAW,CAAC2C,IAAI,EAAEtB,MAAM,CAAC,IAC3DjB,aAAa,CAACwC,UAAU,IAAIxC,aAAa,CAACwC,UAAU,CAACjB,GAAG,CAAC,KAAK,KAAM,IACpEA,GAAG,CAACkB,KAAK,IACRlB,GAAG,CAACkB,KAAK,CAACC,MAAM,KAAK1D,WAAW,CAAC2D,KAAK,IACtCjD,2BAA2B,CACzBa,eAAe,CAACgB,GAAG,CAACf,MAAM,CAAC,EAC3BD,eAAe,CAAC,QAAQ,CAC1B,CAAC,CAACqC,cAAc,CAAC,CAAE,EACrB;MACA;IACF;IAEA3C,SAAS,CAAC4C,MAAM,CAACxD,kBAAkB,CAACyD,aAAa,EAAE1D,iBAAiB,CAACmC,GAAG,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ;AAEA,OAAO,SAASc,qBAAqBA,CAACnB,SAAS,EAAE;EAC/C,OAAO6B,+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,CAACjC,SAAS,CAAC;IAChD;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"assembly.js","names":["ErrorSource","extend2Lev","createEventRateLimiter","getRelativeTime","withSnakeCaseKeys","LifeCycleEventType","deviceInfo","each","RumEventType","isEmptyObject","isNullUndefinedDefaultValue","STATUSES","startLogsAssembly","sessionManager","configuration","lifeCycle","getCommonContext","reportError","statusWithCustom","concat","logRateLimiters","status","eventRateLimiterThreshold","subscribe","RAW_LOG_COLLECTED","data","rawLogsEvent","messageContext","undefined","savedCommonContext","domainContext","startTime","date","session","findTrackedSession","commonContext","log","service","env","version","_gc","sdkName","sdkVersion","id","view","user","device","type","LOGGER","context","getRUMInternalContext","beforeSend","origin","AGENT","isLimitReached","notify","LOG_COLLECTED","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,SACEA,WAAW,EACXC,UAAU,EACVC,sBAAsB,EACtBC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,aAAa,EACbC,2BAA2B,QACtB,yBAAyB;AAEhC,SAASC,QAAQ,QAAQ,UAAU;AAEnC,OAAO,SAASC,iBAAiBA,CAC/BC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,WAAW,EACX;EACA,IAAIC,gBAAgB,GAAGP,QAAQ,CAACQ,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;EAClD,IAAIC,eAAe,GAAG,CAAC,CAAC;EACxBb,IAAI,CAACW,gBAAgB,EAAE,UAAUG,MAAM,EAAE;IACvCD,eAAe,CAACC,MAAM,CAAC,GAAGnB,sBAAsB,CAC9CmB,MAAM,EACNP,aAAa,CAACQ,yBAAyB,EACvCL,WACF,CAAC;EACH,CAAC,CAAC;EACFF,SAAS,CAACQ,SAAS,CAAClB,kBAAkB,CAACmB,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;IAC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CAAE,EACrB;MACA;IACF;IAEAvC,SAAS,CAACwC,MAAM,CAAClD,kBAAkB,CAACmD,aAAa,EAAEpD,iBAAiB,CAACgC,GAAG,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ;AAEA,OAAO,SAASc,qBAAqBA,CAACnB,SAAS,EAAE;EAC/C,OAAO0B,+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,CAAC9B,SAAS,CAAC;IAChD;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ export function buildCommonContext(globalContextManager, userContextManager) {
2
+ return {
3
+ view: {
4
+ referrer: document.referrer,
5
+ url: window.location.href
6
+ },
7
+ context: globalContextManager.getContext(),
8
+ user: userContextManager.getContext()
9
+ };
10
+ }
11
+ //# 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":"AAAA,OAAO,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":"AACA,OAAO,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,14 @@
1
+ export function createErrorFieldFromRawError(rawError, options) {
2
+ if (options === undefined) {
3
+ options = {};
4
+ }
5
+ var includeMessage = options.includeMessage || false;
6
+ return {
7
+ stack: rawError.stack,
8
+ kind: rawError.type,
9
+ message: includeMessage ? rawError.message : undefined,
10
+ causes: rawError.causes,
11
+ handling: rawError.handling
12
+ };
13
+ }
14
+ //# 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":"AAAA,OAAO,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":[]}
@@ -1,10 +1,16 @@
1
- import { assign, extend2Lev, createContextManager, ErrorSource, keys, CustomerDataType, sanitize, computeStackTrace, computeRawError, clocksNow, ErrorHandling, monitor, NonErrorPrefix } from '@cloudcare/browser-core';
1
+ import { extend2Lev, createContextManager, ErrorSource, keys, CustomerDataType, sanitize, computeStackTrace, computeRawError, clocksNow, ErrorHandling, monitor, NonErrorPrefix, createHandlingStack } from '@cloudcare/browser-core';
2
+ import { isAuthorized } from './logsCollection/logger/loggerCollection';
3
+ import { createErrorFieldFromRawError } from './createErrorFieldFromRawError';
2
4
  export var StatusType = {
5
+ ok: 'ok',
3
6
  debug: 'debug',
4
- error: 'error',
5
7
  info: 'info',
8
+ notice: 'notice',
6
9
  warn: 'warn',
7
- critical: 'critical'
10
+ error: 'error',
11
+ critical: 'critical',
12
+ alert: 'alert',
13
+ emerg: 'emerg'
8
14
  };
9
15
  export var HandlerType = {
10
16
  console: 'console',
@@ -14,7 +20,6 @@ export var HandlerType = {
14
20
  export var STATUSES = keys(StatusType);
15
21
  // eslint-disable-next-line @typescript-eslint/no-redeclare
16
22
  export function Logger(handleLogStrategy, name, handlerType, level, loggerContext) {
17
- this.contextManager = createContextManager(CustomerDataType.LoggerContext);
18
23
  if (typeof handlerType === 'undefined') {
19
24
  handlerType = HandlerType.http;
20
25
  }
@@ -24,84 +29,68 @@ export function Logger(handleLogStrategy, name, handlerType, level, loggerContex
24
29
  if (typeof loggerContext === 'undefined') {
25
30
  loggerContext = {};
26
31
  }
32
+ this.contextManager = createContextManager(CustomerDataType.LoggerContext);
27
33
  this.handleLogStrategy = handleLogStrategy;
28
34
  this.handlerType = handlerType;
29
35
  this.level = level;
30
- this.contextManager.set(assign({}, loggerContext, name ? {
31
- logger: {
36
+ this.contextManager.setContext(loggerContext);
37
+ if (name) {
38
+ this.contextManager.setContextProperty('logger', {
32
39
  name: name
33
- }
34
- } : undefined));
40
+ });
41
+ }
35
42
  }
36
43
  Logger.prototype = {
37
- log: monitor(function (message, messageContext, status, error) {
38
- if (typeof status === 'undefined') {
44
+ logImplementation: monitor(function (message, messageContext, status, error, handlingStack) {
45
+ if (status === undefined) {
39
46
  status = StatusType.info;
40
47
  }
41
- var errorContext;
42
- if (status === StatusType.error) {
43
- // Always add origin if status is error (backward compatibility - Remove in next major)
44
- errorContext = {
45
- origin: ErrorSource.LOGGER
46
- };
47
- }
48
+ var sanitizedMessageContext = sanitize(messageContext);
49
+ var context;
48
50
  if (error !== undefined && error !== null) {
49
- var stackTrace = error instanceof Error ? computeStackTrace(error) : undefined;
50
51
  var rawError = computeRawError({
51
- stackTrace: stackTrace,
52
+ stackTrace: error instanceof Error ? computeStackTrace(error) : undefined,
52
53
  originalError: error,
53
54
  nonErrorPrefix: NonErrorPrefix.PROVIDED,
54
55
  source: ErrorSource.LOGGER,
55
56
  handling: ErrorHandling.HANDLED,
56
57
  startClocks: clocksNow()
57
58
  });
58
- errorContext = {
59
- origin: ErrorSource.LOGGER,
60
- // Remove in next major
61
- stack: rawError.stack,
62
- kind: rawError.type,
63
- message: rawError.message,
64
- causes: rawError.causes
65
- };
59
+ context = extend2Lev({
60
+ error: createErrorFieldFromRawError(rawError, {
61
+ includeMessage: true
62
+ })
63
+ }, sanitizedMessageContext);
64
+ } else {
65
+ context = sanitizedMessageContext;
66
66
  }
67
- var sanitizedMessageContext = sanitize(messageContext);
68
- var context = errorContext ? extend2Lev({
69
- error: errorContext
70
- }, sanitizedMessageContext) : sanitizedMessageContext;
71
67
  this.handleLogStrategy({
72
- message: message,
68
+ message: sanitize(message),
73
69
  context: context,
74
70
  status: status
75
- }, this);
71
+ }, this, handlingStack);
76
72
  }),
77
- debug: function debug(message, messageContext, error) {
78
- this.log(message, messageContext, StatusType.debug, error);
79
- },
80
- info: function info(message, messageContext, error) {
81
- this.log(message, messageContext, StatusType.info, error);
82
- },
83
- warn: function warn(message, messageContext, error) {
84
- this.log(message, messageContext, StatusType.warn, error);
85
- },
86
- critical: function critical(message, messageContext, error) {
87
- this.log(message, messageContext, StatusType.critical, error);
88
- },
89
- error: function error(message, messageContext, _error) {
90
- var errorOrigin = {
91
- error: {
92
- origin: ErrorSource.LOGGER
93
- }
94
- };
95
- this.log(message, extend2Lev(errorOrigin, messageContext), StatusType.error, _error);
73
+ log: function log(message, messageContext, status, error) {
74
+ var handlingStack;
75
+ if (isAuthorized(status, HandlerType.http, this)) {
76
+ handlingStack = createHandlingStack();
77
+ }
78
+ this.logImplementation(message, messageContext, status, error, handlingStack);
96
79
  },
97
80
  setContext: function setContext(context) {
98
- this.contextManager.set(context);
81
+ this.contextManager.setContext(context);
99
82
  },
100
83
  getContext: function getContext() {
101
- return this.contextManager.get();
84
+ return this.contextManager.getContext();
85
+ },
86
+ setContextProperty: function setContextProperty(key, value) {
87
+ this.contextManager.setContextProperty(key, value);
102
88
  },
103
89
  addContext: function addContext(key, value) {
104
- this.contextManager.add(key, value);
90
+ this.contextManager.setContextProperty(key, value);
91
+ },
92
+ removeContextProperty: function removeContextProperty(key) {
93
+ this.contextManager.removeContextProperty(key);
105
94
  },
106
95
  removeContext: function removeContext(key) {
107
96
  this.contextManager.remove(key);
@@ -122,4 +111,22 @@ Logger.prototype = {
122
111
  return this.level;
123
112
  }
124
113
  };
114
+ Logger.prototype.ok = createLoggerMethod(StatusType.ok);
115
+ Logger.prototype.debug = createLoggerMethod(StatusType.debug);
116
+ Logger.prototype.info = createLoggerMethod(StatusType.info);
117
+ Logger.prototype.notice = createLoggerMethod(StatusType.notice);
118
+ Logger.prototype.warn = createLoggerMethod(StatusType.warn);
119
+ Logger.prototype.error = createLoggerMethod(StatusType.error);
120
+ Logger.prototype.critical = createLoggerMethod(StatusType.critical);
121
+ Logger.prototype.alert = createLoggerMethod(StatusType.alert);
122
+ Logger.prototype.emerg = createLoggerMethod(StatusType.emerg);
123
+ function createLoggerMethod(status) {
124
+ return function (message, messageContext, error) {
125
+ var handlingStack;
126
+ if (isAuthorized(status, HandlerType.http, this)) {
127
+ handlingStack = createHandlingStack();
128
+ }
129
+ this.logImplementation(message, messageContext, status, error, handlingStack);
130
+ };
131
+ }
125
132
  //# sourceMappingURL=logger.js.map