@openobserve/browser-core 0.2.12-beta.21 → 0.2.12-beta.23

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 (322) hide show
  1. package/cjs/boot/displayAlreadyInitializedError.d.ts +1 -1
  2. package/cjs/boot/init.d.ts +1 -1
  3. package/cjs/boot/init.js +1 -1
  4. package/cjs/browser/addEventListener.d.ts +1 -1
  5. package/cjs/browser/addEventListener.js +1 -1
  6. package/cjs/domain/configuration/configuration.js +5 -4
  7. package/cjs/domain/configuration/configuration.js.map +1 -1
  8. package/cjs/domain/configuration/endpointBuilder.js +21 -12
  9. package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
  10. package/cjs/domain/context/storeContextManager.js +1 -1
  11. package/cjs/domain/tags.js +1 -1
  12. package/cjs/domain/telemetry/telemetry.js +2 -2
  13. package/esm/boot/displayAlreadyInitializedError.d.ts +2 -0
  14. package/esm/boot/displayAlreadyInitializedError.js +7 -0
  15. package/esm/boot/displayAlreadyInitializedError.js.map +1 -0
  16. package/esm/boot/init.d.ts +14 -0
  17. package/esm/boot/init.js +35 -0
  18. package/esm/boot/init.js.map +1 -0
  19. package/esm/browser/addEventListener.d.ts +87 -0
  20. package/esm/browser/addEventListener.js +51 -0
  21. package/esm/browser/addEventListener.js.map +1 -0
  22. package/esm/browser/browser.types.d.ts +51 -0
  23. package/esm/browser/browser.types.js +5 -0
  24. package/esm/browser/browser.types.js.map +1 -0
  25. package/esm/browser/cookie.d.ts +28 -0
  26. package/esm/browser/cookie.js +103 -0
  27. package/esm/browser/cookie.js.map +1 -0
  28. package/esm/browser/fetchObservable.d.ts +38 -0
  29. package/esm/browser/fetchObservable.js +99 -0
  30. package/esm/browser/fetchObservable.js.map +1 -0
  31. package/esm/browser/pageMayExitObservable.d.ts +14 -0
  32. package/esm/browser/pageMayExitObservable.js +40 -0
  33. package/esm/browser/pageMayExitObservable.js.map +1 -0
  34. package/esm/browser/runOnReadyState.d.ts +5 -0
  35. package/esm/browser/runOnReadyState.js +16 -0
  36. package/esm/browser/runOnReadyState.js.map +1 -0
  37. package/esm/browser/xhrObservable.d.ts +24 -0
  38. package/esm/browser/xhrObservable.js +83 -0
  39. package/esm/browser/xhrObservable.js.map +1 -0
  40. package/esm/domain/allowedTrackingOrigins.d.ts +4 -0
  41. package/esm/domain/allowedTrackingOrigins.js +21 -0
  42. package/esm/domain/allowedTrackingOrigins.js.map +1 -0
  43. package/esm/domain/bufferedData.d.ts +14 -0
  44. package/esm/domain/bufferedData.js +19 -0
  45. package/esm/domain/bufferedData.js.map +1 -0
  46. package/esm/domain/configuration/configuration.d.ts +312 -0
  47. package/esm/domain/configuration/configuration.js +132 -0
  48. package/esm/domain/configuration/configuration.js.map +1 -0
  49. package/esm/domain/configuration/endpointBuilder.d.ts +12 -0
  50. package/esm/domain/configuration/endpointBuilder.js +81 -0
  51. package/esm/domain/configuration/endpointBuilder.js.map +1 -0
  52. package/esm/domain/configuration/index.d.ts +5 -0
  53. package/esm/domain/configuration/index.js +4 -0
  54. package/esm/domain/configuration/index.js.map +1 -0
  55. package/esm/domain/configuration/transportConfiguration.d.ts +20 -0
  56. package/esm/domain/configuration/transportConfiguration.js +50 -0
  57. package/esm/domain/configuration/transportConfiguration.js.map +1 -0
  58. package/esm/domain/connectivity/connectivity.d.ts +14 -0
  59. package/esm/domain/connectivity/connectivity.js +11 -0
  60. package/esm/domain/connectivity/connectivity.js.map +1 -0
  61. package/esm/domain/connectivity/index.d.ts +1 -0
  62. package/esm/domain/connectivity/index.js +2 -0
  63. package/esm/domain/connectivity/index.js.map +1 -0
  64. package/esm/domain/console/consoleObservable.d.ts +21 -0
  65. package/esm/domain/console/consoleObservable.js +80 -0
  66. package/esm/domain/console/consoleObservable.js.map +1 -0
  67. package/esm/domain/context/contextConstants.d.ts +21 -0
  68. package/esm/domain/context/contextConstants.js +15 -0
  69. package/esm/domain/context/contextConstants.js.map +1 -0
  70. package/esm/domain/context/contextManager.d.ts +19 -0
  71. package/esm/domain/context/contextManager.js +57 -0
  72. package/esm/domain/context/contextManager.js.map +1 -0
  73. package/esm/domain/context/contextUtils.d.ts +5 -0
  74. package/esm/domain/context/contextUtils.js +13 -0
  75. package/esm/domain/context/contextUtils.js.map +1 -0
  76. package/esm/domain/context/defineContextMethod.d.ts +6 -0
  77. package/esm/domain/context/defineContextMethod.js +17 -0
  78. package/esm/domain/context/defineContextMethod.js.map +1 -0
  79. package/esm/domain/context/storeContextManager.d.ts +6 -0
  80. package/esm/domain/context/storeContextManager.js +35 -0
  81. package/esm/domain/context/storeContextManager.js.map +1 -0
  82. package/esm/domain/contexts/accountContext.d.ts +26 -0
  83. package/esm/domain/contexts/accountContext.js +29 -0
  84. package/esm/domain/contexts/accountContext.js.map +1 -0
  85. package/esm/domain/contexts/globalContext.d.ts +18 -0
  86. package/esm/domain/contexts/globalContext.js +17 -0
  87. package/esm/domain/contexts/globalContext.js.map +1 -0
  88. package/esm/domain/contexts/rumInternalContext.type.d.ts +14 -0
  89. package/esm/domain/contexts/rumInternalContext.type.js +2 -0
  90. package/esm/domain/contexts/rumInternalContext.type.js.map +1 -0
  91. package/esm/domain/contexts/userContext.d.ts +29 -0
  92. package/esm/domain/contexts/userContext.js +41 -0
  93. package/esm/domain/contexts/userContext.js.map +1 -0
  94. package/esm/domain/deflate/deflate.types.d.ts +40 -0
  95. package/esm/domain/deflate/deflate.types.js +2 -0
  96. package/esm/domain/deflate/deflate.types.js.map +1 -0
  97. package/esm/domain/deflate/index.d.ts +1 -0
  98. package/esm/domain/deflate/index.js +2 -0
  99. package/esm/domain/deflate/index.js.map +1 -0
  100. package/esm/domain/error/error.d.ts +23 -0
  101. package/esm/domain/error/error.js +65 -0
  102. package/esm/domain/error/error.js.map +1 -0
  103. package/esm/domain/error/error.types.d.ts +47 -0
  104. package/esm/domain/error/error.types.js +10 -0
  105. package/esm/domain/error/error.types.js.map +1 -0
  106. package/esm/domain/error/trackRuntimeError.d.ts +11 -0
  107. package/esm/domain/error/trackRuntimeError.js +43 -0
  108. package/esm/domain/error/trackRuntimeError.js.map +1 -0
  109. package/esm/domain/eventRateLimiter/createEventRateLimiter.d.ts +5 -0
  110. package/esm/domain/eventRateLimiter/createEventRateLimiter.js +38 -0
  111. package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -0
  112. package/esm/domain/extension/extensionUtils.d.ts +10 -0
  113. package/esm/domain/extension/extensionUtils.js +25 -0
  114. package/esm/domain/extension/extensionUtils.js.map +1 -0
  115. package/esm/domain/intakeSites.d.ts +8 -0
  116. package/esm/domain/intakeSites.js +8 -0
  117. package/esm/domain/intakeSites.js.map +1 -0
  118. package/esm/domain/report/browser.types.d.ts +34 -0
  119. package/esm/domain/report/browser.types.js +2 -0
  120. package/esm/domain/report/browser.types.js.map +1 -0
  121. package/esm/domain/report/reportObservable.d.ts +14 -0
  122. package/esm/domain/report/reportObservable.js +95 -0
  123. package/esm/domain/report/reportObservable.js.map +1 -0
  124. package/esm/domain/resourceUtils.d.ts +18 -0
  125. package/esm/domain/resourceUtils.js +17 -0
  126. package/esm/domain/resourceUtils.js.map +1 -0
  127. package/esm/domain/session/oldCookiesMigration.d.ts +11 -0
  128. package/esm/domain/session/oldCookiesMigration.js +36 -0
  129. package/esm/domain/session/oldCookiesMigration.js.map +1 -0
  130. package/esm/domain/session/sessionConstants.d.ts +15 -0
  131. package/esm/domain/session/sessionConstants.js +13 -0
  132. package/esm/domain/session/sessionConstants.js.map +1 -0
  133. package/esm/domain/session/sessionManager.d.ts +28 -0
  134. package/esm/domain/session/sessionManager.js +196 -0
  135. package/esm/domain/session/sessionManager.js.map +1 -0
  136. package/esm/domain/session/sessionState.d.ts +16 -0
  137. package/esm/domain/session/sessionState.js +60 -0
  138. package/esm/domain/session/sessionState.js.map +1 -0
  139. package/esm/domain/session/sessionStateValidation.d.ts +3 -0
  140. package/esm/domain/session/sessionStateValidation.js +7 -0
  141. package/esm/domain/session/sessionStateValidation.js.map +1 -0
  142. package/esm/domain/session/sessionStore.d.ts +38 -0
  143. package/esm/domain/session/sessionStore.js +179 -0
  144. package/esm/domain/session/sessionStore.js.map +1 -0
  145. package/esm/domain/session/sessionStoreOperations.d.ts +12 -0
  146. package/esm/domain/session/sessionStoreOperations.js +114 -0
  147. package/esm/domain/session/sessionStoreOperations.js.map +1 -0
  148. package/esm/domain/session/storeStrategies/sessionInCookie.d.ts +12 -0
  149. package/esm/domain/session/storeStrategies/sessionInCookie.js +98 -0
  150. package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
  151. package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +6 -0
  152. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +37 -0
  153. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -0
  154. package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +16 -0
  155. package/esm/domain/session/storeStrategies/sessionStoreStrategy.js +2 -0
  156. package/esm/domain/session/storeStrategies/sessionStoreStrategy.js.map +1 -0
  157. package/esm/domain/synthetics/syntheticsWorkerValues.d.ts +12 -0
  158. package/esm/domain/synthetics/syntheticsWorkerValues.js +24 -0
  159. package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -0
  160. package/esm/domain/tags.d.ts +6 -0
  161. package/esm/domain/tags.js +60 -0
  162. package/esm/domain/tags.js.map +1 -0
  163. package/esm/domain/telemetry/index.d.ts +4 -0
  164. package/esm/domain/telemetry/index.js +3 -0
  165. package/esm/domain/telemetry/index.js.map +1 -0
  166. package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +18 -0
  167. package/esm/domain/telemetry/rawTelemetryEvent.types.js +6 -0
  168. package/esm/domain/telemetry/rawTelemetryEvent.types.js.map +1 -0
  169. package/esm/domain/telemetry/telemetry.d.ts +56 -0
  170. package/esm/domain/telemetry/telemetry.js +228 -0
  171. package/esm/domain/telemetry/telemetry.js.map +1 -0
  172. package/esm/domain/telemetry/telemetryEvent.types.d.ts +866 -0
  173. package/esm/domain/telemetry/telemetryEvent.types.js +6 -0
  174. package/esm/domain/telemetry/telemetryEvent.types.js.map +1 -0
  175. package/esm/domain/trackingConsent.d.ts +13 -0
  176. package/esm/domain/trackingConsent.js +24 -0
  177. package/esm/domain/trackingConsent.js.map +1 -0
  178. package/esm/index.d.ts +100 -0
  179. package/esm/index.js +76 -0
  180. package/esm/index.js.map +1 -0
  181. package/esm/tools/abstractHooks.d.ts +24 -0
  182. package/esm/tools/abstractHooks.js +37 -0
  183. package/esm/tools/abstractHooks.js.map +1 -0
  184. package/esm/tools/abstractLifeCycle.d.ts +23 -0
  185. package/esm/tools/abstractLifeCycle.js +24 -0
  186. package/esm/tools/abstractLifeCycle.js.map +1 -0
  187. package/esm/tools/boundedBuffer.d.ts +16 -0
  188. package/esm/tools/boundedBuffer.js +29 -0
  189. package/esm/tools/boundedBuffer.js.map +1 -0
  190. package/esm/tools/catchUserErrors.d.ts +1 -0
  191. package/esm/tools/catchUserErrors.js +12 -0
  192. package/esm/tools/catchUserErrors.js.map +1 -0
  193. package/esm/tools/display.d.ts +38 -0
  194. package/esm/tools/display.js +41 -0
  195. package/esm/tools/display.js.map +1 -0
  196. package/esm/tools/encoder.d.ts +54 -0
  197. package/esm/tools/encoder.js +37 -0
  198. package/esm/tools/encoder.js.map +1 -0
  199. package/esm/tools/experimentalFeatures.d.ts +21 -0
  200. package/esm/tools/experimentalFeatures.js +42 -0
  201. package/esm/tools/experimentalFeatures.js.map +1 -0
  202. package/esm/tools/getZoneJsOriginalValue.d.ts +19 -0
  203. package/esm/tools/getZoneJsOriginalValue.js +26 -0
  204. package/esm/tools/getZoneJsOriginalValue.js.map +1 -0
  205. package/esm/tools/globalObject.d.ts +19 -0
  206. package/esm/tools/globalObject.js +40 -0
  207. package/esm/tools/globalObject.js.map +1 -0
  208. package/esm/tools/instrumentMethod.d.ts +75 -0
  209. package/esm/tools/instrumentMethod.js +114 -0
  210. package/esm/tools/instrumentMethod.js.map +1 -0
  211. package/esm/tools/matchOption.d.ts +8 -0
  212. package/esm/tools/matchOption.js +31 -0
  213. package/esm/tools/matchOption.js.map +1 -0
  214. package/esm/tools/mergeInto.d.ts +25 -0
  215. package/esm/tools/mergeInto.js +93 -0
  216. package/esm/tools/mergeInto.js.map +1 -0
  217. package/esm/tools/monitor.d.ts +9 -0
  218. package/esm/tools/monitor.js +52 -0
  219. package/esm/tools/monitor.js.map +1 -0
  220. package/esm/tools/observable.d.ts +30 -0
  221. package/esm/tools/observable.js +83 -0
  222. package/esm/tools/observable.js.map +1 -0
  223. package/esm/tools/queueMicrotask.d.ts +1 -0
  224. package/esm/tools/queueMicrotask.js +14 -0
  225. package/esm/tools/queueMicrotask.js.map +1 -0
  226. package/esm/tools/readBytesFromStream.d.ts +10 -0
  227. package/esm/tools/readBytesFromStream.js +25 -0
  228. package/esm/tools/readBytesFromStream.js.map +1 -0
  229. package/esm/tools/requestIdleCallback.d.ts +12 -0
  230. package/esm/tools/requestIdleCallback.js +30 -0
  231. package/esm/tools/requestIdleCallback.js.map +1 -0
  232. package/esm/tools/sendToExtension.d.ts +3 -0
  233. package/esm/tools/sendToExtension.js +8 -0
  234. package/esm/tools/sendToExtension.js.map +1 -0
  235. package/esm/tools/serialisation/context.d.ts +9 -0
  236. package/esm/tools/serialisation/context.js +2 -0
  237. package/esm/tools/serialisation/context.js.map +1 -0
  238. package/esm/tools/serialisation/jsonStringify.d.ts +13 -0
  239. package/esm/tools/serialisation/jsonStringify.js +44 -0
  240. package/esm/tools/serialisation/jsonStringify.js.map +1 -0
  241. package/esm/tools/serialisation/sanitize.d.ts +18 -0
  242. package/esm/tools/serialisation/sanitize.js +185 -0
  243. package/esm/tools/serialisation/sanitize.js.map +1 -0
  244. package/esm/tools/stackTrace/computeStackTrace.d.ts +25 -0
  245. package/esm/tools/stackTrace/computeStackTrace.js +183 -0
  246. package/esm/tools/stackTrace/computeStackTrace.js.map +1 -0
  247. package/esm/tools/stackTrace/handlingStack.d.ts +10 -0
  248. package/esm/tools/stackTrace/handlingStack.js +41 -0
  249. package/esm/tools/stackTrace/handlingStack.js.map +1 -0
  250. package/esm/tools/taskQueue.d.ts +15 -0
  251. package/esm/tools/taskQueue.js +50 -0
  252. package/esm/tools/taskQueue.js.map +1 -0
  253. package/esm/tools/timer.d.ts +5 -0
  254. package/esm/tools/timer.js +16 -0
  255. package/esm/tools/timer.js.map +1 -0
  256. package/esm/tools/utils/arrayUtils.d.ts +3 -0
  257. package/esm/tools/utils/arrayUtils.js +15 -0
  258. package/esm/tools/utils/arrayUtils.js.map +1 -0
  259. package/esm/tools/utils/browserDetection.d.ts +8 -0
  260. package/esm/tools/utils/browserDetection.js +28 -0
  261. package/esm/tools/utils/browserDetection.js.map +1 -0
  262. package/esm/tools/utils/byteUtils.d.ts +8 -0
  263. package/esm/tools/utils/byteUtils.js +29 -0
  264. package/esm/tools/utils/byteUtils.js.map +1 -0
  265. package/esm/tools/utils/functionUtils.d.ts +8 -0
  266. package/esm/tools/utils/functionUtils.js +39 -0
  267. package/esm/tools/utils/functionUtils.js.map +1 -0
  268. package/esm/tools/utils/numberUtils.d.ts +9 -0
  269. package/esm/tools/utils/numberUtils.js +18 -0
  270. package/esm/tools/utils/numberUtils.js.map +1 -0
  271. package/esm/tools/utils/objectUtils.d.ts +10 -0
  272. package/esm/tools/utils/objectUtils.js +17 -0
  273. package/esm/tools/utils/objectUtils.js.map +1 -0
  274. package/esm/tools/utils/polyfills.d.ts +7 -0
  275. package/esm/tools/utils/polyfills.js +18 -0
  276. package/esm/tools/utils/polyfills.js.map +1 -0
  277. package/esm/tools/utils/responseUtils.d.ts +2 -0
  278. package/esm/tools/utils/responseUtils.js +13 -0
  279. package/esm/tools/utils/responseUtils.js.map +1 -0
  280. package/esm/tools/utils/stringUtils.d.ts +23 -0
  281. package/esm/tools/utils/stringUtils.js +84 -0
  282. package/esm/tools/utils/stringUtils.js.map +1 -0
  283. package/esm/tools/utils/timeUtils.d.ts +53 -0
  284. package/esm/tools/utils/timeUtils.js +84 -0
  285. package/esm/tools/utils/timeUtils.js.map +1 -0
  286. package/esm/tools/utils/timezone.d.ts +1 -0
  287. package/esm/tools/utils/timezone.js +10 -0
  288. package/esm/tools/utils/timezone.js.map +1 -0
  289. package/esm/tools/utils/typeUtils.d.ts +4 -0
  290. package/esm/tools/utils/typeUtils.js +13 -0
  291. package/esm/tools/utils/typeUtils.js.map +1 -0
  292. package/esm/tools/utils/urlPolyfill.d.ts +5 -0
  293. package/esm/tools/utils/urlPolyfill.js +52 -0
  294. package/esm/tools/utils/urlPolyfill.js.map +1 -0
  295. package/esm/tools/valueHistory.d.ts +27 -0
  296. package/esm/tools/valueHistory.js +100 -0
  297. package/esm/tools/valueHistory.js.map +1 -0
  298. package/esm/transport/batch.d.ts +16 -0
  299. package/esm/transport/batch.js +106 -0
  300. package/esm/transport/batch.js.map +1 -0
  301. package/esm/transport/eventBridge.d.ts +21 -0
  302. package/esm/transport/eventBridge.js +41 -0
  303. package/esm/transport/eventBridge.js.map +1 -0
  304. package/esm/transport/flushController.d.ts +65 -0
  305. package/esm/transport/flushController.js +119 -0
  306. package/esm/transport/flushController.js.map +1 -0
  307. package/esm/transport/httpRequest.d.ts +56 -0
  308. package/esm/transport/httpRequest.js +89 -0
  309. package/esm/transport/httpRequest.js.map +1 -0
  310. package/esm/transport/index.d.ts +7 -0
  311. package/esm/transport/index.js +5 -0
  312. package/esm/transport/index.js.map +1 -0
  313. package/esm/transport/sendWithRetryStrategy.d.ts +41 -0
  314. package/esm/transport/sendWithRetryStrategy.js +158 -0
  315. package/esm/transport/sendWithRetryStrategy.js.map +1 -0
  316. package/package.json +1 -1
  317. package/src/boot/displayAlreadyInitializedError.ts +1 -1
  318. package/src/boot/init.ts +1 -1
  319. package/src/browser/addEventListener.ts +2 -2
  320. package/src/domain/configuration/configuration.ts +6 -5
  321. package/src/domain/configuration/endpointBuilder.ts +25 -15
  322. package/src/domain/context/storeContextManager.ts +1 -1
@@ -0,0 +1,14 @@
1
+ export type NetworkInterface = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
2
+ export type EffectiveType = 'slow-2g' | '2g' | '3g' | '4g';
3
+ export interface NetworkInformation {
4
+ type?: NetworkInterface;
5
+ effectiveType?: EffectiveType;
6
+ saveData: boolean;
7
+ }
8
+ export interface Connectivity {
9
+ status: 'connected' | 'not_connected';
10
+ interfaces?: NetworkInterface[];
11
+ effective_type?: EffectiveType;
12
+ [key: string]: unknown;
13
+ }
14
+ export declare function getConnectivity(): Connectivity;
@@ -0,0 +1,11 @@
1
+ import { globalObject } from '../../tools/globalObject';
2
+ export function getConnectivity() {
3
+ var _a;
4
+ const navigator = globalObject.navigator;
5
+ return {
6
+ status: navigator.onLine ? 'connected' : 'not_connected',
7
+ interfaces: navigator.connection && navigator.connection.type ? [navigator.connection.type] : undefined,
8
+ effective_type: (_a = navigator.connection) === null || _a === void 0 ? void 0 : _a.effectiveType,
9
+ };
10
+ }
11
+ //# sourceMappingURL=connectivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectivity.js","sourceRoot":"","sources":["../../../src/domain/connectivity/connectivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAsBvD,MAAM,UAAU,eAAe;;IAC7B,MAAM,SAAS,GAAG,YAAY,CAAC,SAA6B,CAAA;IAE5D,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe;QACxD,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACvG,cAAc,EAAE,MAAA,SAAS,CAAC,UAAU,0CAAE,aAAa;KACpD,CAAA;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './connectivity';
@@ -0,0 +1,2 @@
1
+ export * from './connectivity';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/connectivity/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { Observable } from '../../tools/observable';
2
+ import { ConsoleApiName } from '../../tools/display';
3
+ import type { RawError } from '../error/error.types';
4
+ export type ConsoleLog = NonErrorConsoleLog | ErrorConsoleLog;
5
+ interface NonErrorConsoleLog extends ConsoleLogBase {
6
+ api: Exclude<ConsoleApiName, typeof ConsoleApiName.error>;
7
+ error: undefined;
8
+ }
9
+ export interface ErrorConsoleLog extends ConsoleLogBase {
10
+ api: typeof ConsoleApiName.error;
11
+ error: RawError;
12
+ }
13
+ interface ConsoleLogBase {
14
+ message: string;
15
+ api: ConsoleApiName;
16
+ handlingStack: string;
17
+ }
18
+ type ConsoleLogForApi<T extends ConsoleApiName> = T extends typeof ConsoleApiName.error ? ErrorConsoleLog : NonErrorConsoleLog;
19
+ export declare function initConsoleObservable<T extends ConsoleApiName[]>(apis: T): Observable<ConsoleLogForApi<T[number]>>;
20
+ export declare function resetConsoleObservable(): void;
21
+ export {};
@@ -0,0 +1,80 @@
1
+ import { isError, computeRawError } from '../error/error';
2
+ import { mergeObservables, Observable } from '../../tools/observable';
3
+ import { ConsoleApiName, globalConsole } from '../../tools/display';
4
+ import { callMonitored } from '../../tools/monitor';
5
+ import { sanitize } from '../../tools/serialisation/sanitize';
6
+ import { jsonStringify } from '../../tools/serialisation/jsonStringify';
7
+ import { ErrorSource } from '../error/error.types';
8
+ import { computeStackTrace } from '../../tools/stackTrace/computeStackTrace';
9
+ import { createHandlingStack, formatErrorMessage } from '../../tools/stackTrace/handlingStack';
10
+ import { clocksNow } from '../../tools/utils/timeUtils';
11
+ let consoleObservablesByApi = {};
12
+ export function initConsoleObservable(apis) {
13
+ const consoleObservables = apis.map((api) => {
14
+ if (!consoleObservablesByApi[api]) {
15
+ consoleObservablesByApi[api] = createConsoleObservable(api); // we are sure that the observable created for this api will yield the expected ConsoleLog type
16
+ }
17
+ return consoleObservablesByApi[api];
18
+ });
19
+ return mergeObservables(...consoleObservables);
20
+ }
21
+ export function resetConsoleObservable() {
22
+ consoleObservablesByApi = {};
23
+ }
24
+ function createConsoleObservable(api) {
25
+ return new Observable((observable) => {
26
+ const originalConsoleApi = globalConsole[api];
27
+ globalConsole[api] = (...params) => {
28
+ originalConsoleApi.apply(console, params);
29
+ const handlingStack = createHandlingStack('console error');
30
+ callMonitored(() => {
31
+ observable.notify(buildConsoleLog(params, api, handlingStack));
32
+ });
33
+ };
34
+ return () => {
35
+ globalConsole[api] = originalConsoleApi;
36
+ };
37
+ });
38
+ }
39
+ function buildConsoleLog(params, api, handlingStack) {
40
+ const message = params.map((param) => formatConsoleParameters(param)).join(' ');
41
+ if (api === ConsoleApiName.error) {
42
+ const firstErrorParam = params.find(isError);
43
+ const rawError = computeRawError({
44
+ originalError: firstErrorParam,
45
+ handlingStack,
46
+ startClocks: clocksNow(),
47
+ source: ErrorSource.CONSOLE,
48
+ handling: "handled" /* ErrorHandling.HANDLED */,
49
+ nonErrorPrefix: "Provided" /* NonErrorPrefix.PROVIDED */,
50
+ // if no good stack is computed from the error, let's not use the fallback stack message
51
+ // advising the user to use an instance of Error, as console.error is commonly used without an
52
+ // Error instance.
53
+ useFallbackStack: false,
54
+ });
55
+ // Use the full log message as the error message instead of just the error instance message.
56
+ rawError.message = message;
57
+ return {
58
+ api,
59
+ message,
60
+ handlingStack,
61
+ error: rawError,
62
+ };
63
+ }
64
+ return {
65
+ api,
66
+ message,
67
+ error: undefined,
68
+ handlingStack,
69
+ };
70
+ }
71
+ function formatConsoleParameters(param) {
72
+ if (typeof param === 'string') {
73
+ return sanitize(param);
74
+ }
75
+ if (isError(param)) {
76
+ return formatErrorMessage(computeStackTrace(param));
77
+ }
78
+ return jsonStringify(sanitize(param), undefined, 2);
79
+ }
80
+ //# sourceMappingURL=console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,GAAG,OAAO,CAAA;QAE1B,OAAO;YACL,GAAG;YACH,OAAO;YACP,aAAa;YACb,KAAK,EAAE,QAAQ;SAChB,CAAA;IACH,CAAC;IAED,OAAO;QACL,GAAG;QACH,OAAO;QACP,KAAK,EAAE,SAAS;QAChB,aAAa;KACd,CAAA;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,21 @@
1
+ export declare const enum CustomerDataType {
2
+ FeatureFlag = 0,
3
+ User = 1,
4
+ GlobalContext = 2,
5
+ View = 3,
6
+ Account = 4
7
+ }
8
+ export declare const CustomerContextKey: {
9
+ readonly userContext: "userContext";
10
+ readonly globalContext: "globalContext";
11
+ readonly accountContext: "accountContext";
12
+ };
13
+ export type CustomerContextKey = (typeof CustomerContextKey)[keyof typeof CustomerContextKey];
14
+ export declare const ContextManagerMethod: {
15
+ readonly getContext: "getContext";
16
+ readonly setContext: "setContext";
17
+ readonly setContextProperty: "setContextProperty";
18
+ readonly removeContextProperty: "removeContextProperty";
19
+ readonly clearContext: "clearContext";
20
+ };
21
+ export type ContextManagerMethod = (typeof ContextManagerMethod)[keyof typeof ContextManagerMethod];
@@ -0,0 +1,15 @@
1
+ // Use a const instead of const enum to avoid inlining the enum values in the bundle and save bytes
2
+ export const CustomerContextKey = {
3
+ userContext: 'userContext',
4
+ globalContext: 'globalContext',
5
+ accountContext: 'accountContext',
6
+ };
7
+ // Use a const instead of const enum to avoid inlining the enum values in the bundle and save bytes
8
+ export const ContextManagerMethod = {
9
+ getContext: 'getContext',
10
+ setContext: 'setContext',
11
+ setContextProperty: 'setContextProperty',
12
+ removeContextProperty: 'removeContextProperty',
13
+ clearContext: 'clearContext',
14
+ };
15
+ //# sourceMappingURL=contextConstants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextConstants.js","sourceRoot":"","sources":["../../../src/domain/context/contextConstants.ts"],"names":[],"mappings":"AAQA,mGAAmG;AACnG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;CACxB,CAAA;AAIV,mGAAmG;AACnG,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,YAAY,EAAE,cAAc;CACpB,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { Context } from '../../tools/serialisation/context';
2
+ import { Observable } from '../../tools/observable';
3
+ export type ContextManager = ReturnType<typeof createContextManager>;
4
+ export interface PropertiesConfig {
5
+ [key: string]: {
6
+ required?: boolean;
7
+ type?: 'string';
8
+ };
9
+ }
10
+ export declare function createContextManager(name?: string, { propertiesConfig, }?: {
11
+ propertiesConfig?: PropertiesConfig;
12
+ }): {
13
+ getContext: () => Context;
14
+ setContext: (newContext: unknown) => void;
15
+ setContextProperty: (key: string, property: any) => void;
16
+ removeContextProperty: (key: string) => void;
17
+ clearContext: () => void;
18
+ changeObservable: Observable<void>;
19
+ };
@@ -0,0 +1,57 @@
1
+ import { deepClone } from '../../tools/mergeInto';
2
+ import { sanitize } from '../../tools/serialisation/sanitize';
3
+ import { Observable } from '../../tools/observable';
4
+ import { display } from '../../tools/display';
5
+ import { checkContext } from './contextUtils';
6
+ function ensureProperties(context, propertiesConfig, name) {
7
+ const newContext = { ...context };
8
+ for (const [key, { required, type }] of Object.entries(propertiesConfig)) {
9
+ /**
10
+ * Ensure specified properties are strings as defined here:
11
+ * https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
12
+ */
13
+ if (type === 'string' && !isDefined(newContext[key])) {
14
+ /* eslint-disable @typescript-eslint/no-base-to-string */
15
+ newContext[key] = String(newContext[key]);
16
+ }
17
+ if (required && isDefined(newContext[key])) {
18
+ display.warn(`The property ${key} of ${name} is required; context will not be sent to the intake.`);
19
+ }
20
+ }
21
+ return newContext;
22
+ }
23
+ function isDefined(value) {
24
+ return value === undefined || value === null || value === '';
25
+ }
26
+ export function createContextManager(name = '', { propertiesConfig = {}, } = {}) {
27
+ let context = {};
28
+ const changeObservable = new Observable();
29
+ const contextManager = {
30
+ getContext: () => deepClone(context),
31
+ setContext: (newContext) => {
32
+ if (checkContext(newContext)) {
33
+ context = sanitize(ensureProperties(newContext, propertiesConfig, name));
34
+ }
35
+ else {
36
+ contextManager.clearContext();
37
+ }
38
+ changeObservable.notify();
39
+ },
40
+ setContextProperty: (key, property) => {
41
+ context = sanitize(ensureProperties({ ...context, [key]: property }, propertiesConfig, name));
42
+ changeObservable.notify();
43
+ },
44
+ removeContextProperty: (key) => {
45
+ delete context[key];
46
+ ensureProperties(context, propertiesConfig, name);
47
+ changeObservable.notify();
48
+ },
49
+ clearContext: () => {
50
+ context = {};
51
+ changeObservable.notify();
52
+ },
53
+ changeObservable,
54
+ };
55
+ return contextManager;
56
+ }
57
+ //# sourceMappingURL=contextManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextManager.js","sourceRoot":"","sources":["../../../src/domain/context/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,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;gBAC7B,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAA;YAC1E,CAAC;iBAAM,CAAC;gBACN,cAAc,CAAC,YAAY,EAAE,CAAA;YAC/B,CAAC;YACD,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,kBAAkB,EAAE,CAAC,GAAW,EAAE,QAAa,EAAE,EAAE;YACjD,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAA;YAC7F,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,qBAAqB,EAAE,CAAC,GAAW,EAAE,EAAE;YACrC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;YACnB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAA;YACjD,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO,GAAG,EAAE,CAAA;YACZ,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,gBAAgB;KACjB,CAAA;IACD,OAAO,cAAc,CAAA;AACvB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Context } from '../../tools/serialisation/context';
2
+ /**
3
+ * Simple check to ensure an object is a valid context
4
+ */
5
+ export declare function checkContext(maybeContext: unknown): maybeContext is Context;
@@ -0,0 +1,13 @@
1
+ import { display } from '../../tools/display';
2
+ import { getType } from '../../tools/utils/typeUtils';
3
+ /**
4
+ * Simple check to ensure an object is a valid context
5
+ */
6
+ export function checkContext(maybeContext) {
7
+ const isValid = getType(maybeContext) === 'object';
8
+ if (!isValid) {
9
+ display.error('Unsupported context:', maybeContext);
10
+ }
11
+ return isValid;
12
+ }
13
+ //# sourceMappingURL=contextUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextUtils.js","sourceRoot":"","sources":["../../../src/domain/context/contextUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAErD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,YAAqB;IAChD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAA;IAClD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { RawTelemetryUsageFeature } from '../telemetry';
2
+ import type { BoundedBuffer } from '../../tools/boundedBuffer';
3
+ import type { ContextManager } from './contextManager';
4
+ import type { ContextManagerMethod, CustomerContextKey } from './contextConstants';
5
+ export declare function defineContextMethod<MethodName extends ContextManagerMethod, Key extends CustomerContextKey>(getStrategy: () => Record<Key, ContextManager>, contextName: Key, methodName: MethodName, usage?: RawTelemetryUsageFeature): ContextManager[MethodName];
6
+ export declare function bufferContextCalls<Key extends string, StartResult extends Record<Key, ContextManager>>(preStartContextManager: ContextManager, name: Key, bufferApiCalls: BoundedBuffer<StartResult>): void;
@@ -0,0 +1,17 @@
1
+ import { addTelemetryUsage } from '../telemetry';
2
+ import { monitor } from '../../tools/monitor';
3
+ export function defineContextMethod(getStrategy, contextName, methodName, usage) {
4
+ return monitor((...args) => {
5
+ if (usage) {
6
+ addTelemetryUsage({ feature: usage });
7
+ }
8
+ return getStrategy()[contextName][methodName](...args);
9
+ });
10
+ }
11
+ export function bufferContextCalls(preStartContextManager, name, bufferApiCalls) {
12
+ preStartContextManager.changeObservable.subscribe(() => {
13
+ const context = preStartContextManager.getContext();
14
+ bufferApiCalls.add((startResult) => startResult[name].setContext(context));
15
+ });
16
+ }
17
+ //# sourceMappingURL=defineContextMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineContextMethod.js","sourceRoot":"","sources":["../../../src/domain/context/defineContextMethod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAK7C,MAAM,UAAU,mBAAmB,CACjC,WAA8C,EAC9C,WAAgB,EAChB,UAAsB,EACtB,KAAgC;IAEhC,OAAO,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QAChC,IAAI,KAAK,EAAE,CAAC;YACV,iBAAiB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAuB,CAAC,CAAA;QAC5D,CAAC;QACD,OAAQ,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,UAAU,CAAqC,CAAC,GAAG,IAAI,CAAC,CAAA;IAC7F,CAAC,CAA+B,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,sBAAsC,EACtC,IAAS,EACT,cAA0C;IAE1C,sBAAsB,CAAC,gBAAgB,CAAC,SAAS,CAAC,GAAG,EAAE;QACrD,MAAM,OAAO,GAAG,sBAAsB,CAAC,UAAU,EAAE,CAAA;QACnD,cAAc,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Configuration } from '../configuration';
2
+ import type { ContextManager } from './contextManager';
3
+ import type { CustomerDataType } from './contextConstants';
4
+ export declare function storeContextManager(configuration: Configuration, contextManager: ContextManager, productKey: string, customerDataType: CustomerDataType): void;
5
+ export declare function buildStorageKey(productKey: string, customerDataType: CustomerDataType): string;
6
+ export declare function removeStorageListeners(): void;
@@ -0,0 +1,35 @@
1
+ import { addEventListener } from '../../browser/addEventListener';
2
+ import { combine } from '../../tools/mergeInto';
3
+ import { isEmptyObject } from '../../tools/utils/objectUtils';
4
+ const CONTEXT_STORE_KEY_PREFIX = '_oo_c';
5
+ const storageListeners = [];
6
+ export function storeContextManager(configuration, contextManager, productKey, customerDataType) {
7
+ const storageKey = buildStorageKey(productKey, customerDataType);
8
+ storageListeners.push(addEventListener(configuration, window, "storage" /* DOM_EVENT.STORAGE */, ({ key }) => {
9
+ if (storageKey === key) {
10
+ synchronizeWithStorage();
11
+ }
12
+ }));
13
+ contextManager.changeObservable.subscribe(dumpToStorage);
14
+ const contextFromStorage = combine(getFromStorage(), contextManager.getContext());
15
+ if (!isEmptyObject(contextFromStorage)) {
16
+ contextManager.setContext(contextFromStorage);
17
+ }
18
+ function synchronizeWithStorage() {
19
+ contextManager.setContext(getFromStorage());
20
+ }
21
+ function dumpToStorage() {
22
+ localStorage.setItem(storageKey, JSON.stringify(contextManager.getContext()));
23
+ }
24
+ function getFromStorage() {
25
+ const rawContext = localStorage.getItem(storageKey);
26
+ return rawContext ? JSON.parse(rawContext) : {};
27
+ }
28
+ }
29
+ export function buildStorageKey(productKey, customerDataType) {
30
+ return `${CONTEXT_STORE_KEY_PREFIX}_${productKey}_${customerDataType}`;
31
+ }
32
+ export function removeStorageListeners() {
33
+ storageListeners.map((listener) => listener.stop());
34
+ }
35
+ //# sourceMappingURL=storeContextManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storeContextManager.js","sourceRoot":"","sources":["../../../src/domain/context/storeContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAa,MAAM,gCAAgC,CAAA;AAG5E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAI7D,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAExC,MAAM,gBAAgB,GAAgC,EAAE,CA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AAsB;IACpC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Configuration } from '../configuration';
2
+ import type { AbstractHooks } from '../../tools/abstractHooks';
3
+ /**
4
+ * Account information for the browser SDK.
5
+ */
6
+ export interface Account {
7
+ id: string;
8
+ name?: string | undefined;
9
+ [key: string]: unknown;
10
+ }
11
+ export declare function startAccountContext(hooks: AbstractHooks, configuration: Configuration, productKey: string): {
12
+ getContext: () => import("../..").Context;
13
+ setContext: (newContext: unknown) => void;
14
+ setContextProperty: (key: string, property: any) => void;
15
+ removeContextProperty: (key: string) => void;
16
+ clearContext: () => void;
17
+ changeObservable: import("../..").Observable<void>;
18
+ };
19
+ export declare function buildAccountContextManager(): {
20
+ getContext: () => import("../..").Context;
21
+ setContext: (newContext: unknown) => void;
22
+ setContextProperty: (key: string, property: any) => void;
23
+ removeContextProperty: (key: string) => void;
24
+ clearContext: () => void;
25
+ changeObservable: import("../..").Observable<void>;
26
+ };
@@ -0,0 +1,29 @@
1
+ import { storeContextManager } from '../context/storeContextManager';
2
+ import { SKIPPED } from '../../tools/abstractHooks';
3
+ import { isEmptyObject } from '../../tools/utils/objectUtils';
4
+ import { createContextManager } from '../context/contextManager';
5
+ export function startAccountContext(hooks, configuration, productKey) {
6
+ const accountContextManager = buildAccountContextManager();
7
+ if (configuration.storeContextsAcrossPages) {
8
+ storeContextManager(configuration, accountContextManager, productKey, 4 /* CustomerDataType.Account */);
9
+ }
10
+ hooks.register(0 /* HookNames.Assemble */, () => {
11
+ const account = accountContextManager.getContext();
12
+ if (isEmptyObject(account) || !account.id) {
13
+ return SKIPPED;
14
+ }
15
+ return {
16
+ account,
17
+ };
18
+ });
19
+ return accountContextManager;
20
+ }
21
+ export function buildAccountContextManager() {
22
+ return createContextManager('account', {
23
+ propertiesConfig: {
24
+ id: { type: 'string', required: true },
25
+ name: { type: 'string' },
26
+ },
27
+ });
28
+ }
29
+ //# sourceMappingURL=accountContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accountContext.js","sourceRoot":"","sources":["../../../src/domain/contexts/accountContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAa,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAWhE,MAAM,UAAU,mBAAmB,CAAC,KAAoB,EAAE,aAA4B,EAAE,UAAkB;IACxG,MAAM,qBAAqB,GAAG,0BAA0B,EAAE,CAAA;IAE1D,IAAI,aAAa,CAAC,wBAAwB,EAAE,CAAC;QAC3C,mBAAmB,CAAC,aAAa,EAAE,qBAAqB,EAAE,UAAU,mCAA2B,CAAA;IACjG,CAAC;IAED,KAAK,CAAC,QAAQ,6BAAqB,GAAG,EAAE;QACtC,MAAM,OAAO,GAAG,qBAAqB,CAAC,UAAU,EAAa,CAAA;QAE7D,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAC1C,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,OAAO;YACL,OAAO;SACR,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,qBAAqB,CAAA;AAC9B,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO,oBAAoB,CAAC,SAAS,EAAE;QACrC,gBAAgB,EAAE;YAChB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;YACtC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzB;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { AbstractHooks } from '../../tools/abstractHooks';
2
+ import type { Configuration } from '../configuration';
3
+ export declare function startGlobalContext(hooks: AbstractHooks, configuration: Configuration, productKey: string, useContextNamespace: boolean): {
4
+ getContext: () => import("../..").Context;
5
+ setContext: (newContext: unknown) => void;
6
+ setContextProperty: (key: string, property: any) => void;
7
+ removeContextProperty: (key: string) => void;
8
+ clearContext: () => void;
9
+ changeObservable: import("../..").Observable<void>;
10
+ };
11
+ export declare function buildGlobalContextManager(): {
12
+ getContext: () => import("../..").Context;
13
+ setContext: (newContext: unknown) => void;
14
+ setContextProperty: (key: string, property: any) => void;
15
+ removeContextProperty: (key: string) => void;
16
+ clearContext: () => void;
17
+ changeObservable: import("../..").Observable<void>;
18
+ };
@@ -0,0 +1,17 @@
1
+ import { storeContextManager } from '../context/storeContextManager';
2
+ import { createContextManager } from '../context/contextManager';
3
+ export function startGlobalContext(hooks, configuration, productKey, useContextNamespace) {
4
+ const globalContextManager = buildGlobalContextManager();
5
+ if (configuration.storeContextsAcrossPages) {
6
+ storeContextManager(configuration, globalContextManager, productKey, 2 /* CustomerDataType.GlobalContext */);
7
+ }
8
+ hooks.register(0 /* HookNames.Assemble */, () => {
9
+ const context = globalContextManager.getContext();
10
+ return useContextNamespace ? { context } : context;
11
+ });
12
+ return globalContextManager;
13
+ }
14
+ export function buildGlobalContextManager() {
15
+ return createContextManager('global context');
16
+ }
17
+ //# sourceMappingURL=globalContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalContext.js","sourceRoot":"","sources":["../../../src/domain/contexts/globalContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAGhE,MAAM,UAAU,kBAAkB,CAChC,KAAoB,EACpB,aAA4B,EAC5B,UAAkB,EAClB,mBAA4B;IAE5B,MAAM,oBAAoB,GAAG,yBAAyB,EAAE,CAAA;IAExD,IAAI,aAAa,CAAC,wBAAwB,EAAE,CAAC;QAC3C,mBAAmB,CAAC,aAAa,EAAE,oBAAoB,EAAE,UAAU,yCAAiC,CAAA;IACtG,CAAC;IAED,KAAK,CAAC,QAAQ,6BAAqB,GAAG,EAAE;QACtC,MAAM,OAAO,GAAG,oBAAoB,CAAC,UAAU,EAAE,CAAA;QACjD,OAAO,mBAAmB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;IACpD,CAAC,CAAC,CAAA;IAEF,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;AAC/C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Context } from '../../tools/serialisation/context';
2
+ export interface RumInternalContext extends Context {
3
+ application_id: string;
4
+ session_id: string | undefined;
5
+ view?: {
6
+ id: string;
7
+ url: string;
8
+ referrer: string;
9
+ name?: string;
10
+ };
11
+ user_action?: {
12
+ id: string | string[];
13
+ };
14
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rumInternalContext.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rumInternalContext.type.js","sourceRoot":"","sources":["../../../src/domain/contexts/rumInternalContext.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { AbstractHooks } from '../../tools/abstractHooks';
2
+ import type { Configuration } from '../configuration';
3
+ import type { RelativeTime } from '../../tools/utils/timeUtils';
4
+ export interface User {
5
+ id?: string | undefined;
6
+ email?: string | undefined;
7
+ name?: string | undefined;
8
+ [key: string]: unknown;
9
+ }
10
+ export declare function startUserContext(hooks: AbstractHooks, configuration: Configuration, sessionManager: {
11
+ findTrackedSession: (startTime?: RelativeTime) => {
12
+ anonymousId?: string;
13
+ } | undefined;
14
+ }, productKey: string): {
15
+ getContext: () => import("../..").Context;
16
+ setContext: (newContext: unknown) => void;
17
+ setContextProperty: (key: string, property: any) => void;
18
+ removeContextProperty: (key: string) => void;
19
+ clearContext: () => void;
20
+ changeObservable: import("../..").Observable<void>;
21
+ };
22
+ export declare function buildUserContextManager(): {
23
+ getContext: () => import("../..").Context;
24
+ setContext: (newContext: unknown) => void;
25
+ setContextProperty: (key: string, property: any) => void;
26
+ removeContextProperty: (key: string) => void;
27
+ clearContext: () => void;
28
+ changeObservable: import("../..").Observable<void>;
29
+ };
@@ -0,0 +1,41 @@
1
+ import { storeContextManager } from '../context/storeContextManager';
2
+ import { SKIPPED } from '../../tools/abstractHooks';
3
+ import { createContextManager } from '../context/contextManager';
4
+ import { isEmptyObject } from '../../tools/utils/objectUtils';
5
+ export function startUserContext(hooks, configuration, sessionManager, productKey) {
6
+ const userContextManager = buildUserContextManager();
7
+ if (configuration.storeContextsAcrossPages) {
8
+ storeContextManager(configuration, userContextManager, productKey, 1 /* CustomerDataType.User */);
9
+ }
10
+ hooks.register(0 /* HookNames.Assemble */, ({ eventType, startTime }) => {
11
+ const user = userContextManager.getContext();
12
+ const session = sessionManager.findTrackedSession(startTime);
13
+ if (session && session.anonymousId && !user.anonymous_id && !!configuration.trackAnonymousUser) {
14
+ user.anonymous_id = session.anonymousId;
15
+ }
16
+ if (isEmptyObject(user)) {
17
+ return SKIPPED;
18
+ }
19
+ return {
20
+ type: eventType,
21
+ usr: user,
22
+ };
23
+ });
24
+ hooks.register(1 /* HookNames.AssembleTelemetry */, ({ startTime }) => {
25
+ var _a;
26
+ return ({
27
+ anonymous_id: (_a = sessionManager.findTrackedSession(startTime)) === null || _a === void 0 ? void 0 : _a.anonymousId,
28
+ });
29
+ });
30
+ return userContextManager;
31
+ }
32
+ export function buildUserContextManager() {
33
+ return createContextManager('user', {
34
+ propertiesConfig: {
35
+ id: { type: 'string' },
36
+ name: { type: 'string' },
37
+ email: { type: 'string' },
38
+ },
39
+ });
40
+ }
41
+ //# sourceMappingURL=userContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userContext.js","sourceRoot":"","sources":["../../../src/domain/cont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xE,CAAC,CAAA;KAAA,CAAC,CAAA;IAEH,OAAO,kBAAkB,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,oBAAoB,CAAC,MAAM,EAAE;QAClC,gBAAgB,EAAE;YAChB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { Encoder } from '../../tools/encoder';
2
+ import type { Uint8ArrayBuffer } from '../../tools/utils/byteUtils';
3
+ export type DeflateWorkerAction = {
4
+ action: 'init';
5
+ } | {
6
+ action: 'write';
7
+ id: number;
8
+ streamId: number;
9
+ data: string;
10
+ } | {
11
+ action: 'reset';
12
+ streamId: number;
13
+ };
14
+ export type DeflateWorkerResponse = {
15
+ type: 'initialized';
16
+ version: string;
17
+ } | {
18
+ type: 'wrote';
19
+ id: number;
20
+ streamId: number;
21
+ result: Uint8ArrayBuffer;
22
+ trailer: Uint8ArrayBuffer;
23
+ additionalBytesCount: number;
24
+ } | {
25
+ type: 'errored';
26
+ streamId?: number;
27
+ error: Error | string;
28
+ };
29
+ export interface DeflateWorker extends Worker {
30
+ postMessage(message: DeflateWorkerAction): void;
31
+ }
32
+ export type DeflateEncoder = Encoder<Uint8ArrayBuffer> & {
33
+ stop: () => void;
34
+ };
35
+ export declare const enum DeflateEncoderStreamId {
36
+ REPLAY = 1,
37
+ RUM = 2,
38
+ TELEMETRY = 4,
39
+ PROFILING = 6
40
+ }