@sentry/browser-utils 10.58.0

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 (312) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/build/cjs/debug-build.js +6 -0
  4. package/build/cjs/debug-build.js.map +1 -0
  5. package/build/cjs/getNativeImplementation.js +51 -0
  6. package/build/cjs/getNativeImplementation.js.map +1 -0
  7. package/build/cjs/htmlTreeAsString.js +110 -0
  8. package/build/cjs/htmlTreeAsString.js.map +1 -0
  9. package/build/cjs/index.js +54 -0
  10. package/build/cjs/index.js.map +1 -0
  11. package/build/cjs/instrument/dom.js +137 -0
  12. package/build/cjs/instrument/dom.js.map +1 -0
  13. package/build/cjs/instrument/history.js +56 -0
  14. package/build/cjs/instrument/history.js.map +1 -0
  15. package/build/cjs/instrument/xhr.js +108 -0
  16. package/build/cjs/instrument/xhr.js.map +1 -0
  17. package/build/cjs/is.js +15 -0
  18. package/build/cjs/is.js.map +1 -0
  19. package/build/cjs/metrics/browserMetrics.js +535 -0
  20. package/build/cjs/metrics/browserMetrics.js.map +1 -0
  21. package/build/cjs/metrics/cls.js +64 -0
  22. package/build/cjs/metrics/cls.js.map +1 -0
  23. package/build/cjs/metrics/elementTiming.js +72 -0
  24. package/build/cjs/metrics/elementTiming.js.map +1 -0
  25. package/build/cjs/metrics/inp.js +170 -0
  26. package/build/cjs/metrics/inp.js.map +1 -0
  27. package/build/cjs/metrics/instrument.js +152 -0
  28. package/build/cjs/metrics/instrument.js.map +1 -0
  29. package/build/cjs/metrics/lcp.js +77 -0
  30. package/build/cjs/metrics/lcp.js.map +1 -0
  31. package/build/cjs/metrics/resourceTiming.js +44 -0
  32. package/build/cjs/metrics/resourceTiming.js.map +1 -0
  33. package/build/cjs/metrics/utils.js +137 -0
  34. package/build/cjs/metrics/utils.js.map +1 -0
  35. package/build/cjs/metrics/web-vitals/getCLS.js +46 -0
  36. package/build/cjs/metrics/web-vitals/getCLS.js.map +1 -0
  37. package/build/cjs/metrics/web-vitals/getINP.js +60 -0
  38. package/build/cjs/metrics/web-vitals/getINP.js.map +1 -0
  39. package/build/cjs/metrics/web-vitals/getLCP.js +62 -0
  40. package/build/cjs/metrics/web-vitals/getLCP.js.map +1 -0
  41. package/build/cjs/metrics/web-vitals/lib/InteractionManager.js +87 -0
  42. package/build/cjs/metrics/web-vitals/lib/InteractionManager.js.map +1 -0
  43. package/build/cjs/metrics/web-vitals/lib/LCPEntryManager.js +11 -0
  44. package/build/cjs/metrics/web-vitals/lib/LCPEntryManager.js.map +1 -0
  45. package/build/cjs/metrics/web-vitals/lib/LayoutShiftManager.js +27 -0
  46. package/build/cjs/metrics/web-vitals/lib/LayoutShiftManager.js.map +1 -0
  47. package/build/cjs/metrics/web-vitals/lib/bindReporter.js +31 -0
  48. package/build/cjs/metrics/web-vitals/lib/bindReporter.js.map +1 -0
  49. package/build/cjs/metrics/web-vitals/lib/generateUniqueID.js +8 -0
  50. package/build/cjs/metrics/web-vitals/lib/generateUniqueID.js.map +1 -0
  51. package/build/cjs/metrics/web-vitals/lib/getActivationStart.js +11 -0
  52. package/build/cjs/metrics/web-vitals/lib/getActivationStart.js.map +1 -0
  53. package/build/cjs/metrics/web-vitals/lib/getNavigationEntry.js +17 -0
  54. package/build/cjs/metrics/web-vitals/lib/getNavigationEntry.js.map +1 -0
  55. package/build/cjs/metrics/web-vitals/lib/getVisibilityWatcher.js +48 -0
  56. package/build/cjs/metrics/web-vitals/lib/getVisibilityWatcher.js.map +1 -0
  57. package/build/cjs/metrics/web-vitals/lib/globalListeners.js +18 -0
  58. package/build/cjs/metrics/web-vitals/lib/globalListeners.js.map +1 -0
  59. package/build/cjs/metrics/web-vitals/lib/initMetric.js +34 -0
  60. package/build/cjs/metrics/web-vitals/lib/initMetric.js.map +1 -0
  61. package/build/cjs/metrics/web-vitals/lib/initUnique.js +16 -0
  62. package/build/cjs/metrics/web-vitals/lib/initUnique.js.map +1 -0
  63. package/build/cjs/metrics/web-vitals/lib/observe.js +20 -0
  64. package/build/cjs/metrics/web-vitals/lib/observe.js.map +1 -0
  65. package/build/cjs/metrics/web-vitals/lib/onHidden.js +17 -0
  66. package/build/cjs/metrics/web-vitals/lib/onHidden.js.map +1 -0
  67. package/build/cjs/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js +32 -0
  68. package/build/cjs/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js.map +1 -0
  69. package/build/cjs/metrics/web-vitals/lib/runOnce.js +14 -0
  70. package/build/cjs/metrics/web-vitals/lib/runOnce.js.map +1 -0
  71. package/build/cjs/metrics/web-vitals/lib/whenActivated.js +14 -0
  72. package/build/cjs/metrics/web-vitals/lib/whenActivated.js.map +1 -0
  73. package/build/cjs/metrics/web-vitals/lib/whenIdleOrHidden.js +24 -0
  74. package/build/cjs/metrics/web-vitals/lib/whenIdleOrHidden.js.map +1 -0
  75. package/build/cjs/metrics/web-vitals/onFCP.js +37 -0
  76. package/build/cjs/metrics/web-vitals/onFCP.js.map +1 -0
  77. package/build/cjs/metrics/web-vitals/onTTFB.js +35 -0
  78. package/build/cjs/metrics/web-vitals/onTTFB.js.map +1 -0
  79. package/build/cjs/metrics/webVitalSpans.js +199 -0
  80. package/build/cjs/metrics/webVitalSpans.js.map +1 -0
  81. package/build/cjs/networkUtils.js +70 -0
  82. package/build/cjs/networkUtils.js.map +1 -0
  83. package/build/cjs/types.js +8 -0
  84. package/build/cjs/types.js.map +1 -0
  85. package/build/esm/debug-build.js +4 -0
  86. package/build/esm/debug-build.js.map +1 -0
  87. package/build/esm/getNativeImplementation.js +46 -0
  88. package/build/esm/getNativeImplementation.js.map +1 -0
  89. package/build/esm/htmlTreeAsString.js +108 -0
  90. package/build/esm/htmlTreeAsString.js.map +1 -0
  91. package/build/esm/index.js +15 -0
  92. package/build/esm/index.js.map +1 -0
  93. package/build/esm/instrument/dom.js +134 -0
  94. package/build/esm/instrument/dom.js.map +1 -0
  95. package/build/esm/instrument/history.js +53 -0
  96. package/build/esm/instrument/history.js.map +1 -0
  97. package/build/esm/instrument/xhr.js +104 -0
  98. package/build/esm/instrument/xhr.js.map +1 -0
  99. package/build/esm/is.js +13 -0
  100. package/build/esm/is.js.map +1 -0
  101. package/build/esm/metrics/browserMetrics.js +524 -0
  102. package/build/esm/metrics/browserMetrics.js.map +1 -0
  103. package/build/esm/metrics/cls.js +61 -0
  104. package/build/esm/metrics/cls.js.map +1 -0
  105. package/build/esm/metrics/elementTiming.js +69 -0
  106. package/build/esm/metrics/elementTiming.js.map +1 -0
  107. package/build/esm/metrics/inp.js +162 -0
  108. package/build/esm/metrics/inp.js.map +1 -0
  109. package/build/esm/metrics/instrument.js +145 -0
  110. package/build/esm/metrics/instrument.js.map +1 -0
  111. package/build/esm/metrics/lcp.js +72 -0
  112. package/build/esm/metrics/lcp.js.map +1 -0
  113. package/build/esm/metrics/resourceTiming.js +42 -0
  114. package/build/esm/metrics/resourceTiming.js.map +1 -0
  115. package/build/esm/metrics/utils.js +128 -0
  116. package/build/esm/metrics/utils.js.map +1 -0
  117. package/build/esm/metrics/web-vitals/getCLS.js +43 -0
  118. package/build/esm/metrics/web-vitals/getCLS.js.map +1 -0
  119. package/build/esm/metrics/web-vitals/getINP.js +57 -0
  120. package/build/esm/metrics/web-vitals/getINP.js.map +1 -0
  121. package/build/esm/metrics/web-vitals/getLCP.js +59 -0
  122. package/build/esm/metrics/web-vitals/getLCP.js.map +1 -0
  123. package/build/esm/metrics/web-vitals/lib/InteractionManager.js +85 -0
  124. package/build/esm/metrics/web-vitals/lib/InteractionManager.js.map +1 -0
  125. package/build/esm/metrics/web-vitals/lib/LCPEntryManager.js +9 -0
  126. package/build/esm/metrics/web-vitals/lib/LCPEntryManager.js.map +1 -0
  127. package/build/esm/metrics/web-vitals/lib/LayoutShiftManager.js +25 -0
  128. package/build/esm/metrics/web-vitals/lib/LayoutShiftManager.js.map +1 -0
  129. package/build/esm/metrics/web-vitals/lib/bindReporter.js +29 -0
  130. package/build/esm/metrics/web-vitals/lib/bindReporter.js.map +1 -0
  131. package/build/esm/metrics/web-vitals/lib/generateUniqueID.js +6 -0
  132. package/build/esm/metrics/web-vitals/lib/generateUniqueID.js.map +1 -0
  133. package/build/esm/metrics/web-vitals/lib/getActivationStart.js +9 -0
  134. package/build/esm/metrics/web-vitals/lib/getActivationStart.js.map +1 -0
  135. package/build/esm/metrics/web-vitals/lib/getNavigationEntry.js +15 -0
  136. package/build/esm/metrics/web-vitals/lib/getNavigationEntry.js.map +1 -0
  137. package/build/esm/metrics/web-vitals/lib/getVisibilityWatcher.js +46 -0
  138. package/build/esm/metrics/web-vitals/lib/getVisibilityWatcher.js.map +1 -0
  139. package/build/esm/metrics/web-vitals/lib/globalListeners.js +15 -0
  140. package/build/esm/metrics/web-vitals/lib/globalListeners.js.map +1 -0
  141. package/build/esm/metrics/web-vitals/lib/initMetric.js +32 -0
  142. package/build/esm/metrics/web-vitals/lib/initMetric.js.map +1 -0
  143. package/build/esm/metrics/web-vitals/lib/initUnique.js +14 -0
  144. package/build/esm/metrics/web-vitals/lib/initUnique.js.map +1 -0
  145. package/build/esm/metrics/web-vitals/lib/observe.js +18 -0
  146. package/build/esm/metrics/web-vitals/lib/observe.js.map +1 -0
  147. package/build/esm/metrics/web-vitals/lib/onHidden.js +15 -0
  148. package/build/esm/metrics/web-vitals/lib/onHidden.js.map +1 -0
  149. package/build/esm/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js +29 -0
  150. package/build/esm/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js.map +1 -0
  151. package/build/esm/metrics/web-vitals/lib/runOnce.js +12 -0
  152. package/build/esm/metrics/web-vitals/lib/runOnce.js.map +1 -0
  153. package/build/esm/metrics/web-vitals/lib/whenActivated.js +12 -0
  154. package/build/esm/metrics/web-vitals/lib/whenActivated.js.map +1 -0
  155. package/build/esm/metrics/web-vitals/lib/whenIdleOrHidden.js +22 -0
  156. package/build/esm/metrics/web-vitals/lib/whenIdleOrHidden.js.map +1 -0
  157. package/build/esm/metrics/web-vitals/onFCP.js +34 -0
  158. package/build/esm/metrics/web-vitals/onFCP.js.map +1 -0
  159. package/build/esm/metrics/web-vitals/onTTFB.js +32 -0
  160. package/build/esm/metrics/web-vitals/onTTFB.js.map +1 -0
  161. package/build/esm/metrics/webVitalSpans.js +191 -0
  162. package/build/esm/metrics/webVitalSpans.js.map +1 -0
  163. package/build/esm/networkUtils.js +64 -0
  164. package/build/esm/networkUtils.js.map +1 -0
  165. package/build/esm/package.json +1 -0
  166. package/build/esm/types.js +6 -0
  167. package/build/esm/types.js.map +1 -0
  168. package/build/types/debug-build.d.ts +7 -0
  169. package/build/types/debug-build.d.ts.map +1 -0
  170. package/build/types/getNativeImplementation.d.ts +69 -0
  171. package/build/types/getNativeImplementation.d.ts.map +1 -0
  172. package/build/types/htmlTreeAsString.d.ts +11 -0
  173. package/build/types/htmlTreeAsString.d.ts.map +1 -0
  174. package/build/types/index.d.ts +15 -0
  175. package/build/types/index.d.ts.map +1 -0
  176. package/build/types/instrument/dom.d.ts +11 -0
  177. package/build/types/instrument/dom.d.ts.map +1 -0
  178. package/build/types/instrument/history.d.ts +15 -0
  179. package/build/types/instrument/history.d.ts.map +1 -0
  180. package/build/types/instrument/xhr.d.ts +14 -0
  181. package/build/types/instrument/xhr.d.ts.map +1 -0
  182. package/build/types/is.d.ts +7 -0
  183. package/build/types/is.d.ts.map +1 -0
  184. package/build/types/metrics/browserMetrics.d.ts +116 -0
  185. package/build/types/metrics/browserMetrics.d.ts.map +1 -0
  186. package/build/types/metrics/cls.d.ts +17 -0
  187. package/build/types/metrics/cls.d.ts.map +1 -0
  188. package/build/types/metrics/elementTiming.d.ts +19 -0
  189. package/build/types/metrics/elementTiming.d.ts.map +1 -0
  190. package/build/types/metrics/inp.d.ts +35 -0
  191. package/build/types/metrics/inp.d.ts.map +1 -0
  192. package/build/types/metrics/instrument.d.ts +121 -0
  193. package/build/types/metrics/instrument.d.ts.map +1 -0
  194. package/build/types/metrics/lcp.d.ts +22 -0
  195. package/build/types/metrics/lcp.d.ts.map +1 -0
  196. package/build/types/metrics/resourceTiming.d.ts +13 -0
  197. package/build/types/metrics/resourceTiming.d.ts.map +1 -0
  198. package/build/types/metrics/utils.d.ts +73 -0
  199. package/build/types/metrics/utils.d.ts.map +1 -0
  200. package/build/types/metrics/web-vitals/getCLS.d.ts +26 -0
  201. package/build/types/metrics/web-vitals/getCLS.d.ts.map +1 -0
  202. package/build/types/metrics/web-vitals/getINP.d.ts +34 -0
  203. package/build/types/metrics/web-vitals/getINP.d.ts.map +1 -0
  204. package/build/types/metrics/web-vitals/getLCP.d.ts +16 -0
  205. package/build/types/metrics/web-vitals/getLCP.d.ts.map +1 -0
  206. package/build/types/metrics/web-vitals/lib/InteractionManager.d.ts +37 -0
  207. package/build/types/metrics/web-vitals/lib/InteractionManager.d.ts.map +1 -0
  208. package/build/types/metrics/web-vitals/lib/LCPEntryManager.d.ts +5 -0
  209. package/build/types/metrics/web-vitals/lib/LCPEntryManager.d.ts.map +1 -0
  210. package/build/types/metrics/web-vitals/lib/LayoutShiftManager.d.ts +7 -0
  211. package/build/types/metrics/web-vitals/lib/LayoutShiftManager.d.ts.map +1 -0
  212. package/build/types/metrics/web-vitals/lib/bindReporter.d.ts +7 -0
  213. package/build/types/metrics/web-vitals/lib/bindReporter.d.ts.map +1 -0
  214. package/build/types/metrics/web-vitals/lib/generateUniqueID.d.ts +7 -0
  215. package/build/types/metrics/web-vitals/lib/generateUniqueID.d.ts.map +1 -0
  216. package/build/types/metrics/web-vitals/lib/getActivationStart.d.ts +2 -0
  217. package/build/types/metrics/web-vitals/lib/getActivationStart.d.ts.map +1 -0
  218. package/build/types/metrics/web-vitals/lib/getNavigationEntry.d.ts +2 -0
  219. package/build/types/metrics/web-vitals/lib/getNavigationEntry.d.ts.map +1 -0
  220. package/build/types/metrics/web-vitals/lib/getVisibilityWatcher.d.ts +5 -0
  221. package/build/types/metrics/web-vitals/lib/getVisibilityWatcher.d.ts.map +1 -0
  222. package/build/types/metrics/web-vitals/lib/globalListeners.d.ts +11 -0
  223. package/build/types/metrics/web-vitals/lib/globalListeners.d.ts.map +1 -0
  224. package/build/types/metrics/web-vitals/lib/initMetric.d.ts +21 -0
  225. package/build/types/metrics/web-vitals/lib/initMetric.d.ts.map +1 -0
  226. package/build/types/metrics/web-vitals/lib/initUnique.d.ts +7 -0
  227. package/build/types/metrics/web-vitals/lib/initUnique.d.ts.map +1 -0
  228. package/build/types/metrics/web-vitals/lib/observe.d.ts +23 -0
  229. package/build/types/metrics/web-vitals/lib/observe.d.ts.map +1 -0
  230. package/build/types/metrics/web-vitals/lib/onHidden.d.ts +27 -0
  231. package/build/types/metrics/web-vitals/lib/onHidden.d.ts.map +1 -0
  232. package/build/types/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.d.ts +15 -0
  233. package/build/types/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.d.ts.map +1 -0
  234. package/build/types/metrics/web-vitals/lib/runOnce.d.ts +2 -0
  235. package/build/types/metrics/web-vitals/lib/runOnce.d.ts.map +1 -0
  236. package/build/types/metrics/web-vitals/lib/whenActivated.d.ts +2 -0
  237. package/build/types/metrics/web-vitals/lib/whenActivated.d.ts.map +1 -0
  238. package/build/types/metrics/web-vitals/lib/whenIdleOrHidden.d.ts +6 -0
  239. package/build/types/metrics/web-vitals/lib/whenIdleOrHidden.d.ts.map +1 -0
  240. package/build/types/metrics/web-vitals/onFCP.d.ts +11 -0
  241. package/build/types/metrics/web-vitals/onFCP.d.ts.map +1 -0
  242. package/build/types/metrics/web-vitals/onTTFB.d.ts +20 -0
  243. package/build/types/metrics/web-vitals/onTTFB.d.ts.map +1 -0
  244. package/build/types/metrics/web-vitals/types/base.d.ts +103 -0
  245. package/build/types/metrics/web-vitals/types/base.d.ts.map +1 -0
  246. package/build/types/metrics/web-vitals/types/cls.d.ts +58 -0
  247. package/build/types/metrics/web-vitals/types/cls.d.ts.map +1 -0
  248. package/build/types/metrics/web-vitals/types/fcp.d.ts +47 -0
  249. package/build/types/metrics/web-vitals/types/fcp.d.ts.map +1 -0
  250. package/build/types/metrics/web-vitals/types/inp.d.ts +150 -0
  251. package/build/types/metrics/web-vitals/types/inp.d.ts.map +1 -0
  252. package/build/types/metrics/web-vitals/types/lcp.d.ts +74 -0
  253. package/build/types/metrics/web-vitals/types/lcp.d.ts.map +1 -0
  254. package/build/types/metrics/web-vitals/types/ttfb.d.ts +60 -0
  255. package/build/types/metrics/web-vitals/types/ttfb.d.ts.map +1 -0
  256. package/build/types/metrics/web-vitals/types.d.ts +78 -0
  257. package/build/types/metrics/web-vitals/types.d.ts.map +1 -0
  258. package/build/types/metrics/webVitalSpans.d.ts +65 -0
  259. package/build/types/metrics/webVitalSpans.d.ts.map +1 -0
  260. package/build/types/networkUtils.d.ts +25 -0
  261. package/build/types/networkUtils.d.ts.map +1 -0
  262. package/build/types/types.d.ts +15 -0
  263. package/build/types/types.d.ts.map +1 -0
  264. package/build/types-ts3.8/debug-build.d.ts +7 -0
  265. package/build/types-ts3.8/getNativeImplementation.d.ts +69 -0
  266. package/build/types-ts3.8/htmlTreeAsString.d.ts +11 -0
  267. package/build/types-ts3.8/index.d.ts +15 -0
  268. package/build/types-ts3.8/instrument/dom.d.ts +11 -0
  269. package/build/types-ts3.8/instrument/history.d.ts +15 -0
  270. package/build/types-ts3.8/instrument/xhr.d.ts +14 -0
  271. package/build/types-ts3.8/is.d.ts +7 -0
  272. package/build/types-ts3.8/metrics/browserMetrics.d.ts +119 -0
  273. package/build/types-ts3.8/metrics/cls.d.ts +17 -0
  274. package/build/types-ts3.8/metrics/elementTiming.d.ts +19 -0
  275. package/build/types-ts3.8/metrics/inp.d.ts +35 -0
  276. package/build/types-ts3.8/metrics/instrument.d.ts +121 -0
  277. package/build/types-ts3.8/metrics/lcp.d.ts +22 -0
  278. package/build/types-ts3.8/metrics/resourceTiming.d.ts +13 -0
  279. package/build/types-ts3.8/metrics/utils.d.ts +73 -0
  280. package/build/types-ts3.8/metrics/web-vitals/getCLS.d.ts +26 -0
  281. package/build/types-ts3.8/metrics/web-vitals/getINP.d.ts +34 -0
  282. package/build/types-ts3.8/metrics/web-vitals/getLCP.d.ts +16 -0
  283. package/build/types-ts3.8/metrics/web-vitals/lib/InteractionManager.d.ts +37 -0
  284. package/build/types-ts3.8/metrics/web-vitals/lib/LCPEntryManager.d.ts +5 -0
  285. package/build/types-ts3.8/metrics/web-vitals/lib/LayoutShiftManager.d.ts +7 -0
  286. package/build/types-ts3.8/metrics/web-vitals/lib/bindReporter.d.ts +7 -0
  287. package/build/types-ts3.8/metrics/web-vitals/lib/generateUniqueID.d.ts +7 -0
  288. package/build/types-ts3.8/metrics/web-vitals/lib/getActivationStart.d.ts +2 -0
  289. package/build/types-ts3.8/metrics/web-vitals/lib/getNavigationEntry.d.ts +2 -0
  290. package/build/types-ts3.8/metrics/web-vitals/lib/getVisibilityWatcher.d.ts +5 -0
  291. package/build/types-ts3.8/metrics/web-vitals/lib/globalListeners.d.ts +11 -0
  292. package/build/types-ts3.8/metrics/web-vitals/lib/initMetric.d.ts +21 -0
  293. package/build/types-ts3.8/metrics/web-vitals/lib/initUnique.d.ts +7 -0
  294. package/build/types-ts3.8/metrics/web-vitals/lib/observe.d.ts +23 -0
  295. package/build/types-ts3.8/metrics/web-vitals/lib/onHidden.d.ts +27 -0
  296. package/build/types-ts3.8/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.d.ts +15 -0
  297. package/build/types-ts3.8/metrics/web-vitals/lib/runOnce.d.ts +2 -0
  298. package/build/types-ts3.8/metrics/web-vitals/lib/whenActivated.d.ts +2 -0
  299. package/build/types-ts3.8/metrics/web-vitals/lib/whenIdleOrHidden.d.ts +6 -0
  300. package/build/types-ts3.8/metrics/web-vitals/onFCP.d.ts +11 -0
  301. package/build/types-ts3.8/metrics/web-vitals/onTTFB.d.ts +20 -0
  302. package/build/types-ts3.8/metrics/web-vitals/types/base.d.ts +106 -0
  303. package/build/types-ts3.8/metrics/web-vitals/types/cls.d.ts +58 -0
  304. package/build/types-ts3.8/metrics/web-vitals/types/fcp.d.ts +47 -0
  305. package/build/types-ts3.8/metrics/web-vitals/types/inp.d.ts +150 -0
  306. package/build/types-ts3.8/metrics/web-vitals/types/lcp.d.ts +74 -0
  307. package/build/types-ts3.8/metrics/web-vitals/types/ttfb.d.ts +60 -0
  308. package/build/types-ts3.8/metrics/web-vitals/types.d.ts +78 -0
  309. package/build/types-ts3.8/metrics/webVitalSpans.d.ts +65 -0
  310. package/build/types-ts3.8/networkUtils.d.ts +28 -0
  311. package/build/types-ts3.8/types.d.ts +15 -0
  312. package/package.json +69 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Functional Software, Inc. dba Sentry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ <p align="center">
2
+ <a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3
+ <img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4
+ </a>
5
+ </p>
6
+
7
+ # Sentry JavaScript SDK Browser Utilities
8
+
9
+ [![npm version](https://img.shields.io/npm/v/@sentry/browser-utils.svg)](https://www.npmjs.com/package/@sentry/browser-utils)
10
+ [![npm dm](https://img.shields.io/npm/dm/@sentry/browser-utils.svg)](https://www.npmjs.com/package/@sentry/browser-utils)
11
+ [![npm dt](https://img.shields.io/npm/dt/@sentry/browser-utils.svg)](https://www.npmjs.com/package/@sentry/browser-utils)
12
+
13
+ > [!NOTE]
14
+ > This package is an internal library published for use by Sentry-owned JavaScript SDK packages. It is not part of the
15
+ > public API contract and may change in any release. Do not rely on SemVer compatibility if you depend on it directly.
16
+
17
+ ## Links
18
+
19
+ - [Official SDK Docs](https://docs.sentry.io/quickstart/)
20
+
21
+ ## General
22
+
23
+ Common utilities used by the Sentry JavaScript SDKs.
@@ -0,0 +1,6 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
4
+
5
+ exports.DEBUG_BUILD = DEBUG_BUILD;
6
+ //# sourceMappingURL=debug-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-build.js","sources":["../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":";;AAOO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
@@ -0,0 +1,51 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const debugBuild = require('./debug-build.js');
5
+ const types = require('./types.js');
6
+
7
+ const cachedImplementations = {};
8
+ function getNativeImplementation(name) {
9
+ const cached = cachedImplementations[name];
10
+ if (cached) {
11
+ return cached;
12
+ }
13
+ let impl = types.WINDOW[name];
14
+ if (core.isNativeFunction(impl)) {
15
+ return cachedImplementations[name] = impl.bind(types.WINDOW);
16
+ }
17
+ const document = types.WINDOW.document;
18
+ if (document && typeof document.createElement === "function") {
19
+ try {
20
+ const sandbox = document.createElement("iframe");
21
+ sandbox.hidden = true;
22
+ document.head.appendChild(sandbox);
23
+ const contentWindow = sandbox.contentWindow;
24
+ if (contentWindow?.[name]) {
25
+ impl = contentWindow[name];
26
+ }
27
+ document.head.removeChild(sandbox);
28
+ } catch (e) {
29
+ debugBuild.DEBUG_BUILD && core.debug.warn(`Could not create sandbox iframe for ${name} check, bailing to window.${name}: `, e);
30
+ }
31
+ }
32
+ if (!impl) {
33
+ return impl;
34
+ }
35
+ return cachedImplementations[name] = impl.bind(types.WINDOW);
36
+ }
37
+ function clearCachedImplementation(name) {
38
+ cachedImplementations[name] = void 0;
39
+ }
40
+ function fetch(...rest) {
41
+ return getNativeImplementation("fetch")(...rest);
42
+ }
43
+ function setTimeout(...rest) {
44
+ return getNativeImplementation("setTimeout")(...rest);
45
+ }
46
+
47
+ exports.clearCachedImplementation = clearCachedImplementation;
48
+ exports.fetch = fetch;
49
+ exports.getNativeImplementation = getNativeImplementation;
50
+ exports.setTimeout = setTimeout;
51
+ //# sourceMappingURL=getNativeImplementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNativeImplementation.js","sources":["../../src/getNativeImplementation.ts"],"sourcesContent":["import { debug, isNativeFunction } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport { WINDOW } from './types';\n\n/**\n * We generally want to use window.fetch / window.setTimeout.\n * However, in some cases this may be wrapped (e.g. by Zone.js for Angular),\n * so we try to get an unpatched version of this from a sandboxed iframe.\n */\n\ninterface CacheableImplementations {\n setTimeout: typeof WINDOW.setTimeout;\n fetch: typeof WINDOW.fetch;\n}\n\nconst cachedImplementations: Partial<CacheableImplementations> = {};\n\n/**\n * Get the native implementation of a browser function.\n *\n * This can be used to ensure we get an unwrapped version of a function, in cases where a wrapped function can lead to problems.\n *\n * The following methods can be retrieved:\n * - `setTimeout`: This can be wrapped by e.g. Angular, causing change detection to be triggered.\n * - `fetch`: This can be wrapped by e.g. ad-blockers, causing an infinite loop when a request is blocked.\n */\nexport function getNativeImplementation<T extends keyof CacheableImplementations>(\n name: T,\n): CacheableImplementations[T] {\n const cached = cachedImplementations[name];\n if (cached) {\n return cached;\n }\n\n let impl = WINDOW[name] as CacheableImplementations[T];\n\n // Fast path to avoid DOM I/O\n if (isNativeFunction(impl)) {\n return (cachedImplementations[name] = impl.bind(WINDOW) as CacheableImplementations[T]);\n }\n\n const document = WINDOW.document;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === 'function') {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow?.[name]) {\n impl = contentWindow[name] as CacheableImplementations[T];\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n // Could not create sandbox iframe, just use window.xxx\n DEBUG_BUILD && debug.warn(`Could not create sandbox iframe for ${name} check, bailing to window.${name}: `, e);\n }\n }\n\n // Sanity check: This _should_ not happen, but if it does, we just skip caching...\n // This can happen e.g. in tests where fetch may not be available in the env, or similar.\n if (!impl) {\n return impl;\n }\n\n return (cachedImplementations[name] = impl.bind(WINDOW) as CacheableImplementations[T]);\n}\n\n/** Clear a cached implementation. */\nexport function clearCachedImplementation(name: keyof CacheableImplementations): void {\n cachedImplementations[name] = undefined;\n}\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nexport function fetch(...rest: Parameters<typeof WINDOW.fetch>): ReturnType<typeof WINDOW.fetch> {\n return getNativeImplementation('fetch')(...rest);\n}\n\n/**\n * Get an unwrapped `setTimeout` method.\n * This ensures that even if e.g. Angular wraps `setTimeout`, we get the native implementation,\n * avoiding triggering change detection.\n */\nexport function setTimeout(...rest: Parameters<typeof WINDOW.setTimeout>): ReturnType<typeof WINDOW.setTimeout> {\n return getNativeImplementation('setTimeout')(...rest);\n}\n"],"names":["WINDOW","isNativeFunction","DEBUG_BUILD","debug"],"mappings":";;;;;;AAeA,MAAM,wBAA2D,EAAC;AAW3D,SAAS,wBACd,IAAA,EAC6B;AAC7B,EAAA,MAAM,MAAA,GAAS,sBAAsB,IAAI,CAAA;AACzC,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,IAAA,GAAOA,aAAO,IAAI,CAAA;AAGtB,EAAA,IAAIC,qBAAA,CAAiB,IAAI,CAAA,EAAG;AA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D;;;;;;;"}
@@ -0,0 +1,110 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+
5
+ const DEFAULT_MAX_STRING_LENGTH = 80;
6
+ const accessors = {};
7
+ try {
8
+ if (typeof Node !== "undefined") {
9
+ accessors.parentNode = Object.getOwnPropertyDescriptor(Node.prototype, "parentNode").get;
10
+ }
11
+ if (typeof Element !== "undefined") {
12
+ accessors.tagName = Object.getOwnPropertyDescriptor(Element.prototype, "tagName").get;
13
+ accessors.id = Object.getOwnPropertyDescriptor(Element.prototype, "id").get;
14
+ accessors.className = Object.getOwnPropertyDescriptor(Element.prototype, "className").get;
15
+ accessors.getAttribute = Element.prototype.getAttribute;
16
+ }
17
+ if (typeof HTMLElement !== "undefined") {
18
+ accessors.dataset = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "dataset").get;
19
+ }
20
+ } catch {
21
+ }
22
+ function _safeRead(el, prop, arg) {
23
+ const fn = accessors[prop];
24
+ if (fn) {
25
+ try {
26
+ return fn.call(el, arg);
27
+ } catch {
28
+ }
29
+ }
30
+ const val = el[prop];
31
+ return typeof val === "function" ? val.call(el, arg) : val;
32
+ }
33
+ function htmlTreeAsString(elem, options = {}) {
34
+ if (!elem) {
35
+ return "<unknown>";
36
+ }
37
+ try {
38
+ let currentElem = elem;
39
+ const MAX_TRAVERSE_HEIGHT = 5;
40
+ const out = [];
41
+ let height = 0;
42
+ let len = 0;
43
+ const separator = " > ";
44
+ const sepLength = separator.length;
45
+ let nextStr;
46
+ const keyAttrs = Array.isArray(options) ? options : options.keyAttrs;
47
+ const maxStringLength = !Array.isArray(options) && options.maxStringLength || DEFAULT_MAX_STRING_LENGTH;
48
+ while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) {
49
+ nextStr = _htmlElementAsString(currentElem, keyAttrs);
50
+ if (nextStr === "html" || height > 1 && len + out.length * sepLength + nextStr.length >= maxStringLength) {
51
+ break;
52
+ }
53
+ out.push(nextStr);
54
+ len += nextStr.length;
55
+ currentElem = _safeRead(currentElem, "parentNode");
56
+ }
57
+ return out.reverse().join(separator);
58
+ } catch {
59
+ return "<unknown>";
60
+ }
61
+ }
62
+ function _htmlElementAsString(el, keyAttrs) {
63
+ const out = [];
64
+ const tagName = _safeRead(el, "tagName");
65
+ if (!tagName) {
66
+ return "";
67
+ }
68
+ if (typeof HTMLElement !== "undefined") {
69
+ if (el instanceof HTMLElement) {
70
+ const dataset = _safeRead(el, "dataset");
71
+ if (dataset) {
72
+ if (dataset["sentryComponent"]) {
73
+ return dataset["sentryComponent"];
74
+ }
75
+ if (dataset["sentryElement"]) {
76
+ return dataset["sentryElement"];
77
+ }
78
+ }
79
+ }
80
+ }
81
+ out.push(tagName.toLowerCase());
82
+ const keyAttrPairs = keyAttrs?.length ? keyAttrs.filter((keyAttr) => _safeRead(el, "getAttribute", keyAttr)).map((keyAttr) => [keyAttr, _safeRead(el, "getAttribute", keyAttr)]) : null;
83
+ if (keyAttrPairs?.length) {
84
+ keyAttrPairs.forEach((keyAttrPair) => {
85
+ out.push(`[${keyAttrPair[0]}="${keyAttrPair[1]}"]`);
86
+ });
87
+ } else {
88
+ const id = _safeRead(el, "id");
89
+ if (id) {
90
+ out.push(`#${id}`);
91
+ }
92
+ const className = _safeRead(el, "className");
93
+ if (className && core.isString(className)) {
94
+ const classes = className.split(/\s+/);
95
+ for (const c of classes) {
96
+ out.push(`.${c}`);
97
+ }
98
+ }
99
+ }
100
+ for (const k of ["aria-label", "type", "name", "title", "alt"]) {
101
+ const attr = _safeRead(el, "getAttribute", k);
102
+ if (attr) {
103
+ out.push(`[${k}="${attr}"]`);
104
+ }
105
+ }
106
+ return out.join("");
107
+ }
108
+
109
+ exports.htmlTreeAsString = htmlTreeAsString;
110
+ //# sourceMappingURL=htmlTreeAsString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"htmlTreeAsString.js","sources":["../../src/htmlTreeAsString.ts"],"sourcesContent":["import { isString } from '@sentry/core';\n\nconst DEFAULT_MAX_STRING_LENGTH = 80;\n\ntype SimpleNode = {\n parentNode: SimpleNode;\n} | null;\n\n// Native DOM accessors cached at module load. Calling these instead of reading\n// instance properties bypasses user-defined getters that shadow the prototypes.\n// Stored unbound and rebound via .call(el) — the unbound-method lint is expected.\n// See https://github.com/getsentry/sentry-javascript/issues/21353\ntype AccessorKey = 'parentNode' | 'tagName' | 'id' | 'className' | 'getAttribute' | 'dataset';\nconst accessors: Partial<Record<AccessorKey, Function>> = {};\n\n// oxlint-disable typescript-eslint(unbound-method)\ntry {\n if (typeof Node !== 'undefined') {\n accessors.parentNode = Object.getOwnPropertyDescriptor(Node.prototype, 'parentNode')!.get!;\n }\n if (typeof Element !== 'undefined') {\n accessors.tagName = Object.getOwnPropertyDescriptor(Element.prototype, 'tagName')!.get!;\n accessors.id = Object.getOwnPropertyDescriptor(Element.prototype, 'id')!.get!;\n accessors.className = Object.getOwnPropertyDescriptor(Element.prototype, 'className')!.get!;\n accessors.getAttribute = Element.prototype.getAttribute;\n }\n if (typeof HTMLElement !== 'undefined') {\n accessors.dataset = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'dataset')!.get!;\n }\n} catch {\n // Polyfilled or stubbed prototypes may not have the expected descriptors.\n // _safeRead falls back to direct property access.\n}\n// oxlint-enable typescript-eslint(unbound-method)\n\nfunction _safeRead<T>(el: unknown, prop: AccessorKey, arg?: string): T {\n const fn = accessors[prop];\n if (fn) {\n try {\n return fn.call(el, arg) as T;\n } catch {\n // Fall through to direct access\n }\n }\n const val = (el as Record<string, unknown>)[prop];\n return typeof val === 'function' ? val.call(el, arg) : (val as T);\n}\n\n/**\n * Given a child DOM element, returns a query-selector statement describing that\n * and its ancestors\n * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz]\n * @returns generated DOM path\n */\nexport function htmlTreeAsString(\n elem: unknown,\n options: string[] | { keyAttrs?: string[]; maxStringLength?: number } = {},\n): string {\n if (!elem) {\n return '<unknown>';\n }\n\n // try/catch both:\n // - accessing event.target (see getsentry/raven-js#838, #768)\n // - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly\n // - can throw an exception in some circumstances.\n try {\n let currentElem = elem as SimpleNode;\n const MAX_TRAVERSE_HEIGHT = 5;\n const out = [];\n let height = 0;\n let len = 0;\n const separator = ' > ';\n const sepLength = separator.length;\n let nextStr;\n const keyAttrs = Array.isArray(options) ? options : options.keyAttrs;\n const maxStringLength = (!Array.isArray(options) && options.maxStringLength) || DEFAULT_MAX_STRING_LENGTH;\n\n while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) {\n nextStr = _htmlElementAsString(currentElem, keyAttrs);\n // bail out if\n // - nextStr is the 'html' element\n // - the length of the string that would be created exceeds maxStringLength\n // (ignore this limit if we are on the first iteration)\n if (nextStr === 'html' || (height > 1 && len + out.length * sepLength + nextStr.length >= maxStringLength)) {\n break;\n }\n\n out.push(nextStr);\n\n len += nextStr.length;\n currentElem = _safeRead<SimpleNode>(currentElem, 'parentNode');\n }\n\n return out.reverse().join(separator);\n } catch {\n return '<unknown>';\n }\n}\n\n/**\n * Returns a simple, query-selector representation of a DOM element\n * e.g. [HTMLElement] => input#foo.btn[name=baz]\n * @returns generated DOM path\n */\nfunction _htmlElementAsString(el: unknown, keyAttrs?: string[]): string {\n const out = [];\n\n const tagName = _safeRead<string | undefined>(el, 'tagName');\n if (!tagName) {\n return '';\n }\n\n if (typeof HTMLElement !== 'undefined') {\n // If using the component name annotation plugin, this value may be available on the DOM node\n if (el instanceof HTMLElement) {\n const dataset = _safeRead<DOMStringMap | undefined>(el, 'dataset');\n if (dataset) {\n if (dataset['sentryComponent']) {\n return dataset['sentryComponent'];\n }\n if (dataset['sentryElement']) {\n return dataset['sentryElement'];\n }\n }\n }\n }\n\n out.push(tagName.toLowerCase());\n\n // Pairs of attribute keys defined in `serializeAttribute` and their values on element.\n const keyAttrPairs = keyAttrs?.length\n ? keyAttrs\n .filter(keyAttr => _safeRead<string | null>(el, 'getAttribute', keyAttr))\n .map(keyAttr => [keyAttr, _safeRead<string | null>(el, 'getAttribute', keyAttr)])\n : null;\n\n if (keyAttrPairs?.length) {\n keyAttrPairs.forEach(keyAttrPair => {\n out.push(`[${keyAttrPair[0]}=\"${keyAttrPair[1]}\"]`);\n });\n } else {\n const id = _safeRead<string | undefined>(el, 'id');\n if (id) {\n out.push(`#${id}`);\n }\n\n const className = _safeRead<string | undefined>(el, 'className');\n if (className && isString(className)) {\n const classes = className.split(/\\s+/);\n for (const c of classes) {\n out.push(`.${c}`);\n }\n }\n }\n for (const k of ['aria-label', 'type', 'name', 'title', 'alt']) {\n const attr = _safeRead<string | null>(el, 'getAttribute', k);\n if (attr) {\n out.push(`[${k}=\"${attr}\"]`);\n }\n }\n\n return out.join('');\n}\n"],"names":["isString"],"mappings":";;;;AAEA,MAAM,yBAAA,GAA4B,EAAA;AAWlC,MAAM,YAAoD,EAAC;AAG3D,IAAI;AACF,EAAA,IAAI,OAAO,SAAS,WAAA,EAAa;AAC/B,IAAA,SAAA,CAAU,aAAa,MAAA,CAAO,wBAAA,CAAyB,IAAA,CAAK,SAAA,EAAW,YAAY,CAAA,CAAG,GAAA;AAAA,EACxF;AACA,EAAA,IAAI,OAAO,YAAY,WAAA,EAAa;AAClC,IAAA,SAAA,CAAU,UAAU,MAAA,CAAO,wBAAA,CAAyB,OAAA,CAAQ,SAAA,EAAW,SAAS,CAAA,CAAG,GAAA;AACnF,IAAA,SAAA,CAAU,KAAK,MAAA,CAAO,wBAAA,CAAyB,OAAA,CAAQ,SAAA,EAAW,IAAI,CAAA,CAAG,GAAA;AACzE,IAAA,SAAA,CAAU,YAAY,MAAA,CAAO,wBAAA,CAAyB,OAAA,CAAQ,SAAA,EAAW,WAAW,CAAA,CAAG,GAAA;AACvF,IAAA,SAAA,CAAU,YAAA,GAAe,QAAQ,SAAA,CAAU,YAAA;AAAA,EAC7C;AACA,EAAA,IAAI,OAAO,gBAAgB,WAAA,EAAa;AACtC,IAAA,SAAA,CAAU,UAA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A,IAAI,IAAA,EAAM;AACR,MAAA,GAAA,CAAI,IAAA,CAAK,CAAA,CAAA,EAAI,CAAC,CAAA,EAAA,EAAK,IAAI,CAAA,EAAA,CAAI,CAAA;AAAA,IAC7B;AAAA,EACF;AAEA,EAAA,OAAO,GAAA,CAAI,KAAK,EAAE,CAAA;AACpB;;;;"}
@@ -0,0 +1,54 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const instrument = require('./metrics/instrument.js');
4
+ const browserMetrics = require('./metrics/browserMetrics.js');
5
+ const elementTiming = require('./metrics/elementTiming.js');
6
+ const utils = require('./metrics/utils.js');
7
+ const webVitalSpans = require('./metrics/webVitalSpans.js');
8
+ const dom = require('./instrument/dom.js');
9
+ const history = require('./instrument/history.js');
10
+ const getNativeImplementation = require('./getNativeImplementation.js');
11
+ const xhr = require('./instrument/xhr.js');
12
+ const networkUtils = require('./networkUtils.js');
13
+ const resourceTiming = require('./metrics/resourceTiming.js');
14
+ const htmlTreeAsString = require('./htmlTreeAsString.js');
15
+ const is = require('./is.js');
16
+ const inp = require('./metrics/inp.js');
17
+
18
+
19
+
20
+ exports.addClsInstrumentationHandler = instrument.addClsInstrumentationHandler;
21
+ exports.addInpInstrumentationHandler = instrument.addInpInstrumentationHandler;
22
+ exports.addLcpInstrumentationHandler = instrument.addLcpInstrumentationHandler;
23
+ exports.addPerformanceInstrumentationHandler = instrument.addPerformanceInstrumentationHandler;
24
+ exports.addTtfbInstrumentationHandler = instrument.addTtfbInstrumentationHandler;
25
+ exports.addPerformanceEntries = browserMetrics.addPerformanceEntries;
26
+ exports.addWebVitalsToSpan = browserMetrics.addWebVitalsToSpan;
27
+ exports.startTrackingInteractions = browserMetrics.startTrackingInteractions;
28
+ exports.startTrackingLongAnimationFrames = browserMetrics.startTrackingLongAnimationFrames;
29
+ exports.startTrackingLongTasks = browserMetrics.startTrackingLongTasks;
30
+ exports.startTrackingWebVitals = browserMetrics.startTrackingWebVitals;
31
+ exports.elementTimingIntegration = elementTiming.elementTimingIntegration;
32
+ exports.startTrackingElementTiming = elementTiming.startTrackingElementTiming;
33
+ exports.extractNetworkProtocol = utils.extractNetworkProtocol;
34
+ exports.trackClsAsSpan = webVitalSpans.trackClsAsSpan;
35
+ exports.trackInpAsSpan = webVitalSpans.trackInpAsSpan;
36
+ exports.trackLcpAsSpan = webVitalSpans.trackLcpAsSpan;
37
+ exports.addClickKeypressInstrumentationHandler = dom.addClickKeypressInstrumentationHandler;
38
+ exports.addHistoryInstrumentationHandler = history.addHistoryInstrumentationHandler;
39
+ exports.clearCachedImplementation = getNativeImplementation.clearCachedImplementation;
40
+ exports.fetch = getNativeImplementation.fetch;
41
+ exports.getNativeImplementation = getNativeImplementation.getNativeImplementation;
42
+ exports.setTimeout = getNativeImplementation.setTimeout;
43
+ exports.SENTRY_XHR_DATA_KEY = xhr.SENTRY_XHR_DATA_KEY;
44
+ exports.addXhrInstrumentationHandler = xhr.addXhrInstrumentationHandler;
45
+ exports.getBodyString = networkUtils.getBodyString;
46
+ exports.getFetchRequestArgBody = networkUtils.getFetchRequestArgBody;
47
+ exports.parseXhrResponseHeaders = networkUtils.parseXhrResponseHeaders;
48
+ exports.serializeFormData = networkUtils.serializeFormData;
49
+ exports.resourceTimingToSpanAttributes = resourceTiming.resourceTimingToSpanAttributes;
50
+ exports.htmlTreeAsString = htmlTreeAsString.htmlTreeAsString;
51
+ exports.isElement = is.isElement;
52
+ exports.registerInpInteractionListener = inp.registerInpInteractionListener;
53
+ exports.startTrackingINP = inp.startTrackingINP;
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,137 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const types = require('../types.js');
5
+
6
+ const DEBOUNCE_DURATION = 1e3;
7
+ let debounceTimerID;
8
+ let lastCapturedEventType;
9
+ let lastCapturedEventTargetId;
10
+ function addClickKeypressInstrumentationHandler(handler) {
11
+ const type = "dom";
12
+ core.addHandler(type, handler);
13
+ core.maybeInstrument(type, instrumentDOM);
14
+ }
15
+ function instrumentDOM() {
16
+ if (!types.WINDOW.document) {
17
+ return;
18
+ }
19
+ const triggerDOMHandler = core.triggerHandlers.bind(null, "dom");
20
+ const globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
21
+ types.WINDOW.document.addEventListener("click", globalDOMEventHandler, false);
22
+ types.WINDOW.document.addEventListener("keypress", globalDOMEventHandler, false);
23
+ ["EventTarget", "Node"].forEach((target) => {
24
+ const globalObject = types.WINDOW;
25
+ const proto = globalObject[target]?.prototype;
26
+ if (!proto?.hasOwnProperty?.("addEventListener")) {
27
+ return;
28
+ }
29
+ core.fill(proto, "addEventListener", function(originalAddEventListener) {
30
+ return function(type, listener, options) {
31
+ if (type === "click" || type == "keypress") {
32
+ try {
33
+ const handlers = this.__sentry_instrumentation_handlers__ = this.__sentry_instrumentation_handlers__ || {};
34
+ const handlerForType = handlers[type] = handlers[type] || { refCount: 0 };
35
+ if (!handlerForType.handler) {
36
+ const handler = makeDOMEventHandler(triggerDOMHandler);
37
+ handlerForType.handler = handler;
38
+ originalAddEventListener.call(this, type, handler, options);
39
+ }
40
+ handlerForType.refCount++;
41
+ } catch {
42
+ }
43
+ }
44
+ return originalAddEventListener.call(this, type, listener, options);
45
+ };
46
+ });
47
+ core.fill(
48
+ proto,
49
+ "removeEventListener",
50
+ function(originalRemoveEventListener) {
51
+ return function(type, listener, options) {
52
+ if (type === "click" || type == "keypress") {
53
+ try {
54
+ const handlers = this.__sentry_instrumentation_handlers__ || {};
55
+ const handlerForType = handlers[type];
56
+ if (handlerForType) {
57
+ handlerForType.refCount--;
58
+ if (handlerForType.refCount <= 0) {
59
+ originalRemoveEventListener.call(this, type, handlerForType.handler, options);
60
+ handlerForType.handler = void 0;
61
+ delete handlers[type];
62
+ }
63
+ if (Object.keys(handlers).length === 0) {
64
+ delete this.__sentry_instrumentation_handlers__;
65
+ }
66
+ }
67
+ } catch {
68
+ }
69
+ }
70
+ return originalRemoveEventListener.call(this, type, listener, options);
71
+ };
72
+ }
73
+ );
74
+ });
75
+ }
76
+ function isSimilarToLastCapturedEvent(event) {
77
+ if (event.type !== lastCapturedEventType) {
78
+ return false;
79
+ }
80
+ try {
81
+ if (!event.target || event.target._sentryId !== lastCapturedEventTargetId) {
82
+ return false;
83
+ }
84
+ } catch {
85
+ }
86
+ return true;
87
+ }
88
+ function shouldSkipDOMEvent(eventType, target) {
89
+ if (eventType !== "keypress") {
90
+ return false;
91
+ }
92
+ if (!target?.tagName) {
93
+ return true;
94
+ }
95
+ if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
96
+ return false;
97
+ }
98
+ return true;
99
+ }
100
+ function makeDOMEventHandler(handler, globalListener = false) {
101
+ return (event) => {
102
+ if (!event || event["_sentryCaptured"]) {
103
+ return;
104
+ }
105
+ const target = getEventTarget(event);
106
+ if (shouldSkipDOMEvent(event.type, target)) {
107
+ return;
108
+ }
109
+ core.addNonEnumerableProperty(event, "_sentryCaptured", true);
110
+ if (target && !target._sentryId) {
111
+ core.addNonEnumerableProperty(target, "_sentryId", core.uuid4());
112
+ }
113
+ const name = event.type === "keypress" ? "input" : event.type;
114
+ if (!isSimilarToLastCapturedEvent(event)) {
115
+ const handlerData = { event, name, global: globalListener };
116
+ handler(handlerData);
117
+ lastCapturedEventType = event.type;
118
+ lastCapturedEventTargetId = target ? target._sentryId : void 0;
119
+ }
120
+ clearTimeout(debounceTimerID);
121
+ debounceTimerID = types.WINDOW.setTimeout(() => {
122
+ lastCapturedEventTargetId = void 0;
123
+ lastCapturedEventType = void 0;
124
+ }, DEBOUNCE_DURATION);
125
+ };
126
+ }
127
+ function getEventTarget(event) {
128
+ try {
129
+ return event.target;
130
+ } catch {
131
+ return null;
132
+ }
133
+ }
134
+
135
+ exports.addClickKeypressInstrumentationHandler = addClickKeypressInstrumentationHandler;
136
+ exports.instrumentDOM = instrumentDOM;
137
+ //# sourceMappingURL=dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.js","sources":["../../../src/instrument/dom.ts"],"sourcesContent":["import type { HandlerDataDom } from '@sentry/core';\nimport { addHandler, addNonEnumerableProperty, fill, maybeInstrument, triggerHandlers, uuid4 } from '@sentry/core';\nimport { WINDOW } from '../types';\n\ntype SentryWrappedTarget = HTMLElement & { _sentryId?: string };\n\ntype AddEventListener = (\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n) => void;\ntype RemoveEventListener = (\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n) => void;\n\ntype InstrumentedElement = Element & {\n __sentry_instrumentation_handlers__?: {\n [key in 'click' | 'keypress']?: {\n handler?: unknown;\n /** The number of custom listeners attached to this element */\n refCount: number;\n };\n };\n};\n\nconst DEBOUNCE_DURATION = 1000;\n\nlet debounceTimerID: number | undefined;\nlet lastCapturedEventType: string | undefined;\nlet lastCapturedEventTargetId: string | undefined;\n\n/**\n * Add an instrumentation handler for when a click or a keypress happens.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addClickKeypressInstrumentationHandler(handler: (data: HandlerDataDom) => void): void {\n const type = 'dom';\n addHandler(type, handler);\n maybeInstrument(type, instrumentDOM);\n}\n\n/** Exported for tests only. */\nexport function instrumentDOM(): void {\n if (!WINDOW.document) {\n return;\n }\n\n // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom\n // handlers. (Normally we have only one, which captures a breadcrumb for each click or keypress.) Do this before\n // we instrument `addEventListener` so that we don't end up attaching this handler twice.\n const triggerDOMHandler = triggerHandlers.bind(null, 'dom');\n const globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);\n WINDOW.document.addEventListener('click', globalDOMEventHandler, false);\n WINDOW.document.addEventListener('keypress', globalDOMEventHandler, false);\n\n // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled\n // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That\n // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler\n // could potentially prevent the event from bubbling up to our global listeners. This way, our handler are still\n // guaranteed to fire at least once.)\n ['EventTarget', 'Node'].forEach((target: string) => {\n const globalObject = WINDOW as unknown as Record<string, { prototype?: object }>;\n const proto = globalObject[target]?.prototype;\n\n // eslint-disable-next-line no-prototype-builtins\n if (!proto?.hasOwnProperty?.('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (originalAddEventListener: AddEventListener): AddEventListener {\n return function (this: InstrumentedElement, type, listener, options): AddEventListener {\n if (type === 'click' || type == 'keypress') {\n try {\n const handlers = (this.__sentry_instrumentation_handlers__ =\n this.__sentry_instrumentation_handlers__ || {});\n const handlerForType = (handlers[type] = handlers[type] || { refCount: 0 });\n\n if (!handlerForType.handler) {\n const handler = makeDOMEventHandler(triggerDOMHandler);\n handlerForType.handler = handler;\n originalAddEventListener.call(this, type, handler, options);\n }\n\n handlerForType.refCount++;\n } catch {\n // Accessing dom properties is always fragile.\n // Also allows us to skip `addEventListeners` calls with no proper `this` context.\n }\n }\n\n return originalAddEventListener.call(this, type, listener, options);\n };\n });\n\n fill(\n proto,\n 'removeEventListener',\n function (originalRemoveEventListener: RemoveEventListener): RemoveEventListener {\n return function (this: InstrumentedElement, type, listener, options): () => void {\n if (type === 'click' || type == 'keypress') {\n try {\n const handlers = this.__sentry_instrumentation_handlers__ || {};\n const handlerForType = handlers[type];\n\n if (handlerForType) {\n handlerForType.refCount--;\n // If there are no longer any custom handlers of the current type on this element, we can remove ours, too.\n if (handlerForType.refCount <= 0) {\n originalRemoveEventListener.call(this, type, handlerForType.handler, options);\n handlerForType.handler = undefined;\n delete handlers[type]; // eslint-disable-line @typescript-eslint/no-dynamic-delete\n }\n\n // If there are no longer any custom handlers of any type on this element, cleanup everything.\n if (Object.keys(handlers).length === 0) {\n delete this.__sentry_instrumentation_handlers__;\n }\n }\n } catch {\n // Accessing dom properties is always fragile.\n // Also allows us to skip `addEventListeners` calls with no proper `this` context.\n }\n }\n\n return originalRemoveEventListener.call(this, type, listener, options);\n };\n },\n );\n });\n}\n\n/**\n * Check whether the event is similar to the last captured one. For example, two click events on the same button.\n */\nfunction isSimilarToLastCapturedEvent(event: Event): boolean {\n // If both events have different type, then user definitely performed two separate actions. e.g. click + keypress.\n if (event.type !== lastCapturedEventType) {\n return false;\n }\n\n try {\n // If both events have the same type, it's still possible that actions were performed on different targets.\n // e.g. 2 clicks on different buttons.\n if (!event.target || (event.target as SentryWrappedTarget)._sentryId !== lastCapturedEventTargetId) {\n return false;\n }\n } catch {\n // just accessing `target` property can throw an exception in some rare circumstances\n // see: https://github.com/getsentry/sentry-javascript/issues/838\n }\n\n // If both events have the same type _and_ same `target` (an element which triggered an event, _not necessarily_\n // to which an event listener was attached), we treat them as the same action, as we want to capture\n // only one breadcrumb. e.g. multiple clicks on the same button, or typing inside a user input box.\n return true;\n}\n\n/**\n * Decide whether an event should be captured.\n * @param event event to be captured\n */\nfunction shouldSkipDOMEvent(eventType: string, target: SentryWrappedTarget | null): boolean {\n // We are only interested in filtering `keypress` events for now.\n if (eventType !== 'keypress') {\n return false;\n }\n\n if (!target?.tagName) {\n return true;\n }\n\n // Only consider keypress events on actual input elements. This will disregard keypresses targeting body\n // e.g.tabbing through elements, hotkeys, etc.\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Wraps addEventListener to capture UI breadcrumbs\n */\nfunction makeDOMEventHandler(\n handler: (data: HandlerDataDom) => void,\n globalListener: boolean = false,\n): (event: Event) => void {\n return (event: Event & { _sentryCaptured?: true }): void => {\n // It's possible this handler might trigger multiple times for the same\n // event (e.g. event propagation through node ancestors).\n // Ignore if we've already captured that event.\n if (!event || event['_sentryCaptured']) {\n return;\n }\n\n const target = getEventTarget(event);\n\n // We always want to skip _some_ events.\n if (shouldSkipDOMEvent(event.type, target)) {\n return;\n }\n\n // Mark event as \"seen\"\n addNonEnumerableProperty(event, '_sentryCaptured', true);\n\n if (target && !target._sentryId) {\n // Add UUID to event target so we can identify if\n addNonEnumerableProperty(target, '_sentryId', uuid4());\n }\n\n const name = event.type === 'keypress' ? 'input' : event.type;\n\n // If there is no last captured event, it means that we can safely capture the new event and store it for future comparisons.\n // If there is a last captured event, see if the new event is different enough to treat it as a unique one.\n // If that's the case, emit the previous event and store locally the newly-captured DOM event.\n if (!isSimilarToLastCapturedEvent(event)) {\n const handlerData: HandlerDataDom = { event, name, global: globalListener };\n handler(handlerData);\n lastCapturedEventType = event.type;\n lastCapturedEventTargetId = target ? target._sentryId : undefined;\n }\n\n // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.\n clearTimeout(debounceTimerID);\n debounceTimerID = WINDOW.setTimeout(() => {\n lastCapturedEventTargetId = undefined;\n lastCapturedEventType = undefined;\n }, DEBOUNCE_DURATION);\n };\n}\n\nfunction getEventTarget(event: Event): SentryWrappedTarget | null {\n try {\n return event.target as SentryWrappedTarget | null;\n } catch {\n // just accessing `target` property can throw an exception in some rare circumstances\n // see: https://github.com/getsentry/sentry-javascript/issues/838\n return null;\n }\n}\n"],"names":["addHandler","maybeInstrument","WINDOW","triggerHandlers","fill","addNonEnumerableProperty","uuid4"],"mappings":";;;;;AA2BA,MAAM,iBAAA,GAAoB,GAAA;AAE1B,IAAI,eAAA;AACJ,IAAI,qBAAA;AACJ,IAAI,yBAAA;AAQG,SAAS,uCAAuC,OAAA,EAA+C;AACpG,EAAA,MAAM,IAAA,GAAO,KAAA;AACb,EAAAA,eAAA,CAAW,MAAM,OAAO,CAAA;AACxB,EAAAC,oBAAA,CAAgB,MAAM,aAAa,CAAA;AACrC;AAGO,SAAS,aAAA,GAAsB;AACpC,EAAA,IAAI,C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A,EAAW;AAE/B,MAAAA,6BAAA,CAAyB,MAAA,EAAQ,WAAA,EAAaC,UAAA,EAAO,CAAA;AAAA,IACvD;AAEA,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,IAAA,KAAS,UAAA,GAAa,UAAU,KAAA,CAAM,IAAA;AAKzD,IAAA,IAAI,CAAC,4BAAA,CAA6B,KAAK,CAAA,EAAG;AACxC,MAAA,MAAM,WAAA,GAA8B,EAAE,KAAA,EAAO,IAAA,EAAM,QAAQ,cAAA,EAAe;AAC1E,MAAA,OAAA,CAAQ,WAAW,CAAA;AACnB,MAAA,qBAAA,GAAwB,KAAA,CAAM,IAAA;AAC9B,MAAA,yBAAA,GAA4B,MAAA,GAAS,OAAO,SAAA,GAAY,MAAA;AAAA,IAC1D;AAGA,IAAA,YAAA,CAAa,eAAe,CAAA;AAC5B,IAAA,eAAA,GAAkBJ,YAAA,CAAO,WAAW,MAAM;AACxC,MAAA,yBAAA,GAA4B,MAAA;AAC5B,MAAA,qBAAA,GAAwB,MAAA;AAAA,IAC1B,GAAG,iBAAiB,CAAA;AAAA,EACtB,CAAA;AACF;AAEA,SAAS,eAAe,KAAA,EAA0C;AAChE,EAAA,IAAI;AACF,IAAA,OAAO,KAAA,CAAM,MAAA;AAAA,EACf,CAAA,CAAA,MAAQ;AAGN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;;;;;"}
@@ -0,0 +1,56 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const types = require('../types.js');
5
+
6
+ let lastHref;
7
+ function addHistoryInstrumentationHandler(handler) {
8
+ const type = "history";
9
+ core.addHandler(type, handler);
10
+ core.maybeInstrument(type, instrumentHistory);
11
+ }
12
+ function instrumentHistory() {
13
+ types.WINDOW.addEventListener("popstate", () => {
14
+ const to = types.WINDOW.location.href;
15
+ const from = lastHref;
16
+ lastHref = to;
17
+ if (from === to) {
18
+ return;
19
+ }
20
+ const handlerData = { from, to };
21
+ core.triggerHandlers("history", handlerData);
22
+ });
23
+ if (!core.supportsHistory()) {
24
+ return;
25
+ }
26
+ function historyReplacementFunction(originalHistoryFunction) {
27
+ return function(...args) {
28
+ const url = args.length > 2 ? args[2] : void 0;
29
+ if (url) {
30
+ const from = lastHref;
31
+ const to = getAbsoluteUrl(String(url));
32
+ lastHref = to;
33
+ if (from === to) {
34
+ return originalHistoryFunction.apply(this, args);
35
+ }
36
+ const handlerData = { from, to };
37
+ core.triggerHandlers("history", handlerData);
38
+ }
39
+ return originalHistoryFunction.apply(this, args);
40
+ };
41
+ }
42
+ core.fill(types.WINDOW.history, "pushState", historyReplacementFunction);
43
+ core.fill(types.WINDOW.history, "replaceState", historyReplacementFunction);
44
+ }
45
+ function getAbsoluteUrl(urlOrPath) {
46
+ try {
47
+ const url = new URL(urlOrPath, types.WINDOW.location.origin);
48
+ return url.toString();
49
+ } catch {
50
+ return urlOrPath;
51
+ }
52
+ }
53
+
54
+ exports.addHistoryInstrumentationHandler = addHistoryInstrumentationHandler;
55
+ exports.instrumentHistory = instrumentHistory;
56
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sources":["../../../src/instrument/history.ts"],"sourcesContent":["import type { HandlerDataHistory } from '@sentry/core';\nimport { addHandler, fill, maybeInstrument, supportsHistory, triggerHandlers } from '@sentry/core';\nimport { WINDOW } from '../types';\n\nlet lastHref: string | undefined;\n\n/**\n * Add an instrumentation handler for when a fetch request happens.\n * The handler function is called once when the request starts and once when it ends,\n * which can be identified by checking if it has an `endTimestamp`.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addHistoryInstrumentationHandler(handler: (data: HandlerDataHistory) => void): void {\n const type = 'history';\n addHandler(type, handler);\n maybeInstrument(type, instrumentHistory);\n}\n\n/**\n * Exported just for testing\n */\nexport function instrumentHistory(): void {\n // The `popstate` event may also be triggered on `pushState`, but it may not always reliably be emitted by the browser\n // Which is why we also monkey-patch methods below, in addition to this\n WINDOW.addEventListener('popstate', () => {\n const to = WINDOW.location.href;\n // keep track of the current URL state, as we always receive only the updated state\n const from = lastHref;\n lastHref = to;\n\n if (from === to) {\n return;\n }\n\n const handlerData = { from, to } satisfies HandlerDataHistory;\n triggerHandlers('history', handlerData);\n });\n\n // Just guard against this not being available, in weird environments\n if (!supportsHistory()) {\n return;\n }\n\n function historyReplacementFunction(originalHistoryFunction: () => void): () => void {\n return function (this: History, ...args: unknown[]): void {\n const url = args.length > 2 ? args[2] : undefined;\n if (url) {\n const from = lastHref;\n\n // Ensure the URL is absolute\n // this can be either a path, then it is relative to the current origin\n // or a full URL of the current origin - other origins are not allowed\n // See: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState#url\n // coerce to string (this is what pushState does)\n const to = getAbsoluteUrl(String(url));\n\n // keep track of the current URL state, as we always receive only the updated state\n lastHref = to;\n\n if (from === to) {\n return originalHistoryFunction.apply(this, args);\n }\n\n const handlerData = { from, to } satisfies HandlerDataHistory;\n triggerHandlers('history', handlerData);\n }\n return originalHistoryFunction.apply(this, args);\n };\n }\n\n fill(WINDOW.history, 'pushState', historyReplacementFunction);\n fill(WINDOW.history, 'replaceState', historyReplacementFunction);\n}\n\nfunction getAbsoluteUrl(urlOrPath: string): string {\n try {\n const url = new URL(urlOrPath, WINDOW.location.origin);\n return url.toString();\n } catch {\n // fallback, just do nothing\n return urlOrPath;\n }\n}\n"],"names":["addHandler","maybeInstrument","WINDOW","triggerHandlers","supportsHistory","fill"],"mappings":";;;;;AAIA,IAAI,QAAA;AAUG,SAAS,iCAAiC,OAAA,EAAmD;AAClG,EAAA,MAAM,IAAA,GAAO,SAAA;AACb,EAAAA,eAAA,CAAW,MAAM,OAAO,CAAA;AACxB,EAAAC,oBAAA,CAAgB,MAAM,iBAAiB,CAAA;AACzC;AAKO,SAAS,iBAAA,GAA0B;AAGxC,EAAAC,YAAA,CAAO,gBAAA,CAAiB,YAAY,MAAM;AACxC,IAAA,MAAM,EA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