@kubesense/kubesense-browser-logs 0.0.0-stage → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +90 -2
  3. package/bundle/kubesense-logs.js +1 -0
  4. package/cjs/boot/logsPublicApi.d.ts +231 -0
  5. package/cjs/boot/logsPublicApi.js +75 -0
  6. package/cjs/boot/logsPublicApi.js.map +1 -0
  7. package/cjs/boot/preStartLogs.d.ts +8 -0
  8. package/cjs/boot/preStartLogs.js +105 -0
  9. package/cjs/boot/preStartLogs.js.map +1 -0
  10. package/cjs/boot/startLogs.d.ts +35 -0
  11. package/cjs/boot/startLogs.js +54 -0
  12. package/cjs/boot/startLogs.js.map +1 -0
  13. package/cjs/domain/assembly.d.ts +5 -0
  14. package/cjs/domain/assembly.js +35 -0
  15. package/cjs/domain/assembly.js.map +1 -0
  16. package/cjs/domain/configuration.d.ts +306 -0
  17. package/cjs/domain/configuration.js +86 -0
  18. package/cjs/domain/configuration.js.map +1 -0
  19. package/cjs/domain/console/consoleCollection.d.ts +20 -0
  20. package/cjs/domain/console/consoleCollection.js +37 -0
  21. package/cjs/domain/console/consoleCollection.js.map +1 -0
  22. package/cjs/domain/contexts/commonContext.d.ts +2 -0
  23. package/cjs/domain/contexts/commonContext.js +13 -0
  24. package/cjs/domain/contexts/commonContext.js.map +1 -0
  25. package/cjs/domain/contexts/internalContext.d.ts +7 -0
  26. package/cjs/domain/contexts/internalContext.js +11 -0
  27. package/cjs/domain/contexts/internalContext.js.map +1 -0
  28. package/cjs/domain/contexts/rumInternalContext.d.ts +2 -0
  29. package/cjs/domain/contexts/rumInternalContext.js +32 -0
  30. package/cjs/domain/contexts/rumInternalContext.js.map +1 -0
  31. package/cjs/domain/contexts/sessionContext.d.ts +4 -0
  32. package/cjs/domain/contexts/sessionContext.js +20 -0
  33. package/cjs/domain/contexts/sessionContext.js.map +1 -0
  34. package/cjs/domain/contexts/trackingConsentContext.d.ts +3 -0
  35. package/cjs/domain/contexts/trackingConsentContext.js +14 -0
  36. package/cjs/domain/contexts/trackingConsentContext.js.map +1 -0
  37. package/cjs/domain/createErrorFieldFromRawError.d.ts +10 -0
  38. package/cjs/domain/createErrorFieldFromRawError.js +15 -0
  39. package/cjs/domain/createErrorFieldFromRawError.js.map +1 -0
  40. package/cjs/domain/hooks.d.ts +28 -0
  41. package/cjs/domain/hooks.js +13 -0
  42. package/cjs/domain/hooks.js.map +1 -0
  43. package/cjs/domain/lifeCycle.d.ts +24 -0
  44. package/cjs/domain/lifeCycle.js +6 -0
  45. package/cjs/domain/lifeCycle.js.map +1 -0
  46. package/cjs/domain/logger/isAuthorized.d.ts +17 -0
  47. package/cjs/domain/logger/isAuthorized.js +34 -0
  48. package/cjs/domain/logger/isAuthorized.js.map +1 -0
  49. package/cjs/domain/logger/loggerCollection.d.ts +7 -0
  50. package/cjs/domain/logger/loggerCollection.js +47 -0
  51. package/cjs/domain/logger/loggerCollection.js.map +1 -0
  52. package/cjs/domain/logger.d.ts +48 -0
  53. package/cjs/domain/logger.js +112 -0
  54. package/cjs/domain/logger.js.map +1 -0
  55. package/cjs/domain/networkError/networkErrorCollection.d.ts +9 -0
  56. package/cjs/domain/networkError/networkErrorCollection.js +57 -0
  57. package/cjs/domain/networkError/networkErrorCollection.js.map +1 -0
  58. package/cjs/domain/plugins.d.ts +49 -0
  59. package/cjs/domain/plugins.js +12 -0
  60. package/cjs/domain/plugins.js.map +1 -0
  61. package/cjs/domain/remoteSdkConfiguration.d.ts +26 -0
  62. package/cjs/domain/remoteSdkConfiguration.js +67 -0
  63. package/cjs/domain/remoteSdkConfiguration.js.map +1 -0
  64. package/cjs/domain/report/reportCollection.d.ts +13 -0
  65. package/cjs/domain/report/reportCollection.js +30 -0
  66. package/cjs/domain/report/reportCollection.js.map +1 -0
  67. package/cjs/domain/reportError.d.ts +2 -0
  68. package/cjs/domain/reportError.js +20 -0
  69. package/cjs/domain/reportError.js.map +1 -0
  70. package/cjs/domain/runtimeError/runtimeErrorCollection.d.ts +14 -0
  71. package/cjs/domain/runtimeError/runtimeErrorCollection.js +29 -0
  72. package/cjs/domain/runtimeError/runtimeErrorCollection.js.map +1 -0
  73. package/cjs/domainContext.types.d.ts +11 -0
  74. package/cjs/entries/main.d.ts +33 -0
  75. package/cjs/entries/main.js +31 -0
  76. package/cjs/entries/main.js.map +1 -0
  77. package/cjs/logsEvent.types.d.ts +192 -0
  78. package/cjs/rawLogsEvent.types.d.ts +59 -0
  79. package/cjs/transport/startLogsBatch.d.ts +4 -0
  80. package/cjs/transport/startLogsBatch.js +22 -0
  81. package/cjs/transport/startLogsBatch.js.map +1 -0
  82. package/cjs/transport/startLogsBridge.d.ts +2 -0
  83. package/cjs/transport/startLogsBridge.js +13 -0
  84. package/cjs/transport/startLogsBridge.js.map +1 -0
  85. package/esm/boot/logsPublicApi.mjs +75 -0
  86. package/esm/boot/logsPublicApi.mjs.map +1 -0
  87. package/esm/boot/preStartLogs.mjs +105 -0
  88. package/esm/boot/preStartLogs.mjs.map +1 -0
  89. package/esm/boot/startLogs.mjs +54 -0
  90. package/esm/boot/startLogs.mjs.map +1 -0
  91. package/esm/domain/assembly.mjs +35 -0
  92. package/esm/domain/assembly.mjs.map +1 -0
  93. package/esm/domain/configuration.mjs +84 -0
  94. package/esm/domain/configuration.mjs.map +1 -0
  95. package/esm/domain/console/consoleCollection.mjs +36 -0
  96. package/esm/domain/console/consoleCollection.mjs.map +1 -0
  97. package/esm/domain/contexts/commonContext.mjs +13 -0
  98. package/esm/domain/contexts/commonContext.mjs.map +1 -0
  99. package/esm/domain/contexts/internalContext.mjs +11 -0
  100. package/esm/domain/contexts/internalContext.mjs.map +1 -0
  101. package/esm/domain/contexts/rumInternalContext.mjs +32 -0
  102. package/esm/domain/contexts/rumInternalContext.mjs.map +1 -0
  103. package/esm/domain/contexts/sessionContext.mjs +20 -0
  104. package/esm/domain/contexts/sessionContext.mjs.map +1 -0
  105. package/esm/domain/contexts/trackingConsentContext.mjs +14 -0
  106. package/esm/domain/contexts/trackingConsentContext.mjs.map +1 -0
  107. package/esm/domain/createErrorFieldFromRawError.mjs +15 -0
  108. package/esm/domain/createErrorFieldFromRawError.mjs.map +1 -0
  109. package/esm/domain/hooks.mjs +13 -0
  110. package/esm/domain/hooks.mjs.map +1 -0
  111. package/esm/domain/lifeCycle.mjs +7 -0
  112. package/esm/domain/lifeCycle.mjs.map +1 -0
  113. package/esm/domain/logger/isAuthorized.mjs +32 -0
  114. package/esm/domain/logger/isAuthorized.mjs.map +1 -0
  115. package/esm/domain/logger/loggerCollection.mjs +47 -0
  116. package/esm/domain/logger/loggerCollection.mjs.map +1 -0
  117. package/esm/domain/logger.mjs +110 -0
  118. package/esm/domain/logger.mjs.map +1 -0
  119. package/esm/domain/networkError/networkErrorCollection.mjs +56 -0
  120. package/esm/domain/networkError/networkErrorCollection.mjs.map +1 -0
  121. package/esm/domain/plugins.mjs +12 -0
  122. package/esm/domain/plugins.mjs.map +1 -0
  123. package/esm/domain/remoteSdkConfiguration.mjs +65 -0
  124. package/esm/domain/remoteSdkConfiguration.mjs.map +1 -0
  125. package/esm/domain/report/reportCollection.mjs +30 -0
  126. package/esm/domain/report/reportCollection.mjs.map +1 -0
  127. package/esm/domain/reportError.mjs +20 -0
  128. package/esm/domain/reportError.mjs.map +1 -0
  129. package/esm/domain/runtimeError/runtimeErrorCollection.mjs +29 -0
  130. package/esm/domain/runtimeError/runtimeErrorCollection.mjs.map +1 -0
  131. package/esm/entries/main.mjs +27 -0
  132. package/esm/entries/main.mjs.map +1 -0
  133. package/esm/transport/startLogsBatch.mjs +22 -0
  134. package/esm/transport/startLogsBatch.mjs.map +1 -0
  135. package/esm/transport/startLogsBridge.mjs +13 -0
  136. package/esm/transport/startLogsBridge.mjs.map +1 -0
  137. package/package.json +53 -3
  138. package/src/boot/logsPublicApi.ts +427 -0
  139. package/src/boot/preStartLogs.ts +192 -0
  140. package/src/boot/startLogs.ts +83 -0
  141. package/src/domain/assembly.ts +73 -0
  142. package/src/domain/configuration.ts +176 -0
  143. package/src/domain/console/consoleCollection.ts +58 -0
  144. package/src/domain/contexts/commonContext.ts +15 -0
  145. package/src/domain/contexts/internalContext.ts +19 -0
  146. package/src/domain/contexts/rumInternalContext.ts +60 -0
  147. package/src/domain/contexts/sessionContext.ts +34 -0
  148. package/src/domain/contexts/trackingConsentContext.ts +18 -0
  149. package/src/domain/createErrorFieldFromRawError.ts +22 -0
  150. package/src/domain/hooks.ts +40 -0
  151. package/src/domain/lifeCycle.ts +25 -0
  152. package/src/domain/logger/isAuthorized.ts +33 -0
  153. package/src/domain/logger/loggerCollection.ts +69 -0
  154. package/src/domain/logger.ts +202 -0
  155. package/src/domain/networkError/networkErrorCollection.ts +104 -0
  156. package/src/domain/plugins.ts +72 -0
  157. package/src/domain/remoteSdkConfiguration.ts +105 -0
  158. package/src/domain/report/reportCollection.ts +47 -0
  159. package/src/domain/reportError.ts +20 -0
  160. package/src/domain/runtimeError/runtimeErrorCollection.ts +51 -0
  161. package/src/domainContext.types.ts +21 -0
  162. package/src/entries/main.ts +65 -0
  163. package/src/logsEvent.types.ts +198 -0
  164. package/src/rawLogsEvent.types.ts +74 -0
  165. package/src/transport/startLogsBatch.ts +29 -0
  166. package/src/transport/startLogsBridge.ts +13 -0
@@ -0,0 +1,67 @@
1
+ let _kubesense_kubesense_js_core_util = require("@kubesense/kubesense-js-core/util");
2
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
3
+ //#region src/domain/remoteSdkConfiguration.ts
4
+ function applyCachedLogsSdkConfiguration(initConfiguration) {
5
+ const remoteConfig = (0, _kubesense_kubesense_browser_core.getCachedSdkConfig)(initConfiguration.clientToken);
6
+ if (!remoteConfig) return {
7
+ initConfiguration,
8
+ logsEnabled: true
9
+ };
10
+ return applyLogsSdkConfiguration(initConfiguration, remoteConfig);
11
+ }
12
+ function applyLogsSdkConfiguration(initConfiguration, remoteConfig) {
13
+ const features = remoteConfig.features;
14
+ if ((0, _kubesense_kubesense_browser_core.readBoolean)(features, "logs") === false) return {
15
+ initConfiguration,
16
+ logsEnabled: false
17
+ };
18
+ const logs = remoteConfig.logs;
19
+ if (!logs) return {
20
+ initConfiguration,
21
+ logsEnabled: true
22
+ };
23
+ const applied = { ...initConfiguration };
24
+ assign(applied, "sessionSampleRate", (0, _kubesense_kubesense_browser_core.readSampleRate)(logs, "sessionSampleRate"));
25
+ assign(applied, "telemetrySampleRate", (0, _kubesense_kubesense_browser_core.readSampleRate)(logs, "telemetrySampleRate"));
26
+ assign(applied, "forwardErrorsToLogs", (0, _kubesense_kubesense_browser_core.readBoolean)(logs, "forwardErrorsToLogs"));
27
+ assign(applied, "trackAnonymousUser", (0, _kubesense_kubesense_browser_core.readBoolean)(logs, "trackAnonymousUser"));
28
+ assign(applied, "trackSessionAcrossSubdomains", (0, _kubesense_kubesense_browser_core.readBoolean)(logs, "trackSessionAcrossSubdomains"));
29
+ assign(applied, "allowedTrackingOrigins", (0, _kubesense_kubesense_browser_core.readStringList)(logs.allowedTrackingOrigins));
30
+ assign(applied, "forwardConsoleLogs", readForwardList(logs.forwardConsoleLogs, (0, _kubesense_kubesense_browser_core.objectValues)(_kubesense_kubesense_js_core_util.ConsoleApiName)));
31
+ assign(applied, "forwardReports", readForwardList(logs.forwardReports, (0, _kubesense_kubesense_browser_core.objectValues)(_kubesense_kubesense_browser_core.RawReportType)));
32
+ assign(applied, "service", (0, _kubesense_kubesense_browser_core.readString)(logs, "service"));
33
+ assign(applied, "env", (0, _kubesense_kubesense_browser_core.readString)(logs, "env"));
34
+ assign(applied, "version", (0, _kubesense_kubesense_browser_core.readString)(logs, "version"));
35
+ return {
36
+ initConfiguration: applied,
37
+ logsEnabled: true
38
+ };
39
+ }
40
+ /**
41
+ * `forwardConsoleLogs` and `forwardReports` accept either the literal `'all'` or a subset of the
42
+ * known names. Unknown names are dropped rather than passed through, so a document written against
43
+ * a newer SDK cannot turn the option into a value this SDK will reject wholesale.
44
+ */
45
+ function readForwardList(value, allowedValues) {
46
+ if (value === "all") return "all";
47
+ const names = (0, _kubesense_kubesense_browser_core.readStringList)(value)?.filter((name) => allowedValues.includes(name));
48
+ return names?.length ? names : void 0;
49
+ }
50
+ function assign(target, key, value) {
51
+ if (value !== void 0) target[key] = value;
52
+ }
53
+ /**
54
+ * Refresh the shared cache for the next page load.
55
+ *
56
+ * When RUM and Logs both run on a page they each schedule a refresh; the requests are
57
+ * idempotent GETs and the last response simply wins, so no coordination is needed.
58
+ */
59
+ function scheduleLogsSdkConfigurationRefresh(initConfiguration) {
60
+ return (0, _kubesense_kubesense_browser_core.refreshSdkConfig)(initConfiguration);
61
+ }
62
+ //#endregion
63
+ exports.applyCachedLogsSdkConfiguration = applyCachedLogsSdkConfiguration;
64
+ exports.applyLogsSdkConfiguration = applyLogsSdkConfiguration;
65
+ exports.scheduleLogsSdkConfigurationRefresh = scheduleLogsSdkConfigurationRefresh;
66
+
67
+ //# sourceMappingURL=remoteSdkConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteSdkConfiguration.js","names":["getCachedSdkConfig","readBoolean","readSampleRate","readStringList","objectValues","ConsoleApiName","RawReportType","readString","refreshSdkConfig"],"sources":["../../src/domain/remoteSdkConfiguration.ts"],"sourcesContent":["import type { RemoteSdkConfig } from '@kubesense/kubesense-browser-core'\nimport {\n RawReportType,\n getCachedSdkConfig,\n objectValues,\n readBoolean,\n readSampleRate,\n readString,\n readStringList,\n refreshSdkConfig,\n} from '@kubesense/kubesense-browser-core'\nimport { ConsoleApiName } from '@kubesense/kubesense-js-core/util'\nimport type { LogsInitConfiguration } from './configuration'\n\n/**\n * Applies the dashboard-managed configuration document to the Logs init configuration.\n *\n * The Logs SDK reads the same cached document as RUM (they share one local-storage entry), but\n * only consumes the `features.logs` switch and the `logs` section — RUM settings never leak\n * into Logs, and vice versa.\n *\n * As in RUM, a missing or invalid field leaves the local `init()` value untouched, and\n * identity/endpoint settings are never remotable.\n */\n\nexport interface LogsRemoteSdkConfigurationResult {\n initConfiguration: LogsInitConfiguration\n /** `false` when the dashboard has switched Logs off entirely. */\n logsEnabled: boolean\n}\n\nexport function applyCachedLogsSdkConfiguration(\n initConfiguration: LogsInitConfiguration\n): LogsRemoteSdkConfigurationResult {\n const remoteConfig = getCachedSdkConfig(initConfiguration.clientToken)\n if (!remoteConfig) {\n return { initConfiguration, logsEnabled: true }\n }\n return applyLogsSdkConfiguration(initConfiguration, remoteConfig)\n}\n\nexport function applyLogsSdkConfiguration(\n initConfiguration: LogsInitConfiguration,\n remoteConfig: RemoteSdkConfig\n): LogsRemoteSdkConfigurationResult {\n const features = remoteConfig.features as { [key: string]: unknown } | undefined\n if (readBoolean(features, 'logs') === false) {\n return { initConfiguration, logsEnabled: false }\n }\n\n const logs = remoteConfig.logs\n if (!logs) {\n return { initConfiguration, logsEnabled: true }\n }\n\n const applied: LogsInitConfiguration = { ...initConfiguration }\n\n assign(applied, 'sessionSampleRate', readSampleRate(logs, 'sessionSampleRate'))\n assign(applied, 'telemetrySampleRate', readSampleRate(logs, 'telemetrySampleRate'))\n assign(applied, 'forwardErrorsToLogs', readBoolean(logs, 'forwardErrorsToLogs'))\n assign(applied, 'trackAnonymousUser', readBoolean(logs, 'trackAnonymousUser'))\n assign(applied, 'trackSessionAcrossSubdomains', readBoolean(logs, 'trackSessionAcrossSubdomains'))\n assign(applied, 'allowedTrackingOrigins', readStringList(logs.allowedTrackingOrigins))\n assign(applied, 'forwardConsoleLogs', readForwardList(logs.forwardConsoleLogs, objectValues(ConsoleApiName)))\n assign(applied, 'forwardReports', readForwardList(logs.forwardReports, objectValues(RawReportType)))\n\n assign(applied, 'service', readString(logs, 'service'))\n assign(applied, 'env', readString(logs, 'env'))\n assign(applied, 'version', readString(logs, 'version'))\n\n return { initConfiguration: applied, logsEnabled: true }\n}\n\n/**\n * `forwardConsoleLogs` and `forwardReports` accept either the literal `'all'` or a subset of the\n * known names. Unknown names are dropped rather than passed through, so a document written against\n * a newer SDK cannot turn the option into a value this SDK will reject wholesale.\n */\nfunction readForwardList<T extends string>(value: unknown, allowedValues: readonly T[]): T[] | 'all' | undefined {\n if (value === 'all') {\n return 'all'\n }\n const names = readStringList(value)?.filter((name): name is T => (allowedValues as readonly string[]).includes(name))\n return names?.length ? names : undefined\n}\n\nfunction assign<K extends keyof LogsInitConfiguration>(\n target: LogsInitConfiguration,\n key: K,\n value: LogsInitConfiguration[K] | undefined\n) {\n if (value !== undefined) {\n target[key] = value\n }\n}\n\n/**\n * Refresh the shared cache for the next page load.\n *\n * When RUM and Logs both run on a page they each schedule a refresh; the requests are\n * idempotent GETs and the last response simply wins, so no coordination is needed.\n */\nexport function scheduleLogsSdkConfigurationRefresh(initConfiguration: LogsInitConfiguration) {\n return refreshSdkConfig(initConfiguration)\n}\n"],"mappings":";;;AA+BA,SAAgB,gCACd,mBACkC;CAClC,MAAM,gBAAA,GAAeA,kCAAAA,mBAAAA,CAAmB,kBAAkB,WAAW;CACrE,IAAI,CAAC,cACH,OAAO;EAAE;EAAmB,aAAa;CAAK;CAEhD,OAAO,0BAA0B,mBAAmB,YAAY;AAClE;AAEA,SAAgB,0BACd,mBACA,cACkC;CAClC,MAAM,WAAW,aAAa;CAC9B,KAAA,GAAIC,kCAAAA,YAAAA,CAAY,UAAU,MAAM,MAAM,OACpC,OAAO;EAAE;EAAmB,aAAa;CAAM;CAGjD,MAAM,OAAO,aAAa;CAC1B,IAAI,CAAC,MACH,OAAO;EAAE;EAAmB,aAAa;CAAK;CAGhD,MAAM,UAAiC,EAAE,GAAG,kBAAkB;CAE9D,OAAO,SAAS,sBAAA,GAAqBC,kCAAAA,eAAAA,CAAe,MAAM,mBAAmB,CAAC;CAC9E,OAAO,SAAS,wBAAA,GAAuBA,kCAAAA,eAAAA,CAAe,MAAM,qBAAqB,CAAC;CAClF,OAAO,SAAS,wBAAA,GAAuBD,kCAAAA,YAAAA,CAAY,MAAM,qBAAqB,CAAC;CAC/E,OAAO,SAAS,uBAAA,GAAsBA,kCAAAA,YAAAA,CAAY,MAAM,oBAAoB,CAAC;CAC7E,OAAO,SAAS,iCAAA,GAAgCA,kCAAAA,YAAAA,CAAY,MAAM,8BAA8B,CAAC;CACjG,OAAO,SAAS,2BAAA,GAA0BE,kCAAAA,eAAAA,CAAe,KAAK,sBAAsB,CAAC;CACrF,OAAO,SAAS,sBAAsB,gBAAgB,KAAK,qBAAA,GAAoBC,kCAAAA,aAAAA,CAAaC,kCAAAA,cAAc,CAAC,CAAC;CAC5G,OAAO,SAAS,kBAAkB,gBAAgB,KAAK,iBAAA,GAAgBD,kCAAAA,aAAAA,CAAaE,kCAAAA,aAAa,CAAC,CAAC;CAEnG,OAAO,SAAS,YAAA,GAAWC,kCAAAA,WAAAA,CAAW,MAAM,SAAS,CAAC;CACtD,OAAO,SAAS,QAAA,GAAOA,kCAAAA,WAAAA,CAAW,MAAM,KAAK,CAAC;CAC9C,OAAO,SAAS,YAAA,GAAWA,kCAAAA,WAAAA,CAAW,MAAM,SAAS,CAAC;CAEtD,OAAO;EAAE,mBAAmB;EAAS,aAAa;CAAK;AACzD;;;;;;AAOA,SAAS,gBAAkC,OAAgB,eAAsD;CAC/G,IAAI,UAAU,OACZ,OAAO;CAET,MAAM,SAAA,GAAQJ,kCAAAA,eAAAA,CAAe,KAAK,CAAC,EAAE,QAAQ,SAAqB,cAAoC,SAAS,IAAI,CAAC;CACpH,OAAO,OAAO,SAAS,QAAQ,KAAA;AACjC;AAEA,SAAS,OACP,QACA,KACA,OACA;CACA,IAAI,UAAU,KAAA,GACZ,OAAO,OAAO;AAElB;;;;;;;AAQA,SAAgB,oCAAoC,mBAA0C;CAC5F,QAAA,GAAOK,kCAAAA,iBAAAA,CAAiB,iBAAiB;AAC3C"}
@@ -0,0 +1,13 @@
1
+ import type { ClocksState } from '@kubesense/kubesense-js-core/time';
2
+ import type { Context } from '@kubesense/kubesense-browser-core';
3
+ import type { LogsConfiguration } from '../configuration';
4
+ import type { LifeCycle } from '../lifeCycle';
5
+ export interface ProvidedError {
6
+ startClocks: ClocksState;
7
+ error: unknown;
8
+ context?: Context;
9
+ handlingStack: string;
10
+ }
11
+ export declare function startReportCollection(configuration: LogsConfiguration, lifeCycle: LifeCycle): {
12
+ stop: () => void;
13
+ };
@@ -0,0 +1,30 @@
1
+ const require_isAuthorized = require("../logger/isAuthorized.js");
2
+ const require_createErrorFieldFromRawError = require("../createErrorFieldFromRawError.js");
3
+ require("../lifeCycle.js");
4
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
5
+ let _kubesense_kubesense_js_core_time = require("@kubesense/kubesense-js-core/time");
6
+ //#region src/domain/report/reportCollection.ts
7
+ function startReportCollection(configuration, lifeCycle) {
8
+ const reportSubscription = (0, _kubesense_kubesense_browser_core.initReportObservable)(configuration.forwardReports).subscribe((rawError) => {
9
+ let message = rawError.message;
10
+ let error;
11
+ const status = rawError.originalError.type === "deprecation" ? require_isAuthorized.StatusType.warn : require_isAuthorized.StatusType.error;
12
+ if (status === require_isAuthorized.StatusType.error) error = require_createErrorFieldFromRawError.createErrorFieldFromRawError(rawError);
13
+ else if (rawError.stack) message += ` Found in ${(0, _kubesense_kubesense_browser_core.getFileFromStackTraceString)(rawError.stack)}`;
14
+ lifeCycle.notify(0, { rawLogsEvent: {
15
+ date: (0, _kubesense_kubesense_js_core_time.timeStampNow)(),
16
+ message,
17
+ origin: _kubesense_kubesense_browser_core.ErrorSource.REPORT,
18
+ error,
19
+ _kubesense: { debug_ids: rawError.debugIds },
20
+ status
21
+ } });
22
+ });
23
+ return { stop: () => {
24
+ reportSubscription.unsubscribe();
25
+ } };
26
+ }
27
+ //#endregion
28
+ exports.startReportCollection = startReportCollection;
29
+
30
+ //# sourceMappingURL=reportCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportCollection.js","names":["initReportObservable","StatusType","createErrorFieldFromRawError","getFileFromStackTraceString","timeStampNow","ErrorSource"],"sources":["../../../src/domain/report/reportCollection.ts"],"sourcesContent":["import type { ClocksState } from '@kubesense/kubesense-js-core/time'\nimport type { Context } from '@kubesense/kubesense-browser-core'\nimport { timeStampNow } from '@kubesense/kubesense-js-core/time'\nimport { ErrorSource, getFileFromStackTraceString, initReportObservable } from '@kubesense/kubesense-browser-core'\nimport type { LogsConfiguration } from '../configuration'\nimport type { LifeCycle } from '../lifeCycle'\nimport { LifeCycleEventType } from '../lifeCycle'\nimport { StatusType } from '../logger/isAuthorized'\nimport { createErrorFieldFromRawError } from '../createErrorFieldFromRawError'\n\nexport interface ProvidedError {\n startClocks: ClocksState\n error: unknown\n context?: Context\n handlingStack: string\n}\n\nexport function startReportCollection(configuration: LogsConfiguration, lifeCycle: LifeCycle) {\n const reportSubscription = initReportObservable(configuration.forwardReports).subscribe((rawError) => {\n let message = rawError.message\n let error\n const status = rawError.originalError.type === 'deprecation' ? StatusType.warn : StatusType.error\n\n if (status === StatusType.error) {\n error = createErrorFieldFromRawError(rawError)\n } else if (rawError.stack) {\n message += ` Found in ${getFileFromStackTraceString(rawError.stack)!}`\n }\n\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n date: timeStampNow(),\n message,\n origin: ErrorSource.REPORT,\n error,\n _kubesense: { debug_ids: rawError.debugIds },\n status,\n },\n })\n })\n\n return {\n stop: () => {\n reportSubscription.unsubscribe()\n },\n }\n}\n"],"mappings":";;;;;;AAiBA,SAAgB,sBAAsB,eAAkC,WAAsB;CAC5F,MAAM,sBAAA,GAAqBA,kCAAAA,qBAAAA,CAAqB,cAAc,cAAc,CAAC,CAAC,WAAW,aAAa;EACpG,IAAI,UAAU,SAAS;EACvB,IAAI;EACJ,MAAM,SAAS,SAAS,cAAc,SAAS,gBAAgBC,qBAAAA,WAAW,OAAOA,qBAAAA,WAAW;EAE5F,IAAI,WAAWA,qBAAAA,WAAW,OACxB,QAAQC,qCAAAA,6BAA6B,QAAQ;OACxC,IAAI,SAAS,OAClB,WAAW,cAAA,GAAaC,kCAAAA,4BAAAA,CAA4B,SAAS,KAAK;EAGpE,UAAU,OAAA,GAA6C,EACrD,cAAc;GACZ,OAAA,GAAMC,kCAAAA,aAAAA,CAAa;GACnB;GACA,QAAQC,kCAAAA,YAAY;GACpB;GACA,YAAY,EAAE,WAAW,SAAS,SAAS;GAC3C;EACF,EACF,CAAC;CACH,CAAC;CAED,OAAO,EACL,YAAY;EACV,mBAAmB,YAAY;CACjC,EACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import type { LifeCycle } from './lifeCycle';
2
+ export declare function startReportError(lifeCycle: LifeCycle): (message: string) => void;
@@ -0,0 +1,20 @@
1
+ const require_isAuthorized = require("./logger/isAuthorized.js");
2
+ require("./lifeCycle.js");
3
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
4
+ let _kubesense_kubesense_js_core_time = require("@kubesense/kubesense-js-core/time");
5
+ //#region src/domain/reportError.ts
6
+ function startReportError(lifeCycle) {
7
+ return (message) => {
8
+ lifeCycle.notify(0, { rawLogsEvent: {
9
+ message,
10
+ date: (0, _kubesense_kubesense_js_core_time.timeStampNow)(),
11
+ origin: _kubesense_kubesense_browser_core.ErrorSource.AGENT,
12
+ status: require_isAuthorized.StatusType.error
13
+ } });
14
+ (0, _kubesense_kubesense_browser_core.addTelemetryDebug)("Error reported to customer", { "error.message": message });
15
+ };
16
+ }
17
+ //#endregion
18
+ exports.startReportError = startReportError;
19
+
20
+ //# sourceMappingURL=reportError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportError.js","names":["timeStampNow","ErrorSource","StatusType"],"sources":["../../src/domain/reportError.ts"],"sourcesContent":["import { ErrorSource, addTelemetryDebug } from '@kubesense/kubesense-browser-core'\nimport { timeStampNow } from '@kubesense/kubesense-js-core/time'\nimport type { LifeCycle } from './lifeCycle'\nimport { LifeCycleEventType } from './lifeCycle'\nimport { StatusType } from './logger/isAuthorized'\n\nexport function startReportError(lifeCycle: LifeCycle) {\n return (message: string) => {\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: {\n message,\n date: timeStampNow(),\n origin: ErrorSource.AGENT,\n status: StatusType.error,\n },\n })\n // monitor-until: forever, to keep an eye on the errors reported to customers\n addTelemetryDebug('Error reported to customer', { 'error.message': message })\n }\n}\n"],"mappings":";;;;;AAMA,SAAgB,iBAAiB,WAAsB;CACrD,QAAQ,YAAoB;EAC1B,UAAU,OAAA,GAA6C,EACrD,cAAc;GACZ;GACA,OAAA,GAAMA,kCAAAA,aAAAA,CAAa;GACnB,QAAQC,kCAAAA,YAAY;GACpB,QAAQC,qBAAAA,WAAW;EACrB,EACF,CAAC;EAED,CAAA,GAAA,kCAAA,kBAAA,CAAkB,8BAA8B,EAAE,iBAAiB,QAAQ,CAAC;CAC9E;AACF"}
@@ -0,0 +1,14 @@
1
+ import type { ClocksState } from '@kubesense/kubesense-js-core/time';
2
+ import type { Context, Observable, BufferedData } from '@kubesense/kubesense-browser-core';
3
+ import { noop } from '@kubesense/kubesense-browser-core';
4
+ import type { LogsConfiguration } from '../configuration';
5
+ import type { LifeCycle } from '../lifeCycle';
6
+ export interface ProvidedError {
7
+ startClocks: ClocksState;
8
+ error: unknown;
9
+ context?: Context;
10
+ handlingStack: string;
11
+ }
12
+ export declare function startRuntimeErrorCollection(configuration: LogsConfiguration, lifeCycle: LifeCycle, bufferedDataObservable: Observable<BufferedData>): {
13
+ stop: typeof noop;
14
+ };
@@ -0,0 +1,29 @@
1
+ const require_isAuthorized = require("../logger/isAuthorized.js");
2
+ const require_createErrorFieldFromRawError = require("../createErrorFieldFromRawError.js");
3
+ require("../lifeCycle.js");
4
+ let _kubesense_kubesense_js_core_util = require("@kubesense/kubesense-js-core/util");
5
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
6
+ //#region src/domain/runtimeError/runtimeErrorCollection.ts
7
+ function startRuntimeErrorCollection(configuration, lifeCycle, bufferedDataObservable) {
8
+ if (!configuration.forwardErrorsToLogs) return { stop: _kubesense_kubesense_browser_core.noop };
9
+ const rawErrorSubscription = bufferedDataObservable.subscribe((bufferedData) => {
10
+ if (bufferedData.type === _kubesense_kubesense_browser_core.BufferedDataType.RUNTIME_ERROR) {
11
+ const error = bufferedData.data;
12
+ lifeCycle.notify(0, { rawLogsEvent: (0, _kubesense_kubesense_js_core_util.combine)({
13
+ message: error.message,
14
+ date: error.startClocks.timeStamp,
15
+ error: require_createErrorFieldFromRawError.createErrorFieldFromRawError(error),
16
+ _kubesense: { debug_ids: error.debugIds },
17
+ origin: _kubesense_kubesense_browser_core.ErrorSource.SOURCE,
18
+ status: require_isAuthorized.StatusType.error
19
+ }, error.context) });
20
+ }
21
+ });
22
+ return { stop: () => {
23
+ rawErrorSubscription.unsubscribe();
24
+ } };
25
+ }
26
+ //#endregion
27
+ exports.startRuntimeErrorCollection = startRuntimeErrorCollection;
28
+
29
+ //# sourceMappingURL=runtimeErrorCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeErrorCollection.js","names":["noop","BufferedDataType","combine","createErrorFieldFromRawError","ErrorSource","StatusType"],"sources":["../../../src/domain/runtimeError/runtimeErrorCollection.ts"],"sourcesContent":["import type { ClocksState } from '@kubesense/kubesense-js-core/time'\nimport { combine } from '@kubesense/kubesense-js-core/util'\nimport type { Context, Observable, BufferedData } from '@kubesense/kubesense-browser-core'\nimport { noop, ErrorSource, BufferedDataType } from '@kubesense/kubesense-browser-core'\nimport type { LogsConfiguration } from '../configuration'\nimport type { LifeCycle } from '../lifeCycle'\nimport { LifeCycleEventType } from '../lifeCycle'\nimport { StatusType } from '../logger/isAuthorized'\nimport { createErrorFieldFromRawError } from '../createErrorFieldFromRawError'\n\nexport interface ProvidedError {\n startClocks: ClocksState\n error: unknown\n context?: Context\n handlingStack: string\n}\n\nexport function startRuntimeErrorCollection(\n configuration: LogsConfiguration,\n lifeCycle: LifeCycle,\n bufferedDataObservable: Observable<BufferedData>\n) {\n if (!configuration.forwardErrorsToLogs) {\n return { stop: noop }\n }\n\n const rawErrorSubscription = bufferedDataObservable.subscribe((bufferedData) => {\n if (bufferedData.type === BufferedDataType.RUNTIME_ERROR) {\n const error = bufferedData.data\n lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {\n rawLogsEvent: combine(\n {\n message: error.message,\n date: error.startClocks.timeStamp,\n error: createErrorFieldFromRawError(error),\n _kubesense: { debug_ids: error.debugIds },\n origin: ErrorSource.SOURCE,\n status: StatusType.error,\n },\n error.context\n ),\n })\n }\n })\n\n return {\n stop: () => {\n rawErrorSubscription.unsubscribe()\n },\n }\n}\n"],"mappings":";;;;;;AAiBA,SAAgB,4BACd,eACA,WACA,wBACA;CACA,IAAI,CAAC,cAAc,qBACjB,OAAO,EAAE,MAAMA,kCAAAA,KAAK;CAGtB,MAAM,uBAAuB,uBAAuB,WAAW,iBAAiB;EAC9E,IAAI,aAAa,SAASC,kCAAAA,iBAAiB,eAAe;GACxD,MAAM,QAAQ,aAAa;GAC3B,UAAU,OAAA,GAA6C,EACrD,eAAA,GAAcC,kCAAAA,QAAAA,CACZ;IACE,SAAS,MAAM;IACf,MAAM,MAAM,YAAY;IACxB,OAAOC,qCAAAA,6BAA6B,KAAK;IACzC,YAAY,EAAE,WAAW,MAAM,SAAS;IACxC,QAAQC,kCAAAA,YAAY;IACpB,QAAQC,qBAAAA,WAAW;GACrB,GACA,MAAM,OACR,EACF,CAAC;EACH;CACF,CAAC;CAED,OAAO,EACL,YAAY;EACV,qBAAqB,YAAY;CACnC,EACF;AACF"}
@@ -0,0 +1,11 @@
1
+ import type { ErrorSource } from '@kubesense/kubesense-browser-core';
2
+ export type LogsEventDomainContext<T extends ErrorSource = any> = T extends typeof ErrorSource.NETWORK ? NetworkLogsEventDomainContext : T extends typeof ErrorSource.CONSOLE ? ConsoleLogsEventDomainContext : T extends typeof ErrorSource.LOGGER ? LoggerLogsEventDomainContext : undefined;
3
+ export interface NetworkLogsEventDomainContext {
4
+ handlingStack?: string;
5
+ }
6
+ export interface ConsoleLogsEventDomainContext {
7
+ handlingStack: string;
8
+ }
9
+ export interface LoggerLogsEventDomainContext {
10
+ handlingStack: string;
11
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ *
3
+ * KubeSense Browser Logs SDK for collecting and forwarding browser logs to KubeSense.
4
+ * Provides comprehensive logging capabilities with automatic error tracking and custom log collection.
5
+ *
6
+ * @packageDocumentation
7
+ * @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)
8
+ */
9
+ import type { LogsPublicApi } from '../boot/logsPublicApi';
10
+ export type { InternalContext } from '../domain/contexts/internalContext';
11
+ export type { LogsMessage } from '../domain/logger';
12
+ export { Logger, HandlerType } from '../domain/logger';
13
+ export { StatusType } from '../domain/logger/isAuthorized';
14
+ export type { LoggerConfiguration, LogsPublicApi as KubesenseLogs } from '../boot/logsPublicApi';
15
+ export type { LogsInitConfiguration, LogsBeforeSend } from '../domain/configuration';
16
+ export type { LogsEvent } from '../logsEvent.types';
17
+ export type { LogsPlugin, OnLogsStartOptions, OnInitOptions } from '../domain/plugins';
18
+ export type { LogsEventDomainContext, NetworkLogsEventDomainContext, ConsoleLogsEventDomainContext, LoggerLogsEventDomainContext, } from '../domainContext.types';
19
+ /**
20
+ * @deprecated Use {@link KubesenseLogs} instead
21
+ */
22
+ export type LogsGlobal = LogsPublicApi;
23
+ export type { InitConfiguration, PublicApi, Context, ContextValue, ContextArray, User, Account, TraceContextInjection, SessionPersistence, TrackingConsent, MatchOption, RawReportType, ErrorSource, } from '@kubesense/kubesense-browser-core';
24
+ export type { ProxyFn, Site } from '@kubesense/kubesense-js-core/transport';
25
+ export type { ConsoleApiName } from '@kubesense/kubesense-js-core/util';
26
+ /**
27
+ * The global Logs instance. Use this to call Logs methods.
28
+ *
29
+ * @category Main
30
+ * @see {@link KubesenseLogs}
31
+ * @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)
32
+ */
33
+ export declare const kubesenseLogs: LogsPublicApi;
@@ -0,0 +1,31 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_isAuthorized = require("../domain/logger/isAuthorized.js");
3
+ const require_logger = require("../domain/logger.js");
4
+ const require_logsPublicApi = require("../boot/logsPublicApi.js");
5
+ let _kubesense_kubesense_js_core_util = require("@kubesense/kubesense-js-core/util");
6
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
7
+ //#region src/entries/main.ts
8
+ /**
9
+ *
10
+ * KubeSense Browser Logs SDK for collecting and forwarding browser logs to KubeSense.
11
+ * Provides comprehensive logging capabilities with automatic error tracking and custom log collection.
12
+ *
13
+ * @packageDocumentation
14
+ * @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)
15
+ */
16
+ /**
17
+ * The global Logs instance. Use this to call Logs methods.
18
+ *
19
+ * @category Main
20
+ * @see {@link KubesenseLogs}
21
+ * @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)
22
+ */
23
+ const kubesenseLogs = require_logsPublicApi.makeLogsPublicApi({ sdkName: "logs" });
24
+ (0, _kubesense_kubesense_browser_core.defineGlobal)(_kubesense_kubesense_js_core_util.globalObject, "KUBESENSE_LOGS", kubesenseLogs);
25
+ //#endregion
26
+ exports.HandlerType = require_logger.HandlerType;
27
+ exports.Logger = require_logger.Logger;
28
+ exports.StatusType = require_isAuthorized.StatusType;
29
+ exports.kubesenseLogs = kubesenseLogs;
30
+
31
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["makeLogsPublicApi","defineGlobal","globalObject"],"sources":["../../src/entries/main.ts"],"sourcesContent":["/**\n *\n * KubeSense Browser Logs SDK for collecting and forwarding browser logs to KubeSense.\n * Provides comprehensive logging capabilities with automatic error tracking and custom log collection.\n *\n * @packageDocumentation\n * @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)\n */\n\nimport { globalObject } from '@kubesense/kubesense-js-core/util'\nimport { defineGlobal } from '@kubesense/kubesense-browser-core'\nimport type { LogsPublicApi } from '../boot/logsPublicApi'\nimport { makeLogsPublicApi } from '../boot/logsPublicApi'\n\nexport type { InternalContext } from '../domain/contexts/internalContext'\nexport type { LogsMessage } from '../domain/logger'\nexport { Logger, HandlerType } from '../domain/logger'\nexport { StatusType } from '../domain/logger/isAuthorized'\nexport type { LoggerConfiguration, LogsPublicApi as KubesenseLogs } from '../boot/logsPublicApi'\nexport type { LogsInitConfiguration, LogsBeforeSend } from '../domain/configuration'\nexport type { LogsEvent } from '../logsEvent.types'\nexport type { LogsPlugin, OnLogsStartOptions, OnInitOptions } from '../domain/plugins'\nexport type {\n LogsEventDomainContext,\n NetworkLogsEventDomainContext,\n ConsoleLogsEventDomainContext,\n LoggerLogsEventDomainContext,\n} from '../domainContext.types'\n\n/**\n * @deprecated Use {@link KubesenseLogs} instead\n */\nexport type LogsGlobal = LogsPublicApi\n\nexport type {\n InitConfiguration,\n PublicApi,\n Context,\n ContextValue,\n ContextArray,\n User,\n Account,\n TraceContextInjection,\n SessionPersistence,\n TrackingConsent,\n MatchOption,\n RawReportType,\n ErrorSource,\n} from '@kubesense/kubesense-browser-core'\nexport type { ProxyFn, Site } from '@kubesense/kubesense-js-core/transport'\nexport type { ConsoleApiName } from '@kubesense/kubesense-js-core/util'\n\n/**\n * The global Logs instance. Use this to call Logs methods.\n *\n * @category Main\n * @see {@link KubesenseLogs}\n * @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)\n */\nexport const kubesenseLogs = makeLogsPublicApi({ sdkName: 'logs' })\n\ninterface BrowserWindow {\n KUBESENSE_LOGS?: LogsPublicApi\n}\ndefineGlobal(globalObject as BrowserWindow, 'KUBESENSE_LOGS', kubesenseLogs)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,gBAAgBA,sBAAAA,kBAAkB,EAAE,SAAS,OAAO,CAAC;CAKlEC,GAAAA,kCAAAA,aAAAA,CAAaC,kCAAAA,cAA+B,kBAAkB,aAAa"}
@@ -0,0 +1,192 @@
1
+ export interface LogsEvent {
2
+ /**
3
+ * Start of the log in ms from epoch
4
+ */
5
+ date: number;
6
+ /**
7
+ * The log message
8
+ */
9
+ message: string;
10
+ /**
11
+ * The log status
12
+ */
13
+ status: 'ok' | 'debug' | 'info' | 'notice' | 'warn' | 'error' | 'critical' | 'alert' | 'emerg';
14
+ /**
15
+ * Origin of the log
16
+ */
17
+ origin: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'report';
18
+ /**
19
+ * UUID of the application
20
+ */
21
+ application_id?: string;
22
+ /**
23
+ * The service name
24
+ */
25
+ service?: string;
26
+ /**
27
+ * Tags of the log
28
+ */
29
+ ktags?: string;
30
+ /**
31
+ * UUID of the session (deprecated in favor of session.id)
32
+ */
33
+ session_id?: string;
34
+ /**
35
+ * Session properties
36
+ */
37
+ session?: {
38
+ /**
39
+ * UUID of the session
40
+ */
41
+ id?: string;
42
+ [k: string]: unknown;
43
+ };
44
+ /**
45
+ * View properties
46
+ */
47
+ view: {
48
+ /**
49
+ * URL that linked to the initial view of the page
50
+ */
51
+ referrer?: string;
52
+ /**
53
+ * URL of the view
54
+ */
55
+ url: string;
56
+ /**
57
+ * UUID of the view
58
+ */
59
+ id?: string;
60
+ /**
61
+ * User defined name of the view
62
+ */
63
+ name?: string;
64
+ [k: string]: unknown;
65
+ };
66
+ /**
67
+ * Logger properties
68
+ */
69
+ logger?: {
70
+ /**
71
+ * Name of the logger
72
+ */
73
+ name: string;
74
+ [k: string]: unknown;
75
+ };
76
+ /**
77
+ * Error properties
78
+ */
79
+ error?: {
80
+ /**
81
+ * Kind of the error
82
+ */
83
+ kind?: string;
84
+ /**
85
+ * Stacktrace of the error
86
+ */
87
+ stack?: string;
88
+ /**
89
+ * Fingerprint of the error
90
+ */
91
+ fingerprint?: string;
92
+ /**
93
+ * Message of the error
94
+ */
95
+ message?: string;
96
+ /**
97
+ * Flattened causes of the error
98
+ */
99
+ causes?: Array<{
100
+ message: string;
101
+ source: string;
102
+ type?: string;
103
+ stack?: string;
104
+ }>;
105
+ /**
106
+ * The language or platform impacting the error stack trace format
107
+ */
108
+ source_type?: 'browser' | 'browser+wasm';
109
+ /**
110
+ * WebAssembly modules available for stack trace symbolication
111
+ */
112
+ wasm_modules?: Array<{
113
+ url: string;
114
+ build_id: string;
115
+ }>;
116
+ [k: string]: unknown;
117
+ };
118
+ /**
119
+ * Resource properties of the error
120
+ */
121
+ http?: {
122
+ /**
123
+ * HTTP method of the resource
124
+ */
125
+ method: 'POST' | 'GET' | 'HEAD' | 'PUT' | 'DELETE' | 'PATCH';
126
+ /**
127
+ * HTTP Status code of the resource
128
+ */
129
+ status_code: number;
130
+ /**
131
+ * URL of the resource
132
+ */
133
+ url: string;
134
+ [k: string]: unknown;
135
+ };
136
+ user_action?: {
137
+ id: string | string[];
138
+ };
139
+ usr?: {
140
+ /**
141
+ * Identifier of the user
142
+ */
143
+ id?: string;
144
+ /**
145
+ * Name of the user
146
+ */
147
+ name?: string;
148
+ /**
149
+ * Email of the user
150
+ */
151
+ email?: string;
152
+ /**
153
+ * Mobile phone number of the user
154
+ */
155
+ mobile?: string;
156
+ /**
157
+ * Identifier of the user across sessions
158
+ */
159
+ anonymous_id?: string;
160
+ [k: string]: unknown;
161
+ };
162
+ account?: {
163
+ /**
164
+ * Identifier of the account
165
+ */
166
+ id: string;
167
+ /**
168
+ * Name of the account
169
+ */
170
+ name?: string;
171
+ [k: string]: unknown;
172
+ };
173
+ /**
174
+ * Internal properties
175
+ */
176
+ _kubesense?: {
177
+ /**
178
+ * Mapping of source file URLs to their debug IDs for source map deobfuscation
179
+ */
180
+ debug_ids?: Array<{
181
+ /**
182
+ * URL of the source file
183
+ */
184
+ url: string;
185
+ /**
186
+ * Debug ID (UUID) for the source file
187
+ */
188
+ id: string;
189
+ }>;
190
+ };
191
+ [k: string]: unknown;
192
+ }
@@ -0,0 +1,59 @@
1
+ import type { ErrorSource, RawErrorCause, ErrorHandling, DebugIdEntry } from '@kubesense/kubesense-browser-core';
2
+ import type { TimeStamp } from '@kubesense/kubesense-js-core/time';
3
+ import type { StatusType } from './domain/logger/isAuthorized';
4
+ export type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;
5
+ interface Error {
6
+ message?: string;
7
+ kind?: string;
8
+ stack?: string;
9
+ fingerprint?: string;
10
+ causes?: RawErrorCause[];
11
+ handling: ErrorHandling | undefined;
12
+ }
13
+ export interface CommonRawLogsEvent {
14
+ date: TimeStamp;
15
+ message: string;
16
+ status: StatusType;
17
+ error?: Error;
18
+ origin: ErrorSource;
19
+ _kubesense?: {
20
+ debug_ids?: DebugIdEntry[];
21
+ };
22
+ [key: string]: unknown;
23
+ }
24
+ export interface RawConsoleLogsEvent extends CommonRawLogsEvent {
25
+ origin: typeof ErrorSource.CONSOLE;
26
+ }
27
+ export interface RawLoggerLogsEvent extends CommonRawLogsEvent {
28
+ origin: typeof ErrorSource.LOGGER;
29
+ }
30
+ export interface RawNetworkLogsEvent extends CommonRawLogsEvent {
31
+ origin: typeof ErrorSource.NETWORK;
32
+ status: typeof StatusType.error;
33
+ error: Error;
34
+ http: {
35
+ method: 'POST' | 'GET' | 'HEAD' | 'PUT' | 'DELETE' | 'PATCH';
36
+ status_code: number;
37
+ url: string;
38
+ [k: string]: unknown;
39
+ };
40
+ }
41
+ export interface RawReportLogsEvent extends CommonRawLogsEvent {
42
+ origin: typeof ErrorSource.REPORT;
43
+ }
44
+ export interface RawRuntimeLogsEvent extends CommonRawLogsEvent {
45
+ origin: typeof ErrorSource.SOURCE;
46
+ status: typeof StatusType.error;
47
+ error: Error;
48
+ }
49
+ export interface RawAgentLogsEvent extends CommonRawLogsEvent {
50
+ origin: typeof ErrorSource.AGENT;
51
+ status: typeof StatusType.error;
52
+ }
53
+ export interface CommonContext {
54
+ view?: {
55
+ referrer: string;
56
+ url: string;
57
+ };
58
+ }
59
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { SessionManager } from '@kubesense/kubesense-browser-core';
2
+ import type { LogsConfiguration } from '../domain/configuration';
3
+ import type { LifeCycle } from '../domain/lifeCycle';
4
+ export declare function startLogsBatch(configuration: LogsConfiguration, lifeCycle: LifeCycle, reportError: (message: string) => void, sessionManager: SessionManager): import("@kubesense/kubesense-browser-core").Batch;
@@ -0,0 +1,22 @@
1
+ require("../domain/lifeCycle.js");
2
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
3
+ let _kubesense_kubesense_js_core_transport = require("@kubesense/kubesense-js-core/transport");
4
+ //#region src/transport/startLogsBatch.ts
5
+ function startLogsBatch(configuration, lifeCycle, reportError, sessionManager) {
6
+ const endpoints = [(0, _kubesense_kubesense_js_core_transport.createEndpointBuilder)(configuration, "logs")];
7
+ const replicaEndpoint = (0, _kubesense_kubesense_js_core_transport.createReplicaEndpointBuilder)(configuration, "logs");
8
+ if (replicaEndpoint) endpoints.push(replicaEndpoint);
9
+ const batch = (0, _kubesense_kubesense_browser_core.createBatch)({
10
+ endpoints,
11
+ reportError
12
+ });
13
+ sessionManager.expireObservable.subscribe(() => batch.forceFlush("session_expire"));
14
+ lifeCycle.subscribe(1, (serverLogsEvent) => {
15
+ batch.add(serverLogsEvent);
16
+ });
17
+ return batch;
18
+ }
19
+ //#endregion
20
+ exports.startLogsBatch = startLogsBatch;
21
+
22
+ //# sourceMappingURL=startLogsBatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startLogsBatch.js","names":["createEndpointBuilder","createReplicaEndpointBuilder","createBatch"],"sources":["../../src/transport/startLogsBatch.ts"],"sourcesContent":["import type { Context, SessionManager } from '@kubesense/kubesense-browser-core'\nimport { createBatch } from '@kubesense/kubesense-browser-core'\nimport { createEndpointBuilder, createReplicaEndpointBuilder } from '@kubesense/kubesense-js-core/transport'\nimport type { LogsConfiguration } from '../domain/configuration'\nimport type { LifeCycle } from '../domain/lifeCycle'\nimport { LifeCycleEventType } from '../domain/lifeCycle'\nimport type { LogsEvent } from '../logsEvent.types'\n\nexport function startLogsBatch(\n configuration: LogsConfiguration,\n lifeCycle: LifeCycle,\n reportError: (message: string) => void,\n sessionManager: SessionManager\n) {\n const endpoints = [createEndpointBuilder(configuration, 'logs')]\n const replicaEndpoint = createReplicaEndpointBuilder(configuration, 'logs')\n if (replicaEndpoint) {\n endpoints.push(replicaEndpoint)\n }\n\n const batch = createBatch({ endpoints, reportError })\n sessionManager.expireObservable.subscribe(() => batch.forceFlush('session_expire'))\n\n lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, (serverLogsEvent: LogsEvent & Context) => {\n batch.add(serverLogsEvent)\n })\n\n return batch\n}\n"],"mappings":";;;;AAQA,SAAgB,eACd,eACA,WACA,aACA,gBACA;CACA,MAAM,YAAY,EAAA,GAACA,uCAAAA,sBAAAA,CAAsB,eAAe,MAAM,CAAC;CAC/D,MAAM,mBAAA,GAAkBC,uCAAAA,6BAAAA,CAA6B,eAAe,MAAM;CAC1E,IAAI,iBACF,UAAU,KAAK,eAAe;CAGhC,MAAM,SAAA,GAAQC,kCAAAA,YAAAA,CAAY;EAAE;EAAW;CAAY,CAAC;CACpD,eAAe,iBAAiB,gBAAgB,MAAM,WAAW,gBAAgB,CAAC;CAElF,UAAU,UAAA,IAA6C,oBAAyC;EAC9F,MAAM,IAAI,eAAe;CAC3B,CAAC;CAED,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ import type { LifeCycle } from '../domain/lifeCycle';
2
+ export declare function startLogsBridge(lifeCycle: LifeCycle): void;
@@ -0,0 +1,13 @@
1
+ require("../domain/lifeCycle.js");
2
+ let _kubesense_kubesense_browser_core = require("@kubesense/kubesense-browser-core");
3
+ //#region src/transport/startLogsBridge.ts
4
+ function startLogsBridge(lifeCycle) {
5
+ const bridge = (0, _kubesense_kubesense_browser_core.getEventBridge)();
6
+ lifeCycle.subscribe(1, (serverLogsEvent) => {
7
+ bridge.send("log", serverLogsEvent);
8
+ });
9
+ }
10
+ //#endregion
11
+ exports.startLogsBridge = startLogsBridge;
12
+
13
+ //# sourceMappingURL=startLogsBridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startLogsBridge.js","names":["getEventBridge"],"sources":["../../src/transport/startLogsBridge.ts"],"sourcesContent":["import type { Context } from '@kubesense/kubesense-browser-core'\nimport { getEventBridge } from '@kubesense/kubesense-browser-core'\nimport type { LifeCycle } from '../domain/lifeCycle'\nimport { LifeCycleEventType } from '../domain/lifeCycle'\nimport type { LogsEvent } from '../logsEvent.types'\n\nexport function startLogsBridge(lifeCycle: LifeCycle) {\n const bridge = getEventBridge<'log', LogsEvent>()!\n\n lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, (serverLogsEvent: LogsEvent & Context) => {\n bridge.send('log', serverLogsEvent)\n })\n}\n"],"mappings":";;;AAMA,SAAgB,gBAAgB,WAAsB;CACpD,MAAM,UAAA,GAASA,kCAAAA,eAAAA,CAAiC;CAEhD,UAAU,UAAA,IAA6C,oBAAyC;EAC9F,OAAO,KAAK,OAAO,eAAe;CACpC,CAAC;AACH"}