@cloudcare/browser-logs 3.0.29 → 3.1.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 (75) hide show
  1. package/bundle/dataflux-logs.js +1 -1
  2. package/cjs/boot/buildEnv.js +3 -2
  3. package/cjs/boot/buildEnv.js.map +1 -0
  4. package/cjs/boot/logsPublicApi.js +2 -30
  5. package/cjs/boot/logsPublicApi.js.map +1 -0
  6. package/cjs/boot/startLogs.js +34 -19
  7. package/cjs/boot/startLogs.js.map +1 -0
  8. package/cjs/domain/assembly.js +4 -13
  9. package/cjs/domain/assembly.js.map +1 -0
  10. package/cjs/domain/configuration.js +2 -12
  11. package/cjs/domain/configuration.js.map +1 -0
  12. package/cjs/domain/internalContext.js +2 -3
  13. package/cjs/domain/internalContext.js.map +1 -0
  14. package/cjs/domain/logger.js +5 -16
  15. package/cjs/domain/logger.js.map +1 -0
  16. package/cjs/domain/logsCollection/console/consoleCollection.js +6 -8
  17. package/cjs/domain/logsCollection/console/consoleCollection.js.map +1 -0
  18. package/cjs/domain/logsCollection/logger/loggerCollection.js +6 -12
  19. package/cjs/domain/logsCollection/logger/loggerCollection.js.map +1 -0
  20. package/cjs/domain/logsCollection/networkError/networkErrorCollection.js +5 -23
  21. package/cjs/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -0
  22. package/cjs/domain/logsCollection/report/reportCollection.js +7 -11
  23. package/cjs/domain/logsCollection/report/reportCollection.js.map +1 -0
  24. package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -8
  25. package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -0
  26. package/cjs/domain/logsSessionManager.js +2 -9
  27. package/cjs/domain/logsSessionManager.js.map +1 -0
  28. package/cjs/entries/main.js +2 -5
  29. package/cjs/entries/main.js.map +1 -0
  30. package/cjs/index.js +2 -2
  31. package/cjs/index.js.map +1 -0
  32. package/cjs/transport/startLogsBatch.js +2 -3
  33. package/cjs/transport/startLogsBatch.js.map +1 -0
  34. package/cjs/transport/startLogsBridge.js +14 -0
  35. package/cjs/transport/startLogsBridge.js.map +1 -0
  36. package/esm/boot/buildEnv.js +3 -2
  37. package/esm/boot/buildEnv.js.map +1 -0
  38. package/esm/boot/logsPublicApi.js +2 -25
  39. package/esm/boot/logsPublicApi.js.map +1 -0
  40. package/esm/boot/startLogs.js +36 -9
  41. package/esm/boot/startLogs.js.map +1 -0
  42. package/esm/domain/assembly.js +4 -7
  43. package/esm/domain/assembly.js.map +1 -0
  44. package/esm/domain/configuration.js +2 -7
  45. package/esm/domain/configuration.js.map +1 -0
  46. package/esm/domain/internalContext.js +2 -2
  47. package/esm/domain/internalContext.js.map +1 -0
  48. package/esm/domain/logger.js +6 -13
  49. package/esm/domain/logger.js.map +1 -0
  50. package/esm/domain/logsCollection/console/consoleCollection.js +6 -4
  51. package/esm/domain/logsCollection/console/consoleCollection.js.map +1 -0
  52. package/esm/domain/logsCollection/logger/loggerCollection.js +6 -7
  53. package/esm/domain/logsCollection/logger/loggerCollection.js.map +1 -0
  54. package/esm/domain/logsCollection/networkError/networkErrorCollection.js +5 -17
  55. package/esm/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -0
  56. package/esm/domain/logsCollection/report/reportCollection.js +7 -7
  57. package/esm/domain/logsCollection/report/reportCollection.js.map +1 -0
  58. package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
  59. package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -0
  60. package/esm/domain/logsSessionManager.js +2 -5
  61. package/esm/domain/logsSessionManager.js.map +1 -0
  62. package/esm/entries/main.js +2 -1
  63. package/esm/entries/main.js.map +1 -0
  64. package/esm/index.js +2 -1
  65. package/esm/index.js.map +1 -0
  66. package/esm/transport/startLogsBatch.js +2 -1
  67. package/esm/transport/startLogsBatch.js.map +1 -0
  68. package/esm/transport/startLogsBridge.js +8 -0
  69. package/esm/transport/startLogsBridge.js.map +1 -0
  70. package/package.json +5 -4
  71. package/src/boot/startLogs.js +68 -10
  72. package/src/domain/logger.js +3 -2
  73. package/src/domain/logsCollection/logger/loggerCollection.js +24 -16
  74. package/src/domain/logsCollection/report/reportCollection.js +10 -8
  75. package/src/transport/startLogsBridge.js +11 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","names":["assign","extend2Lev","createContextManager","ErrorSource","keys","CustomerDataType","sanitize","computeStackTrace","computeRawError","clocksNow","ErrorHandling","monitor","NonErrorPrefix","StatusType","debug","error","info","warn","critical","HandlerType","console","http","silent","STATUSES","Logger","handleLogStrategy","name","handlerType","level","loggerContext","contextManager","LoggerContext","set","logger","undefined","prototype","log","message","messageContext","status","errorContext","origin","LOGGER","stackTrace","Error","rawError","originalError","nonErrorPrefix","PROVIDED","source","handling","HANDLED","startClocks","stack","kind","type","sanitizedMessageContext","context","errorOrigin","setContext","getContext","get","addContext","key","value","add","removeContext","remove","setHandler","handler","getHandler","setLevel","getLevel"],"sources":["../../src/domain/logger.js"],"sourcesContent":["import {\n assign,\n extend2Lev,\n createContextManager,\n ErrorSource,\n keys,\n CustomerDataType,\n sanitize,\n computeStackTrace,\n computeRawError,\n clocksNow,\n ErrorHandling,\n monitor,\n NonErrorPrefix\n} from '@cloudcare/browser-core'\n\nexport var StatusType = {\n debug: 'debug',\n error: 'error',\n info: 'info',\n warn: 'warn',\n critical: 'critical'\n}\n\nexport var HandlerType = {\n console: 'console',\n http: 'http',\n silent: 'silent'\n}\n\nexport var STATUSES = keys(StatusType)\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport function Logger(\n handleLogStrategy,\n name,\n handlerType,\n level,\n loggerContext\n) {\n this.contextManager = createContextManager(CustomerDataType.LoggerContext)\n if (typeof handlerType === 'undefined') {\n handlerType = HandlerType.http\n }\n if (typeof level === 'undefined') {\n level = StatusType.debug\n }\n if (typeof loggerContext === 'undefined') {\n loggerContext = {}\n }\n this.handleLogStrategy = handleLogStrategy\n this.handlerType = handlerType\n this.level = level\n this.contextManager.set(\n assign({}, loggerContext, name ? { logger: { name: name } } : undefined)\n )\n}\nLogger.prototype = {\n log: monitor(function (message, messageContext, status, error) {\n if (typeof status === 'undefined') {\n status = StatusType.info\n }\n var errorContext\n if (status === StatusType.error) {\n // Always add origin if status is error (backward compatibility - Remove in next major)\n errorContext = { origin: ErrorSource.LOGGER }\n }\n if (error !== undefined && error !== null) {\n var stackTrace =\n error instanceof Error ? computeStackTrace(error) : undefined\n var rawError = computeRawError({\n stackTrace: stackTrace,\n originalError: error,\n nonErrorPrefix: NonErrorPrefix.PROVIDED,\n source: ErrorSource.LOGGER,\n handling: ErrorHandling.HANDLED,\n startClocks: clocksNow()\n })\n\n errorContext = {\n origin: ErrorSource.LOGGER, // Remove in next major\n stack: rawError.stack,\n kind: rawError.type,\n message: rawError.message\n }\n }\n\n var sanitizedMessageContext = sanitize(messageContext)\n\n var context = errorContext\n ? extend2Lev({ error: errorContext }, sanitizedMessageContext)\n : sanitizedMessageContext\n\n this.handleLogStrategy(\n { message: message, context: context, status: status },\n this\n )\n }),\n\n debug: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.debug, error)\n },\n\n info: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.info, error)\n },\n\n warn: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.warn, error)\n },\n critical: function (message, messageContext, error) {\n this.log(message, messageContext, StatusType.critical, error)\n },\n error: function (message, messageContext, error) {\n var errorOrigin = {\n error: {\n origin: ErrorSource.LOGGER\n }\n }\n this.log(\n message,\n extend2Lev(errorOrigin, messageContext),\n StatusType.error,\n error\n )\n },\n\n setContext: function (context) {\n this.contextManager.set(context)\n },\n\n getContext: function () {\n return this.contextManager.get()\n },\n\n addContext: function (key, value) {\n this.contextManager.add(key, value)\n },\n\n removeContext: function (key) {\n this.contextManager.remove(key)\n },\n\n setHandler: function (handler) {\n this.handlerType = handler\n },\n\n getHandler: function () {\n return this.handlerType\n },\n setLevel: function (level) {\n this.level = level\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CAAC;EAED4C,UAAU,EAAE,SAAAA,WAAUF,OAAO,EAAE;IAC7B,IAAI,CAAC3B,cAAc,CAACE,GAAG,CAACyB,OAAO,CAAC;EAClC,CAAC;EAEDG,UAAU,EAAE,SAAAA,WAAA,EAAY;IACtB,OAAO,IAAI,CAAC9B,cAAc,CAAC+B,GAAG,CAAC,CAAC;EAClC,CAAC;EAEDC,UAAU,EAAE,SAAAA,WAAUC,GAAG,EAAEC,KAAK,EAAE;IAChC,IAAI,CAAClC,cAAc,CAACmC,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC;EACrC,CAAC;EAEDE,aAAa,EAAE,SAAAA,cAAUH,GAAG,EAAE;IAC5B,IAAI,CAACjC,cAAc,CAACqC,MAAM,CAACJ,GAAG,CAAC;EACjC,CAAC;EAEDK,UAAU,EAAE,SAAAA,WAAUC,OAAO,EAAE;IAC7B,IAAI,CAAC1C,WAAW,GAAG0C,OAAO;EAC5B,CAAC;EAEDC,UAAU,EAAE,SAAAA,WAAA,EAAY;IACtB,OAAO,IAAI,CAAC3C,WAAW;EACzB,CAAC;EACD4C,QAAQ,EAAE,SAAAA,SAAU3C,KAAK,EAAE;IACzB,IAAI,CAACA,KAAK,GAAGA,KAAK;EACpB,CAAC;EACD4C,QAAQ,EAAE,SAAAA,SAAA,EAAY;IACpB,OAAO,IAAI,CAAC5C,KAAK;EACnB;AACF,CAAC"}
@@ -1,7 +1,8 @@
1
1
  var _LogStatusForApi;
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
2
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
6
  import { timeStampNow, ConsoleApiName, ErrorSource, initConsoleObservable, LifeCycleEventType } from '@cloudcare/browser-core';
6
7
  import { StatusType } from '../../logger';
7
8
  var LogStatusForApi = (_LogStatusForApi = {}, _defineProperty(_LogStatusForApi, ConsoleApiName.log, StatusType.info), _defineProperty(_LogStatusForApi, ConsoleApiName.debug, StatusType.debug), _defineProperty(_LogStatusForApi, ConsoleApiName.info, StatusType.info), _defineProperty(_LogStatusForApi, ConsoleApiName.warn, StatusType.warn), _defineProperty(_LogStatusForApi, ConsoleApiName.error, StatusType.error), _LogStatusForApi);
@@ -26,4 +27,5 @@ export function startConsoleCollection(configuration, lifeCycle) {
26
27
  consoleSubscription.unsubscribe();
27
28
  }
28
29
  };
29
- }
30
+ }
31
+ //# sourceMappingURL=consoleCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleCollection.js","names":["timeStampNow","ConsoleApiName","ErrorSource","initConsoleObservable","LifeCycleEventType","StatusType","LogStatusForApi","_LogStatusForApi","_defineProperty","log","info","debug","warn","error","startConsoleCollection","configuration","lifeCycle","consoleSubscription","forwardConsoleLogs","subscribe","notify","RAW_LOG_COLLECTED","rawLogsEvent","date","message","origin","CONSOLE","api","stack","undefined","status","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/console/consoleCollection.js"],"sourcesContent":["import { timeStampNow, ConsoleApiName, ErrorSource, initConsoleObservable, LifeCycleEventType } from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\n\nvar LogStatusForApi = {\n [ConsoleApiName.log]: StatusType.info,\n [ConsoleApiName.debug]: StatusType.debug,\n [ConsoleApiName.info]: StatusType.info,\n [ConsoleApiName.warn]: StatusType.warn,\n [ConsoleApiName.error]: StatusType.error,\n}\nexport function startConsoleCollection(configuration, lifeCycle) {\n var consoleSubscription = initConsoleObservable(configuration.forwardConsoleLogs).subscribe(function(log) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: timeStampNow(),\n message: log.message,\n origin: ErrorSource.CONSOLE,\n error:\n log.api === ConsoleApiName.error\n ? {\n origin: ErrorSource.CONSOLE, // Todo: Remove in the next major release\n stack: log.stack,\n }\n : undefined,\n status: LogStatusForApi[log.api],\n },\n })\n })\n\n return {\n stop: function(){\n consoleSubscription.unsubscribe()\n },\n }\n}\n"],"mappings":";;;;;AAAA,SAASA,YAAY,EAAEC,cAAc,EAAEC,WAAW,EAAEC,qBAAqB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAC9H,SAASC,UAAU,QAAQ,cAAc;AAGzC,IAAIC,eAAe,IAAAC,gBAAA,OAAAC,eAAA,CAAAD,gBAAA,EAChBN,cAAc,CAACQ,GAAG,EAAGJ,UAAU,CAACK,IAAI,GAAAF,eAAA,CAAAD,gBAAA,EACpCN,cAAc,CAACU,KAAK,EAAGN,UAAU,CAACM,KAAK,GAAAH,eAAA,CAAAD,gBAAA,EACvCN,cAAc,CAACS,IAAI,EAAGL,UAAU,CAACK,IAAI,GAAAF,eAAA,CAAAD,gBAAA,EACrCN,cAAc,CAACW,IAAI,EAAGP,UAAU,CAACO,IAAI,GAAAJ,eAAA,CAAAD,gBAAA,EACrCN,cAAc,CAACY,KAAK,EAAGR,UAAU,CAACQ,KAAK,GAAAN,gBAAA,CACzC;AACD,OAAO,SAASO,sBAAsBA,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC/D,IAAIC,mBAAmB,GAAGd,qBAAqB,CAACY,aAAa,CAACG,kBAAkB,CAAC,CAACC,SAAS,CAAC,UAASV,GAAG,EAAE;IACxGO,SAAS,CAACI,MAAM,CAAChB,kBAAkB,CAACiB,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAEvB,YAAY,CAAC,CAAC;QACpBwB,OAAO,EAAEf,GAAG,CAACe,OAAO;QACpBC,MAAM,EAAEvB,WAAW,CAACwB,OAAO;QAC3Bb,KAAK,EACHJ,GAAG,CAACkB,GAAG,KAAK1B,cAAc,CAACY,KAAK,GAC5B;UACEY,MAAM,EAAEvB,WAAW,CAACwB,OAAO;UAAE;UAC7BE,KAAK,EAAEnB,GAAG,CAACmB;QACb,CAAC,GACDC,SAAS;QACfC,MAAM,EAAExB,eAAe,CAACG,GAAG,CAACkB,GAAG;MACjC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLI,IAAI,EAAE,SAAAA,KAAA,EAAU;MACdd,mBAAmB,CAACe,WAAW,CAAC,CAAC;IACnC;EACF,CAAC;AACH"}
@@ -1,18 +1,17 @@
1
1
  var _STATUS_PRIORITIES;
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
2
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
6
  import { includes, display, extend2Lev, ErrorSource, timeStampNow, LifeCycleEventType, isArray } from '@cloudcare/browser-core';
6
7
  import { StatusType, HandlerType } from '../../logger';
7
8
  export var STATUS_PRIORITIES = (_STATUS_PRIORITIES = {}, _defineProperty(_STATUS_PRIORITIES, StatusType.debug, 0), _defineProperty(_STATUS_PRIORITIES, StatusType.info, 1), _defineProperty(_STATUS_PRIORITIES, StatusType.warn, 2), _defineProperty(_STATUS_PRIORITIES, StatusType.error, 3), _STATUS_PRIORITIES);
8
9
  export function startLoggerCollection(lifeCycle) {
9
10
  function handleLog(logsMessage, logger, savedCommonContext, savedDate) {
10
11
  var messageContext = logsMessage.context;
11
-
12
12
  if (isAuthorized(logsMessage.status, HandlerType.console, logger)) {
13
13
  display(logsMessage.status, logsMessage.message, extend2Lev(logger.getContext(), messageContext));
14
14
  }
15
-
16
15
  lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
17
16
  rawLogsEvent: {
18
17
  date: savedDate || timeStampNow(),
@@ -25,7 +24,6 @@ export function startLoggerCollection(lifeCycle) {
25
24
  logger: logger
26
25
  });
27
26
  }
28
-
29
27
  return {
30
28
  handleLog: handleLog
31
29
  };
@@ -34,4 +32,5 @@ export function isAuthorized(status, handlerType, logger) {
34
32
  var loggerHandler = logger.getHandler();
35
33
  var sanitizedHandlerType = isArray(loggerHandler) ? loggerHandler : [loggerHandler];
36
34
  return STATUS_PRIORITIES[status] >= STATUS_PRIORITIES[logger.getLevel()] && includes(sanitizedHandlerType, handlerType);
37
- }
35
+ }
36
+ //# sourceMappingURL=loggerCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loggerCollection.js","names":["includes","display","extend2Lev","ErrorSource","timeStampNow","LifeCycleEventType","isArray","StatusType","HandlerType","STATUS_PRIORITIES","_STATUS_PRIORITIES","_defineProperty","debug","info","warn","error","startLoggerCollection","lifeCycle","handleLog","logsMessage","logger","savedCommonContext","savedDate","messageContext","context","isAuthorized","status","console","message","getContext","notify","RAW_LOG_COLLECTED","rawLogsEvent","date","origin","LOGGER","handlerType","loggerHandler","getHandler","sanitizedHandlerType","getLevel"],"sources":["../../../../src/domain/logsCollection/logger/loggerCollection.js"],"sourcesContent":["import {\n includes,\n display,\n extend2Lev,\n ErrorSource,\n timeStampNow,\n LifeCycleEventType,\n isArray\n} from '@cloudcare/browser-core'\nimport { StatusType, HandlerType } from '../../logger'\n\nexport var STATUS_PRIORITIES = {\n [StatusType.debug]: 0,\n [StatusType.info]: 1,\n [StatusType.warn]: 2,\n [StatusType.error]: 3\n}\n\nexport function startLoggerCollection(lifeCycle) {\n function handleLog(logsMessage, logger, savedCommonContext, savedDate) {\n var messageContext = logsMessage.context\n if (isAuthorized(logsMessage.status, HandlerType.console, logger)) {\n display(\n logsMessage.status,\n logsMessage.message,\n extend2Lev(logger.getContext(), messageContext)\n )\n }\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: savedDate || timeStampNow(),\n message: logsMessage.message,\n status: logsMessage.status,\n origin: ErrorSource.LOGGER\n },\n messageContext: messageContext,\n savedCommonContext: savedCommonContext,\n logger: logger\n })\n }\n\n return {\n handleLog: handleLog\n }\n}\n\nexport function isAuthorized(status, handlerType, logger) {\n var loggerHandler = logger.getHandler()\n var sanitizedHandlerType = isArray(loggerHandler)\n ? loggerHandler\n : [loggerHandler]\n return (\n STATUS_PRIORITIES[status] >= STATUS_PRIORITIES[logger.getLevel()] &&\n includes(sanitizedHandlerType, handlerType)\n )\n}\n"],"mappings":";;;;;AAAA,SACEA,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,kBAAkB,EAClBC,OAAO,QACF,yBAAyB;AAChC,SAASC,UAAU,EAAEC,WAAW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EACxD,IAAIiB,aAAa,GAAGjB,MAAM,CAACkB,UAAU,CAAC,CAAC;EACvC,IAAIC,oBAAoB,GAAGjC,OAAO,CAAC+B,aAAa,CAAC,GAC7CA,aAAa,GACb,CAACA,aAAa,CAAC;EACnB,OACE5B,iBAAiB,CAACiB,MAAM,CAAC,IAAIjB,iBAAiB,CAACW,MAAM,CAACoB,QAAQ,CAAC,CAAC,CAAC,IACjExC,QAAQ,CAACuC,oBAAoB,EAAEH,WAAW,CAAC;AAE/C"}
@@ -6,7 +6,6 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
6
6
  stop: noop
7
7
  };
8
8
  }
9
-
10
9
  var xhrSubscription = initXhrObservable().subscribe(function (context) {
11
10
  if (context.state === 'complete') {
12
11
  handleCompleteRequest(RequestType.XHR, context);
@@ -17,7 +16,6 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
17
16
  handleCompleteRequest(RequestType.FETCH, context);
18
17
  }
19
18
  });
20
-
21
19
  function handleCompleteRequest(type, request) {
22
20
  if (!configuration.isIntakeUrl(request.url) && (isRejected(request) || isServerError(request) || configuration.isServerError(request))) {
23
21
  if ('xhr' in request) {
@@ -28,7 +26,6 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
28
26
  computeFetchErrorText(request.error, configuration, onResponseDataAvailable);
29
27
  }
30
28
  }
31
-
32
29
  function onResponseDataAvailable(responseData) {
33
30
  var urlObj = urlParse(request.url).getParse();
34
31
  lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
@@ -56,19 +53,19 @@ export function startNetworkErrorCollection(configuration, lifeCycle) {
56
53
  });
57
54
  }
58
55
  }
59
-
60
56
  return {
61
57
  stop: function stop() {
62
58
  xhrSubscription.unsubscribe();
63
59
  fetchSubscription.unsubscribe();
64
60
  }
65
61
  };
66
- } // TODO: ideally, computeXhrResponseData should always call the callback with a string instead of
62
+ }
63
+
64
+ // TODO: ideally, computeXhrResponseData should always call the callback with a string instead of
67
65
  // `unknown`. But to keep backward compatibility, in the case of XHR with a `responseType` different
68
66
  // than "text", the response data should be whatever `xhr.response` is. This is a bit confusing as
69
67
  // Logs event 'stack' is expected to be a string. This should be changed in a future major version
70
68
  // as it could be a breaking change.
71
-
72
69
  export function computeXhrResponseData(xhr, configuration, callback) {
73
70
  if (typeof xhr.response === 'string') {
74
71
  callback(truncateResponseText(xhr.response, configuration));
@@ -81,7 +78,6 @@ export function computeFetchErrorText(error, configuration, callback) {
81
78
  }
82
79
  export function computeFetchResponseText(response, configuration, callback) {
83
80
  var clonedResponse = tryToClone(response);
84
-
85
81
  if (!clonedResponse || !clonedResponse.body) {
86
82
  // if the clone failed or if the body is null, let's not try to read it.
87
83
  callback();
@@ -128,46 +124,38 @@ export function computeFetchResponseText(response, configuration, callback) {
128
124
  });
129
125
  }
130
126
  }
131
-
132
127
  function isRejected(request) {
133
128
  return request.status === 0 && request.responseType !== 'opaque';
134
129
  }
135
-
136
130
  function isServerError(request) {
137
131
  return request.status >= 500;
138
132
  }
139
-
140
133
  function truncateResponseText(responseText, configuration) {
141
134
  if (responseText.length > configuration.requestErrorResponseLengthLimit) {
142
135
  return responseText.substring(0, configuration.requestErrorResponseLengthLimit) + '...';
143
136
  }
144
-
145
137
  return responseText;
146
138
  }
147
-
148
139
  function format(type) {
149
140
  if (RequestType.XHR === type) {
150
141
  return 'XHR';
151
142
  }
152
-
153
143
  return 'Fetch';
154
144
  }
155
-
156
145
  function truncateResponseStream(stream, bytesLimit, callback) {
157
146
  readBytesFromStream(stream, function (error, bytes, limitExceeded) {
158
147
  if (error) {
159
148
  callback(error);
160
149
  } else {
161
150
  var responseText = new TextDecoder().decode(bytes);
162
-
163
151
  if (limitExceeded) {
164
152
  responseText += '...';
165
153
  }
166
-
167
154
  callback(undefined, responseText);
168
155
  }
169
156
  }, {
170
157
  bytesLimit: bytesLimit,
171
158
  collectStreamBody: true
172
159
  });
173
- }
160
+ }
161
+ //# sourceMappingURL=networkErrorCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"networkErrorCollection.js","names":["ErrorSource","initXhrObservable","RequestType","initFetchObservable","computeStackTrace","toStackTraceString","noop","each","LifeCycleEventType","getStatusGroup","urlParse","replaceNumberCharByPath","tryToClone","readBytesFromStream","monitor","StatusType","startNetworkErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","xhrSubscription","subscribe","context","state","handleCompleteRequest","XHR","fetchSubscription","FETCH","type","request","isIntakeUrl","url","isRejected","isServerError","computeXhrResponseData","xhr","onResponseDataAvailable","response","computeFetchResponseText","error","computeFetchErrorText","responseData","urlObj","getParse","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","format","method","date","startClocks","timeStamp","origin","NETWORK","stack","http","status_code","status","statusGroup","urlHost","Host","urlPath","Path","urlPathGroup","unsubscribe","callback","truncateResponseText","clonedResponse","body","window","TextDecoder","text","then","truncateResponseStream","requestErrorResponseLengthLimit","responseText","responseType","length","substring","stream","bytesLimit","bytes","limitExceeded","decode","undefined","collectStreamBody"],"sources":["../../../../src/domain/logsCollection/networkError/networkErrorCollection.js"],"sourcesContent":["import {\n ErrorSource,\n initXhrObservable,\n RequestType,\n initFetchObservable,\n computeStackTrace,\n toStackTraceString,\n noop,\n each,\n LifeCycleEventType,\n getStatusGroup,\n urlParse,\n replaceNumberCharByPath,\n tryToClone,\n readBytesFromStream,\n monitor\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nexport function startNetworkErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var xhrSubscription = initXhrObservable().subscribe(function (context) {\n if (context.state === 'complete') {\n handleCompleteRequest(RequestType.XHR, context)\n }\n })\n var fetchSubscription = initFetchObservable().subscribe(function (context) {\n if (context.state === 'resolve') {\n handleCompleteRequest(RequestType.FETCH, context)\n }\n })\n\n function handleCompleteRequest(type, request) {\n if (\n !configuration.isIntakeUrl(request.url) &&\n (isRejected(request) ||\n isServerError(request) ||\n configuration.isServerError(request))\n ) {\n if ('xhr' in request) {\n computeXhrResponseData(\n request.xhr,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.response) {\n computeFetchResponseText(\n request.response,\n configuration,\n onResponseDataAvailable\n )\n } else if (request.error) {\n computeFetchErrorText(\n request.error,\n configuration,\n onResponseDataAvailable\n )\n }\n }\n\n function onResponseDataAvailable(responseData) {\n var urlObj = urlParse(request.url).getParse()\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message:\n format(type) + ' error ' + request.method + ' ' + request.url,\n date: request.startClocks.timeStamp,\n error: {\n origin: ErrorSource.NETWORK, // Todo: Remove in the next major release\n stack: responseData || 'Failed to load'\n },\n http: {\n method: request.method, // Cast resource method because of case mismatch cf issue RUMF-1152\n status_code: request.status,\n url: request.url,\n statusGroup: getStatusGroup(request.status),\n urlHost: urlObj.Host,\n urlPath: urlObj.Path,\n urlPathGroup: replaceNumberCharByPath(urlObj.Path)\n },\n status: StatusType.error,\n origin: ErrorSource.NETWORK\n }\n })\n }\n }\n\n return {\n stop: function () {\n xhrSubscription.unsubscribe()\n fetchSubscription.unsubscribe()\n }\n }\n}\n\n// TODO: ideally, computeXhrResponseData should always call the callback with a string instead of\n// `unknown`. But to keep backward compatibility, in the case of XHR with a `responseType` different\n// than \"text\", the response data should be whatever `xhr.response` is. This is a bit confusing as\n// Logs event 'stack' is expected to be a string. This should be changed in a future major version\n// as it could be a breaking change.\nexport function computeXhrResponseData(xhr, configuration, callback) {\n if (typeof xhr.response === 'string') {\n callback(truncateResponseText(xhr.response, configuration))\n } else {\n callback(xhr.response)\n }\n}\n\nexport function computeFetchErrorText(error, configuration, callback) {\n callback(\n truncateResponseText(\n toStackTraceString(computeStackTrace(error)),\n configuration\n )\n )\n}\n\nexport function computeFetchResponseText(response, configuration, callback) {\n var clonedResponse = tryToClone(response)\n if (!clonedResponse || !clonedResponse.body) {\n // if the clone failed or if the body is null, let's not try to read it.\n callback()\n } else if (!window.TextDecoder) {\n // If the browser doesn't support TextDecoder, let's read the whole response then truncate it.\n //\n // This should only be the case on early versions of Edge (before they migrated to Chromium).\n // Even if it could be possible to implement a workaround for the missing TextDecoder API (using\n // a Blob and FileReader), we found another issue preventing us from reading only the first\n // bytes from the response: contrary to other browsers, when reading from the cloned response,\n // if the original response gets canceled, the cloned response is also canceled and we can't\n // know about it. In the following illustration, the promise returned by `reader.read()` may\n // never be fulfilled:\n //\n // fetch('/').then((response) => {\n // const reader = response.clone().body.getReader()\n // readMore()\n // function readMore() {\n // reader.read().then(\n // (result) => {\n // if (result.done) {\n // console.log('done')\n // } else {\n // readMore()\n // }\n // },\n // () => console.log('error')\n // )\n // }\n // response.body.getReader().cancel()\n // })\n clonedResponse.text().then(\n monitor(function (text) {\n return callback(truncateResponseText(text, configuration))\n }),\n monitor(function (error) {\n return callback('Unable to retrieve response: ' + error)\n })\n )\n } else {\n truncateResponseStream(\n clonedResponse.body,\n configuration.requestErrorResponseLengthLimit,\n function (error, responseText) {\n if (error) {\n callback('Unable to retrieve response: ' + error)\n } else {\n callback(responseText)\n }\n }\n )\n }\n}\n\nfunction isRejected(request) {\n return request.status === 0 && request.responseType !== 'opaque'\n}\n\nfunction isServerError(request) {\n return request.status >= 500\n}\n\nfunction truncateResponseText(responseText, configuration) {\n if (responseText.length > configuration.requestErrorResponseLengthLimit) {\n return (\n responseText.substring(0, configuration.requestErrorResponseLengthLimit) +\n '...'\n )\n }\n return responseText\n}\n\nfunction format(type) {\n if (RequestType.XHR === type) {\n return 'XHR'\n }\n return 'Fetch'\n}\n\nfunction truncateResponseStream(stream, bytesLimit, callback) {\n readBytesFromStream(\n stream,\n function (error, bytes, limitExceeded) {\n if (error) {\n callback(error)\n } else {\n var responseText = new TextDecoder().decode(bytes)\n if (limitExceeded) {\n responseText += '...'\n }\n callback(undefined, responseText)\n }\n },\n {\n bytesLimit: bytesLimit,\n collectStreamBody: true\n }\n )\n}\n"],"mappings":"AAAA,SACEA,WAAW,EACXC,iBAAiB,EACj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IqC,YAAY,GAAG,IAAIL,WAAW,CAAC,CAAC,CAACa,MAAM,CAACF,KAAK,CAAC;MAClD,IAAIC,aAAa,EAAE;QACjBP,YAAY,IAAI,KAAK;MACvB;MACAV,QAAQ,CAACmB,SAAS,EAAET,YAAY,CAAC;IACnC;EACF,CAAC,EACD;IACEK,UAAU,EAAEA,UAAU;IACtBK,iBAAiB,EAAE;EACrB,CACF,CAAC;AACH"}
@@ -1,16 +1,16 @@
1
1
  var _LogStatusForReport;
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
2
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
6
  import { timeStampNow, ErrorSource, RawReportType, getFileFromStackTraceString, initReportObservable, LifeCycleEventType } from '@cloudcare/browser-core';
6
7
  import { StatusType } from '../../logger';
7
8
  var LogStatusForReport = (_LogStatusForReport = {}, _defineProperty(_LogStatusForReport, RawReportType.cspViolation, StatusType.error), _defineProperty(_LogStatusForReport, RawReportType.intervention, StatusType.error), _defineProperty(_LogStatusForReport, RawReportType.deprecation, StatusType.warn), _LogStatusForReport);
8
9
  export function startReportCollection(configuration, lifeCycle) {
9
- var reportSubscription = initReportObservable(configuration.forwardReports).subscribe(function (report) {
10
+ var reportSubscription = initReportObservable(configuration, configuration.forwardReports).subscribe(function (report) {
10
11
  var message = report.message;
11
12
  var status = LogStatusForReport[report.type];
12
13
  var error;
13
-
14
14
  if (status === StatusType.error) {
15
15
  error = {
16
16
  kind: report.subtype,
@@ -21,7 +21,6 @@ export function startReportCollection(configuration, lifeCycle) {
21
21
  } else if (report.stack) {
22
22
  message += ' Found in ' + getFileFromStackTraceString(report.stack);
23
23
  }
24
-
25
24
  lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
26
25
  rawLogsEvent: {
27
26
  date: timeStampNow(),
@@ -37,4 +36,5 @@ export function startReportCollection(configuration, lifeCycle) {
37
36
  reportSubscription.unsubscribe();
38
37
  }
39
38
  };
40
- }
39
+ }
40
+ //# sourceMappingURL=reportCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportCollection.js","names":["timeStampNow","ErrorSource","RawReportType","getFileFromStackTraceString","initReportObservable","LifeCycleEventType","StatusType","LogStatusForReport","_LogStatusForReport","_defineProperty","cspViolation","error","intervention","deprecation","warn","startReportCollection","configuration","lifeCycle","reportSubscription","forwardReports","subscribe","report","message","status","type","kind","subtype","origin","REPORT","stack","notify","RAW_LOG_COLLECTED","rawLogsEvent","date","stop","unsubscribe"],"sources":["../../../../src/domain/logsCollection/report/reportCollection.js"],"sourcesContent":["import {\n timeStampNow,\n ErrorSource,\n RawReportType,\n getFileFromStackTraceString,\n initReportObservable,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nvar LogStatusForReport = {\n [RawReportType.cspViolation]: StatusType.error,\n [RawReportType.intervention]: StatusType.error,\n [RawReportType.deprecation]: StatusType.warn\n}\n\nexport function startReportCollection(configuration, lifeCycle) {\n var reportSubscription = initReportObservable(\n configuration,\n configuration.forwardReports\n ).subscribe(function (report) {\n var message = report.message\n var status = LogStatusForReport[report.type]\n var error\n if (status === StatusType.error) {\n error = {\n kind: report.subtype,\n origin: ErrorSource.REPORT, // Todo: Remove in the next major release\n stack: report.stack\n }\n } else if (report.stack) {\n message += ' Found in ' + getFileFromStackTraceString(report.stack)\n }\n\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: timeStampNow(),\n message: message,\n origin: ErrorSource.REPORT,\n error: error,\n status: status\n }\n })\n })\n\n return {\n stop: function () {\n reportSubscription.unsubscribe()\n }\n }\n}\n"],"mappings":";;;;;AAAA,SACEA,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,2BAA2B,EAC3BC,oBAAoB,EACpBC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,UAAU,QAAQ,cAAc;AAEzC,IAAIC,kBAAkB,IAAAC,mBAAA,OAAAC,eAAA,CAAAD,mBAAA,EACnBN,aAAa,CAACQ,YAAY,EAAGJ,UAAU,CAACK,KAAK,GAAAF,eAAA,CAAAD,mBAAA,EAC7CN,aAAa,CAACU,YAAY,EAAGN,UAAU,CAACK,KAAK,GAAAF,eAAA,CAAAD,mBAAA,EAC7CN,aAAa,CAACW,WAAW,EAAGP,UAAU,CAACQ,IAAI,GAAAN,mBAAA,CAC7C;AAED,OAAO,SAASO,qBAAqBA,CAACC,aAAa,EAAEC,SAAS,EAAE;EAC9D,IAAIC,kBAAkB,GAAGd,oBAAoB,CAC3CY,aAAa,EACbA,aAAa,CAACG,cAChB,CAAC,CAACC,SAAS,CAAC,UAAUC,MAAM,EAAE;IAC5B,IAAIC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC5B,IAAIC,MAAM,GAAGhB,kBAAkB,CAACc,MAAM,CAACG,IAAI,CAAC;IAC5C,IAAIb,KAAK;IACT,IAAIY,MAAM,KAAKjB,UAAU,CAACK,KAAK,EAAE;MAC/BA,KAAK,GAAG;QACNc,IAAI,EAAEJ,MAAM,CAACK,OAAO;QACpBC,MAAM,EAAE1B,WAAW,CAAC2B,MAAM;QAAE;QAC5BC,KAAK,EAAER,MAAM,CAACQ;MAChB,CAAC;IACH,CAAC,MAAM,IAAIR,MAAM,CAACQ,KAAK,EAAE;MACvBP,OAAO,IAAI,YAAY,GAAGnB,2BAA2B,CAACkB,MAAM,CAACQ,KAAK,CAAC;IACrE;IAEAZ,SAAS,CAACa,MAAM,CAACzB,kBAAkB,CAAC0B,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,IAAI,EAAEjC,YAAY,CAAC,CAAC;QACpBsB,OAAO,EAAEA,OAAO;QAChBK,MAAM,EAAE1B,WAAW,CAAC2B,MAAM;QAC1BjB,KAAK,EAAEA,KAAK;QACZY,MAAM,EAAEA;MACV;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLW,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBhB,kBAAkB,CAACiB,WAAW,CAAC,CAAC;IAClC;EACF,CAAC;AACH"}
@@ -6,11 +6,8 @@ export function startRuntimeErrorCollection(configuration, lifeCycle) {
6
6
  stop: noop
7
7
  };
8
8
  }
9
-
10
9
  var rawErrorObservable = new Observable();
11
-
12
10
  var _trackRuntimeError = trackRuntimeError(rawErrorObservable);
13
-
14
11
  var rawErrorSubscription = rawErrorObservable.subscribe(function (rawError) {
15
12
  lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
16
13
  rawLogsEvent: {
@@ -30,8 +27,8 @@ export function startRuntimeErrorCollection(configuration, lifeCycle) {
30
27
  return {
31
28
  stop: function stop() {
32
29
  _trackRuntimeError.stop();
33
-
34
30
  rawErrorSubscription.unsubscribe();
35
31
  }
36
32
  };
37
- }
33
+ }
34
+ //# sourceMappingURL=runtimeErrorCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeErrorCollection.js","names":["noop","ErrorSource","trackRuntimeError","Observable","LifeCycleEventType","StatusType","startRuntimeErrorCollection","configuration","lifeCycle","forwardErrorsToLogs","stop","rawErrorObservable","_trackRuntimeError","rawErrorSubscription","subscribe","rawError","notify","RAW_LOG_COLLECTED","rawLogsEvent","message","date","startClocks","timeStamp","error","kind","type","origin","SOURCE","stack","status","unsubscribe"],"sources":["../../../../src/domain/logsCollection/rumtimeError/runtimeErrorCollection.js"],"sourcesContent":["import { noop, ErrorSource, trackRuntimeError, Observable, LifeCycleEventType } from '@cloudcare/browser-core'\nimport { StatusType } from '../../logger'\n\nexport function startRuntimeErrorCollection(configuration, lifeCycle) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n var rawErrorObservable = new Observable()\n\n var _trackRuntimeError = trackRuntimeError(rawErrorObservable)\n\n var rawErrorSubscription = rawErrorObservable.subscribe(function(rawError) {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message: rawError.message,\n date: rawError.startClocks.timeStamp,\n error: {\n kind: rawError.type,\n origin: ErrorSource.SOURCE, // Todo: Remove in the next major release\n stack: rawError.stack,\n },\n origin: ErrorSource.SOURCE,\n status: StatusType.error,\n },\n })\n })\n\n return {\n stop: function() {\n _trackRuntimeError.stop()\n rawErrorSubscription.unsubscribe()\n },\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,WAAW,EAAEC,iBAAiB,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,yBAAyB;AAC9G,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,SAASC,2BAA2BA,CAACC,aAAa,EAAEC,SAAS,EAAE;EACpE,IAAI,CAACD,aAAa,CAACE,mBAAmB,EAAE;IACtC,OAAO;MAAEC,IAAI,EAAEV;IAAK,CAAC;EACvB;EAEA,IAAIW,kBAAkB,GAAG,IAAIR,UAAU,CAAC,CAAC;EAEzC,IAAIS,kBAAkB,GAAGV,iBAAiB,CAACS,kBAAkB,CAAC;EAE9D,IAAIE,oBAAoB,GAAGF,kBAAkB,CAACG,SAAS,CAAC,UAASC,QAAQ,EAAE;IACzEP,SAAS,CAACQ,MAAM,CAACZ,kBAAkB,CAACa,iBAAiB,EAAE;MACrDC,YAAY,EAAE;QACZC,OAAO,EAAEJ,QAAQ,CAACI,OAAO;QACzBC,IAAI,EAAEL,QAAQ,CAACM,WAAW,CAACC,SAAS;QACpCC,KAAK,EAAE;UACLC,IAAI,EAAET,QAAQ,CAACU,IAAI;UACnBC,MAAM,EAAEzB,WAAW,CAAC0B,MAAM;UAAE;UAC5BC,KAAK,EAAEb,QAAQ,CAACa;QAClB,CAAC;QACDF,MAAM,EAAEzB,WAAW,CAAC0B,MAAM;QAC1BE,MAAM,EAAExB,UAAU,CAACkB;MACrB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLb,IAAI,EAAE,SAAAA,KAAA,EAAW;MACfE,kBAAkB,CAACF,IAAI,CAAC,CAAC;MACzBG,oBAAoB,CAACiB,WAAW,CAAC,CAAC;IACpC;EACF,CAAC;AACH"}
@@ -28,15 +28,12 @@ export function startLogsSessionManagerStub(configuration) {
28
28
  expireObservable: new Observable()
29
29
  };
30
30
  }
31
-
32
31
  function computeTrackingType(configuration) {
33
32
  if (!performDraw(configuration.sessionSampleRate)) {
34
33
  return LoggerTrackingType.NOT_TRACKED;
35
34
  }
36
-
37
35
  return LoggerTrackingType.TRACKED;
38
36
  }
39
-
40
37
  function computeSessionState(configuration, rawSessionType) {
41
38
  var trackingType = hasValidLoggerSession(rawSessionType) ? rawSessionType : computeTrackingType(configuration);
42
39
  return {
@@ -44,7 +41,7 @@ function computeSessionState(configuration, rawSessionType) {
44
41
  isTracked: trackingType === LoggerTrackingType.TRACKED
45
42
  };
46
43
  }
47
-
48
44
  function hasValidLoggerSession(trackingType) {
49
45
  return trackingType === LoggerTrackingType.NOT_TRACKED || trackingType === LoggerTrackingType.TRACKED;
50
- }
46
+ }
47
+ //# sourceMappingURL=logsSessionManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logsSessionManager.js","names":["performDraw","startSessionManager","Observable","LOGS_SESSION_KEY","LoggerTrackingType","NOT_TRACKED","TRACKED","startLogsSessionManager","configuration","sessionManager","cookieOptions","rawTrackingType","computeSessionState","findTrackedSession","startTime","session","findActiveSession","trackingType","id","undefined","expireObservable","startLogsSessionManagerStub","isTracked","computeTrackingType","sessionSampleRate","rawSessionType","hasValidLoggerSession"],"sources":["../../src/domain/logsSessionManager.js"],"sourcesContent":["import {\n performDraw,\n startSessionManager,\n Observable\n} from '@cloudcare/browser-core'\n\nexport var LOGS_SESSION_KEY = 'logs'\n\nexport var LoggerTrackingType = {\n NOT_TRACKED: '0',\n TRACKED: '1'\n}\n\nexport function startLogsSessionManager(configuration) {\n var sessionManager = startSessionManager(\n configuration.cookieOptions,\n LOGS_SESSION_KEY,\n function (rawTrackingType) {\n return computeSessionState(configuration, rawTrackingType)\n }\n )\n return {\n findTrackedSession: function (startTime) {\n var session = sessionManager.findActiveSession(startTime)\n return session && session.trackingType === LoggerTrackingType.TRACKED\n ? {\n id: session.id\n }\n : undefined\n },\n expireObservable: sessionManager.expireObservable\n }\n}\n\nexport function startLogsSessionManagerStub(configuration) {\n var isTracked =\n computeTrackingType(configuration) === LoggerTrackingType.TRACKED\n var session = isTracked ? {} : undefined\n return {\n findTrackedSession: function () {\n return session\n },\n expireObservable: new Observable()\n }\n}\n\nfunction computeTrackingType(configuration) {\n if (!performDraw(configuration.sessionSampleRate)) {\n return LoggerTrackingType.NOT_TRACKED\n }\n return LoggerTrackingType.TRACKED\n}\n\nfunction computeSessionState(configuration, rawSessionType) {\n var trackingType = hasValidLoggerSession(rawSessionType)\n ? rawSessionType\n : computeTrackingType(configuration)\n return {\n trackingType: trackingType,\n isTracked: trackingType === LoggerTrackingType.TRACKED\n }\n}\n\nfunction hasValidLoggerSession(trackingType) {\n return (\n trackingType === LoggerTrackingType.NOT_TRACKED ||\n trackingType === LoggerTrackingType.TRACKED\n )\n}\n"],"mappings":"AAAA,SACEA,WAAW,EACXC,mBAAmB,EACnBC,U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ACJ,aAAa,EAAEiB,cAAc,EAAE;EAC1D,IAAIR,YAAY,GAAGS,qBAAqB,CAACD,cAAc,CAAC,GACpDA,cAAc,GACdF,mBAAmB,CAACf,aAAa,CAAC;EACtC,OAAO;IACLS,YAAY,EAAEA,YAAY;IAC1BK,SAAS,EAAEL,YAAY,KAAKb,kBAAkB,CAACE;EACjD,CAAC;AACH;AAEA,SAASoB,qBAAqBA,CAACT,YAAY,EAAE;EAC3C,OACEA,YAAY,KAAKb,kBAAkB,CAACC,WAAW,IAC/CY,YAAY,KAAKb,kBAAkB,CAACE,OAAO;AAE/C"}
@@ -2,4 +2,5 @@ import { defineGlobal, getGlobalObject } from '@cloudcare/browser-core';
2
2
  import { makeLogsPublicApi } from '../boot/logsPublicApi';
3
3
  import { startLogs } from '../boot/startLogs';
4
4
  export var datafluxLogs = makeLogsPublicApi(startLogs);
5
- defineGlobal(getGlobalObject(), 'DATAFLUX_LOGS', datafluxLogs);
5
+ defineGlobal(getGlobalObject(), 'DATAFLUX_LOGS', datafluxLogs);
6
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["defineGlobal","getGlobalObject","makeLogsPublicApi","startLogs","datafluxLogs"],"sources":["../../src/entries/main.js"],"sourcesContent":["import { defineGlobal, getGlobalObject } from '@cloudcare/browser-core'\nimport { makeLogsPublicApi } from '../boot/logsPublicApi'\nimport { startLogs } from '../boot/startLogs'\n\nexport const datafluxLogs = makeLogsPublicApi(startLogs)\n\ndefineGlobal(getGlobalObject(), 'DATAFLUX_LOGS', datafluxLogs)\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,eAAe,QAAQ,yBAAyB;AACvE,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,SAAS,QAAQ,mBAAmB;AAE7C,OAAO,IAAMC,YAAY,GAAGF,iBAAiB,CAACC,SAAS,CAAC;AAExDH,YAAY,CAACC,eAAe,CAAC,CAAC,EAAE,eAAe,EAAEG,YAAY,CAAC"}
package/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { datafluxLogs } from './entries/main';
2
- export { datafluxLogs };
2
+ export { datafluxLogs };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["datafluxLogs"],"sources":["../src/index.js"],"sourcesContent":["import { datafluxLogs } from './entries/main'\nexport { datafluxLogs }\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASA,YAAY"}
@@ -4,4 +4,5 @@ export function startLogsBatch(configuration, lifeCycle, reportError, pageExitOb
4
4
  lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, function (serverLogsEvent) {
5
5
  batch.add(serverLogsEvent);
6
6
  });
7
- }
7
+ }
8
+ //# sourceMappingURL=startLogsBatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startLogsBatch.js","names":["startBatchWithReplica","LifeCycleEventType","startLogsBatch","configuration","lifeCycle","reportError","pageExitObservable","sessionExpireObservable","batch","logsEndpoint","subscribe","LOG_COLLECTED","serverLogsEvent","add"],"sources":["../../src/transport/startLogsBatch.js"],"sourcesContent":["import {\n startBatchWithReplica,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\n\nexport function startLogsBatch(\n configuration,\n lifeCycle,\n reportError,\n pageExitObservable,\n sessionExpireObservable\n) {\n var batch = startBatchWithReplica(\n configuration,\n configuration.logsEndpoint,\n reportError,\n pageExitObservable,\n sessionExpireObservable\n )\n\n lifeCycle.subscribe(\n LifeCycleEventType.LOG_COLLECTED,\n function (serverLogsEvent) {\n batch.add(serverLogsEvent)\n }\n )\n}\n"],"mappings":"AAAA,SACEA,qBAAqB,EACrBC,kBAAkB,QACb,yBAAyB;AAEhC,OAAO,SAASC,cAAcA,CAC5BC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,kBAAkB,EAClBC,uBAAuB,EACvB;EACA,IAAIC,KAAK,GAAGR,qBAAqB,CAC/BG,aAAa,EACbA,aAAa,CAACM,YAAY,EAC1BJ,WAAW,EACXC,kBAAkB,EAClBC,uBACF,CAAC;EAEDH,SAAS,CAACM,SAAS,CACjBT,kBAAkB,CAACU,aAAa,EAChC,UAAUC,eAAe,EAAE;IACzBJ,KAAK,CAACK,GAAG,CAACD,eAAe,CAAC;EAC5B,CACF,CAAC;AACH"}
@@ -0,0 +1,8 @@
1
+ import { LifeCycleEventType, getEventBridge } from '@cloudcare/browser-core';
2
+ export function startLogsBridge(lifeCycle) {
3
+ var bridge = getEventBridge();
4
+ lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, function (serverLogsEvent) {
5
+ bridge.send('log', serverLogsEvent);
6
+ });
7
+ }
8
+ //# sourceMappingURL=startLogsBridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startLogsBridge.js","names":["LifeCycleEventType","getEventBridge","startLogsBridge","lifeCycle","bridge","subscribe","LOG_COLLECTED","serverLogsEvent","send"],"sources":["../../src/transport/startLogsBridge.js"],"sourcesContent":["import { LifeCycleEventType, getEventBridge } from '@cloudcare/browser-core'\nexport function startLogsBridge(lifeCycle) {\n const bridge = getEventBridge()\n\n lifeCycle.subscribe(\n LifeCycleEventType.LOG_COLLECTED,\n function (serverLogsEvent) {\n bridge.send('log', serverLogsEvent)\n }\n )\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,cAAc,QAAQ,yBAAyB;AAC5E,OAAO,SAASC,eAAeA,CAACC,SAAS,EAAE;EACzC,IAAMC,MAAM,GAAGH,cAAc,CAAC,CAAC;EAE/BE,SAAS,CAACE,SAAS,CACjBL,kBAAkB,CAACM,aAAa,EAChC,UAAUC,eAAe,EAAE;IACzBH,MAAM,CAACI,IAAI,CAAC,KAAK,EAAED,eAAe,CAAC;EACrC,CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@cloudcare/browser-logs",
3
3
  "main": "cjs/index.js",
4
4
  "module": "esm/index.js",
5
- "version": "3.0.29",
5
+ "version": "3.1.0",
6
6
  "dependencies": {
7
- "@cloudcare/browser-core": "3.0.29"
7
+ "@cloudcare/browser-core": "3.1.0"
8
8
  },
9
9
  "scripts": {
10
10
  "dev": "webpack serve --open --mode=development",
@@ -12,8 +12,9 @@
12
12
  "build:cjs": "rm -rf cjs && babel --config-file ./babel.cjs.json --out-dir cjs ./src && npm run replace-build-env cjs",
13
13
  "build:esm": "rm -rf esm && babel --config-file ./babel.esm.json --out-dir esm ./src && npm run replace-build-env esm",
14
14
  "build:bundle": "rm -rf bundle && webpack --mode=production",
15
- "publish:oss": "npm run build:bundle && node ./scripts/publish-oss.js",
15
+ "publish:oss:current": "npm run build:bundle && node ./scripts/publish-oss.js current",
16
16
  "publish:oss:test": "npm run build:bundle && node ./scripts/publish-oss.js test",
17
+ "publish:oss:lts": "npm run build:bundle && node ./scripts/publish-oss.js lts",
17
18
  "replace-build-env": "node ../../scripts/replace-build-env.js"
18
19
  },
19
20
  "keywords": [
@@ -28,5 +29,5 @@
28
29
  "author": "dataflux",
29
30
  "license": "MIT",
30
31
  "description": "DataFlux RUM Web 端数据指标监控",
31
- "gitHead": "104fa066dfa70d87d54c3002bc6651c64d168478"
32
+ "gitHead": "6863a7abc368adb01df9a2de5efbed111db1e286"
32
33
  }
@@ -3,13 +3,17 @@ import {
3
3
  LifeCycle,
4
4
  LifeCycleEventType,
5
5
  createPageExitObservable,
6
- areCookiesAuthorized
6
+ areCookiesAuthorized,
7
+ startTelemetry,
8
+ startBatchWithReplica,
9
+ canUseEventBridge,
10
+ TelemetryService
7
11
  } from '@cloudcare/browser-core'
8
12
  import {
9
13
  startLogsSessionManager,
10
14
  startLogsSessionManagerStub
11
15
  } from '../domain/logsSessionManager'
12
- import { startLogsAssembly } from '../domain/assembly'
16
+ import { startLogsAssembly, getRUMInternalContext } from '../domain/assembly'
13
17
  import { startConsoleCollection } from '../domain/logsCollection/console/consoleCollection'
14
18
  import { startReportCollection } from '../domain/logsCollection/report/reportCollection'
15
19
  import { startNetworkErrorCollection } from '../domain/logsCollection/networkError/networkErrorCollection'
@@ -39,6 +43,38 @@ export function startLogs(configuration, buildCommonContext, mainLogger) {
39
43
  var session = areCookiesAuthorized(configuration.cookieOptions)
40
44
  ? startLogsSessionManager(configuration)
41
45
  : startLogsSessionManagerStub(configuration)
46
+ const telemetry = startLogsTelemetry(
47
+ configuration,
48
+ reportError,
49
+ pageExitObservable,
50
+ session.expireObservable
51
+ )
52
+ telemetry.setContextProvider(function () {
53
+ var RUMInternalContext = getRUMInternalContext()
54
+ return {
55
+ application: {
56
+ id:
57
+ RUMInternalContext &&
58
+ RUMInternalContext.application &&
59
+ RUMInternalContext.application.id
60
+ },
61
+ session: {
62
+ id: session.findTrackedSession() && session.findTrackedSession().id
63
+ },
64
+ view: {
65
+ id:
66
+ RUMInternalContext &&
67
+ RUMInternalContext.view &&
68
+ RUMInternalContext.view.id
69
+ },
70
+ action: {
71
+ id:
72
+ RUMInternalContext &&
73
+ RUMInternalContext.userAction &&
74
+ RUMInternalContext.userAction.id
75
+ }
76
+ }
77
+ })
42
78
  startNetworkErrorCollection(configuration, lifeCycle)
43
79
  startRuntimeErrorCollection(configuration, lifeCycle)
44
80
  startConsoleCollection(configuration, lifeCycle)
@@ -53,14 +89,15 @@ export function startLogs(configuration, buildCommonContext, mainLogger) {
53
89
  mainLogger,
54
90
  reportError
55
91
  )
56
-
57
- startLogsBatch(
58
- configuration,
59
- lifeCycle,
60
- reportError,
61
- pageExitObservable,
62
- session.expireObservable
63
- )
92
+ if (!canUseEventBridge()) {
93
+ startLogsBatch(
94
+ configuration,
95
+ lifeCycle,
96
+ reportError,
97
+ pageExitObservable,
98
+ session.expireObservable
99
+ )
100
+ }
64
101
 
65
102
  var internalContext = startInternalContext(session)
66
103
 
@@ -69,3 +106,24 @@ export function startLogs(configuration, buildCommonContext, mainLogger) {
69
106
  getInternalContext: internalContext.get
70
107
  }
71
108
  }
109
+ function startLogsTelemetry(
110
+ configuration,
111
+ reportError,
112
+ pageExitObservable,
113
+ sessionExpireObservable
114
+ ) {
115
+ const telemetry = startTelemetry(TelemetryService.LOGS, configuration)
116
+ if (!canUseEventBridge()) {
117
+ var telemetryBatch = startBatchWithReplica(
118
+ configuration,
119
+ configuration.rumEndpoint,
120
+ reportError,
121
+ pageExitObservable,
122
+ sessionExpireObservable
123
+ )
124
+ telemetry.observable.subscribe(function (event) {
125
+ telemetryBatch.add(event)
126
+ })
127
+ }
128
+ return telemetry
129
+ }
@@ -10,7 +10,8 @@ import {
10
10
  computeRawError,
11
11
  clocksNow,
12
12
  ErrorHandling,
13
- monitor
13
+ monitor,
14
+ NonErrorPrefix
14
15
  } from '@cloudcare/browser-core'
15
16
 
16
17
  export var StatusType = {
@@ -69,7 +70,7 @@ Logger.prototype = {
69
70
  var rawError = computeRawError({
70
71
  stackTrace: stackTrace,
71
72
  originalError: error,
72
- nonErrorPrefix: 'Provided',
73
+ nonErrorPrefix: NonErrorPrefix.PROVIDED,
73
74
  source: ErrorSource.LOGGER,
74
75
  handling: ErrorHandling.HANDLED,
75
76
  startClocks: clocksNow()