@openobserve/browser-core 0.2.9 → 0.2.11-rc1

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 +12 -4
  4. package/cjs/browser/addEventListener.js +50 -8
  5. package/cjs/browser/addEventListener.js.map +1 -1
  6. package/cjs/browser/cookie.d.ts +7 -0
  7. package/cjs/browser/cookie.js +19 -2
  8. package/cjs/browser/cookie.js.map +1 -1
  9. package/cjs/browser/fetchObservable.js +14 -19
  10. package/cjs/browser/fetchObservable.js.map +1 -1
  11. package/cjs/browser/pageExitObservable.js +6 -7
  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 +1 -2
  16. package/cjs/browser/xhrObservable.js +26 -34
  17. package/cjs/browser/xhrObservable.js.map +1 -1
  18. package/cjs/domain/configuration/configuration.d.ts +17 -12
  19. package/cjs/domain/configuration/configuration.js +8 -9
  20. package/cjs/domain/configuration/configuration.js.map +1 -1
  21. package/cjs/domain/configuration/endpointBuilder.d.ts +6 -10
  22. package/cjs/domain/configuration/endpointBuilder.js +28 -38
  23. package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
  24. package/cjs/domain/configuration/index.d.ts +2 -1
  25. package/cjs/domain/configuration/index.js +3 -1
  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/connectivity/connectivity.d.ts +13 -0
  31. package/cjs/domain/connectivity/connectivity.js +14 -0
  32. package/cjs/domain/connectivity/connectivity.js.map +1 -0
  33. package/cjs/domain/connectivity/index.d.ts +1 -0
  34. package/cjs/domain/{deflate → connectivity}/index.js +1 -1
  35. package/cjs/domain/connectivity/index.js.map +1 -0
  36. package/cjs/domain/console/consoleObservable.js +4 -7
  37. package/cjs/domain/console/consoleObservable.js.map +1 -1
  38. package/cjs/domain/context/contextConstants.d.ts +5 -0
  39. package/cjs/domain/{tracekit/types.js → context/contextConstants.js} +1 -1
  40. package/cjs/domain/context/contextConstants.js.map +1 -0
  41. package/cjs/domain/context/contextManager.d.ts +12 -0
  42. package/cjs/domain/context/contextManager.js +43 -0
  43. package/cjs/domain/context/contextManager.js.map +1 -0
  44. package/cjs/domain/context/customerDataTracker.d.ts +45 -0
  45. package/cjs/domain/context/customerDataTracker.js +107 -0
  46. package/cjs/domain/context/customerDataTracker.js.map +1 -0
  47. package/cjs/domain/context/storeContextManager.d.ts +6 -0
  48. package/cjs/domain/context/storeContextManager.js +38 -0
  49. package/cjs/domain/context/storeContextManager.js.map +1 -0
  50. package/cjs/domain/deflate/types.d.ts +0 -26
  51. package/cjs/domain/error/computeStackTrace.d.ts +33 -0
  52. package/cjs/domain/{tracekit → error}/computeStackTrace.js +28 -4
  53. package/cjs/domain/error/computeStackTrace.js.map +1 -0
  54. package/cjs/domain/error/error.d.ts +1 -1
  55. package/cjs/domain/error/error.js +3 -3
  56. package/cjs/domain/error/error.js.map +1 -1
  57. package/cjs/domain/error/error.types.d.ts +2 -2
  58. package/cjs/domain/error/error.types.js.map +1 -1
  59. package/cjs/domain/error/trackRuntimeError.d.ts +8 -0
  60. package/cjs/domain/error/trackRuntimeError.js +39 -6
  61. package/cjs/domain/error/trackRuntimeError.js.map +1 -1
  62. package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
  63. package/cjs/domain/report/browser.types.d.ts +10 -0
  64. package/cjs/domain/report/reportObservable.d.ts +2 -0
  65. package/cjs/domain/report/reportObservable.js +7 -7
  66. package/cjs/domain/report/reportObservable.js.map +1 -1
  67. package/cjs/domain/session/oldCookiesMigration.js +4 -4
  68. package/cjs/domain/session/oldCookiesMigration.js.map +1 -1
  69. package/cjs/domain/session/sessionManager.js +2 -2
  70. package/cjs/domain/session/sessionManager.js.map +1 -1
  71. package/cjs/domain/session/sessionState.js.map +1 -1
  72. package/cjs/domain/session/sessionStore.js.map +1 -1
  73. package/cjs/domain/session/sessionStoreOperations.d.ts +0 -5
  74. package/cjs/domain/session/sessionStoreOperations.js +6 -14
  75. package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
  76. package/cjs/domain/session/storeStrategies/sessionInCookie.js +13 -2
  77. package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
  78. package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +1 -0
  79. package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
  80. package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +1 -0
  81. package/cjs/domain/synthetics/syntheticsWorkerValues.js +3 -3
  82. package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
  83. package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +4 -0
  84. package/cjs/domain/telemetry/telemetry.d.ts +5 -1
  85. package/cjs/domain/telemetry/telemetry.js +17 -6
  86. package/cjs/domain/telemetry/telemetry.js.map +1 -1
  87. package/cjs/domain/telemetry/telemetryEvent.types.d.ts +18 -2
  88. package/cjs/domain/user/user.js.map +1 -1
  89. package/cjs/tools/abstractLifeCycle.js.map +1 -1
  90. package/cjs/tools/boundedBuffer.js.map +1 -1
  91. package/cjs/tools/catchUserErrors.js.map +1 -1
  92. package/cjs/tools/display.d.ts +2 -2
  93. package/cjs/tools/display.js +13 -17
  94. package/cjs/tools/display.js.map +1 -1
  95. package/cjs/tools/encoder.d.ts +53 -0
  96. package/cjs/tools/encoder.js +41 -0
  97. package/cjs/tools/encoder.js.map +1 -0
  98. package/cjs/tools/experimentalFeatures.d.ts +3 -5
  99. package/cjs/tools/experimentalFeatures.js +2 -4
  100. package/cjs/tools/experimentalFeatures.js.map +1 -1
  101. package/cjs/tools/getGlobalObject.js.map +1 -1
  102. package/cjs/tools/getZoneJsOriginalValue.js.map +1 -1
  103. package/cjs/tools/instrumentMethod.d.ts +50 -10
  104. package/cjs/tools/instrumentMethod.js +59 -36
  105. package/cjs/tools/instrumentMethod.js.map +1 -1
  106. package/cjs/tools/matchOption.js.map +1 -1
  107. package/cjs/tools/mergeInto.js.map +1 -1
  108. package/cjs/tools/monitor.d.ts +1 -2
  109. package/cjs/tools/monitor.js +6 -6
  110. package/cjs/tools/monitor.js.map +1 -1
  111. package/cjs/tools/observable.d.ts +1 -1
  112. package/cjs/tools/observable.js +2 -3
  113. package/cjs/tools/observable.js.map +1 -1
  114. package/cjs/tools/readBytesFromStream.js.map +1 -1
  115. package/cjs/tools/sendToExtension.js.map +1 -1
  116. package/cjs/tools/serialisation/jsonStringify.d.ts +1 -2
  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 +8 -0
  120. package/cjs/tools/utils/browserDetection.js +33 -3
  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 +1 -0
  128. package/cjs/tools/utils/stringUtils.js +31 -4
  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 +5 -3
  135. package/cjs/transport/batch.js +73 -29
  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 +12 -2
  139. package/cjs/transport/flushController.js +22 -7
  140. package/cjs/transport/flushController.js.map +1 -1
  141. package/cjs/transport/httpRequest.d.ts +3 -2
  142. package/cjs/transport/httpRequest.js +21 -17
  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 +9 -4
  148. package/cjs/transport/startBatchWithReplica.js +9 -4
  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 +12 -4
  153. package/esm/browser/addEventListener.js +49 -7
  154. package/esm/browser/addEventListener.js.map +1 -1
  155. package/esm/browser/cookie.d.ts +7 -0
  156. package/esm/browser/cookie.js +17 -2
  157. package/esm/browser/cookie.js.map +1 -1
  158. package/esm/browser/fetchObservable.js +15 -20
  159. package/esm/browser/fetchObservable.js.map +1 -1
  160. package/esm/browser/pageExitObservable.js +7 -8
  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 +1 -2
  165. package/esm/browser/xhrObservable.js +28 -36
  166. package/esm/browser/xhrObservable.js.map +1 -1
  167. package/esm/domain/configuration/configuration.d.ts +17 -12
  168. package/esm/domain/configuration/configuration.js +8 -9
  169. package/esm/domain/configuration/configuration.js.map +1 -1
  170. package/esm/domain/configuration/endpointBuilder.d.ts +6 -10
  171. package/esm/domain/configuration/endpointBuilder.js +27 -37
  172. package/esm/domain/configuration/endpointBuilder.js.map +1 -1
  173. package/esm/domain/configuration/index.d.ts +2 -1
  174. package/esm/domain/configuration/index.js +1 -0
  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/connectivity/connectivity.d.ts +13 -0
  180. package/esm/domain/connectivity/connectivity.js +10 -0
  181. package/esm/domain/connectivity/connectivity.js.map +1 -0
  182. package/esm/domain/connectivity/index.d.ts +1 -0
  183. package/esm/domain/connectivity/index.js +2 -0
  184. package/esm/domain/connectivity/index.js.map +1 -0
  185. package/esm/domain/console/consoleObservable.js +2 -5
  186. package/esm/domain/console/consoleObservable.js.map +1 -1
  187. package/esm/domain/context/contextConstants.d.ts +5 -0
  188. package/esm/domain/context/contextConstants.js +2 -0
  189. package/esm/domain/context/contextConstants.js.map +1 -0
  190. package/esm/domain/context/contextManager.d.ts +12 -0
  191. package/esm/domain/context/contextManager.js +39 -0
  192. package/esm/domain/context/contextManager.js.map +1 -0
  193. package/esm/domain/context/customerDataTracker.d.ts +45 -0
  194. package/esm/domain/context/customerDataTracker.js +102 -0
  195. package/esm/domain/context/customerDataTracker.js.map +1 -0
  196. package/esm/domain/context/storeContextManager.d.ts +6 -0
  197. package/esm/domain/context/storeContextManager.js +32 -0
  198. package/esm/domain/context/storeContextManager.js.map +1 -0
  199. package/esm/domain/deflate/types.d.ts +12 -0
  200. package/esm/domain/error/computeStackTrace.d.ts +33 -0
  201. package/esm/domain/{tracekit → error}/computeStackTrace.js +26 -3
  202. package/esm/domain/error/computeStackTrace.js.map +1 -0
  203. package/esm/domain/error/error.d.ts +1 -1
  204. package/esm/domain/error/error.js +1 -1
  205. package/esm/domain/error/error.js.map +1 -1
  206. package/esm/domain/error/error.types.d.ts +2 -2
  207. package/esm/domain/error/error.types.js.map +1 -1
  208. package/esm/domain/error/trackRuntimeError.d.ts +8 -0
  209. package/esm/domain/error/trackRuntimeError.js +35 -4
  210. package/esm/domain/error/trackRuntimeError.js.map +1 -1
  211. package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
  212. package/esm/domain/report/browser.types.d.ts +10 -0
  213. package/esm/domain/report/reportObservable.d.ts +2 -0
  214. package/esm/domain/report/reportObservable.js +8 -8
  215. package/esm/domain/report/reportObservable.js.map +1 -1
  216. package/esm/domain/session/oldCookiesMigration.js +5 -5
  217. package/esm/domain/session/oldCookiesMigration.js.map +1 -1
  218. package/esm/domain/session/sessionManager.js +3 -3
  219. package/esm/domain/session/sessionManager.js.map +1 -1
  220. package/esm/domain/session/sessionState.js.map +1 -1
  221. package/esm/domain/session/sessionStore.js.map +1 -1
  222. package/esm/domain/session/sessionStoreOperations.d.ts +0 -5
  223. package/esm/domain/session/sessionStoreOperations.js +5 -12
  224. package/esm/domain/session/sessionStoreOperations.js.map +1 -1
  225. package/esm/domain/session/storeStrategies/sessionInCookie.js +13 -2
  226. package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
  227. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +1 -0
  228. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
  229. package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +1 -0
  230. package/esm/domain/synthetics/syntheticsWorkerValues.js +4 -4
  231. package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
  232. package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +4 -0
  233. package/esm/domain/telemetry/telemetry.d.ts +5 -1
  234. package/esm/domain/telemetry/telemetry.js +16 -5
  235. package/esm/domain/telemetry/telemetry.js.map +1 -1
  236. package/esm/domain/telemetry/telemetryEvent.types.d.ts +18 -2
  237. package/esm/domain/user/user.js.map +1 -1
  238. package/esm/index.d.ts +9 -5
  239. package/esm/index.js +8 -5
  240. package/esm/index.js.map +1 -1
  241. package/esm/tools/abstractLifeCycle.js.map +1 -1
  242. package/esm/tools/boundedBuffer.js.map +1 -1
  243. package/esm/tools/catchUserErrors.js.map +1 -1
  244. package/esm/tools/display.d.ts +2 -2
  245. package/esm/tools/display.js +12 -15
  246. package/esm/tools/display.js.map +1 -1
  247. package/esm/tools/encoder.d.ts +53 -0
  248. package/esm/tools/encoder.js +37 -0
  249. package/esm/tools/encoder.js.map +1 -0
  250. package/esm/tools/experimentalFeatures.d.ts +3 -5
  251. package/esm/tools/experimentalFeatures.js +2 -4
  252. package/esm/tools/experimentalFeatures.js.map +1 -1
  253. package/esm/tools/getGlobalObject.js.map +1 -1
  254. package/esm/tools/getZoneJsOriginalValue.js.map +1 -1
  255. package/esm/tools/instrumentMethod.d.ts +50 -10
  256. package/esm/tools/instrumentMethod.js +58 -34
  257. package/esm/tools/instrumentMethod.js.map +1 -1
  258. package/esm/tools/matchOption.js.map +1 -1
  259. package/esm/tools/mergeInto.js.map +1 -1
  260. package/esm/tools/monitor.d.ts +1 -2
  261. package/esm/tools/monitor.js +7 -7
  262. package/esm/tools/monitor.js.map +1 -1
  263. package/esm/tools/observable.d.ts +1 -1
  264. package/esm/tools/observable.js +2 -3
  265. package/esm/tools/observable.js.map +1 -1
  266. package/esm/tools/readBytesFromStream.js.map +1 -1
  267. package/esm/tools/sendToExtension.js.map +1 -1
  268. package/esm/tools/serialisation/jsonStringify.d.ts +1 -2
  269. package/esm/tools/serialisation/jsonStringify.js.map +1 -1
  270. package/esm/tools/serialisation/sanitize.js.map +1 -1
  271. package/esm/tools/utils/browserDetection.d.ts +8 -0
  272. package/esm/tools/utils/browserDetection.js +30 -2
  273. package/esm/tools/utils/browserDetection.js.map +1 -1
  274. package/esm/tools/utils/byteUtils.js.map +1 -1
  275. package/esm/tools/utils/functionUtils.js.map +1 -1
  276. package/esm/tools/utils/objectUtils.js.map +1 -1
  277. package/esm/tools/utils/polyfills.js.map +1 -1
  278. package/esm/tools/utils/responseUtils.js.map +1 -1
  279. package/esm/tools/utils/stringUtils.d.ts +1 -0
  280. package/esm/tools/utils/stringUtils.js +29 -3
  281. package/esm/tools/utils/stringUtils.js.map +1 -1
  282. package/esm/tools/utils/timeUtils.js.map +1 -1
  283. package/esm/tools/utils/typeUtils.js.map +1 -1
  284. package/esm/tools/utils/urlPolyfill.js.map +1 -1
  285. package/esm/tools/valueHistory.js.map +1 -1
  286. package/esm/transport/batch.d.ts +5 -3
  287. package/esm/transport/batch.js +73 -29
  288. package/esm/transport/batch.js.map +1 -1
  289. package/esm/transport/eventBridge.js.map +1 -1
  290. package/esm/transport/flushController.d.ts +12 -2
  291. package/esm/transport/flushController.js +22 -7
  292. package/esm/transport/flushController.js.map +1 -1
  293. package/esm/transport/httpRequest.d.ts +3 -2
  294. package/esm/transport/httpRequest.js +21 -17
  295. package/esm/transport/httpRequest.js.map +1 -1
  296. package/esm/transport/sendWithRetryStrategy.d.ts +2 -2
  297. package/esm/transport/sendWithRetryStrategy.js +9 -9
  298. package/esm/transport/sendWithRetryStrategy.js.map +1 -1
  299. package/esm/transport/startBatchWithReplica.d.ts +9 -4
  300. package/esm/transport/startBatchWithReplica.js +9 -4
  301. package/esm/transport/startBatchWithReplica.js.map +1 -1
  302. package/package.json +1 -1
  303. package/src/browser/addEventListener.ts +37 -31
  304. package/src/browser/cookie.ts +21 -2
  305. package/src/browser/fetchObservable.ts +21 -25
  306. package/src/browser/pageExitObservable.ts +1 -3
  307. package/src/browser/xhrObservable.ts +31 -37
  308. package/src/domain/configuration/configuration.ts +24 -22
  309. package/src/domain/configuration/endpointBuilder.ts +40 -53
  310. package/src/domain/configuration/index.ts +2 -1
  311. package/src/domain/configuration/transportConfiguration.ts +1 -1
  312. package/src/domain/connectivity/connectivity.ts +27 -0
  313. package/src/domain/connectivity/index.ts +1 -0
  314. package/src/domain/console/consoleObservable.ts +3 -7
  315. package/src/domain/context/contextConstants.ts +5 -0
  316. package/src/domain/context/contextManager.ts +48 -0
  317. package/src/domain/context/customerDataTracker.ts +134 -0
  318. package/src/domain/context/storeContextManager.ts +51 -0
  319. package/src/domain/deflate/types.ts +14 -0
  320. package/src/domain/{tracekit → error}/computeStackTrace.ts +49 -4
  321. package/src/domain/error/error.ts +2 -2
  322. package/src/domain/error/error.types.ts +11 -2
  323. package/src/domain/error/trackRuntimeError.ts +44 -12
  324. package/src/domain/report/browser.types.ts +12 -0
  325. package/src/domain/report/reportObservable.ts +8 -6
  326. package/src/domain/session/oldCookiesMigration.ts +5 -5
  327. package/src/domain/session/sessionStoreOperations.ts +5 -13
  328. package/src/domain/session/storeStrategies/sessionInCookie.ts +13 -2
  329. package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +1 -0
  330. package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +1 -0
  331. package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
  332. package/src/domain/telemetry/rawTelemetryEvent.types.ts +5 -0
  333. package/src/domain/telemetry/telemetry.ts +22 -7
  334. package/src/domain/telemetry/telemetryEvent.types.ts +18 -2
  335. package/src/index.ts +13 -7
  336. package/src/tools/display.ts +14 -13
  337. package/src/tools/encoder.ts +102 -0
  338. package/src/tools/experimentalFeatures.ts +2 -4
  339. package/src/tools/instrumentMethod.ts +103 -59
  340. package/src/tools/mergeInto.ts +16 -16
  341. package/src/tools/monitor.ts +5 -5
  342. package/src/tools/observable.ts +3 -5
  343. package/src/tools/utils/browserDetection.ts +43 -2
  344. package/src/tools/utils/polyfills.ts +1 -4
  345. package/src/tools/utils/stringUtils.ts +30 -4
  346. package/src/transport/batch.ts +86 -31
  347. package/src/transport/flushController.ts +22 -7
  348. package/src/transport/httpRequest.ts +23 -16
  349. package/src/transport/sendWithRetryStrategy.ts +10 -10
  350. package/src/transport/startBatchWithReplica.ts +22 -6
  351. package/cjs/domain/deflate/index.d.ts +0 -1
  352. package/cjs/domain/deflate/index.js.map +0 -1
  353. package/cjs/domain/tracekit/computeStackTrace.d.ts +0 -5
  354. package/cjs/domain/tracekit/computeStackTrace.js.map +0 -1
  355. package/cjs/domain/tracekit/index.d.ts +0 -3
  356. package/cjs/domain/tracekit/index.js +0 -8
  357. package/cjs/domain/tracekit/index.js.map +0 -1
  358. package/cjs/domain/tracekit/tracekit.d.ts +0 -35
  359. package/cjs/domain/tracekit/tracekit.js +0 -95
  360. package/cjs/domain/tracekit/tracekit.js.map +0 -1
  361. package/cjs/domain/tracekit/types.d.ts +0 -44
  362. package/cjs/domain/tracekit/types.js.map +0 -1
  363. package/cjs/index.d.ts +0 -63
  364. package/cjs/index.js +0 -155
  365. package/cjs/index.js.map +0 -1
  366. package/cjs/tools/serialisation/contextManager.d.ts +0 -21
  367. package/cjs/tools/serialisation/contextManager.js +0 -70
  368. package/cjs/tools/serialisation/contextManager.js.map +0 -1
  369. package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +0 -8
  370. package/cjs/tools/serialisation/heavyCustomerDataWarning.js +0 -18
  371. package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +0 -1
  372. package/esm/domain/tracekit/computeStackTrace.d.ts +0 -5
  373. package/esm/domain/tracekit/computeStackTrace.js.map +0 -1
  374. package/esm/domain/tracekit/index.d.ts +0 -3
  375. package/esm/domain/tracekit/index.js +0 -3
  376. package/esm/domain/tracekit/index.js.map +0 -1
  377. package/esm/domain/tracekit/tracekit.d.ts +0 -35
  378. package/esm/domain/tracekit/tracekit.js +0 -91
  379. package/esm/domain/tracekit/tracekit.js.map +0 -1
  380. package/esm/domain/tracekit/types.d.ts +0 -44
  381. package/esm/domain/tracekit/types.js +0 -2
  382. package/esm/domain/tracekit/types.js.map +0 -1
  383. package/esm/tools/serialisation/contextManager.d.ts +0 -21
  384. package/esm/tools/serialisation/contextManager.js +0 -66
  385. package/esm/tools/serialisation/contextManager.js.map +0 -1
  386. package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +0 -8
  387. package/esm/tools/serialisation/heavyCustomerDataWarning.js +0 -14
  388. package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +0 -1
  389. package/src/domain/tracekit/index.ts +0 -3
  390. package/src/domain/tracekit/tracekit.ts +0 -96
  391. package/src/domain/tracekit/types.ts +0 -47
  392. package/src/tools/serialisation/contextManager.ts +0 -79
  393. package/src/tools/serialisation/heavyCustomerDataWarning.ts +0 -26
@@ -1,7 +1,48 @@
1
+ // Exported only for tests
2
+ export const enum Browser {
3
+ IE,
4
+ CHROMIUM,
5
+ SAFARI,
6
+ OTHER,
7
+ }
8
+
1
9
  export function isIE() {
2
- return Boolean((document as any).documentMode)
10
+ return detectBrowserCached() === Browser.IE
3
11
  }
4
12
 
5
13
  export function isChromium() {
6
- return !!(window as any).chrome || /HeadlessChrome/.test(window.navigator.userAgent)
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
7
48
  }
@@ -27,10 +27,7 @@ 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(
31
- array: ArrayLike<unknown>,
32
- predicate: (item: unknown, index: number) => boolean
33
- ): unknown | undefined {
30
+ export function find(array: ArrayLike<unknown>, predicate: (item: unknown, index: number) => boolean): unknown {
34
31
  for (let i = 0; i < array.length; i += 1) {
35
32
  const item = array[i]
36
33
  if (predicate(item, i)) {
@@ -9,10 +9,36 @@ export function generateUUID(placeholder?: string): string {
9
9
  : `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(/[018]/g, generateUUID)
10
10
  }
11
11
 
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
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
16
42
  }
17
43
 
18
44
  export function safeTruncate(candidate: string, length: number, suffix = '') {
@@ -2,21 +2,24 @@ import { display } from '../tools/display'
2
2
  import type { Context } from '../tools/serialisation/context'
3
3
  import { objectValues } from '../tools/utils/polyfills'
4
4
  import { isPageExitReason } from '../browser/pageExitObservable'
5
- import { computeBytesCount } from '../tools/utils/byteUtils'
6
5
  import { jsonStringify } from '../tools/serialisation/jsonStringify'
7
- import type { HttpRequest } from './httpRequest'
6
+ import type { Subscription } from '../tools/observable'
7
+ import type { Encoder, EncoderResult } from '../tools/encoder'
8
+ import { computeBytesCount } from '../tools/utils/byteUtils'
9
+ import type { HttpRequest, Payload } from './httpRequest'
8
10
  import type { FlushController, FlushEvent } from './flushController'
9
11
 
10
12
  export class Batch {
11
- private pushOnlyBuffer: string[] = []
12
13
  private upsertBuffer: { [key: string]: string } = {}
14
+ private flushSubscription: Subscription
13
15
 
14
16
  constructor(
17
+ private encoder: Encoder,
15
18
  private request: HttpRequest,
16
19
  public flushController: FlushController,
17
20
  private messageBytesLimit: number
18
21
  ) {
19
- this.flushController.flushObservable.subscribe((event) => this.flush(event))
22
+ this.flushSubscription = this.flushController.flushObservable.subscribe((event) => this.flush(event))
20
23
  }
21
24
 
22
25
  add(message: Context) {
@@ -27,24 +30,57 @@ export class Batch {
27
30
  this.addOrUpdate(message, key)
28
31
  }
29
32
 
30
- private flush(event: FlushEvent) {
31
- const messages = this.pushOnlyBuffer.concat(objectValues(this.upsertBuffer))
33
+ stop() {
34
+ this.flushSubscription.unsubscribe()
35
+ }
32
36
 
33
- this.pushOnlyBuffer = []
37
+ private flush(event: FlushEvent) {
38
+ const upsertMessages = objectValues(this.upsertBuffer).join('\n')
34
39
  this.upsertBuffer = {}
35
40
 
36
- const payload = { data: messages.join('\n'), bytesCount: event.bytesCount, flushReason: event.reason }
37
- if (isPageExitReason(event.reason)) {
38
- this.request.sendOnExit(payload)
41
+ const isPageExit = isPageExitReason(event.reason)
42
+ const send = isPageExit ? this.request.sendOnExit : this.request.send
43
+
44
+ if (
45
+ isPageExit &&
46
+ // Note: checking that the encoder is async is not strictly needed, but it's an optimization:
47
+ // if the encoder is async we need to send two requests in some cases (one for encoded data
48
+ // and the other for non-encoded data). But if it's not async, we don't have to worry about
49
+ // it and always send a single request.
50
+ this.encoder.isAsync
51
+ ) {
52
+ const encoderResult = this.encoder.finishSync()
53
+
54
+ // Send encoded messages
55
+ if (encoderResult.outputBytesCount) {
56
+ send(formatPayloadFromEncoder(encoderResult, event))
57
+ }
58
+
59
+ // Send messages that are not yet encoded at this point
60
+ const pendingMessages = [encoderResult.pendingData, upsertMessages].filter(Boolean).join('\n')
61
+ if (pendingMessages) {
62
+ send({
63
+ data: pendingMessages,
64
+ bytesCount: computeBytesCount(pendingMessages),
65
+ flushReason: event.reason,
66
+ })
67
+ }
39
68
  } else {
40
- this.request.send(payload)
69
+ if (upsertMessages) {
70
+ this.encoder.write(this.encoder.isEmpty ? upsertMessages : `\n${upsertMessages}`)
71
+ }
72
+ this.encoder.finish((encoderResult) => {
73
+ send(formatPayloadFromEncoder(encoderResult, event))
74
+ })
41
75
  }
42
76
  }
43
77
 
44
78
  private addOrUpdate(message: Context, key?: string) {
45
- const { processedMessage, messageBytesCount } = this.process(message)
79
+ const serializedMessage = jsonStringify(message)!
80
+
81
+ const estimatedMessageBytesCount = this.encoder.estimateEncodedBytesCount(serializedMessage)
46
82
 
47
- if (messageBytesCount >= this.messageBytesLimit) {
83
+ if (estimatedMessageBytesCount >= this.messageBytesLimit) {
48
84
  display.warn(
49
85
  `Discarded a message whose size was bigger than the maximum allowed size ${this.messageBytesLimit}KB.`
50
86
  )
@@ -55,38 +91,57 @@ export class Batch {
55
91
  this.remove(key)
56
92
  }
57
93
 
58
- this.push(processedMessage, messageBytesCount, key)
59
- }
60
-
61
- private process(message: Context) {
62
- const processedMessage = jsonStringify(message)!
63
- const messageBytesCount = computeBytesCount(processedMessage)
64
- return { processedMessage, messageBytesCount }
94
+ this.push(serializedMessage, estimatedMessageBytesCount, key)
65
95
  }
66
96
 
67
- private push(processedMessage: string, messageBytesCount: number, key?: string) {
68
- // If there are other messages, a '\n' will be added at serialization
69
- const separatorBytesCount = this.flushController.messagesCount > 0 ? 1 : 0
97
+ private push(serializedMessage: string, estimatedMessageBytesCount: number, key?: string) {
98
+ this.flushController.notifyBeforeAddMessage(estimatedMessageBytesCount)
70
99
 
71
- this.flushController.notifyBeforeAddMessage(messageBytesCount + separatorBytesCount)
72
100
  if (key !== undefined) {
73
- this.upsertBuffer[key] = processedMessage
101
+ this.upsertBuffer[key] = serializedMessage
102
+ this.flushController.notifyAfterAddMessage()
74
103
  } else {
75
- this.pushOnlyBuffer.push(processedMessage)
104
+ this.encoder.write(
105
+ this.encoder.isEmpty ? serializedMessage : `\n${serializedMessage}`,
106
+ (realMessageBytesCount) => {
107
+ this.flushController.notifyAfterAddMessage(realMessageBytesCount - estimatedMessageBytesCount)
108
+ }
109
+ )
76
110
  }
77
- this.flushController.notifyAfterAddMessage()
78
111
  }
79
112
 
80
113
  private remove(key: string) {
81
114
  const removedMessage = this.upsertBuffer[key]
82
115
  delete this.upsertBuffer[key]
83
- const messageBytesCount = computeBytesCount(removedMessage)
84
- // If there are other messages, a '\n' will be added at serialization
85
- const separatorBytesCount = this.flushController.messagesCount > 1 ? 1 : 0
86
- this.flushController.notifyAfterRemoveMessage(messageBytesCount + separatorBytesCount)
116
+ const messageBytesCount = this.encoder.estimateEncodedBytesCount(removedMessage)
117
+ this.flushController.notifyAfterRemoveMessage(messageBytesCount)
87
118
  }
88
119
 
89
120
  private hasMessageFor(key?: string): key is string {
90
121
  return key !== undefined && this.upsertBuffer[key] !== undefined
91
122
  }
92
123
  }
124
+
125
+ function formatPayloadFromEncoder(encoderResult: EncoderResult, flushEvent: FlushEvent): Payload {
126
+ let data: string | Blob
127
+ if (typeof encoderResult.output === 'string') {
128
+ data = encoderResult.output
129
+ } else {
130
+ data = new Blob([encoderResult.output], {
131
+ // This will set the 'Content-Type: text/plain' header. Reasoning:
132
+ // * The intake rejects the request if there is no content type.
133
+ // * The browser will issue CORS preflight requests if we set it to 'application/json', which
134
+ // could induce higher intake load (and maybe has other impacts).
135
+ // * Also it's not quite JSON, since we are concatenating multiple JSON objects separated by
136
+ // new lines.
137
+ type: 'text/plain',
138
+ })
139
+ }
140
+
141
+ return {
142
+ data,
143
+ bytesCount: encoderResult.outputBytesCount,
144
+ encoding: encoderResult.encoding,
145
+ flushReason: flushEvent.reason,
146
+ }
147
+ }
@@ -33,10 +33,13 @@ export function createFlushController({
33
33
  pageExitObservable,
34
34
  sessionExpireObservable,
35
35
  }: FlushControllerOptions) {
36
- const flushObservable = new Observable<FlushEvent>()
36
+ const pageExitSubscription = pageExitObservable.subscribe((event) => flush(event.reason))
37
+ const sessionExpireSubscription = sessionExpireObservable.subscribe(() => flush('session_expire'))
37
38
 
38
- pageExitObservable.subscribe((event) => flush(event.reason))
39
- sessionExpireObservable.subscribe(() => flush('session_expire'))
39
+ const flushObservable = new Observable<FlushEvent>(() => () => {
40
+ pageExitSubscription.unsubscribe()
41
+ sessionExpireSubscription.unsubscribe()
42
+ })
40
43
 
41
44
  let currentBytesCount = 0
42
45
  let currentMessagesCount = 0
@@ -85,16 +88,19 @@ export function createFlushController({
85
88
  *
86
89
  * This function needs to be called synchronously, right before adding the message, so no flush
87
90
  * event can happen after `notifyBeforeAddMessage` and before adding the message.
91
+ *
92
+ * @param estimatedMessageBytesCount: an estimation of the message bytes count once it is
93
+ * actually added.
88
94
  */
89
- notifyBeforeAddMessage(messageBytesCount: number) {
90
- if (currentBytesCount + messageBytesCount >= bytesLimit) {
95
+ notifyBeforeAddMessage(estimatedMessageBytesCount: number) {
96
+ if (currentBytesCount + estimatedMessageBytesCount >= bytesLimit) {
91
97
  flush('bytes_limit')
92
98
  }
93
99
  // Consider the message to be added now rather than in `notifyAfterAddMessage`, because if no
94
100
  // message was added yet and `notifyAfterAddMessage` is called asynchronously, we still want
95
101
  // to notify when a flush is needed (for example on page exit).
96
102
  currentMessagesCount += 1
97
- currentBytesCount += messageBytesCount
103
+ currentBytesCount += estimatedMessageBytesCount
98
104
  scheduleDurationLimitTimeout()
99
105
  },
100
106
 
@@ -103,8 +109,13 @@ export function createFlushController({
103
109
  *
104
110
  * This function can be called asynchronously after the message was added, but in this case it
105
111
  * should not be called if a flush event occurred in between.
112
+ *
113
+ * @param messageBytesCountDiff: the difference between the estimated message bytes count and
114
+ * its actual bytes count once added to the pool.
106
115
  */
107
- notifyAfterAddMessage() {
116
+ notifyAfterAddMessage(messageBytesCountDiff = 0) {
117
+ currentBytesCount += messageBytesCountDiff
118
+
108
119
  if (currentMessagesCount >= messagesLimit) {
109
120
  flush('messages_limit')
110
121
  } else if (currentBytesCount >= bytesLimit) {
@@ -117,6 +128,10 @@ export function createFlushController({
117
128
  *
118
129
  * This function needs to be called synchronously, right after removing the message, so no flush
119
130
  * event can happen after removing the message and before `notifyAfterRemoveMessage`.
131
+ *
132
+ * @param messageBytesCount: the message bytes count that was added to the pool. Should
133
+ * correspond to the sum of bytes counts passed to `notifyBeforeAddMessage` and
134
+ * `notifyAfterAddMessage`.
120
135
  */
121
136
  notifyAfterRemoveMessage(messageBytesCount: number) {
122
137
  currentBytesCount -= messageBytesCount
@@ -24,10 +24,11 @@ export interface HttpResponse extends Context {
24
24
  }
25
25
 
26
26
  export interface Payload {
27
- data: string | FormData
27
+ data: string | FormData | Blob
28
28
  bytesCount: number
29
29
  retry?: RetryInfo
30
30
  flushReason?: FlushReason
31
+ encoding?: 'deflate'
31
32
  }
32
33
 
33
34
  export interface RetryInfo {
@@ -47,7 +48,7 @@ export function createHttpRequest(
47
48
 
48
49
  return {
49
50
  send: (payload: Payload) => {
50
- sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointBuilder.endpointType, reportError)
51
+ sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointBuilder.trackType, reportError)
51
52
  },
52
53
  /**
53
54
  * Since fetch keepalive behaves like regular fetch on Firefox,
@@ -63,13 +64,13 @@ function sendBeaconStrategy(
63
64
  configuration: Configuration,
64
65
  endpointBuilder: EndpointBuilder,
65
66
  bytesLimit: number,
66
- { data, bytesCount, flushReason }: Payload
67
+ payload: Payload
67
68
  ) {
68
- const canUseBeacon = !!navigator.sendBeacon && bytesCount < bytesLimit
69
+ const canUseBeacon = !!navigator.sendBeacon && payload.bytesCount < bytesLimit
69
70
  if (canUseBeacon) {
70
71
  try {
71
- const beaconUrl = endpointBuilder.build('beacon', flushReason)
72
- const isQueued = navigator.sendBeacon(beaconUrl, data)
72
+ const beaconUrl = endpointBuilder.build('beacon', payload)
73
+ const isQueued = navigator.sendBeacon(beaconUrl, payload.data)
73
74
 
74
75
  if (isQueued) {
75
76
  return
@@ -79,8 +80,8 @@ function sendBeaconStrategy(
79
80
  }
80
81
  }
81
82
 
82
- const xhrUrl = endpointBuilder.build('xhr', flushReason)
83
- sendXHR(configuration, xhrUrl, data)
83
+ const xhrUrl = endpointBuilder.build('xhr', payload)
84
+ sendXHR(configuration, xhrUrl, payload.data)
84
85
  }
85
86
 
86
87
  let hasReportedBeaconError = false
@@ -96,23 +97,23 @@ export function fetchKeepAliveStrategy(
96
97
  configuration: Configuration,
97
98
  endpointBuilder: EndpointBuilder,
98
99
  bytesLimit: number,
99
- { data, bytesCount, flushReason, retry }: Payload,
100
+ payload: Payload,
100
101
  onResponse?: (r: HttpResponse) => void
101
102
  ) {
102
- const canUseKeepAlive = isKeepAliveSupported() && bytesCount < bytesLimit
103
+ const canUseKeepAlive = isKeepAliveSupported() && payload.bytesCount < bytesLimit
103
104
  if (canUseKeepAlive) {
104
- const fetchUrl = endpointBuilder.build('fetch', flushReason, retry)
105
- fetch(fetchUrl, { method: 'POST', body: data, keepalive: true, mode: 'cors' }).then(
105
+ const fetchUrl = endpointBuilder.build('fetch', payload)
106
+ fetch(fetchUrl, { method: 'POST', body: payload.data, keepalive: true, mode: 'cors' }).then(
106
107
  monitor((response: Response) => onResponse?.({ status: response.status, type: response.type })),
107
108
  monitor(() => {
108
- const xhrUrl = endpointBuilder.build('xhr', flushReason, retry)
109
+ const xhrUrl = endpointBuilder.build('xhr', payload)
109
110
  // failed to queue the request
110
- sendXHR(configuration, xhrUrl, data, onResponse)
111
+ sendXHR(configuration, xhrUrl, payload.data, onResponse)
111
112
  })
112
113
  )
113
114
  } else {
114
- const xhrUrl = endpointBuilder.build('xhr', flushReason, retry)
115
- sendXHR(configuration, xhrUrl, data, onResponse)
115
+ const xhrUrl = endpointBuilder.build('xhr', payload)
116
+ sendXHR(configuration, xhrUrl, payload.data, onResponse)
116
117
  }
117
118
  }
118
119
 
@@ -133,6 +134,12 @@ export function sendXHR(
133
134
  ) {
134
135
  const request = new XMLHttpRequest()
135
136
  request.open('POST', url, true)
137
+ if (data instanceof Blob) {
138
+ // When using a Blob instance, IE does not use its 'type' to define the 'Content-Type' header
139
+ // automatically, so the intake request ends up being rejected with an HTTP status 415
140
+ // Defining the header manually fixes this issue.
141
+ request.setRequestHeader('Content-Type', data.type)
142
+ }
136
143
  addEventListener(
137
144
  configuration,
138
145
  request,
@@ -1,4 +1,4 @@
1
- import type { EndpointType } from '../domain/configuration'
1
+ import type { TrackType } from '../domain/configuration'
2
2
  import { setTimeout } from '../tools/timer'
3
3
  import { clocksNow, ONE_MINUTE, ONE_SECOND } from '../tools/utils/timeUtils'
4
4
  import { ONE_MEBI_BYTE, ONE_KIBI_BYTE } from '../tools/utils/byteUtils'
@@ -38,7 +38,7 @@ export function sendWithRetryStrategy(
38
38
  payload: Payload,
39
39
  state: RetryState,
40
40
  sendStrategy: SendStrategy,
41
- endpointType: EndpointType,
41
+ trackType: TrackType,
42
42
  reportError: (error: RawError) => void
43
43
  ) {
44
44
  if (
@@ -47,10 +47,10 @@ export function sendWithRetryStrategy(
47
47
  state.bandwidthMonitor.canHandle(payload)
48
48
  ) {
49
49
  send(payload, state, sendStrategy, {
50
- onSuccess: () => retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, endpointType, reportError),
50
+ onSuccess: () => retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, trackType, reportError),
51
51
  onFailure: () => {
52
52
  state.queuedPayloads.enqueue(payload)
53
- scheduleRetry(state, sendStrategy, endpointType, reportError)
53
+ scheduleRetry(state, sendStrategy, trackType, reportError)
54
54
  },
55
55
  })
56
56
  } else {
@@ -61,7 +61,7 @@ export function sendWithRetryStrategy(
61
61
  function scheduleRetry(
62
62
  state: RetryState,
63
63
  sendStrategy: SendStrategy,
64
- endpointType: EndpointType,
64
+ trackType: TrackType,
65
65
  reportError: (error: RawError) => void
66
66
  ) {
67
67
  if (state.transportStatus !== TransportStatus.DOWN) {
@@ -73,11 +73,11 @@ function scheduleRetry(
73
73
  onSuccess: () => {
74
74
  state.queuedPayloads.dequeue()
75
75
  state.currentBackoffTime = INITIAL_BACKOFF_TIME
76
- retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, endpointType, reportError)
76
+ retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, trackType, reportError)
77
77
  },
78
78
  onFailure: () => {
79
79
  state.currentBackoffTime = Math.min(MAX_BACKOFF_TIME, state.currentBackoffTime * 2)
80
- scheduleRetry(state, sendStrategy, endpointType, reportError)
80
+ scheduleRetry(state, sendStrategy, trackType, reportError)
81
81
  },
82
82
  })
83
83
  }, state.currentBackoffTime)
@@ -112,12 +112,12 @@ function retryQueuedPayloads(
112
112
  reason: RetryReason,
113
113
  state: RetryState,
114
114
  sendStrategy: SendStrategy,
115
- endpointType: EndpointType,
115
+ trackType: TrackType,
116
116
  reportError: (error: RawError) => void
117
117
  ) {
118
118
  if (reason === RetryReason.AFTER_SUCCESS && state.queuedPayloads.isFull() && !state.queueFullReported) {
119
119
  reportError({
120
- message: `Reached max ${endpointType} events size queued for upload: ${MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE}MiB`,
120
+ message: `Reached max ${trackType} events size queued for upload: ${MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE}MiB`,
121
121
  source: ErrorSource.AGENT,
122
122
  startClocks: clocksNow(),
123
123
  })
@@ -126,7 +126,7 @@ function retryQueuedPayloads(
126
126
  const previousQueue = state.queuedPayloads
127
127
  state.queuedPayloads = newPayloadQueue()
128
128
  while (previousQueue.size() > 0) {
129
- sendWithRetryStrategy(previousQueue.dequeue()!, state, sendStrategy, endpointType, reportError)
129
+ sendWithRetryStrategy(previousQueue.dequeue()!, state, sendStrategy, trackType, reportError)
130
130
  }
131
131
  }
132
132
 
@@ -3,24 +3,35 @@ import type { Context } from '../tools/serialisation/context'
3
3
  import type { Observable } from '../tools/observable'
4
4
  import type { PageExitEvent } from '../browser/pageExitObservable'
5
5
  import type { RawError } from '../domain/error/error.types'
6
+ import type { Encoder } from '../tools/encoder'
6
7
  import { Batch } from './batch'
7
8
  import { createHttpRequest } from './httpRequest'
8
9
  import { createFlushController } from './flushController'
9
10
 
11
+ export interface BatchConfiguration {
12
+ endpoint: EndpointBuilder
13
+ encoder: Encoder
14
+ }
15
+
16
+ interface ReplicaBatchConfiguration<T> extends BatchConfiguration {
17
+ transformMessage?: (message: T) => T
18
+ }
19
+
10
20
  export function startBatchWithReplica<T extends Context>(
11
21
  configuration: Configuration,
12
- primary: { endpoint: EndpointBuilder },
13
- replica: { endpoint: EndpointBuilder; transformMessage?: (message: T) => T } | undefined,
22
+ primary: BatchConfiguration,
23
+ replica: ReplicaBatchConfiguration<T> | undefined,
14
24
  reportError: (error: RawError) => void,
15
25
  pageExitObservable: Observable<PageExitEvent>,
16
26
  sessionExpireObservable: Observable<void>
17
27
  ) {
18
- const primaryBatch = createBatch(configuration, primary.endpoint)
19
- const replicaBatch = replica && createBatch(configuration, replica.endpoint)
28
+ const primaryBatch = createBatch(configuration, primary)
29
+ const replicaBatch = replica && createBatch(configuration, replica)
20
30
 
21
- function createBatch(configuration: Configuration, endpointBuilder: EndpointBuilder) {
31
+ function createBatch(configuration: Configuration, { endpoint, encoder }: BatchConfiguration) {
22
32
  return new Batch(
23
- createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError),
33
+ encoder,
34
+ createHttpRequest(configuration, endpoint, configuration.batchBytesLimit, reportError),
24
35
  createFlushController({
25
36
  messagesLimit: configuration.batchMessagesLimit,
26
37
  bytesLimit: configuration.batchBytesLimit,
@@ -48,5 +59,10 @@ export function startBatchWithReplica<T extends Context>(
48
59
  replicaBatch.upsert(replica.transformMessage ? replica.transformMessage(message) : message, key)
49
60
  }
50
61
  },
62
+
63
+ stop: () => {
64
+ primaryBatch.stop()
65
+ replicaBatch?.stop()
66
+ },
51
67
  }
52
68
  }
@@ -1 +0,0 @@
1
- export * from './types';
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/deflate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB"}
@@ -1,5 +0,0 @@
1
- import type { StackTrace } from './types';
2
- /**
3
- * Computes a stack trace for an exception.
4
- */
5
- export declare function computeStackTrace(ex: unknown): StackTrace;
@@ -1 +0,0 @@
1
- {"version":3,"file":"computeStackTrace.js","sourceRoot":"","sources":["../../../src/domain/tracekit/computeStackTrace.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAGxD,IAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,EAAW;IAC3C,IAAM,KAAK,GAAiB,EAAE,CAAA;IAE9B,IAAI,aAAa,GAAG,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC/C,IAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;IAC3B,IAAI,aAAa,IAAI,IAAA,sBAAU,EAAC,aAAa,EAAE,QAAQ,CAAC,EAAE;QACxD,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;KACrD;IACD,IAAI,aAAa,EAAE;QACjB,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAC,IAAI;YACrC,IAAM,UAAU,GACd,eAAe,CAAC,IAAI,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;YACvG,IAAI,UAAU,EAAE;gBACd,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE;oBACvC,UAAU,CAAC,IAAI,GAAG,gBAAgB,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AAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;QACzC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QACxC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,gBAAgB;QAClC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QACtC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;KACd,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,SAAkB,EAAE,QAAgB;IAC1D,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,IAAI,SAAS,CAAC,EAAE;QAC3E,OAAO,SAAS,CAAA;KACjB;IACD,IAAM,KAAK,GAAI,SAAsC,CAAC,QAAQ,CAAC,CAAA;IAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC"}
@@ -1,3 +0,0 @@
1
- export { StackTrace, BrowserError } from './types';
2
- export { computeStackTrace } from './computeStackTrace';
3
- export { startUnhandledErrorCollection } from './tracekit';
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startUnhandledErrorCollection = exports.computeStackTrace = void 0;
4
- var computeStackTrace_1 = require("./computeStackTrace");
5
- Object.defineProperty(exports, "computeStackTrace", { enumerable: true, get: function () { return computeStackTrace_1.computeStackTrace; } });
6
- var tracekit_1 = require("./tracekit");
7
- Object.defineProperty(exports, "startUnhandledErrorCollection", { enumerable: true, get: function () { return tracekit_1.startUnhandledErrorCollection; } });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/tracekit/index.ts"],"names":[],"mappings":";;;AACA,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAC1B,uCAA0D;AAAjD,yHAAA,6BAA6B,OAAA"}
@@ -1,35 +0,0 @@
1
- import type { UnhandledErrorCallback } from './types';
2
- /**
3
- * Cross-browser collection of unhandled errors
4
- *
5
- * Supports:
6
- * - Firefox: full stack trace with line numbers, plus column number
7
- * on top frame; column number is not guaranteed
8
- * - Opera: full stack trace with line and column numbers
9
- * - Chrome: full stack trace with line and column numbers
10
- * - Safari: line and column number for the top frame only; some frames
11
- * may be missing, and column number is not guaranteed
12
- * - IE: line and column number for the top frame only; some frames
13
- * may be missing, and column number is not guaranteed
14
- *
15
- * In theory, TraceKit should work on all of the following versions:
16
- * - IE5.5+ (only 8.0 tested)
17
- * - Firefox 0.9+ (only 3.5+ tested)
18
- * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require
19
- * Exceptions Have Stacktrace to be enabled in opera:config)
20
- * - Safari 3+ (only 4+ tested)
21
- * - Chrome 1+ (only 5+ tested)
22
- * - Konqueror 3.5+ (untested)
23
- *
24
- * Tries to catch all unhandled errors and report them to the
25
- * callback.
26
- *
27
- * Callbacks receive a StackTrace object as described in the
28
- * computeStackTrace docs.
29
- *
30
- * @memberof TraceKit
31
- * @namespace
32
- */
33
- export declare function startUnhandledErrorCollection(callback: UnhandledErrorCallback): {
34
- stop: () => void;
35
- };