@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,91 +0,0 @@
1
- import { instrumentMethodAndCallOriginal } from '../../tools/instrumentMethod';
2
- import { computeStackTrace } from './computeStackTrace';
3
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
4
- var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;
5
- /**
6
- * Cross-browser collection of unhandled errors
7
- *
8
- * Supports:
9
- * - Firefox: full stack trace with line numbers, plus column number
10
- * on top frame; column number is not guaranteed
11
- * - Opera: full stack trace with line and column numbers
12
- * - Chrome: full stack trace with line and column numbers
13
- * - Safari: line and column number for the top frame only; some frames
14
- * may be missing, and column number is not guaranteed
15
- * - IE: line and column number for the top frame only; some frames
16
- * may be missing, and column number is not guaranteed
17
- *
18
- * In theory, TraceKit should work on all of the following versions:
19
- * - IE5.5+ (only 8.0 tested)
20
- * - Firefox 0.9+ (only 3.5+ tested)
21
- * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require
22
- * Exceptions Have Stacktrace to be enabled in opera:config)
23
- * - Safari 3+ (only 4+ tested)
24
- * - Chrome 1+ (only 5+ tested)
25
- * - Konqueror 3.5+ (untested)
26
- *
27
- * Tries to catch all unhandled errors and report them to the
28
- * callback.
29
- *
30
- * Callbacks receive a StackTrace object as described in the
31
- * computeStackTrace docs.
32
- *
33
- * @memberof TraceKit
34
- * @namespace
35
- */
36
- export function startUnhandledErrorCollection(callback) {
37
- var stopInstrumentingOnError = instrumentOnError(callback).stop;
38
- var stopInstrumentingOnUnhandledRejection = instrumentUnhandledRejection(callback).stop;
39
- return {
40
- stop: function () {
41
- stopInstrumentingOnError();
42
- stopInstrumentingOnUnhandledRejection();
43
- },
44
- };
45
- }
46
- /**
47
- * Install a global onerror handler
48
- */
49
- function instrumentOnError(callback) {
50
- return instrumentMethodAndCallOriginal(window, 'onerror', {
51
- before: function (messageObj, url, line, column, errorObj) {
52
- var stackTrace;
53
- if (errorObj instanceof Error) {
54
- stackTrace = computeStackTrace(errorObj);
55
- }
56
- else {
57
- var stack = [{ url: url, column: column, line: line }];
58
- var _a = tryToParseMessage(messageObj), name_1 = _a.name, message = _a.message;
59
- stackTrace = {
60
- name: name_1,
61
- message: message,
62
- stack: stack,
63
- };
64
- }
65
- callback(stackTrace, errorObj !== null && errorObj !== void 0 ? errorObj : messageObj);
66
- },
67
- });
68
- }
69
- function tryToParseMessage(messageObj) {
70
- var _a;
71
- var name;
72
- var message;
73
- if ({}.toString.call(messageObj) === '[object String]') {
74
- ;
75
- _a = ERROR_TYPES_RE.exec(messageObj), name = _a[1], message = _a[2];
76
- }
77
- return { name: name, message: message };
78
- }
79
- /**
80
- * Install a global onunhandledrejection handler
81
- */
82
- function instrumentUnhandledRejection(callback) {
83
- return instrumentMethodAndCallOriginal(window, 'onunhandledrejection', {
84
- before: function (e) {
85
- var reason = e.reason || 'Empty reason';
86
- var stack = computeStackTrace(reason);
87
- callback(stack, reason);
88
- },
89
- });
90
- }
91
- //# sourceMappingURL=tracekit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tracekit.js","sourceRoot":"","sources":["../../../src/domain/tracekit/tracekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,qGAAqG;AACrG,IAAM,cAAc,GAClB,8GAA8G,CAAA;AAEhH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,UAAU,6BAA6B,CAAC,QAAgC;IACpE,IAAM,wBAAwB,GAAK,iBAAiB,CAAC,QAAQ,CAAC,KAAhC,CAAgC;IAC9D,IAAM,qCAAqC,GAAK,4BAA4B,CAAC,QAAQ,CAAC,KAA3C,CAA2C;IAE9F,OAAO;QACL,IAAI,EAAE;YACJ,wBAAwB,EAAE,CAAA;YAC1B,qCAAqC,EAAE,CAAA;QACzC,CAAC;KACF,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,QAAgC;IACzD,OAAO,+BAA+B,CAAC,MAAM,EAAE,SAAS,EAAE;QACxD,MAAM,YAAY,UAAmB,EAAE,GAAY,EAAE,IAAa,EAAE,MAAe,EAAE,QAAkB;YACrG,IAAI,UAAsB,CAAA;YAC1B,IAAI,QAAQ,YAAY,KAAK,EAAE;gBAC7B,UAAU,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAA;aACzC;iBAAM;gBACL,IAAM,KAAK,GAAG,CAAC,EAAE,GAAG,KAAA,EAAE,MAAM,QAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAA;gBAC/B,IAAA,KAAoB,iBAAiB,CAAC,UAAU,CAAC,EAA/C,MAAI,UAAA,EAAE,OAAO,aAAkC,CAAA;gBACvD,UAAU,GAAG;oBACX,IAAI,QAAA;oBACJ,OAAO,SAAA;oBACP,KAAK,OAAA;iBACN,CAAA;aACF;YACD,QAAQ,CAAC,UAAU,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,UAAU,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAmB;;IAC5C,IAAI,IAAI,CAAA;IACR,IAAI,OAAO,CAAA;IACX,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,iBAAiB,EAAE;QACtD,CAAC;QAAA,KAAoB,cAAc,CAAC,IAAI,CAAC,UAAoB,CAAE,EAA3D,IAAI,QAAA,EAAE,OAAO,QAAA,CAA8C;KAChE;IACD,OAAO,EAAE,IAAI,MAAA,EAAE,OAAO,SAAA,EAAE,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,4BAA4B,CAAC,QAAgC;IACpE,OAAO,+BAA+B,CAAC,MAAM,EAAE,sBAAsB,EAAE;QACrE,MAAM,YAAC,CAAwB;YAC7B,IAAM,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,cAAc,CAAA;YACzC,IAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAA;YACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QACzB,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -1,44 +0,0 @@
1
- export interface BrowserError extends Error {
2
- sourceURL?: string;
3
- fileName?: string;
4
- line?: string | number;
5
- lineNumber?: string | number;
6
- description?: string;
7
- }
8
- export type UnhandledErrorCallback = (stack: StackTrace, errorObject?: any) => any;
9
- /**
10
- * An object representing a single stack frame.
11
- * @typedef {Object} StackFrame
12
- * @property {string=} url The JavaScript or HTML file URL.
13
- * @property {string=} func The function name, or empty for anonymous functions (if guessing did not work).
14
- * @property {string[]=} args The arguments passed to the function, if known.
15
- * @property {number=} line The line number, if known.
16
- * @property {number=} column The column number, if known.
17
- * @property {string[]=} context An array of source code lines; the middle element corresponds to the correct line#.
18
- * @memberof TraceKit
19
- */
20
- export interface StackFrame {
21
- url?: string;
22
- func?: string;
23
- args?: string[];
24
- line?: number;
25
- column?: number;
26
- context?: string[];
27
- }
28
- /**
29
- * An object representing a JavaScript stack trace.
30
- * @typedef {Object} StackTrace
31
- * @property {string=} name The name of the thrown exception.
32
- * @property {string} message The exception error message.
33
- * @property {StackFrame[]} stack An array of stack frames.
34
- * -- method used to collect the stack trace.
35
- * @memberof TraceKit
36
- */
37
- export interface StackTrace {
38
- name?: string;
39
- message?: string;
40
- url?: string;
41
- stack: StackFrame[];
42
- incomplete?: boolean;
43
- partial?: boolean;
44
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/domain/tracekit/types.ts"],"names":[],"mappings":""}
@@ -1,21 +0,0 @@
1
- import { computeBytesCount } from '../utils/byteUtils';
2
- import type { CustomerDataType } from './heavyCustomerDataWarning';
3
- import type { Context } from './context';
4
- export declare const BYTES_COMPUTATION_THROTTLING_DELAY = 200;
5
- export type ContextManager = ReturnType<typeof createContextManager>;
6
- export declare function createContextManager(customerDataType: CustomerDataType, computeBytesCountImpl?: typeof computeBytesCount): {
7
- getBytesCount: () => number;
8
- /** @deprecated use getContext instead */
9
- get: () => Context;
10
- /** @deprecated use setContextProperty instead */
11
- add: (key: string, value: any) => void;
12
- /** @deprecated renamed to removeContextProperty */
13
- remove: (key: string) => void;
14
- /** @deprecated use setContext instead */
15
- set: (newContext: object) => void;
16
- getContext: () => Context;
17
- setContext: (newContext: Context) => void;
18
- setContextProperty: (key: string, property: any) => void;
19
- removeContextProperty: (key: string) => void;
20
- clearContext: () => void;
21
- };
@@ -1,66 +0,0 @@
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
- export var BYTES_COMPUTATION_THROTTLING_DELAY = 200;
9
- export function createContextManager(customerDataType, computeBytesCountImpl) {
10
- if (computeBytesCountImpl === void 0) { computeBytesCountImpl = computeBytesCount; }
11
- var context = {};
12
- var bytesCountCache;
13
- var alreadyWarned = false;
14
- // Throttle the bytes computation to minimize the impact on performance.
15
- // Especially useful if the user call context APIs synchronously multiple times in a row
16
- var computeBytesCountThrottled = throttle(function (context) {
17
- bytesCountCache = computeBytesCountImpl(jsonStringify(context));
18
- if (!alreadyWarned) {
19
- alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, customerDataType);
20
- }
21
- }, BYTES_COMPUTATION_THROTTLING_DELAY).throttled;
22
- var contextManager = {
23
- getBytesCount: function () { return bytesCountCache; },
24
- /** @deprecated use getContext instead */
25
- get: function () { return context; },
26
- /** @deprecated use setContextProperty instead */
27
- add: function (key, value) {
28
- context[key] = value;
29
- computeBytesCountThrottled(context);
30
- },
31
- /** @deprecated renamed to removeContextProperty */
32
- remove: function (key) {
33
- delete context[key];
34
- computeBytesCountThrottled(context);
35
- },
36
- /** @deprecated use setContext instead */
37
- set: function (newContext) {
38
- context = newContext;
39
- computeBytesCountThrottled(context);
40
- },
41
- getContext: function () { return deepClone(context); },
42
- setContext: function (newContext) {
43
- if (getType(newContext) === 'object') {
44
- context = sanitize(newContext);
45
- computeBytesCountThrottled(context);
46
- }
47
- else {
48
- contextManager.clearContext();
49
- }
50
- },
51
- setContextProperty: function (key, property) {
52
- context[key] = sanitize(property);
53
- computeBytesCountThrottled(context);
54
- },
55
- removeContextProperty: function (key) {
56
- delete context[key];
57
- computeBytesCountThrottled(context);
58
- },
59
- clearContext: function () {
60
- context = {};
61
- bytesCountCache = 0;
62
- },
63
- };
64
- return contextManager;
65
- }
66
- //# sourceMappingURL=contextManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contextManager.js","sourceRoot":"","sources":["../../../src/tools/serialisation/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAA;AAI3E,MAAM,CAAC,IAAM,kCAAkC,GAAG,GAAG,CAAA;AAIrD,MAAM,UAAU,oBAAoB,CAAC,gBAAkC,EAAE,qBAAyC;IAAzC,sCAAA,EAAA,yCAAyC;IAChH,IAAI,OAAO,GAAY,EAAE,CAAA;IACzB,IAAI,eAAuB,CAAA;IAC3B,IAAI,aAAa,GAAG,KAAK,CAAA;IAEzB,wEAAwE;IACxE,wFAAwF;IAChF,IAAW,0BAA0B,GAAK,QAAQ,CAAC,UAAC,OAAgB;QAC1E,eAAe,GAAG,qBAAqB,CAAC,aAAa,CAAC,OAAO,CAAE,CAAC,CAAA;QAChE,IAAI,CAAC,aAAa,EAAE;YAClB,aAAa,GAAG,8BAA8B,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAA;SAClF;IACH,CAAC,EAAE,kCAAkC,CAAC,UALO,CAKP;IAEtC,IAAM,cAAc,GAAG;QACrB,aAAa,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;QACpC,yCAAyC;QACzC,GAAG,EAAE,cAAM,OAAA,OAAO,EAAP,CAAO;QAElB,iDAAiD;QACjD,GAAG,EAAE,UAAC,GAAW,EAAE,KAAU;YAC3B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAqB,CAAA;YACpC,0BAA0B,CAAC,OAAO,CAAC,CAAA;QACrC,CAAC;QAED,mDAAmD;QACnD,MAAM,EAAE,UAAC,GAAW;YAClB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;YACnB,0BAA0B,CAAC,OAAO,CAAC,CAAA;QACrC,CAAC;QAED,yCAAyC;QACzC,GAAG,EAAE,UAAC,UAAkB;YACtB,OAAO,GAAG,UAAqB,CAAA;YAC/B,0BAA0B,CAAC,OAAO,CAAC,CAAA;QACrC,CAAC;QAED,UAAU,EAAE,cAAM,OAAA,SAAS,CAAC,OAAO,CAAC,EAAlB,CAAkB;QAEpC,UAAU,EAAE,UAAC,UAAmB;YAC9B,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE;gBACpC,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;gBAC9B,0BAA0B,CAAC,OAAO,CAAC,CAAA;aACpC;iBAAM;gBACL,cAAc,CAAC,YAAY,EAAE,CAAA;aAC9B;QACH,CAAC;QAED,kBAAkB,EAAE,UAAC,GAAW,EAAE,QAAa;YAC7C,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACjC,0BAA0B,CAAC,OAAO,CAAC,CAAA;QACrC,CAAC;QAED,qBAAqB,EAAE,UAAC,GAAW;YACjC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;YACnB,0BAA0B,CAAC,OAAO,CAAC,CAAA;QACrC,CAAC;QAED,YAAY,EAAE;YACZ,OAAO,GAAG,EAAE,CAAA;YACZ,eAAe,GAAG,CAAC,CAAA;QACrB,CAAC;KACF,CAAA;IACD,OAAO,cAAc,CAAA;AACvB,CAAC"}
@@ -1,8 +0,0 @@
1
- export declare const CUSTOMER_DATA_BYTES_LIMIT: number;
2
- export declare const enum CustomerDataType {
3
- FeatureFlag = "feature flag evaluation",
4
- User = "user",
5
- GlobalContext = "global context",
6
- LoggerContext = "logger context"
7
- }
8
- export declare function warnIfCustomerDataLimitReached(bytesCount: number, customerDataType: CustomerDataType): boolean;
@@ -1,14 +0,0 @@
1
- import { ONE_KIBI_BYTE } from '../utils/byteUtils';
2
- import { display } from '../display';
3
- // RUM and logs batch bytes limit is 16KB
4
- // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
5
- // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
6
- export var CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE;
7
- export function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {
8
- if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
9
- display.warn("The ".concat(customerDataType, " data exceeds the recommended ").concat(CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE, "KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-3kib-warning"));
10
- return true;
11
- }
12
- return false;
13
- }
14
- //# sourceMappingURL=heavyCustomerDataWarning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"heavyCustomerDataWarning.js","sourceRoot":"","sources":["../../../src/tools/serialisation/heavyCustomerDataWarning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,yCAAyC;AACzC,uGAAuG;AACvG,+EAA+E;AAC/E,MAAM,CAAC,IAAM,yBAAyB,GAAG,CAAC,GAAG,aAAa,CAAA;AAS1D,MAAM,UAAU,8BAA8B,CAAC,UAAkB,EAAE,gBAAkC;IACnG,IAAI,UAAU,GAAG,yBAAyB,EAAE;QAC1C,OAAO,CAAC,IAAI,CACV,cAAO,gBAAgB,2CACrB,yBAAyB,GAAG,aAAa,6JAC+G,CAC3J,CAAA;QACD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,3 +0,0 @@
1
- export { StackTrace, BrowserError } from './types'
2
- export { computeStackTrace } from './computeStackTrace'
3
- export { startUnhandledErrorCollection } from './tracekit'
@@ -1,96 +0,0 @@
1
- import { instrumentMethodAndCallOriginal } from '../../tools/instrumentMethod'
2
- import { computeStackTrace } from './computeStackTrace'
3
- import type { UnhandledErrorCallback, StackTrace } from './types'
4
-
5
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
6
- const ERROR_TYPES_RE =
7
- /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/
8
-
9
- /**
10
- * Cross-browser collection of unhandled errors
11
- *
12
- * Supports:
13
- * - Firefox: full stack trace with line numbers, plus column number
14
- * on top frame; column number is not guaranteed
15
- * - Opera: full stack trace with line and column numbers
16
- * - Chrome: full stack trace with line and column numbers
17
- * - Safari: line and column number for the top frame only; some frames
18
- * may be missing, and column number is not guaranteed
19
- * - IE: line and column number for the top frame only; some frames
20
- * may be missing, and column number is not guaranteed
21
- *
22
- * In theory, TraceKit should work on all of the following versions:
23
- * - IE5.5+ (only 8.0 tested)
24
- * - Firefox 0.9+ (only 3.5+ tested)
25
- * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require
26
- * Exceptions Have Stacktrace to be enabled in opera:config)
27
- * - Safari 3+ (only 4+ tested)
28
- * - Chrome 1+ (only 5+ tested)
29
- * - Konqueror 3.5+ (untested)
30
- *
31
- * Tries to catch all unhandled errors and report them to the
32
- * callback.
33
- *
34
- * Callbacks receive a StackTrace object as described in the
35
- * computeStackTrace docs.
36
- *
37
- * @memberof TraceKit
38
- * @namespace
39
- */
40
-
41
- export function startUnhandledErrorCollection(callback: UnhandledErrorCallback) {
42
- const { stop: stopInstrumentingOnError } = instrumentOnError(callback)
43
- const { stop: stopInstrumentingOnUnhandledRejection } = instrumentUnhandledRejection(callback)
44
-
45
- return {
46
- stop: () => {
47
- stopInstrumentingOnError()
48
- stopInstrumentingOnUnhandledRejection()
49
- },
50
- }
51
- }
52
-
53
- /**
54
- * Install a global onerror handler
55
- */
56
- function instrumentOnError(callback: UnhandledErrorCallback) {
57
- return instrumentMethodAndCallOriginal(window, 'onerror', {
58
- before(this: any, messageObj: unknown, url?: string, line?: number, column?: number, errorObj?: unknown) {
59
- let stackTrace: StackTrace
60
- if (errorObj instanceof Error) {
61
- stackTrace = computeStackTrace(errorObj)
62
- } else {
63
- const stack = [{ url, column, line }]
64
- const { name, message } = tryToParseMessage(messageObj)
65
- stackTrace = {
66
- name,
67
- message,
68
- stack,
69
- }
70
- }
71
- callback(stackTrace, errorObj ?? messageObj)
72
- },
73
- })
74
- }
75
-
76
- function tryToParseMessage(messageObj: unknown) {
77
- let name
78
- let message
79
- if ({}.toString.call(messageObj) === '[object String]') {
80
- ;[, name, message] = ERROR_TYPES_RE.exec(messageObj as string)!
81
- }
82
- return { name, message }
83
- }
84
-
85
- /**
86
- * Install a global onunhandledrejection handler
87
- */
88
- function instrumentUnhandledRejection(callback: UnhandledErrorCallback) {
89
- return instrumentMethodAndCallOriginal(window, 'onunhandledrejection', {
90
- before(e: PromiseRejectionEvent) {
91
- const reason = e.reason || 'Empty reason'
92
- const stack = computeStackTrace(reason)
93
- callback(stack, reason)
94
- },
95
- })
96
- }
@@ -1,47 +0,0 @@
1
- export interface BrowserError extends Error {
2
- sourceURL?: string
3
- fileName?: string
4
- line?: string | number
5
- lineNumber?: string | number
6
- description?: string
7
- }
8
-
9
- export type UnhandledErrorCallback = (stack: StackTrace, errorObject?: any) => any
10
-
11
- /**
12
- * An object representing a single stack frame.
13
- * @typedef {Object} StackFrame
14
- * @property {string=} url The JavaScript or HTML file URL.
15
- * @property {string=} func The function name, or empty for anonymous functions (if guessing did not work).
16
- * @property {string[]=} args The arguments passed to the function, if known.
17
- * @property {number=} line The line number, if known.
18
- * @property {number=} column The column number, if known.
19
- * @property {string[]=} context An array of source code lines; the middle element corresponds to the correct line#.
20
- * @memberof TraceKit
21
- */
22
- export interface StackFrame {
23
- url?: string
24
- func?: string
25
- args?: string[]
26
- line?: number
27
- column?: number
28
- context?: string[]
29
- }
30
-
31
- /**
32
- * An object representing a JavaScript stack trace.
33
- * @typedef {Object} StackTrace
34
- * @property {string=} name The name of the thrown exception.
35
- * @property {string} message The exception error message.
36
- * @property {StackFrame[]} stack An array of stack frames.
37
- * -- method used to collect the stack trace.
38
- * @memberof TraceKit
39
- */
40
- export interface StackTrace {
41
- name?: string
42
- message?: string
43
- url?: string
44
- stack: StackFrame[]
45
- incomplete?: boolean
46
- partial?: boolean
47
- }
@@ -1,79 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }