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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/cjs/boot/displayAlreadyInitializedError.d.ts +1 -1
  2. package/cjs/boot/init.d.ts +1 -1
  3. package/cjs/boot/init.js +1 -1
  4. package/cjs/browser/addEventListener.d.ts +1 -1
  5. package/cjs/browser/addEventListener.js +1 -1
  6. package/cjs/domain/configuration/configuration.js +5 -4
  7. package/cjs/domain/configuration/configuration.js.map +1 -1
  8. package/cjs/domain/configuration/endpointBuilder.js +21 -12
  9. package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
  10. package/cjs/domain/context/storeContextManager.js +1 -1
  11. package/cjs/domain/tags.js +1 -1
  12. package/cjs/domain/telemetry/telemetry.js +2 -2
  13. package/esm/boot/displayAlreadyInitializedError.d.ts +2 -0
  14. package/esm/boot/displayAlreadyInitializedError.js +7 -0
  15. package/esm/boot/displayAlreadyInitializedError.js.map +1 -0
  16. package/esm/boot/init.d.ts +14 -0
  17. package/esm/boot/init.js +35 -0
  18. package/esm/boot/init.js.map +1 -0
  19. package/esm/browser/addEventListener.d.ts +87 -0
  20. package/esm/browser/addEventListener.js +51 -0
  21. package/esm/browser/addEventListener.js.map +1 -0
  22. package/esm/browser/browser.types.d.ts +51 -0
  23. package/esm/browser/browser.types.js +5 -0
  24. package/esm/browser/browser.types.js.map +1 -0
  25. package/esm/browser/cookie.d.ts +28 -0
  26. package/esm/browser/cookie.js +103 -0
  27. package/esm/browser/cookie.js.map +1 -0
  28. package/esm/browser/fetchObservable.d.ts +38 -0
  29. package/esm/browser/fetchObservable.js +99 -0
  30. package/esm/browser/fetchObservable.js.map +1 -0
  31. package/esm/browser/pageMayExitObservable.d.ts +14 -0
  32. package/esm/browser/pageMayExitObservable.js +40 -0
  33. package/esm/browser/pageMayExitObservable.js.map +1 -0
  34. package/esm/browser/runOnReadyState.d.ts +5 -0
  35. package/esm/browser/runOnReadyState.js +16 -0
  36. package/esm/browser/runOnReadyState.js.map +1 -0
  37. package/esm/browser/xhrObservable.d.ts +24 -0
  38. package/esm/browser/xhrObservable.js +83 -0
  39. package/esm/browser/xhrObservable.js.map +1 -0
  40. package/esm/domain/allowedTrackingOrigins.d.ts +4 -0
  41. package/esm/domain/allowedTrackingOrigins.js +21 -0
  42. package/esm/domain/allowedTrackingOrigins.js.map +1 -0
  43. package/esm/domain/bufferedData.d.ts +14 -0
  44. package/esm/domain/bufferedData.js +19 -0
  45. package/esm/domain/bufferedData.js.map +1 -0
  46. package/esm/domain/configuration/configuration.d.ts +312 -0
  47. package/esm/domain/configuration/configuration.js +132 -0
  48. package/esm/domain/configuration/configuration.js.map +1 -0
  49. package/esm/domain/configuration/endpointBuilder.d.ts +12 -0
  50. package/esm/domain/configuration/endpointBuilder.js +81 -0
  51. package/esm/domain/configuration/endpointBuilder.js.map +1 -0
  52. package/esm/domain/configuration/index.d.ts +5 -0
  53. package/esm/domain/configuration/index.js +4 -0
  54. package/esm/domain/configuration/index.js.map +1 -0
  55. package/esm/domain/configuration/transportConfiguration.d.ts +20 -0
  56. package/esm/domain/configuration/transportConfiguration.js +50 -0
  57. package/esm/domain/configuration/transportConfiguration.js.map +1 -0
  58. package/esm/domain/connectivity/connectivity.d.ts +14 -0
  59. package/esm/domain/connectivity/connectivity.js +11 -0
  60. package/esm/domain/connectivity/connectivity.js.map +1 -0
  61. package/esm/domain/connectivity/index.d.ts +1 -0
  62. package/esm/domain/connectivity/index.js +2 -0
  63. package/esm/domain/connectivity/index.js.map +1 -0
  64. package/esm/domain/console/consoleObservable.d.ts +21 -0
  65. package/esm/domain/console/consoleObservable.js +80 -0
  66. package/esm/domain/console/consoleObservable.js.map +1 -0
  67. package/esm/domain/context/contextConstants.d.ts +21 -0
  68. package/esm/domain/context/contextConstants.js +15 -0
  69. package/esm/domain/context/contextConstants.js.map +1 -0
  70. package/esm/domain/context/contextManager.d.ts +19 -0
  71. package/esm/domain/context/contextManager.js +57 -0
  72. package/esm/domain/context/contextManager.js.map +1 -0
  73. package/esm/domain/context/contextUtils.d.ts +5 -0
  74. package/esm/domain/context/contextUtils.js +13 -0
  75. package/esm/domain/context/contextUtils.js.map +1 -0
  76. package/esm/domain/context/defineContextMethod.d.ts +6 -0
  77. package/esm/domain/context/defineContextMethod.js +17 -0
  78. package/esm/domain/context/defineContextMethod.js.map +1 -0
  79. package/esm/domain/context/storeContextManager.d.ts +6 -0
  80. package/esm/domain/context/storeContextManager.js +35 -0
  81. package/esm/domain/context/storeContextManager.js.map +1 -0
  82. package/esm/domain/contexts/accountContext.d.ts +26 -0
  83. package/esm/domain/contexts/accountContext.js +29 -0
  84. package/esm/domain/contexts/accountContext.js.map +1 -0
  85. package/esm/domain/contexts/globalContext.d.ts +18 -0
  86. package/esm/domain/contexts/globalContext.js +17 -0
  87. package/esm/domain/contexts/globalContext.js.map +1 -0
  88. package/esm/domain/contexts/rumInternalContext.type.d.ts +14 -0
  89. package/esm/domain/contexts/rumInternalContext.type.js +2 -0
  90. package/esm/domain/contexts/rumInternalContext.type.js.map +1 -0
  91. package/esm/domain/contexts/userContext.d.ts +29 -0
  92. package/esm/domain/contexts/userContext.js +41 -0
  93. package/esm/domain/contexts/userContext.js.map +1 -0
  94. package/esm/domain/deflate/deflate.types.d.ts +40 -0
  95. package/esm/domain/deflate/deflate.types.js +2 -0
  96. package/esm/domain/deflate/deflate.types.js.map +1 -0
  97. package/esm/domain/deflate/index.d.ts +1 -0
  98. package/esm/domain/deflate/index.js +2 -0
  99. package/esm/domain/deflate/index.js.map +1 -0
  100. package/esm/domain/error/error.d.ts +23 -0
  101. package/esm/domain/error/error.js +65 -0
  102. package/esm/domain/error/error.js.map +1 -0
  103. package/esm/domain/error/error.types.d.ts +47 -0
  104. package/esm/domain/error/error.types.js +10 -0
  105. package/esm/domain/error/error.types.js.map +1 -0
  106. package/esm/domain/error/trackRuntimeError.d.ts +11 -0
  107. package/esm/domain/error/trackRuntimeError.js +43 -0
  108. package/esm/domain/error/trackRuntimeError.js.map +1 -0
  109. package/esm/domain/eventRateLimiter/createEventRateLimiter.d.ts +5 -0
  110. package/esm/domain/eventRateLimiter/createEventRateLimiter.js +38 -0
  111. package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -0
  112. package/esm/domain/extension/extensionUtils.d.ts +10 -0
  113. package/esm/domain/extension/extensionUtils.js +25 -0
  114. package/esm/domain/extension/extensionUtils.js.map +1 -0
  115. package/esm/domain/intakeSites.d.ts +8 -0
  116. package/esm/domain/intakeSites.js +8 -0
  117. package/esm/domain/intakeSites.js.map +1 -0
  118. package/esm/domain/report/browser.types.d.ts +34 -0
  119. package/esm/domain/report/browser.types.js +2 -0
  120. package/esm/domain/report/browser.types.js.map +1 -0
  121. package/esm/domain/report/reportObservable.d.ts +14 -0
  122. package/esm/domain/report/reportObservable.js +95 -0
  123. package/esm/domain/report/reportObservable.js.map +1 -0
  124. package/esm/domain/resourceUtils.d.ts +18 -0
  125. package/esm/domain/resourceUtils.js +17 -0
  126. package/esm/domain/resourceUtils.js.map +1 -0
  127. package/esm/domain/session/oldCookiesMigration.d.ts +11 -0
  128. package/esm/domain/session/oldCookiesMigration.js +36 -0
  129. package/esm/domain/session/oldCookiesMigration.js.map +1 -0
  130. package/esm/domain/session/sessionConstants.d.ts +15 -0
  131. package/esm/domain/session/sessionConstants.js +13 -0
  132. package/esm/domain/session/sessionConstants.js.map +1 -0
  133. package/esm/domain/session/sessionManager.d.ts +28 -0
  134. package/esm/domain/session/sessionManager.js +196 -0
  135. package/esm/domain/session/sessionManager.js.map +1 -0
  136. package/esm/domain/session/sessionState.d.ts +16 -0
  137. package/esm/domain/session/sessionState.js +60 -0
  138. package/esm/domain/session/sessionState.js.map +1 -0
  139. package/esm/domain/session/sessionStateValidation.d.ts +3 -0
  140. package/esm/domain/session/sessionStateValidation.js +7 -0
  141. package/esm/domain/session/sessionStateValidation.js.map +1 -0
  142. package/esm/domain/session/sessionStore.d.ts +38 -0
  143. package/esm/domain/session/sessionStore.js +179 -0
  144. package/esm/domain/session/sessionStore.js.map +1 -0
  145. package/esm/domain/session/sessionStoreOperations.d.ts +12 -0
  146. package/esm/domain/session/sessionStoreOperations.js +114 -0
  147. package/esm/domain/session/sessionStoreOperations.js.map +1 -0
  148. package/esm/domain/session/storeStrategies/sessionInCookie.d.ts +12 -0
  149. package/esm/domain/session/storeStrategies/sessionInCookie.js +98 -0
  150. package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
  151. package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +6 -0
  152. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +37 -0
  153. package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -0
  154. package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +16 -0
  155. package/esm/domain/session/storeStrategies/sessionStoreStrategy.js +2 -0
  156. package/esm/domain/session/storeStrategies/sessionStoreStrategy.js.map +1 -0
  157. package/esm/domain/synthetics/syntheticsWorkerValues.d.ts +12 -0
  158. package/esm/domain/synthetics/syntheticsWorkerValues.js +24 -0
  159. package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -0
  160. package/esm/domain/tags.d.ts +6 -0
  161. package/esm/domain/tags.js +60 -0
  162. package/esm/domain/tags.js.map +1 -0
  163. package/esm/domain/telemetry/index.d.ts +4 -0
  164. package/esm/domain/telemetry/index.js +3 -0
  165. package/esm/domain/telemetry/index.js.map +1 -0
  166. package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +18 -0
  167. package/esm/domain/telemetry/rawTelemetryEvent.types.js +6 -0
  168. package/esm/domain/telemetry/rawTelemetryEvent.types.js.map +1 -0
  169. package/esm/domain/telemetry/telemetry.d.ts +56 -0
  170. package/esm/domain/telemetry/telemetry.js +228 -0
  171. package/esm/domain/telemetry/telemetry.js.map +1 -0
  172. package/esm/domain/telemetry/telemetryEvent.types.d.ts +866 -0
  173. package/esm/domain/telemetry/telemetryEvent.types.js +6 -0
  174. package/esm/domain/telemetry/telemetryEvent.types.js.map +1 -0
  175. package/esm/domain/trackingConsent.d.ts +13 -0
  176. package/esm/domain/trackingConsent.js +24 -0
  177. package/esm/domain/trackingConsent.js.map +1 -0
  178. package/esm/index.d.ts +100 -0
  179. package/esm/index.js +76 -0
  180. package/esm/index.js.map +1 -0
  181. package/esm/tools/abstractHooks.d.ts +24 -0
  182. package/esm/tools/abstractHooks.js +37 -0
  183. package/esm/tools/abstractHooks.js.map +1 -0
  184. package/esm/tools/abstractLifeCycle.d.ts +23 -0
  185. package/esm/tools/abstractLifeCycle.js +24 -0
  186. package/esm/tools/abstractLifeCycle.js.map +1 -0
  187. package/esm/tools/boundedBuffer.d.ts +16 -0
  188. package/esm/tools/boundedBuffer.js +29 -0
  189. package/esm/tools/boundedBuffer.js.map +1 -0
  190. package/esm/tools/catchUserErrors.d.ts +1 -0
  191. package/esm/tools/catchUserErrors.js +12 -0
  192. package/esm/tools/catchUserErrors.js.map +1 -0
  193. package/esm/tools/display.d.ts +38 -0
  194. package/esm/tools/display.js +41 -0
  195. package/esm/tools/display.js.map +1 -0
  196. package/esm/tools/encoder.d.ts +54 -0
  197. package/esm/tools/encoder.js +37 -0
  198. package/esm/tools/encoder.js.map +1 -0
  199. package/esm/tools/experimentalFeatures.d.ts +21 -0
  200. package/esm/tools/experimentalFeatures.js +42 -0
  201. package/esm/tools/experimentalFeatures.js.map +1 -0
  202. package/esm/tools/getZoneJsOriginalValue.d.ts +19 -0
  203. package/esm/tools/getZoneJsOriginalValue.js +26 -0
  204. package/esm/tools/getZoneJsOriginalValue.js.map +1 -0
  205. package/esm/tools/globalObject.d.ts +19 -0
  206. package/esm/tools/globalObject.js +40 -0
  207. package/esm/tools/globalObject.js.map +1 -0
  208. package/esm/tools/instrumentMethod.d.ts +75 -0
  209. package/esm/tools/instrumentMethod.js +114 -0
  210. package/esm/tools/instrumentMethod.js.map +1 -0
  211. package/esm/tools/matchOption.d.ts +8 -0
  212. package/esm/tools/matchOption.js +31 -0
  213. package/esm/tools/matchOption.js.map +1 -0
  214. package/esm/tools/mergeInto.d.ts +25 -0
  215. package/esm/tools/mergeInto.js +93 -0
  216. package/esm/tools/mergeInto.js.map +1 -0
  217. package/esm/tools/monitor.d.ts +9 -0
  218. package/esm/tools/monitor.js +52 -0
  219. package/esm/tools/monitor.js.map +1 -0
  220. package/esm/tools/observable.d.ts +30 -0
  221. package/esm/tools/observable.js +83 -0
  222. package/esm/tools/observable.js.map +1 -0
  223. package/esm/tools/queueMicrotask.d.ts +1 -0
  224. package/esm/tools/queueMicrotask.js +14 -0
  225. package/esm/tools/queueMicrotask.js.map +1 -0
  226. package/esm/tools/readBytesFromStream.d.ts +10 -0
  227. package/esm/tools/readBytesFromStream.js +25 -0
  228. package/esm/tools/readBytesFromStream.js.map +1 -0
  229. package/esm/tools/requestIdleCallback.d.ts +12 -0
  230. package/esm/tools/requestIdleCallback.js +30 -0
  231. package/esm/tools/requestIdleCallback.js.map +1 -0
  232. package/esm/tools/sendToExtension.d.ts +3 -0
  233. package/esm/tools/sendToExtension.js +8 -0
  234. package/esm/tools/sendToExtension.js.map +1 -0
  235. package/esm/tools/serialisation/context.d.ts +9 -0
  236. package/esm/tools/serialisation/context.js +2 -0
  237. package/esm/tools/serialisation/context.js.map +1 -0
  238. package/esm/tools/serialisation/jsonStringify.d.ts +13 -0
  239. package/esm/tools/serialisation/jsonStringify.js +44 -0
  240. package/esm/tools/serialisation/jsonStringify.js.map +1 -0
  241. package/esm/tools/serialisation/sanitize.d.ts +18 -0
  242. package/esm/tools/serialisation/sanitize.js +185 -0
  243. package/esm/tools/serialisation/sanitize.js.map +1 -0
  244. package/esm/tools/stackTrace/computeStackTrace.d.ts +25 -0
  245. package/esm/tools/stackTrace/computeStackTrace.js +183 -0
  246. package/esm/tools/stackTrace/computeStackTrace.js.map +1 -0
  247. package/esm/tools/stackTrace/handlingStack.d.ts +10 -0
  248. package/esm/tools/stackTrace/handlingStack.js +41 -0
  249. package/esm/tools/stackTrace/handlingStack.js.map +1 -0
  250. package/esm/tools/taskQueue.d.ts +15 -0
  251. package/esm/tools/taskQueue.js +50 -0
  252. package/esm/tools/taskQueue.js.map +1 -0
  253. package/esm/tools/timer.d.ts +5 -0
  254. package/esm/tools/timer.js +16 -0
  255. package/esm/tools/timer.js.map +1 -0
  256. package/esm/tools/utils/arrayUtils.d.ts +3 -0
  257. package/esm/tools/utils/arrayUtils.js +15 -0
  258. package/esm/tools/utils/arrayUtils.js.map +1 -0
  259. package/esm/tools/utils/browserDetection.d.ts +8 -0
  260. package/esm/tools/utils/browserDetection.js +28 -0
  261. package/esm/tools/utils/browserDetection.js.map +1 -0
  262. package/esm/tools/utils/byteUtils.d.ts +8 -0
  263. package/esm/tools/utils/byteUtils.js +29 -0
  264. package/esm/tools/utils/byteUtils.js.map +1 -0
  265. package/esm/tools/utils/functionUtils.d.ts +8 -0
  266. package/esm/tools/utils/functionUtils.js +39 -0
  267. package/esm/tools/utils/functionUtils.js.map +1 -0
  268. package/esm/tools/utils/numberUtils.d.ts +9 -0
  269. package/esm/tools/utils/numberUtils.js +18 -0
  270. package/esm/tools/utils/numberUtils.js.map +1 -0
  271. package/esm/tools/utils/objectUtils.d.ts +10 -0
  272. package/esm/tools/utils/objectUtils.js +17 -0
  273. package/esm/tools/utils/objectUtils.js.map +1 -0
  274. package/esm/tools/utils/polyfills.d.ts +7 -0
  275. package/esm/tools/utils/polyfills.js +18 -0
  276. package/esm/tools/utils/polyfills.js.map +1 -0
  277. package/esm/tools/utils/responseUtils.d.ts +2 -0
  278. package/esm/tools/utils/responseUtils.js +13 -0
  279. package/esm/tools/utils/responseUtils.js.map +1 -0
  280. package/esm/tools/utils/stringUtils.d.ts +23 -0
  281. package/esm/tools/utils/stringUtils.js +84 -0
  282. package/esm/tools/utils/stringUtils.js.map +1 -0
  283. package/esm/tools/utils/timeUtils.d.ts +53 -0
  284. package/esm/tools/utils/timeUtils.js +84 -0
  285. package/esm/tools/utils/timeUtils.js.map +1 -0
  286. package/esm/tools/utils/timezone.d.ts +1 -0
  287. package/esm/tools/utils/timezone.js +10 -0
  288. package/esm/tools/utils/timezone.js.map +1 -0
  289. package/esm/tools/utils/typeUtils.d.ts +4 -0
  290. package/esm/tools/utils/typeUtils.js +13 -0
  291. package/esm/tools/utils/typeUtils.js.map +1 -0
  292. package/esm/tools/utils/urlPolyfill.d.ts +5 -0
  293. package/esm/tools/utils/urlPolyfill.js +52 -0
  294. package/esm/tools/utils/urlPolyfill.js.map +1 -0
  295. package/esm/tools/valueHistory.d.ts +27 -0
  296. package/esm/tools/valueHistory.js +100 -0
  297. package/esm/tools/valueHistory.js.map +1 -0
  298. package/esm/transport/batch.d.ts +16 -0
  299. package/esm/transport/batch.js +106 -0
  300. package/esm/transport/batch.js.map +1 -0
  301. package/esm/transport/eventBridge.d.ts +21 -0
  302. package/esm/transport/eventBridge.js +41 -0
  303. package/esm/transport/eventBridge.js.map +1 -0
  304. package/esm/transport/flushController.d.ts +65 -0
  305. package/esm/transport/flushController.js +119 -0
  306. package/esm/transport/flushController.js.map +1 -0
  307. package/esm/transport/httpRequest.d.ts +56 -0
  308. package/esm/transport/httpRequest.js +89 -0
  309. package/esm/transport/httpRequest.js.map +1 -0
  310. package/esm/transport/index.d.ts +7 -0
  311. package/esm/transport/index.js +5 -0
  312. package/esm/transport/index.js.map +1 -0
  313. package/esm/transport/sendWithRetryStrategy.d.ts +41 -0
  314. package/esm/transport/sendWithRetryStrategy.js +158 -0
  315. package/esm/transport/sendWithRetryStrategy.js.map +1 -0
  316. package/package.json +1 -1
  317. package/src/boot/displayAlreadyInitializedError.ts +1 -1
  318. package/src/boot/init.ts +1 -1
  319. package/src/browser/addEventListener.ts +2 -2
  320. package/src/domain/configuration/configuration.ts +6 -5
  321. package/src/domain/configuration/endpointBuilder.ts +25 -15
  322. package/src/domain/context/storeContextManager.ts +1 -1
@@ -0,0 +1,38 @@
1
+ import { Observable } from '../tools/observable';
2
+ import type { ClocksState } from '../tools/utils/timeUtils';
3
+ interface FetchContextBase {
4
+ method: string;
5
+ startClocks: ClocksState;
6
+ input: unknown;
7
+ init?: RequestInit;
8
+ url: string;
9
+ handlingStack?: string;
10
+ }
11
+ export interface FetchStartContext extends FetchContextBase {
12
+ state: 'start';
13
+ }
14
+ export interface FetchResolveContext extends FetchContextBase {
15
+ state: 'resolve';
16
+ status: number;
17
+ response?: Response;
18
+ responseBody?: string;
19
+ responseType?: string;
20
+ isAborted: boolean;
21
+ error?: Error;
22
+ }
23
+ export type FetchContext = FetchStartContext | FetchResolveContext;
24
+ type ResponseBodyActionGetter = (context: FetchResolveContext) => ResponseBodyAction;
25
+ /**
26
+ * Action to take with the response body of a fetch request.
27
+ * Values are ordered by priority: higher values take precedence when multiple actions are requested.
28
+ */
29
+ export declare const enum ResponseBodyAction {
30
+ IGNORE = 0,
31
+ WAIT = 1,
32
+ COLLECT = 2
33
+ }
34
+ export declare function initFetchObservable({ responseBodyAction }?: {
35
+ responseBodyAction?: ResponseBodyActionGetter;
36
+ }): Observable<FetchContext>;
37
+ export declare function resetFetchObservable(): void;
38
+ export {};
@@ -0,0 +1,99 @@
1
+ import { instrumentMethod } from '../tools/instrumentMethod';
2
+ import { monitorError } from '../tools/monitor';
3
+ import { Observable } from '../tools/observable';
4
+ import { clocksNow } from '../tools/utils/timeUtils';
5
+ import { normalizeUrl } from '../tools/utils/urlPolyfill';
6
+ import { globalObject } from '../tools/globalObject';
7
+ import { readBytesFromStream } from '../tools/readBytesFromStream';
8
+ import { tryToClone } from '../tools/utils/responseUtils';
9
+ let fetchObservable;
10
+ const responseBodyActionGetters = [];
11
+ export function initFetchObservable({ responseBodyAction } = {}) {
12
+ if (responseBodyAction) {
13
+ responseBodyActionGetters.push(responseBodyAction);
14
+ }
15
+ if (!fetchObservable) {
16
+ fetchObservable = createFetchObservable();
17
+ }
18
+ return fetchObservable;
19
+ }
20
+ export function resetFetchObservable() {
21
+ fetchObservable = undefined;
22
+ responseBodyActionGetters.length = 0;
23
+ }
24
+ function createFetchObservable() {
25
+ return new Observable((observable) => {
26
+ if (!globalObject.fetch) {
27
+ return;
28
+ }
29
+ const { stop } = instrumentMethod(globalObject, 'fetch', (call) => beforeSend(call, observable), {
30
+ computeHandlingStack: true,
31
+ });
32
+ return stop;
33
+ });
34
+ }
35
+ function beforeSend({ parameters, onPostCall, handlingStack }, observable) {
36
+ const [input, init] = parameters;
37
+ let methodFromParams = init && init.method;
38
+ if (methodFromParams === undefined && input instanceof Request) {
39
+ methodFromParams = input.method;
40
+ }
41
+ const method = methodFromParams !== undefined ? String(methodFromParams).toUpperCase() : 'GET';
42
+ const url = input instanceof Request ? input.url : normalizeUrl(String(input));
43
+ const startClocks = clocksNow();
44
+ const context = {
45
+ state: 'start',
46
+ init,
47
+ input,
48
+ method,
49
+ startClocks,
50
+ url,
51
+ handlingStack,
52
+ };
53
+ observable.notify(context);
54
+ // Those properties can be changed by observable subscribers
55
+ parameters[0] = context.input;
56
+ parameters[1] = context.init;
57
+ onPostCall((responsePromise) => {
58
+ afterSend(observable, responsePromise, context).catch(monitorError);
59
+ });
60
+ }
61
+ async function afterSend(observable, responsePromise, startContext) {
62
+ var _a, _b;
63
+ const context = startContext;
64
+ context.state = 'resolve';
65
+ let response;
66
+ try {
67
+ response = await responsePromise;
68
+ }
69
+ catch (error) {
70
+ context.status = 0;
71
+ context.isAborted =
72
+ ((_b = (_a = context.init) === null || _a === void 0 ? void 0 : _a.signal) === null || _b === void 0 ? void 0 : _b.aborted) || (error instanceof DOMException && error.code === DOMException.ABORT_ERR);
73
+ context.error = error;
74
+ observable.notify(context);
75
+ return;
76
+ }
77
+ context.response = response;
78
+ context.status = response.status;
79
+ context.responseType = response.type;
80
+ context.isAborted = false;
81
+ const responseBodyCondition = responseBodyActionGetters.reduce((action, getter) => Math.max(action, getter(context)), 0 /* ResponseBodyAction.IGNORE */);
82
+ if (responseBodyCondition !== 0 /* ResponseBodyAction.IGNORE */) {
83
+ const clonedResponse = tryToClone(response);
84
+ if (clonedResponse && clonedResponse.body) {
85
+ try {
86
+ const bytes = await readBytesFromStream(clonedResponse.body, {
87
+ collectStreamBody: responseBodyCondition === 2 /* ResponseBodyAction.COLLECT */,
88
+ });
89
+ context.responseBody = bytes && new TextDecoder().decode(bytes);
90
+ }
91
+ catch (_c) {
92
+ // Ignore errors when reading the response body (e.g., stream aborted, network errors)
93
+ // This is not critical and should not be reported as an SDK error
94
+ }
95
+ }
96
+ }
97
+ observable.notify(context);
98
+ }
99
+ //# sourceMappingURL=fetchObservable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchObservable.js","sourceRoot":"","sources":["../../src/browser/fetchObservable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAyCzD,IAAI,eAAqD,CAAA;AACzD,MAAM,yBAAyB,GAA+B,EAAE,CAAA;AAEhE,MAAM,UAAU,mBAAmB,CAAC,EAAE,kBAAkB,KAAwD,EAAE;IAChH,IAAI,kBAAkB,EAAE,CAAC;QACvB,yBAAyB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACpD,CAAC;IACD,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,qBAAqB,EAAE,CAAA;IAC3C,CAAC;IACD,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,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C,MAAM,CAC5D,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,oCAEhC,CAAA;IAEvB,IAAI,qBAAqB,sCAA8B,EAAE,CAAC;QACxD,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;QAC3C,IAAI,cAAc,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC;YAC1C,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,cAAc,CAAC,IAAI,EAAE;oBAC3D,iBAAiB,EAAE,qBAAqB,uCAA+B;iBACxE,CAAC,CAAA;gBACF,OAAO,CAAC,YAAY,GAAG,KAAK,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACjE,CAAC;YAAC,WAAM,CAAC;gBACP,sFAAsF;gBACtF,kEAAkE;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAED,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Observable } from '../tools/observable';
2
+ import type { Configuration } from '../domain/configuration';
3
+ export declare const PageExitReason: {
4
+ readonly HIDDEN: "visibility_hidden";
5
+ readonly UNLOADING: "before_unload";
6
+ readonly PAGEHIDE: "page_hide";
7
+ readonly FROZEN: "page_frozen";
8
+ };
9
+ export type PageExitReason = (typeof PageExitReason)[keyof typeof PageExitReason];
10
+ export interface PageMayExitEvent {
11
+ reason: PageExitReason;
12
+ }
13
+ export declare function createPageMayExitObservable(configuration: Configuration): Observable<PageMayExitEvent>;
14
+ export declare function isPageExitReason(reason: string): reason is PageExitReason;
@@ -0,0 +1,40 @@
1
+ import { Observable } from '../tools/observable';
2
+ import { objectValues } from '../tools/utils/polyfills';
3
+ import { addEventListeners, addEventListener } from './addEventListener';
4
+ export const PageExitReason = {
5
+ HIDDEN: 'visibility_hidden',
6
+ UNLOADING: 'before_unload',
7
+ PAGEHIDE: 'page_hide',
8
+ FROZEN: 'page_frozen',
9
+ };
10
+ export function createPageMayExitObservable(configuration) {
11
+ return new Observable((observable) => {
12
+ const { stop: stopListeners } = addEventListeners(configuration, window, ["visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, "freeze" /* DOM_EVENT.FREEZE */], (event) => {
13
+ if (event.type === "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */ && document.visibilityState === 'hidden') {
14
+ /**
15
+ * Only event that guarantee to fire on mobile devices when the page transitions to background state
16
+ * (e.g. when user switches to a different application, goes to homescreen, etc), or is being unloaded.
17
+ */
18
+ observable.notify({ reason: PageExitReason.HIDDEN });
19
+ }
20
+ else if (event.type === "freeze" /* DOM_EVENT.FREEZE */) {
21
+ /**
22
+ * After transitioning in background a tab can be freezed to preserve resources. (cf: https://developer.chrome.com/blog/page-lifecycle-api)
23
+ * Allow to collect events happening between hidden and frozen state.
24
+ */
25
+ observable.notify({ reason: PageExitReason.FROZEN });
26
+ }
27
+ }, { capture: true });
28
+ const stopBeforeUnloadListener = addEventListener(configuration, window, "beforeunload" /* DOM_EVENT.BEFORE_UNLOAD */, () => {
29
+ observable.notify({ reason: PageExitReason.UNLOADING });
30
+ }).stop;
31
+ return () => {
32
+ stopListeners();
33
+ stopBeforeUnloadListener();
34
+ };
35
+ });
36
+ }
37
+ export function isPageExitReason(reason) {
38
+ return objectValues(PageExitReason).includes(reason);
39
+ }
40
+ //# sourceMappingURL=pageMayExitObservable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageMayExitObservable.js","sourceRoot":"","sources":["../../src/browser/pageMayExitObservable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAa,MAAM,oBAAoB,CAAA;AAE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ACxE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Configuration } from '../domain/configuration';
2
+ export declare function runOnReadyState(configuration: Configuration, expectedReadyState: 'complete' | 'interactive', callback: () => void): {
3
+ stop: () => void;
4
+ };
5
+ export declare function asyncRunOnReadyState(configuration: Configuration, expectedReadyState: 'complete' | 'interactive'): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import { noop } from '../tools/utils/functionUtils';
2
+ import { addEventListener } from './addEventListener';
3
+ export function runOnReadyState(configuration, expectedReadyState, callback) {
4
+ if (document.readyState === expectedReadyState || document.readyState === 'complete') {
5
+ callback();
6
+ return { stop: noop };
7
+ }
8
+ const eventName = expectedReadyState === 'complete' ? "load" /* DOM_EVENT.LOAD */ : "DOMContentLoaded" /* DOM_EVENT.DOM_CONTENT_LOADED */;
9
+ return addEventListener(configuration, window, eventName, callback, { once: true });
10
+ }
11
+ export function asyncRunOnReadyState(configuration, expectedReadyState) {
12
+ return new Promise((resolve) => {
13
+ runOnReadyState(configuration, expectedReadyState, resolve);
14
+ });
15
+ }
16
+ //# sourceMappingURL=runOnReadyState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runOnReadyState.js","sourceRoot":"","sources":["../../src/browser/runOnReadyState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AACnD,OAAO,EAAa,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAEhE,MAAM,UAAU,eAAe,CAC7B,aAA4B,EAC5B,kBAA8C,EAC9C,QAAoB;IAEpB,IAAI,QAAQ,CAAC,UAAU,KAAK,kBAAkB,IAAI,QAAQ,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QACrF,QAAQ,EAAE,CAAA;QACV,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IACvB,CAAC;IACD,MAAM,SAAS,GAAG,kBAAkB,KAAK,UAAU,CAAC,CAAC,6BAAgB,CAAC,sDAA6B,CAAA;IACnG,OAAO,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,aAA4B,EAC5B,kBAA8C;IAE9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,eAAe,CAAC,aAAa,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Observable } from '../tools/observable';
2
+ import type { Duration, ClocksState } from '../tools/utils/timeUtils';
3
+ import type { Configuration } from '../domain/configuration';
4
+ export interface XhrOpenContext {
5
+ state: 'open';
6
+ method: string;
7
+ url: string;
8
+ }
9
+ export interface XhrStartContext extends Omit<XhrOpenContext, 'state'> {
10
+ state: 'start';
11
+ startClocks: ClocksState;
12
+ isAborted: boolean;
13
+ xhr: XMLHttpRequest;
14
+ handlingStack?: string;
15
+ requestBody?: unknown;
16
+ }
17
+ export interface XhrCompleteContext extends Omit<XhrStartContext, 'state'> {
18
+ state: 'complete';
19
+ duration: Duration;
20
+ status: number;
21
+ responseBody?: string;
22
+ }
23
+ export type XhrContext = XhrOpenContext | XhrStartContext | XhrCompleteContext;
24
+ export declare function initXhrObservable(configuration: Configuration): Observable<XhrContext>;
@@ -0,0 +1,83 @@
1
+ import { instrumentMethod } from '../tools/instrumentMethod';
2
+ import { Observable } from '../tools/observable';
3
+ import { elapsed, clocksNow, timeStampNow } from '../tools/utils/timeUtils';
4
+ import { normalizeUrl } from '../tools/utils/urlPolyfill';
5
+ import { shallowClone } from '../tools/utils/objectUtils';
6
+ import { addEventListener } from './addEventListener';
7
+ let xhrObservable;
8
+ const xhrContexts = new WeakMap();
9
+ export function initXhrObservable(configuration) {
10
+ if (!xhrObservable) {
11
+ xhrObservable = createXhrObservable(configuration);
12
+ }
13
+ return xhrObservable;
14
+ }
15
+ function createXhrObservable(configuration) {
16
+ return new Observable((observable) => {
17
+ const { stop: stopInstrumentingStart } = instrumentMethod(XMLHttpRequest.prototype, 'open', openXhr);
18
+ const { stop: stopInstrumentingSend } = instrumentMethod(XMLHttpRequest.prototype, 'send', (call) => {
19
+ sendXhr(call, configuration, observable);
20
+ }, { computeHandlingStack: true });
21
+ const { stop: stopInstrumentingAbort } = instrumentMethod(XMLHttpRequest.prototype, 'abort', abortXhr);
22
+ return () => {
23
+ stopInstrumentingStart();
24
+ stopInstrumentingSend();
25
+ stopInstrumentingAbort();
26
+ };
27
+ });
28
+ }
29
+ function openXhr({ target: xhr, parameters: [method, url] }) {
30
+ xhrContexts.set(xhr, {
31
+ state: 'open',
32
+ method: String(method).toUpperCase(),
33
+ url: normalizeUrl(String(url)),
34
+ });
35
+ }
36
+ function sendXhr({ target: xhr, parameters: [body], handlingStack }, configuration, observable) {
37
+ const context = xhrContexts.get(xhr);
38
+ if (!context) {
39
+ return;
40
+ }
41
+ const startContext = context;
42
+ startContext.state = 'start';
43
+ startContext.startClocks = clocksNow();
44
+ startContext.isAborted = false;
45
+ startContext.xhr = xhr;
46
+ startContext.handlingStack = handlingStack;
47
+ startContext.requestBody = body;
48
+ let hasBeenReported = false;
49
+ const { stop: stopInstrumentingOnReadyStateChange } = instrumentMethod(xhr, 'onreadystatechange', () => {
50
+ if (xhr.readyState === XMLHttpRequest.DONE) {
51
+ // Try to report the XHR as soon as possible, because the XHR may be mutated by the
52
+ // application during a future event. For example, Angular is calling .abort() on
53
+ // completed requests during an onreadystatechange event, so the status becomes '0'
54
+ // before the request is collected.
55
+ onEnd();
56
+ }
57
+ });
58
+ const onEnd = () => {
59
+ unsubscribeLoadEndListener();
60
+ stopInstrumentingOnReadyStateChange();
61
+ if (hasBeenReported) {
62
+ return;
63
+ }
64
+ hasBeenReported = true;
65
+ const completeContext = context;
66
+ completeContext.state = 'complete';
67
+ completeContext.duration = elapsed(startContext.startClocks.timeStamp, timeStampNow());
68
+ completeContext.status = xhr.status;
69
+ if (typeof xhr.response === 'string') {
70
+ completeContext.responseBody = xhr.response;
71
+ }
72
+ observable.notify(shallowClone(completeContext));
73
+ };
74
+ const { stop: unsubscribeLoadEndListener } = addEventListener(configuration, xhr, 'loadend', onEnd);
75
+ observable.notify(startContext);
76
+ }
77
+ function abortXhr({ target: xhr }) {
78
+ const context = xhrContexts.get(xhr);
79
+ if (context) {
80
+ context.isAborted = true;
81
+ }
82
+ }
83
+ //# sourceMappingURL=xhrObservable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xhrObservable.js","sourceRoot":"","sources":["../../src/browser/xhrObservable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AA0BrD,IAAI,aAAiD,CAAA;AACrD,MAAM,WAAW,GAAG,IAAI,OAAO,EAA8B,CAAA;AAE7D,MAAM,UAAU,iBAAiB,CAAC,aAA4B;IAC5D,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,SAAS,mBAAmB,CAAC,aAA4B;IACvD,OAAO,IAAI,UAAU,CAAa,CAAC,UAAU,EAAE,EAAE;QAC/C,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE,GAAG,gBAAgB,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAEpG,MAAM,EAAE,IAAI,EA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C,YAAY,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,EAAmD;IAChF,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAgC,CAAA;IACnE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,SAAS,GAAG,IAAI,CAAA;IAC1B,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { InitConfiguration } from './configuration';
2
+ export declare const ERROR_DOES_NOT_HAVE_ALLOWED_TRACKING_ORIGIN = "Running the Browser SDK in a Web extension content script is forbidden unless the `allowedTrackingOrigins` option is provided.";
3
+ export declare const ERROR_NOT_ALLOWED_TRACKING_ORIGIN = "SDK initialized on a non-allowed domain.";
4
+ export declare function isAllowedTrackingOrigins(configuration: InitConfiguration, errorStack: string, windowOrigin?: string): boolean;
@@ -0,0 +1,21 @@
1
+ import { display } from '../tools/display';
2
+ import { matchList } from '../tools/matchOption';
3
+ import { isUnsupportedExtensionEnvironment } from './extension/extensionUtils';
4
+ export const ERROR_DOES_NOT_HAVE_ALLOWED_TRACKING_ORIGIN = 'Running the Browser SDK in a Web extension content script is forbidden unless the `allowedTrackingOrigins` option is provided.';
5
+ export const ERROR_NOT_ALLOWED_TRACKING_ORIGIN = 'SDK initialized on a non-allowed domain.';
6
+ export function isAllowedTrackingOrigins(configuration, errorStack, windowOrigin = typeof location !== 'undefined' ? location.origin : '') {
7
+ const allowedTrackingOrigins = configuration.allowedTrackingOrigins;
8
+ if (!allowedTrackingOrigins) {
9
+ if (isUnsupportedExtensionEnvironment(windowOrigin, errorStack)) {
10
+ display.error(ERROR_DOES_NOT_HAVE_ALLOWED_TRACKING_ORIGIN);
11
+ return false;
12
+ }
13
+ return true;
14
+ }
15
+ const isAllowed = matchList(allowedTrackingOrigins, windowOrigin);
16
+ if (!isAllowed) {
17
+ display.error(ERROR_NOT_ALLOWED_TRACKING_ORIGIN);
18
+ }
19
+ return isAllowed;
20
+ }
21
+ //# sourceMappingURL=allowedTrackingOrigins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowedTrackingOrigins.js","sourceRoot":"","sources":["../../src/domain/allowedTrackingOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAA;AAE9E,MAAM,CAAC,MAAM,2CAA2C,GACtD,gIAAgI,CAAA;AAClI,MAAM,CAAC,MAAM,iCAAiC,GAAG,0CAA0C,CAAA;AAE3F,MAAM,UAAU,wBAAwB,CACtC,aAAgC,EAChC,UAAkB,EAClB,YAAY,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;IAErE,MAAM,sBAAsB,GAAG,aAAa,CAAC,sBAAsB,CAAA;IACnE,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,IAAI,iCAAiC,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,CAAC;YAChE,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;YAE1D,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAA;IACjE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { BufferedObservable } from '../tools/observable';
2
+ import type { RawError } from './error/error.types';
3
+ import { trackRuntimeError } from './error/trackRuntimeError';
4
+ export declare const enum BufferedDataType {
5
+ RUNTIME_ERROR = 0
6
+ }
7
+ export interface BufferedData {
8
+ type: BufferedDataType.RUNTIME_ERROR;
9
+ error: RawError;
10
+ }
11
+ export declare function startBufferingData(trackRuntimeErrorImpl?: typeof trackRuntimeError): {
12
+ observable: BufferedObservable<BufferedData>;
13
+ stop: () => void;
14
+ };
@@ -0,0 +1,19 @@
1
+ import { BufferedObservable } from '../tools/observable';
2
+ import { trackRuntimeError } from './error/trackRuntimeError';
3
+ const BUFFER_LIMIT = 500;
4
+ export function startBufferingData(trackRuntimeErrorImpl = trackRuntimeError) {
5
+ const observable = new BufferedObservable(BUFFER_LIMIT);
6
+ const runtimeErrorSubscription = trackRuntimeErrorImpl().subscribe((error) => {
7
+ observable.notify({
8
+ type: 0 /* BufferedDataType.RUNTIME_ERROR */,
9
+ error,
10
+ });
11
+ });
12
+ return {
13
+ observable,
14
+ stop: () => {
15
+ runtimeErrorSubscription.unsubscribe();
16
+ },
17
+ };
18
+ }
19
+ //# sourceMappingURL=bufferedData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferedData.js","sourceRoot":"","sources":["../../src/domain/bufferedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,MAAM,YAAY,GAAG,GAAG,CAAA;AAWxB,MAAM,UAAU,kBAAkB,CAAC,qBAAqB,GAAG,iBAAiB;IAC1E,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAe,YAAY,CAAC,CAAA;IAErE,MAAM,wBAAwB,GAAG,qBAAqB,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3E,UAAU,CAAC,MAAM,CAAC;YAChB,IAAI,wCAAgC;YACpC,KAAK;SACN,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,UAAU;QACV,IAAI,EAAE,GAAG,EAAE;YACT,wBAAwB,CAAC,WAAW,EAAE,CAAA;QACxC,CAAC;KACF,CAAA;AACH,CAAC"}