@openobserve/browser-core 0.2.11-rc1 → 0.2.11

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 (393) hide show
  1. package/cjs/boot/init.js +1 -1
  2. package/cjs/boot/init.js.map +1 -1
  3. package/cjs/browser/addEventListener.d.ts +4 -12
  4. package/cjs/browser/addEventListener.js +8 -50
  5. package/cjs/browser/addEventListener.js.map +1 -1
  6. package/cjs/browser/cookie.d.ts +0 -7
  7. package/cjs/browser/cookie.js +2 -19
  8. package/cjs/browser/cookie.js.map +1 -1
  9. package/cjs/browser/fetchObservable.js +19 -14
  10. package/cjs/browser/fetchObservable.js.map +1 -1
  11. package/cjs/browser/pageExitObservable.js +7 -6
  12. package/cjs/browser/pageExitObservable.js.map +1 -1
  13. package/cjs/browser/runOnReadyState.js +1 -1
  14. package/cjs/browser/runOnReadyState.js.map +1 -1
  15. package/cjs/browser/xhrObservable.d.ts +2 -1
  16. package/cjs/browser/xhrObservable.js +34 -26
  17. package/cjs/browser/xhrObservable.js.map +1 -1
  18. package/cjs/domain/configuration/configuration.d.ts +12 -17
  19. package/cjs/domain/configuration/configuration.js +9 -8
  20. package/cjs/domain/configuration/configuration.js.map +1 -1
  21. package/cjs/domain/configuration/endpointBuilder.d.ts +10 -6
  22. package/cjs/domain/configuration/endpointBuilder.js +33 -23
  23. package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
  24. package/cjs/domain/configuration/index.d.ts +1 -2
  25. package/cjs/domain/configuration/index.js +1 -3
  26. package/cjs/domain/configuration/index.js.map +1 -1
  27. package/cjs/domain/configuration/tags.js.map +1 -1
  28. package/cjs/domain/configuration/transportConfiguration.js +1 -1
  29. package/cjs/domain/configuration/transportConfiguration.js.map +1 -1
  30. package/cjs/domain/console/consoleObservable.js +7 -4
  31. package/cjs/domain/console/consoleObservable.js.map +1 -1
  32. package/cjs/domain/deflate/index.d.ts +1 -0
  33. package/cjs/domain/{connectivity → deflate}/index.js +1 -1
  34. package/cjs/domain/deflate/index.js.map +1 -0
  35. package/cjs/domain/deflate/types.d.ts +26 -0
  36. package/cjs/domain/error/error.d.ts +1 -1
  37. package/cjs/domain/error/error.js +3 -3
  38. package/cjs/domain/error/error.js.map +1 -1
  39. package/cjs/domain/error/error.types.d.ts +2 -2
  40. package/cjs/domain/error/error.types.js.map +1 -1
  41. package/cjs/domain/error/trackRuntimeError.d.ts +0 -8
  42. package/cjs/domain/error/trackRuntimeError.js +6 -39
  43. package/cjs/domain/error/trackRuntimeError.js.map +1 -1
  44. package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
  45. package/cjs/domain/report/browser.types.d.ts +0 -10
  46. package/cjs/domain/report/reportObservable.d.ts +0 -2
  47. package/cjs/domain/report/reportObservable.js +7 -7
  48. package/cjs/domain/report/reportObservable.js.map +1 -1
  49. package/cjs/domain/session/oldCookiesMigration.js +4 -4
  50. package/cjs/domain/session/oldCookiesMigration.js.map +1 -1
  51. package/cjs/domain/session/sessionManager.js +2 -2
  52. package/cjs/domain/session/sessionManager.js.map +1 -1
  53. package/cjs/domain/session/sessionState.js.map +1 -1
  54. package/cjs/domain/session/sessionStore.js.map +1 -1
  55. package/cjs/domain/session/sessionStoreOperations.d.ts +5 -0
  56. package/cjs/domain/session/sessionStoreOperations.js +14 -6
  57. package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
  58. package/cjs/domain/session/storeStrategies/sessionInCookie.js +2 -13
  59. package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
  60. package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
  61. package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
  62. package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
  63. package/cjs/domain/synthetics/syntheticsWorkerValues.js +3 -3
  64. package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
  65. package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -4
  66. package/cjs/domain/telemetry/telemetry.d.ts +1 -5
  67. package/cjs/domain/telemetry/telemetry.js +6 -17
  68. package/cjs/domain/telemetry/telemetry.js.map +1 -1
  69. package/cjs/domain/telemetry/telemetryEvent.types.d.ts +2 -18
  70. package/cjs/domain/tracekit/computeStackTrace.d.ts +5 -0
  71. package/cjs/domain/{error → tracekit}/computeStackTrace.js +4 -28
  72. package/cjs/domain/tracekit/computeStackTrace.js.map +1 -0
  73. package/cjs/domain/tracekit/index.d.ts +3 -0
  74. package/cjs/domain/tracekit/index.js +8 -0
  75. package/cjs/domain/tracekit/index.js.map +1 -0
  76. package/cjs/domain/tracekit/tracekit.d.ts +35 -0
  77. package/cjs/domain/tracekit/tracekit.js +95 -0
  78. package/cjs/domain/tracekit/tracekit.js.map +1 -0
  79. package/cjs/domain/tracekit/types.d.ts +44 -0
  80. package/cjs/domain/{context/contextConstants.js → tracekit/types.js} +1 -1
  81. package/cjs/domain/tracekit/types.js.map +1 -0
  82. package/cjs/domain/user/user.js.map +1 -1
  83. package/cjs/index.d.ts +63 -0
  84. package/cjs/index.js +155 -0
  85. package/cjs/index.js.map +1 -0
  86. package/cjs/tools/abstractLifeCycle.js.map +1 -1
  87. package/cjs/tools/boundedBuffer.js.map +1 -1
  88. package/cjs/tools/catchUserErrors.js.map +1 -1
  89. package/cjs/tools/display.d.ts +2 -2
  90. package/cjs/tools/display.js +17 -13
  91. package/cjs/tools/display.js.map +1 -1
  92. package/cjs/tools/experimentalFeatures.d.ts +5 -3
  93. package/cjs/tools/experimentalFeatures.js +4 -2
  94. package/cjs/tools/experimentalFeatures.js.map +1 -1
  95. package/cjs/tools/getGlobalObject.js.map +1 -1
  96. package/cjs/tools/getZoneJsOriginalValue.js.map +1 -1
  97. package/cjs/tools/instrumentMethod.d.ts +10 -50
  98. package/cjs/tools/instrumentMethod.js +36 -59
  99. package/cjs/tools/instrumentMethod.js.map +1 -1
  100. package/cjs/tools/matchOption.js.map +1 -1
  101. package/cjs/tools/mergeInto.js.map +1 -1
  102. package/cjs/tools/monitor.d.ts +2 -1
  103. package/cjs/tools/monitor.js +6 -6
  104. package/cjs/tools/monitor.js.map +1 -1
  105. package/cjs/tools/observable.d.ts +1 -1
  106. package/cjs/tools/observable.js +3 -2
  107. package/cjs/tools/observable.js.map +1 -1
  108. package/cjs/tools/readBytesFromStream.js.map +1 -1
  109. package/cjs/tools/sendToExtension.js.map +1 -1
  110. package/cjs/tools/serialisation/contextManager.d.ts +21 -0
  111. package/cjs/tools/serialisation/contextManager.js +70 -0
  112. package/cjs/tools/serialisation/contextManager.js.map +1 -0
  113. package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
  114. package/cjs/tools/serialisation/heavyCustomerDataWarning.js +18 -0
  115. package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
  116. package/cjs/tools/serialisation/jsonStringify.d.ts +2 -1
  117. package/cjs/tools/serialisation/jsonStringify.js.map +1 -1
  118. package/cjs/tools/serialisation/sanitize.js.map +1 -1
  119. package/cjs/tools/utils/browserDetection.d.ts +0 -8
  120. package/cjs/tools/utils/browserDetection.js +3 -33
  121. package/cjs/tools/utils/browserDetection.js.map +1 -1
  122. package/cjs/tools/utils/byteUtils.js.map +1 -1
  123. package/cjs/tools/utils/functionUtils.js.map +1 -1
  124. package/cjs/tools/utils/objectUtils.js.map +1 -1
  125. package/cjs/tools/utils/polyfills.js.map +1 -1
  126. package/cjs/tools/utils/responseUtils.js.map +1 -1
  127. package/cjs/tools/utils/stringUtils.d.ts +0 -1
  128. package/cjs/tools/utils/stringUtils.js +4 -31
  129. package/cjs/tools/utils/stringUtils.js.map +1 -1
  130. package/cjs/tools/utils/timeUtils.js.map +1 -1
  131. package/cjs/tools/utils/typeUtils.js.map +1 -1
  132. package/cjs/tools/utils/urlPolyfill.js.map +1 -1
  133. package/cjs/tools/valueHistory.js.map +1 -1
  134. package/cjs/transport/batch.d.ts +3 -5
  135. package/cjs/transport/batch.js +29 -73
  136. package/cjs/transport/batch.js.map +1 -1
  137. package/cjs/transport/eventBridge.js.map +1 -1
  138. package/cjs/transport/flushController.d.ts +2 -12
  139. package/cjs/transport/flushController.js +7 -22
  140. package/cjs/transport/flushController.js.map +1 -1
  141. package/cjs/transport/httpRequest.d.ts +2 -3
  142. package/cjs/transport/httpRequest.js +17 -21
  143. package/cjs/transport/httpRequest.js.map +1 -1
  144. package/cjs/transport/sendWithRetryStrategy.d.ts +2 -2
  145. package/cjs/transport/sendWithRetryStrategy.js +9 -9
  146. package/cjs/transport/sendWithRetryStrategy.js.map +1 -1
  147. package/cjs/transport/startBatchWithReplica.d.ts +4 -9
  148. package/cjs/transport/startBatchWithReplica.js +4 -9
  149. package/cjs/transport/startBatchWithReplica.js.map +1 -1
  150. package/esm/boot/init.js +1 -1
  151. package/esm/boot/init.js.map +1 -1
  152. package/esm/browser/addEventListener.d.ts +4 -12
  153. package/esm/browser/addEventListener.js +7 -49
  154. package/esm/browser/addEventListener.js.map +1 -1
  155. package/esm/browser/cookie.d.ts +0 -7
  156. package/esm/browser/cookie.js +2 -17
  157. package/esm/browser/cookie.js.map +1 -1
  158. package/esm/browser/fetchObservable.js +20 -15
  159. package/esm/browser/fetchObservable.js.map +1 -1
  160. package/esm/browser/pageExitObservable.js +8 -7
  161. package/esm/browser/pageExitObservable.js.map +1 -1
  162. package/esm/browser/runOnReadyState.js +2 -2
  163. package/esm/browser/runOnReadyState.js.map +1 -1
  164. package/esm/browser/xhrObservable.d.ts +2 -1
  165. package/esm/browser/xhrObservable.js +36 -28
  166. package/esm/browser/xhrObservable.js.map +1 -1
  167. package/esm/domain/configuration/configuration.d.ts +12 -17
  168. package/esm/domain/configuration/configuration.js +9 -8
  169. package/esm/domain/configuration/configuration.js.map +1 -1
  170. package/esm/domain/configuration/endpointBuilder.d.ts +10 -6
  171. package/esm/domain/configuration/endpointBuilder.js +32 -22
  172. package/esm/domain/configuration/endpointBuilder.js.map +1 -1
  173. package/esm/domain/configuration/index.d.ts +1 -2
  174. package/esm/domain/configuration/index.js +0 -1
  175. package/esm/domain/configuration/index.js.map +1 -1
  176. package/esm/domain/configuration/tags.js.map +1 -1
  177. package/esm/domain/configuration/transportConfiguration.js +1 -1
  178. package/esm/domain/configuration/transportConfiguration.js.map +1 -1
  179. package/esm/domain/console/consoleObservable.js +5 -2
  180. package/esm/domain/console/consoleObservable.js.map +1 -1
  181. package/esm/domain/deflate/types.d.ts +0 -12
  182. package/esm/domain/error/error.d.ts +1 -1
  183. package/esm/domain/error/error.js +1 -1
  184. package/esm/domain/error/error.js.map +1 -1
  185. package/esm/domain/error/error.types.d.ts +2 -2
  186. package/esm/domain/error/error.types.js.map +1 -1
  187. package/esm/domain/error/trackRuntimeError.d.ts +0 -8
  188. package/esm/domain/error/trackRuntimeError.js +4 -35
  189. package/esm/domain/error/trackRuntimeError.js.map +1 -1
  190. package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
  191. package/esm/domain/report/browser.types.d.ts +0 -10
  192. package/esm/domain/report/reportObservable.d.ts +0 -2
  193. package/esm/domain/report/reportObservable.js +8 -8
  194. package/esm/domain/report/reportObservable.js.map +1 -1
  195. package/esm/domain/session/oldCookiesMigration.js +5 -5
  196. package/esm/domain/session/oldCookiesMigration.js.map +1 -1
  197. package/esm/domain/session/sessionManager.js +3 -3
  198. package/esm/domain/session/sessionManager.js.map +1 -1
  199. package/esm/domain/session/sessionState.js.map +1 -1
  200. package/esm/domain/session/sessionStore.js.map +1 -1
  201. package/esm/domain/session/sessionStoreOperations.d.ts +5 -0
  202. package/esm/domain/session/sessionStoreOperations.js +12 -5
  203. package/esm/domain/session/sessionStoreOperations.js.map +1 -1
  204. package/esm/domain/session/storeStrategies/sessionInCookie.js +2 -13
  205. package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
  206. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
  207. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
  208. package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
  209. package/esm/domain/synthetics/syntheticsWorkerValues.js +4 -4
  210. package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
  211. package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -4
  212. package/esm/domain/telemetry/telemetry.d.ts +1 -5
  213. package/esm/domain/telemetry/telemetry.js +5 -16
  214. package/esm/domain/telemetry/telemetry.js.map +1 -1
  215. package/esm/domain/telemetry/telemetryEvent.types.d.ts +2 -18
  216. package/esm/domain/tracekit/computeStackTrace.d.ts +5 -0
  217. package/esm/domain/{error → tracekit}/computeStackTrace.js +3 -26
  218. package/esm/domain/tracekit/computeStackTrace.js.map +1 -0
  219. package/esm/domain/tracekit/index.d.ts +3 -0
  220. package/esm/domain/tracekit/index.js +3 -0
  221. package/esm/domain/tracekit/index.js.map +1 -0
  222. package/esm/domain/tracekit/tracekit.d.ts +35 -0
  223. package/esm/domain/tracekit/tracekit.js +91 -0
  224. package/esm/domain/tracekit/tracekit.js.map +1 -0
  225. package/esm/domain/tracekit/types.d.ts +44 -0
  226. package/esm/domain/tracekit/types.js +2 -0
  227. package/esm/domain/tracekit/types.js.map +1 -0
  228. package/esm/domain/user/user.js.map +1 -1
  229. package/esm/index.d.ts +5 -9
  230. package/esm/index.js +5 -8
  231. package/esm/index.js.map +1 -1
  232. package/esm/tools/abstractLifeCycle.js.map +1 -1
  233. package/esm/tools/boundedBuffer.js.map +1 -1
  234. package/esm/tools/catchUserErrors.js.map +1 -1
  235. package/esm/tools/display.d.ts +2 -2
  236. package/esm/tools/display.js +15 -12
  237. package/esm/tools/display.js.map +1 -1
  238. package/esm/tools/experimentalFeatures.d.ts +5 -3
  239. package/esm/tools/experimentalFeatures.js +4 -2
  240. package/esm/tools/experimentalFeatures.js.map +1 -1
  241. package/esm/tools/getGlobalObject.js.map +1 -1
  242. package/esm/tools/getZoneJsOriginalValue.js.map +1 -1
  243. package/esm/tools/instrumentMethod.d.ts +10 -50
  244. package/esm/tools/instrumentMethod.js +34 -58
  245. package/esm/tools/instrumentMethod.js.map +1 -1
  246. package/esm/tools/matchOption.js.map +1 -1
  247. package/esm/tools/mergeInto.js.map +1 -1
  248. package/esm/tools/monitor.d.ts +2 -1
  249. package/esm/tools/monitor.js +7 -7
  250. package/esm/tools/monitor.js.map +1 -1
  251. package/esm/tools/observable.d.ts +1 -1
  252. package/esm/tools/observable.js +3 -2
  253. package/esm/tools/observable.js.map +1 -1
  254. package/esm/tools/readBytesFromStream.js.map +1 -1
  255. package/esm/tools/sendToExtension.js.map +1 -1
  256. package/esm/tools/serialisation/contextManager.d.ts +21 -0
  257. package/esm/tools/serialisation/contextManager.js +66 -0
  258. package/esm/tools/serialisation/contextManager.js.map +1 -0
  259. package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
  260. package/esm/tools/serialisation/heavyCustomerDataWarning.js +14 -0
  261. package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
  262. package/esm/tools/serialisation/jsonStringify.d.ts +2 -1
  263. package/esm/tools/serialisation/jsonStringify.js.map +1 -1
  264. package/esm/tools/serialisation/sanitize.js.map +1 -1
  265. package/esm/tools/utils/browserDetection.d.ts +0 -8
  266. package/esm/tools/utils/browserDetection.js +2 -30
  267. package/esm/tools/utils/browserDetection.js.map +1 -1
  268. package/esm/tools/utils/byteUtils.js.map +1 -1
  269. package/esm/tools/utils/functionUtils.js.map +1 -1
  270. package/esm/tools/utils/objectUtils.js.map +1 -1
  271. package/esm/tools/utils/polyfills.js.map +1 -1
  272. package/esm/tools/utils/responseUtils.js.map +1 -1
  273. package/esm/tools/utils/stringUtils.d.ts +0 -1
  274. package/esm/tools/utils/stringUtils.js +3 -29
  275. package/esm/tools/utils/stringUtils.js.map +1 -1
  276. package/esm/tools/utils/timeUtils.js.map +1 -1
  277. package/esm/tools/utils/typeUtils.js.map +1 -1
  278. package/esm/tools/utils/urlPolyfill.js.map +1 -1
  279. package/esm/tools/valueHistory.js.map +1 -1
  280. package/esm/transport/batch.d.ts +3 -5
  281. package/esm/transport/batch.js +29 -73
  282. package/esm/transport/batch.js.map +1 -1
  283. package/esm/transport/eventBridge.js.map +1 -1
  284. package/esm/transport/flushController.d.ts +2 -12
  285. package/esm/transport/flushController.js +7 -22
  286. package/esm/transport/flushController.js.map +1 -1
  287. package/esm/transport/httpRequest.d.ts +2 -3
  288. package/esm/transport/httpRequest.js +17 -21
  289. package/esm/transport/httpRequest.js.map +1 -1
  290. package/esm/transport/sendWithRetryStrategy.d.ts +2 -2
  291. package/esm/transport/sendWithRetryStrategy.js +9 -9
  292. package/esm/transport/sendWithRetryStrategy.js.map +1 -1
  293. package/esm/transport/startBatchWithReplica.d.ts +4 -9
  294. package/esm/transport/startBatchWithReplica.js +4 -9
  295. package/esm/transport/startBatchWithReplica.js.map +1 -1
  296. package/package.json +1 -1
  297. package/src/browser/addEventListener.ts +31 -37
  298. package/src/browser/cookie.ts +2 -21
  299. package/src/browser/fetchObservable.ts +25 -21
  300. package/src/browser/pageExitObservable.ts +3 -1
  301. package/src/browser/xhrObservable.ts +37 -31
  302. package/src/domain/configuration/configuration.ts +22 -24
  303. package/src/domain/configuration/endpointBuilder.ts +46 -33
  304. package/src/domain/configuration/index.ts +1 -2
  305. package/src/domain/configuration/transportConfiguration.ts +1 -1
  306. package/src/domain/console/consoleObservable.ts +7 -3
  307. package/src/domain/deflate/types.ts +0 -14
  308. package/src/domain/error/error.ts +2 -2
  309. package/src/domain/error/error.types.ts +2 -11
  310. package/src/domain/error/trackRuntimeError.ts +12 -44
  311. package/src/domain/report/browser.types.ts +0 -12
  312. package/src/domain/report/reportObservable.ts +6 -8
  313. package/src/domain/session/oldCookiesMigration.ts +5 -5
  314. package/src/domain/session/sessionStoreOperations.ts +13 -5
  315. package/src/domain/session/storeStrategies/sessionInCookie.ts +2 -13
  316. package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +0 -1
  317. package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +0 -1
  318. package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
  319. package/src/domain/telemetry/rawTelemetryEvent.types.ts +0 -5
  320. package/src/domain/telemetry/telemetry.ts +7 -22
  321. package/src/domain/telemetry/telemetryEvent.types.ts +2 -18
  322. package/src/domain/{error → tracekit}/computeStackTrace.ts +4 -49
  323. package/src/domain/tracekit/index.ts +3 -0
  324. package/src/domain/tracekit/tracekit.ts +96 -0
  325. package/src/domain/tracekit/types.ts +47 -0
  326. package/src/index.ts +7 -13
  327. package/src/tools/display.ts +13 -14
  328. package/src/tools/experimentalFeatures.ts +4 -2
  329. package/src/tools/instrumentMethod.ts +59 -103
  330. package/src/tools/mergeInto.ts +16 -16
  331. package/src/tools/monitor.ts +5 -5
  332. package/src/tools/observable.ts +5 -3
  333. package/src/tools/serialisation/contextManager.ts +79 -0
  334. package/src/tools/serialisation/heavyCustomerDataWarning.ts +26 -0
  335. package/src/tools/utils/browserDetection.ts +2 -43
  336. package/src/tools/utils/polyfills.ts +4 -1
  337. package/src/tools/utils/stringUtils.ts +4 -30
  338. package/src/transport/batch.ts +31 -86
  339. package/src/transport/flushController.ts +7 -22
  340. package/src/transport/httpRequest.ts +16 -23
  341. package/src/transport/sendWithRetryStrategy.ts +10 -10
  342. package/src/transport/startBatchWithReplica.ts +6 -22
  343. package/cjs/domain/connectivity/connectivity.d.ts +0 -13
  344. package/cjs/domain/connectivity/connectivity.js +0 -14
  345. package/cjs/domain/connectivity/connectivity.js.map +0 -1
  346. package/cjs/domain/connectivity/index.d.ts +0 -1
  347. package/cjs/domain/connectivity/index.js.map +0 -1
  348. package/cjs/domain/context/contextConstants.d.ts +0 -5
  349. package/cjs/domain/context/contextConstants.js.map +0 -1
  350. package/cjs/domain/context/contextManager.d.ts +0 -12
  351. package/cjs/domain/context/contextManager.js +0 -43
  352. package/cjs/domain/context/contextManager.js.map +0 -1
  353. package/cjs/domain/context/customerDataTracker.d.ts +0 -45
  354. package/cjs/domain/context/customerDataTracker.js +0 -107
  355. package/cjs/domain/context/customerDataTracker.js.map +0 -1
  356. package/cjs/domain/context/storeContextManager.d.ts +0 -6
  357. package/cjs/domain/context/storeContextManager.js +0 -38
  358. package/cjs/domain/context/storeContextManager.js.map +0 -1
  359. package/cjs/domain/error/computeStackTrace.d.ts +0 -33
  360. package/cjs/domain/error/computeStackTrace.js.map +0 -1
  361. package/cjs/tools/encoder.d.ts +0 -53
  362. package/cjs/tools/encoder.js +0 -41
  363. package/cjs/tools/encoder.js.map +0 -1
  364. package/esm/domain/connectivity/connectivity.d.ts +0 -13
  365. package/esm/domain/connectivity/connectivity.js +0 -10
  366. package/esm/domain/connectivity/connectivity.js.map +0 -1
  367. package/esm/domain/connectivity/index.d.ts +0 -1
  368. package/esm/domain/connectivity/index.js +0 -2
  369. package/esm/domain/connectivity/index.js.map +0 -1
  370. package/esm/domain/context/contextConstants.d.ts +0 -5
  371. package/esm/domain/context/contextConstants.js +0 -2
  372. package/esm/domain/context/contextConstants.js.map +0 -1
  373. package/esm/domain/context/contextManager.d.ts +0 -12
  374. package/esm/domain/context/contextManager.js +0 -39
  375. package/esm/domain/context/contextManager.js.map +0 -1
  376. package/esm/domain/context/customerDataTracker.d.ts +0 -45
  377. package/esm/domain/context/customerDataTracker.js +0 -102
  378. package/esm/domain/context/customerDataTracker.js.map +0 -1
  379. package/esm/domain/context/storeContextManager.d.ts +0 -6
  380. package/esm/domain/context/storeContextManager.js +0 -32
  381. package/esm/domain/context/storeContextManager.js.map +0 -1
  382. package/esm/domain/error/computeStackTrace.d.ts +0 -33
  383. package/esm/domain/error/computeStackTrace.js.map +0 -1
  384. package/esm/tools/encoder.d.ts +0 -53
  385. package/esm/tools/encoder.js +0 -37
  386. package/esm/tools/encoder.js.map +0 -1
  387. package/src/domain/connectivity/connectivity.ts +0 -27
  388. package/src/domain/connectivity/index.ts +0 -1
  389. package/src/domain/context/contextConstants.ts +0 -5
  390. package/src/domain/context/contextManager.ts +0 -48
  391. package/src/domain/context/customerDataTracker.ts +0 -134
  392. package/src/domain/context/storeContextManager.ts +0 -51
  393. package/src/tools/encoder.ts +0 -102
@@ -2,77 +2,30 @@ import { setTimeout } from './timer'
2
2
  import { callMonitored } from './monitor'
3
3
  import { noop } from './utils/functionUtils'
4
4
 
5
- /**
6
- * Object passed to the callback of an instrumented method call. See `instrumentMethod` for more
7
- * info.
8
- */
9
- export type InstrumentedMethodCall<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET> = {
10
- /**
11
- * The target object on which the method was called.
12
- */
13
- target: TARGET
14
-
15
- /**
16
- * The parameters with which the method was called. To avoid having to clone the argument list
17
- * every time, this property is actually an instance of Argument, not Array, so not all methods
18
- * are available (like .forEach).
19
- *
20
- * Note: if needed, parameters can be mutated by the instrumentation
21
- */
22
- parameters: Parameters<TARGET[METHOD]>
23
-
24
- /**
25
- * Registers a callback that will be called after the original method is called, with the method
26
- * result passed as argument.
27
- */
28
- onPostCall: (callback: PostCallCallback<TARGET, METHOD>) => void
29
- }
30
-
31
- type PostCallCallback<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET> = (
32
- result: ReturnType<TARGET[METHOD]>
33
- ) => void
34
-
35
- /**
36
- * Instruments a method on a object, calling the given callback before the original method is
37
- * invoked. The callback receives an object with information about the method call.
38
- *
39
- * Note: it is generally better to instrument methods that are "owned" by the object instead of ones
40
- * that are inherited from the prototype chain. Example:
41
- * * do: `instrumentMethod(Array.prototype, 'push', ...)`
42
- * * don't: `instrumentMethod([], 'push', ...)`
43
- *
44
- * @example
45
- *
46
- * instrumentMethod(window, 'fetch', ({ target, parameters, onPostCall }) => {
47
- * console.log('Before calling fetch on', target, 'with parameters', parameters)
48
- *
49
- * onPostCall((result) => {
50
- * console.log('After fetch calling on', target, 'with parameters', parameters, 'and result', result)
51
- * })
52
- * })
53
- */
54
- export function instrumentMethod<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET>(
55
- targetPrototype: TARGET,
5
+ export function instrumentMethod<OBJECT extends { [key: string]: any }, METHOD extends keyof OBJECT>(
6
+ object: OBJECT,
56
7
  method: METHOD,
57
- onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void
8
+ instrumentationFactory: (
9
+ original: OBJECT[METHOD]
10
+ ) => (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => ReturnType<OBJECT[METHOD]>
58
11
  ) {
59
- const original = targetPrototype[method]
12
+ const original = object[method]
60
13
 
61
- let instrumentation = createInstrumentedMethod(original, onPreCall)
14
+ let instrumentation = instrumentationFactory(original)
62
15
 
63
- const instrumentationWrapper = function (this: TARGET): ReturnType<TARGET[METHOD]> | undefined {
16
+ const instrumentationWrapper = function (this: OBJECT): ReturnType<OBJECT[METHOD]> | undefined {
64
17
  if (typeof instrumentation !== 'function') {
65
18
  return undefined
66
19
  }
67
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
68
- return instrumentation.apply(this, arguments as unknown as Parameters<TARGET[METHOD]>)
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
21
+ return instrumentation.apply(this, arguments as unknown as Parameters<OBJECT[METHOD]>)
69
22
  }
70
- targetPrototype[method] = instrumentationWrapper as TARGET[METHOD]
23
+ object[method] = instrumentationWrapper as OBJECT[METHOD]
71
24
 
72
25
  return {
73
26
  stop: () => {
74
- if (targetPrototype[method] === instrumentationWrapper) {
75
- targetPrototype[method] = original
27
+ if (object[method] === instrumentationWrapper) {
28
+ object[method] = original
76
29
  } else {
77
30
  instrumentation = original
78
31
  }
@@ -80,71 +33,74 @@ export function instrumentMethod<TARGET extends { [key: string]: any }, METHOD e
80
33
  }
81
34
  }
82
35
 
83
- function createInstrumentedMethod<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET>(
84
- original: TARGET[METHOD],
85
- onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void
86
- ): TARGET[METHOD] {
87
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
88
- return function (this: TARGET) {
89
- const parameters = arguments as unknown as Parameters<TARGET[METHOD]>
90
- let result
91
-
92
- let postCallCallback: PostCallCallback<TARGET, METHOD> | undefined
93
-
94
- callMonitored(onPreCall, null, [
95
- {
96
- target: this,
97
- parameters,
98
- onPostCall: (callback) => {
99
- postCallCallback = callback
100
- },
101
- },
102
- ])
103
-
104
- if (typeof original === 'function') {
105
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
106
- result = original.apply(this, parameters)
107
- }
108
-
109
- if (postCallCallback) {
110
- callMonitored(postCallCallback, null, [result])
111
- }
112
-
113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
114
- return result
115
- } as TARGET[METHOD]
36
+ export function instrumentMethodAndCallOriginal<OBJECT extends { [key: string]: any }, METHOD extends keyof OBJECT>(
37
+ object: OBJECT,
38
+ method: METHOD,
39
+ {
40
+ before,
41
+ after,
42
+ }: {
43
+ before?: (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => void
44
+ after?: (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => void
45
+ }
46
+ ) {
47
+ return instrumentMethod(
48
+ object,
49
+ method,
50
+ (original) =>
51
+ function () {
52
+ const args = arguments as unknown as Parameters<OBJECT[METHOD]>
53
+ let result
54
+
55
+ if (before) {
56
+ callMonitored(before, this, args)
57
+ }
58
+
59
+ if (typeof original === 'function') {
60
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
61
+ result = original.apply(this, args)
62
+ }
63
+
64
+ if (after) {
65
+ callMonitored(after, this, args)
66
+ }
67
+
68
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
69
+ return result
70
+ }
71
+ )
116
72
  }
117
73
 
118
- export function instrumentSetter<TARGET extends { [key: string]: any }, PROPERTY extends keyof TARGET>(
119
- targetPrototype: TARGET,
74
+ export function instrumentSetter<OBJECT extends { [key: string]: any }, PROPERTY extends keyof OBJECT>(
75
+ object: OBJECT,
120
76
  property: PROPERTY,
121
- after: (target: TARGET, value: TARGET[PROPERTY]) => void
77
+ after: (thisObject: OBJECT, value: OBJECT[PROPERTY]) => void
122
78
  ) {
123
- const originalDescriptor = Object.getOwnPropertyDescriptor(targetPrototype, property)
79
+ const originalDescriptor = Object.getOwnPropertyDescriptor(object, property)
124
80
  if (!originalDescriptor || !originalDescriptor.set || !originalDescriptor.configurable) {
125
81
  return { stop: noop }
126
82
  }
127
83
 
128
- let instrumentation = (target: TARGET, value: TARGET[PROPERTY]) => {
84
+ let instrumentation = (thisObject: OBJECT, value: OBJECT[PROPERTY]) => {
129
85
  // put hooked setter into event loop to avoid of set latency
130
86
  setTimeout(() => {
131
- after(target, value)
87
+ after(thisObject, value)
132
88
  }, 0)
133
89
  }
134
90
 
135
- const instrumentationWrapper = function (this: TARGET, value: TARGET[PROPERTY]) {
91
+ const instrumentationWrapper = function (this: OBJECT, value: OBJECT[PROPERTY]) {
136
92
  originalDescriptor.set!.call(this, value)
137
93
  instrumentation(this, value)
138
94
  }
139
95
 
140
- Object.defineProperty(targetPrototype, property, {
96
+ Object.defineProperty(object, property, {
141
97
  set: instrumentationWrapper,
142
98
  })
143
99
 
144
100
  return {
145
101
  stop: () => {
146
- if (Object.getOwnPropertyDescriptor(targetPrototype, property)?.set === instrumentationWrapper) {
147
- Object.defineProperty(targetPrototype, property, originalDescriptor)
102
+ if (Object.getOwnPropertyDescriptor(object, property)?.set === instrumentationWrapper) {
103
+ Object.defineProperty(object, property, originalDescriptor)
148
104
  } else {
149
105
  instrumentation = noop
150
106
  }
@@ -5,22 +5,22 @@ type Merged<TDestination, TSource> =
5
5
  TSource extends undefined
6
6
  ? TDestination
7
7
  : // case 2 - destination is undefined - return source
8
- TDestination extends undefined
9
- ? TSource
10
- : // case 3 - source is an array - see if it merges or overwrites
11
- TSource extends any[]
12
- ? TDestination extends any[]
13
- ? TDestination & TSource
14
- : TSource
15
- : // case 4 - source is an object - see if it merges or overwrites
16
- TSource extends object
17
- ? TDestination extends object
18
- ? TDestination extends any[]
19
- ? TSource
20
- : TDestination & TSource
21
- : TSource
22
- : // case 5 - cannot merge - return source
23
- TSource
8
+ TDestination extends undefined
9
+ ? TSource
10
+ : // case 3 - source is an array - see if it merges or overwrites
11
+ TSource extends any[]
12
+ ? TDestination extends any[]
13
+ ? TDestination & TSource
14
+ : TSource
15
+ : // case 4 - source is an object - see if it merges or overwrites
16
+ TSource extends object
17
+ ? TDestination extends object
18
+ ? TDestination extends any[]
19
+ ? TSource
20
+ : TDestination & TSource
21
+ : TSource
22
+ : // case 5 - cannot merge - return source
23
+ TSource
24
24
 
25
25
  /**
26
26
  * Iterate over source and affect its sub values into destination, recursively.
@@ -1,4 +1,4 @@
1
- import { display } from './display'
1
+ import { ConsoleApiName, display } from './display'
2
2
 
3
3
  let onMonitorErrorCollected: undefined | ((error: unknown) => void)
4
4
  let debugMode = false
@@ -50,19 +50,19 @@ export function callMonitored<T extends (...args: any[]) => any>(
50
50
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
51
51
  return fn.apply(context, args)
52
52
  } catch (e) {
53
- displayIfDebugEnabled(e)
53
+ displayIfDebugEnabled(ConsoleApiName.error, e)
54
54
  if (onMonitorErrorCollected) {
55
55
  try {
56
56
  onMonitorErrorCollected(e)
57
57
  } catch (e) {
58
- displayIfDebugEnabled(e)
58
+ displayIfDebugEnabled(ConsoleApiName.error, e)
59
59
  }
60
60
  }
61
61
  }
62
62
  }
63
63
 
64
- export function displayIfDebugEnabled(...args: any[]) {
64
+ export function displayIfDebugEnabled(api: ConsoleApiName, ...args: any[]) {
65
65
  if (debugMode) {
66
- display.error('[MONITOR]', ...args)
66
+ display(api, '[MONITOR]', ...args)
67
67
  }
68
68
  }
@@ -6,11 +6,11 @@ export class Observable<T> {
6
6
  private observers: Array<(data: T) => void> = []
7
7
  private onLastUnsubscribe?: () => void
8
8
 
9
- constructor(private onFirstSubscribe?: (observable: Observable<T>) => (() => void) | void) {}
9
+ constructor(private onFirstSubscribe?: () => (() => void) | void) {}
10
10
 
11
11
  subscribe(f: (data: T) => void): Subscription {
12
12
  if (!this.observers.length && this.onFirstSubscribe) {
13
- this.onLastUnsubscribe = this.onFirstSubscribe(this) || undefined
13
+ this.onLastUnsubscribe = this.onFirstSubscribe() || undefined
14
14
  }
15
15
  this.observers.push(f)
16
16
  return {
@@ -29,10 +29,12 @@ export class Observable<T> {
29
29
  }
30
30
 
31
31
  export function mergeObservables<T>(...observables: Array<Observable<T>>) {
32
- return new Observable<T>((globalObservable) => {
32
+ const globalObservable = new Observable<T>(() => {
33
33
  const subscriptions: Subscription[] = observables.map((observable) =>
34
34
  observable.subscribe((data) => globalObservable.notify(data))
35
35
  )
36
36
  return () => subscriptions.forEach((subscription) => subscription.unsubscribe())
37
37
  })
38
+
39
+ return globalObservable
38
40
  }
@@ -0,0 +1,79 @@
1
+ import { computeBytesCount } from '../utils/byteUtils'
2
+ import { throttle } from '../utils/functionUtils'
3
+ import { deepClone } from '../mergeInto'
4
+ import { getType } from '../utils/typeUtils'
5
+ import { jsonStringify } from './jsonStringify'
6
+ import { sanitize } from './sanitize'
7
+ import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'
8
+ import type { CustomerDataType } from './heavyCustomerDataWarning'
9
+ import type { Context, ContextValue } from './context'
10
+
11
+ export const BYTES_COMPUTATION_THROTTLING_DELAY = 200
12
+
13
+ export type ContextManager = ReturnType<typeof createContextManager>
14
+
15
+ export function createContextManager(customerDataType: CustomerDataType, computeBytesCountImpl = computeBytesCount) {
16
+ let context: Context = {}
17
+ let bytesCountCache: number
18
+ let alreadyWarned = false
19
+
20
+ // Throttle the bytes computation to minimize the impact on performance.
21
+ // Especially useful if the user call context APIs synchronously multiple times in a row
22
+ const { throttled: computeBytesCountThrottled } = throttle((context: Context) => {
23
+ bytesCountCache = computeBytesCountImpl(jsonStringify(context)!)
24
+ if (!alreadyWarned) {
25
+ alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, customerDataType)
26
+ }
27
+ }, BYTES_COMPUTATION_THROTTLING_DELAY)
28
+
29
+ const contextManager = {
30
+ getBytesCount: () => bytesCountCache,
31
+ /** @deprecated use getContext instead */
32
+ get: () => context,
33
+
34
+ /** @deprecated use setContextProperty instead */
35
+ add: (key: string, value: any) => {
36
+ context[key] = value as ContextValue
37
+ computeBytesCountThrottled(context)
38
+ },
39
+
40
+ /** @deprecated renamed to removeContextProperty */
41
+ remove: (key: string) => {
42
+ delete context[key]
43
+ computeBytesCountThrottled(context)
44
+ },
45
+
46
+ /** @deprecated use setContext instead */
47
+ set: (newContext: object) => {
48
+ context = newContext as Context
49
+ computeBytesCountThrottled(context)
50
+ },
51
+
52
+ getContext: () => deepClone(context),
53
+
54
+ setContext: (newContext: Context) => {
55
+ if (getType(newContext) === 'object') {
56
+ context = sanitize(newContext)
57
+ computeBytesCountThrottled(context)
58
+ } else {
59
+ contextManager.clearContext()
60
+ }
61
+ },
62
+
63
+ setContextProperty: (key: string, property: any) => {
64
+ context[key] = sanitize(property)
65
+ computeBytesCountThrottled(context)
66
+ },
67
+
68
+ removeContextProperty: (key: string) => {
69
+ delete context[key]
70
+ computeBytesCountThrottled(context)
71
+ },
72
+
73
+ clearContext: () => {
74
+ context = {}
75
+ bytesCountCache = 0
76
+ },
77
+ }
78
+ return contextManager
79
+ }
@@ -0,0 +1,26 @@
1
+ import { ONE_KIBI_BYTE } from '../utils/byteUtils'
2
+ import { display } from '../display'
3
+
4
+ // RUM and logs batch bytes limit is 16KB
5
+ // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
6
+ // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
7
+ export const CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE
8
+
9
+ export const enum CustomerDataType {
10
+ FeatureFlag = 'feature flag evaluation',
11
+ User = 'user',
12
+ GlobalContext = 'global context',
13
+ LoggerContext = 'logger context',
14
+ }
15
+
16
+ export function warnIfCustomerDataLimitReached(bytesCount: number, customerDataType: CustomerDataType): boolean {
17
+ if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
18
+ display.warn(
19
+ `The ${customerDataType} data exceeds the recommended ${
20
+ CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE
21
+ }KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-3kib-warning`
22
+ )
23
+ return true
24
+ }
25
+ return false
26
+ }
@@ -1,48 +1,7 @@
1
- // Exported only for tests
2
- export const enum Browser {
3
- IE,
4
- CHROMIUM,
5
- SAFARI,
6
- OTHER,
7
- }
8
-
9
1
  export function isIE() {
10
- return detectBrowserCached() === Browser.IE
2
+ return Boolean((document as any).documentMode)
11
3
  }
12
4
 
13
5
  export function isChromium() {
14
- return detectBrowserCached() === Browser.CHROMIUM
15
- }
16
-
17
- export function isSafari() {
18
- return detectBrowserCached() === Browser.SAFARI
19
- }
20
-
21
- let browserCache: Browser | undefined
22
- function detectBrowserCached() {
23
- return browserCache ?? (browserCache = detectBrowser())
24
- }
25
-
26
- // Exported only for tests
27
- export function detectBrowser(browserWindow: Window = window) {
28
- const userAgent = browserWindow.navigator.userAgent
29
- if ((browserWindow as any).chrome || /HeadlessChrome/.test(userAgent)) {
30
- return Browser.CHROMIUM
31
- }
32
-
33
- if (
34
- // navigator.vendor is deprecated, but it is the most resilient way we found to detect
35
- // "Apple maintained browsers" (AKA Safari). If one day it gets removed, we still have the
36
- // useragent test as a semi-working fallback.
37
- browserWindow.navigator.vendor?.indexOf('Apple') === 0 ||
38
- (/safari/i.test(userAgent) && !/chrome|android/i.test(userAgent))
39
- ) {
40
- return Browser.SAFARI
41
- }
42
-
43
- if ((browserWindow.document as any).documentMode) {
44
- return Browser.IE
45
- }
46
-
47
- return Browser.OTHER
6
+ return !!(window as any).chrome || /HeadlessChrome/.test(window.navigator.userAgent)
48
7
  }
@@ -27,7 +27,10 @@ export function find<T, S extends T>(
27
27
  predicate: (item: T, index: number) => item is S
28
28
  ): S | undefined
29
29
  export function find<T>(array: ArrayLike<T>, predicate: (item: T, index: number) => boolean): T | undefined
30
- export function find(array: ArrayLike<unknown>, predicate: (item: unknown, index: number) => boolean): unknown {
30
+ export function find(
31
+ array: ArrayLike<unknown>,
32
+ predicate: (item: unknown, index: number) => boolean
33
+ ): unknown | undefined {
31
34
  for (let i = 0; i < array.length; i += 1) {
32
35
  const item = array[i]
33
36
  if (predicate(item, i)) {
@@ -9,36 +9,10 @@ export function generateUUID(placeholder?: string): string {
9
9
  : `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(/[018]/g, generateUUID)
10
10
  }
11
11
 
12
- const COMMA_SEPARATED_KEY_VALUE = /([\w-]+)\s*=\s*([^;]+)/g
13
-
14
- export function findCommaSeparatedValue(rawString: string, name: string): string | undefined {
15
- COMMA_SEPARATED_KEY_VALUE.lastIndex = 0
16
- // eslint-disable-next-line no-constant-condition
17
- while (true) {
18
- const match = COMMA_SEPARATED_KEY_VALUE.exec(rawString)
19
- if (match) {
20
- if (match[1] === name) {
21
- return match[2]
22
- }
23
- } else {
24
- break
25
- }
26
- }
27
- }
28
-
29
- export function findCommaSeparatedValues(rawString: string): Map<string, string> {
30
- const result = new Map<string, string>()
31
- COMMA_SEPARATED_KEY_VALUE.lastIndex = 0
32
- // eslint-disable-next-line no-constant-condition
33
- while (true) {
34
- const match = COMMA_SEPARATED_KEY_VALUE.exec(rawString)
35
- if (match) {
36
- result.set(match[1], match[2])
37
- } else {
38
- break
39
- }
40
- }
41
- return result
12
+ export function findCommaSeparatedValue(rawString: string, name: string) {
13
+ const regex = new RegExp(`(?:^|;)\\s*${name}\\s*=\\s*([^;]+)`)
14
+ const matches = regex.exec(rawString)
15
+ return matches ? matches[1] : undefined
42
16
  }
43
17
 
44
18
  export function safeTruncate(candidate: string, length: number, suffix = '') {