@atlaskit/react-ufo 1.1.0 → 2.0.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 (486) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +5 -0
  3. package/additional-payload/package.json +15 -0
  4. package/bundle-eval-timing/package.json +15 -0
  5. package/coinflip/package.json +15 -0
  6. package/common/package.json +5 -5
  7. package/config/package.json +15 -0
  8. package/create-payload/package.json +15 -0
  9. package/create-post-interaction-log-payload/package.json +15 -0
  10. package/custom-data/package.json +15 -0
  11. package/custom-mark/package.json +15 -0
  12. package/custom-spans/package.json +15 -0
  13. package/custom-timings/package.json +15 -0
  14. package/dist/cjs/additional-payload/index.js +25 -0
  15. package/dist/cjs/additional-payload/utils/cache-hit-ratio/index.js +69 -0
  16. package/dist/cjs/additional-payload/utils/lighthouse-metrics/cls/index.js +53 -0
  17. package/dist/cjs/additional-payload/utils/lighthouse-metrics/const.js +10 -0
  18. package/dist/cjs/additional-payload/utils/lighthouse-metrics/index.js +29 -0
  19. package/dist/cjs/additional-payload/utils/lighthouse-metrics/tbt/index.js +25 -0
  20. package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +38 -0
  21. package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +37 -0
  22. package/dist/cjs/bundle-eval-timing/index.js +48 -0
  23. package/dist/cjs/coinflip/index.js +22 -0
  24. package/dist/cjs/common/common/types.js +5 -0
  25. package/dist/cjs/common/constants.js +7 -0
  26. package/dist/cjs/common/index.js +1 -0
  27. package/dist/cjs/common/vc/types.js +11 -0
  28. package/dist/cjs/config/index.js +222 -0
  29. package/dist/cjs/create-payload/common/types.js +1 -0
  30. package/dist/cjs/create-payload/common/utils/index.js +15 -0
  31. package/dist/cjs/create-payload/index.js +784 -0
  32. package/dist/cjs/create-post-interaction-log-payload/index.js +207 -0
  33. package/dist/cjs/custom-data/index.js +31 -0
  34. package/dist/cjs/custom-data/types.js +5 -0
  35. package/dist/cjs/custom-mark/index.js +45 -0
  36. package/dist/cjs/custom-spans/index.js +14 -0
  37. package/dist/cjs/custom-timings/index.js +65 -0
  38. package/dist/cjs/experience-trace-id-context/index.js +40 -0
  39. package/dist/cjs/experience-trace-id-context/types.js +1 -0
  40. package/dist/cjs/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +12 -0
  41. package/dist/cjs/feature-flags-accessed/common/constants.js +7 -0
  42. package/dist/cjs/feature-flags-accessed/common/types.js +5 -0
  43. package/dist/cjs/feature-flags-accessed/common/utils/index.js +38 -0
  44. package/dist/cjs/feature-flags-accessed/index.js +32 -0
  45. package/dist/cjs/generate-id/index.js +12 -0
  46. package/dist/cjs/global-error-handler/index.js +74 -0
  47. package/dist/cjs/hidden-timing/index.js +94 -0
  48. package/dist/cjs/initial-page-load-extra-timing/index.js +49 -0
  49. package/dist/cjs/interaction-context/index.js +14 -0
  50. package/dist/cjs/interaction-id-context/index.js +27 -0
  51. package/dist/cjs/interaction-metrics/common/constants.js +8 -0
  52. package/dist/cjs/interaction-metrics/index.js +810 -1
  53. package/dist/cjs/interaction-metrics/post-interaction-log.js +190 -0
  54. package/dist/cjs/interaction-metrics-init/index.js +89 -0
  55. package/dist/cjs/label/UFOLabel.js +45 -0
  56. package/dist/cjs/label/index.js +9 -0
  57. package/dist/cjs/load-hold/UFOLoadHold.js +76 -0
  58. package/dist/cjs/load-hold/index.js +9 -0
  59. package/dist/cjs/placeholder/Placeholder.js +34 -0
  60. package/dist/cjs/placeholder/index.js +9 -0
  61. package/dist/cjs/placeholder/loosely-lazy/index.js +19 -0
  62. package/dist/cjs/placeholder/loosely-lazy/lazy-suspense.js +80 -0
  63. package/dist/cjs/placeholder/loosely-lazy/types.js +5 -0
  64. package/dist/cjs/placeholder/loosely-lazy/wait-context.js +15 -0
  65. package/dist/cjs/resource-timing/common/types.js +1 -0
  66. package/dist/cjs/resource-timing/common/utils/config.js +70 -0
  67. package/dist/cjs/resource-timing/common/utils/resource-timing-buffer.js +111 -0
  68. package/dist/cjs/resource-timing/index.js +26 -0
  69. package/dist/cjs/resource-timing/main.js +141 -0
  70. package/dist/cjs/resource-timing/utils.js +10 -0
  71. package/dist/cjs/round-number/index.js +11 -0
  72. package/dist/cjs/route-name/index.js +12 -0
  73. package/dist/cjs/route-name-context/index.js +11 -0
  74. package/dist/cjs/segment/index.js +9 -0
  75. package/dist/cjs/segment/segment-highlight.js +40 -0
  76. package/dist/cjs/segment/segment.js +247 -0
  77. package/dist/cjs/set-interaction-error/index.js +17 -0
  78. package/dist/cjs/short-id/index.js +15 -0
  79. package/dist/cjs/ssr/index.js +70 -0
  80. package/dist/cjs/trace-interaction/index.js +48 -0
  81. package/dist/cjs/trace-pageload/index.js +58 -0
  82. package/dist/cjs/trace-press/index.js +34 -0
  83. package/dist/cjs/trace-redirect/index.js +17 -0
  84. package/dist/cjs/trace-transition/index.js +60 -0
  85. package/dist/cjs/trace-transition/utils/generate-span-id/index.js +11 -0
  86. package/dist/cjs/trace-transition/utils/set-interaction-active-trace/index.js +11 -0
  87. package/dist/cjs/typing-performance-tracing/index.js +262 -0
  88. package/dist/cjs/use-press-tracing/index.js +19 -0
  89. package/dist/cjs/vc/index.js +15 -0
  90. package/dist/cjs/vc/vc-observer/attachAbortListeners.js +40 -0
  91. package/dist/cjs/vc/vc-observer/getViewport.js +27 -0
  92. package/dist/cjs/vc/vc-observer/index.js +562 -0
  93. package/dist/cjs/vc/vc-observer/media-wrapper/index.js +15 -0
  94. package/dist/cjs/vc/vc-observer/media-wrapper/vc-utils.js +16 -0
  95. package/dist/cjs/vc/vc-observer/observers/index.js +270 -0
  96. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +183 -0
  97. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +22 -0
  98. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +20 -0
  99. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +19 -0
  100. package/dist/cjs/vc/vc-observer/observers/types.js +5 -0
  101. package/dist/es2019/additional-payload/index.js +2 -0
  102. package/dist/es2019/additional-payload/utils/cache-hit-ratio/index.js +63 -0
  103. package/dist/es2019/additional-payload/utils/lighthouse-metrics/cls/index.js +33 -0
  104. package/dist/es2019/additional-payload/utils/lighthouse-metrics/const.js +4 -0
  105. package/dist/es2019/additional-payload/utils/lighthouse-metrics/index.js +23 -0
  106. package/dist/es2019/additional-payload/utils/lighthouse-metrics/tbt/index.js +15 -0
  107. package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +23 -0
  108. package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
  109. package/dist/es2019/bundle-eval-timing/index.js +43 -0
  110. package/dist/es2019/coinflip/index.js +16 -0
  111. package/dist/es2019/common/common/types.js +1 -0
  112. package/dist/es2019/common/constants.js +1 -0
  113. package/dist/es2019/common/vc/types.js +5 -0
  114. package/dist/es2019/config/index.js +215 -0
  115. package/dist/es2019/create-payload/common/types.js +0 -0
  116. package/dist/es2019/create-payload/common/utils/index.js +8 -0
  117. package/dist/es2019/create-payload/index.js +792 -0
  118. package/dist/es2019/create-post-interaction-log-payload/index.js +188 -0
  119. package/dist/es2019/custom-data/index.js +24 -0
  120. package/dist/es2019/custom-data/types.js +1 -0
  121. package/dist/es2019/custom-mark/index.js +38 -0
  122. package/dist/es2019/custom-spans/index.js +6 -0
  123. package/dist/es2019/custom-timings/index.js +57 -0
  124. package/dist/es2019/experience-trace-id-context/index.js +31 -0
  125. package/dist/es2019/experience-trace-id-context/types.js +0 -0
  126. package/dist/es2019/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +4 -0
  127. package/dist/es2019/feature-flags-accessed/common/constants.js +1 -0
  128. package/dist/es2019/feature-flags-accessed/common/types.js +1 -0
  129. package/dist/es2019/feature-flags-accessed/common/utils/index.js +24 -0
  130. package/dist/es2019/feature-flags-accessed/index.js +21 -0
  131. package/dist/es2019/generate-id/index.js +6 -0
  132. package/dist/es2019/global-error-handler/index.js +64 -0
  133. package/dist/es2019/hidden-timing/index.js +87 -0
  134. package/dist/es2019/initial-page-load-extra-timing/index.js +43 -0
  135. package/dist/es2019/interaction-context/index.js +6 -0
  136. package/dist/es2019/interaction-id-context/index.js +18 -0
  137. package/dist/es2019/interaction-metrics/common/constants.js +2 -0
  138. package/dist/es2019/interaction-metrics/index.js +736 -0
  139. package/dist/es2019/interaction-metrics/post-interaction-log.js +158 -0
  140. package/dist/es2019/interaction-metrics-init/index.js +72 -0
  141. package/dist/es2019/label/UFOLabel.js +34 -0
  142. package/dist/es2019/label/index.js +2 -0
  143. package/dist/es2019/load-hold/UFOLoadHold.js +66 -0
  144. package/dist/es2019/load-hold/index.js +2 -0
  145. package/dist/es2019/placeholder/Placeholder.js +25 -0
  146. package/dist/es2019/placeholder/index.js +2 -0
  147. package/dist/es2019/placeholder/loosely-lazy/index.js +2 -0
  148. package/dist/es2019/placeholder/loosely-lazy/lazy-suspense.js +63 -0
  149. package/dist/es2019/placeholder/loosely-lazy/types.js +1 -0
  150. package/dist/es2019/placeholder/loosely-lazy/wait-context.js +5 -0
  151. package/dist/es2019/resource-timing/common/types.js +0 -0
  152. package/dist/es2019/resource-timing/common/utils/config.js +44 -0
  153. package/dist/es2019/resource-timing/common/utils/resource-timing-buffer.js +88 -0
  154. package/dist/es2019/resource-timing/index.js +3 -0
  155. package/dist/es2019/resource-timing/main.js +130 -0
  156. package/dist/es2019/resource-timing/utils.js +4 -0
  157. package/dist/es2019/round-number/index.js +4 -0
  158. package/dist/es2019/route-name/index.js +6 -0
  159. package/dist/es2019/route-name-context/index.js +5 -0
  160. package/dist/es2019/segment/index.js +2 -0
  161. package/dist/es2019/segment/segment-highlight.js +27 -0
  162. package/dist/es2019/segment/segment.js +218 -0
  163. package/dist/es2019/set-interaction-error/index.js +11 -0
  164. package/dist/es2019/short-id/index.js +8 -0
  165. package/dist/es2019/ssr/index.js +54 -0
  166. package/dist/es2019/trace-interaction/index.js +41 -0
  167. package/dist/es2019/trace-pageload/index.js +48 -0
  168. package/dist/es2019/trace-press/index.js +27 -0
  169. package/dist/es2019/trace-redirect/index.js +10 -0
  170. package/dist/es2019/trace-transition/index.js +48 -0
  171. package/dist/es2019/trace-transition/utils/generate-span-id/index.js +1 -0
  172. package/dist/es2019/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
  173. package/dist/es2019/typing-performance-tracing/index.js +255 -0
  174. package/dist/es2019/use-press-tracing/index.js +12 -0
  175. package/dist/es2019/vc/index.js +8 -0
  176. package/dist/es2019/vc/vc-observer/attachAbortListeners.js +34 -0
  177. package/dist/es2019/vc/vc-observer/getViewport.js +18 -0
  178. package/dist/es2019/vc/vc-observer/index.js +522 -0
  179. package/dist/es2019/vc/vc-observer/media-wrapper/index.js +9 -0
  180. package/dist/es2019/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
  181. package/dist/es2019/vc/vc-observer/observers/index.js +231 -0
  182. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +146 -0
  183. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
  184. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
  185. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
  186. package/dist/es2019/vc/vc-observer/observers/types.js +1 -0
  187. package/dist/esm/additional-payload/index.js +2 -0
  188. package/dist/esm/additional-payload/utils/cache-hit-ratio/index.js +63 -0
  189. package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/index.js +47 -0
  190. package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/types.js +0 -0
  191. package/dist/esm/additional-payload/utils/lighthouse-metrics/const.js +4 -0
  192. package/dist/esm/additional-payload/utils/lighthouse-metrics/index.js +22 -0
  193. package/dist/esm/additional-payload/utils/lighthouse-metrics/tbt/index.js +19 -0
  194. package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +31 -0
  195. package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
  196. package/dist/esm/bundle-eval-timing/index.js +41 -0
  197. package/dist/esm/coinflip/index.js +16 -0
  198. package/dist/esm/common/common/types.js +1 -0
  199. package/dist/esm/common/constants.js +1 -0
  200. package/dist/esm/common/index.js +0 -0
  201. package/dist/esm/common/vc/types.js +5 -0
  202. package/dist/esm/config/index.js +206 -0
  203. package/dist/esm/create-payload/common/types.js +0 -0
  204. package/dist/esm/create-payload/common/utils/index.js +8 -0
  205. package/dist/esm/create-payload/index.js +774 -0
  206. package/dist/esm/create-post-interaction-log-payload/index.js +200 -0
  207. package/dist/esm/custom-data/index.js +23 -0
  208. package/dist/esm/custom-data/types.js +1 -0
  209. package/dist/esm/custom-mark/index.js +36 -0
  210. package/dist/esm/custom-spans/index.js +8 -0
  211. package/dist/esm/custom-timings/index.js +56 -0
  212. package/dist/esm/experience-trace-id-context/index.js +34 -0
  213. package/dist/esm/experience-trace-id-context/types.js +0 -0
  214. package/dist/esm/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +6 -0
  215. package/dist/esm/feature-flags-accessed/common/constants.js +1 -0
  216. package/dist/esm/feature-flags-accessed/common/types.js +1 -0
  217. package/dist/esm/feature-flags-accessed/common/utils/index.js +31 -0
  218. package/dist/esm/feature-flags-accessed/index.js +21 -0
  219. package/dist/esm/generate-id/index.js +6 -0
  220. package/dist/esm/global-error-handler/index.js +67 -0
  221. package/dist/esm/hidden-timing/index.js +87 -0
  222. package/dist/esm/initial-page-load-extra-timing/index.js +42 -0
  223. package/dist/esm/interaction-context/index.js +6 -0
  224. package/dist/esm/interaction-id-context/index.js +22 -0
  225. package/dist/esm/interaction-metrics/common/constants.js +2 -0
  226. package/dist/esm/interaction-metrics/index.js +773 -0
  227. package/dist/esm/interaction-metrics/post-interaction-log.js +184 -0
  228. package/dist/esm/interaction-metrics-init/index.js +77 -0
  229. package/dist/esm/label/UFOLabel.js +36 -0
  230. package/dist/esm/label/index.js +2 -0
  231. package/dist/esm/load-hold/UFOLoadHold.js +66 -0
  232. package/dist/esm/load-hold/index.js +2 -0
  233. package/dist/esm/placeholder/Placeholder.js +25 -0
  234. package/dist/esm/placeholder/index.js +2 -0
  235. package/dist/esm/placeholder/loosely-lazy/index.js +2 -0
  236. package/dist/esm/placeholder/loosely-lazy/lazy-suspense.js +70 -0
  237. package/dist/esm/placeholder/loosely-lazy/types.js +1 -0
  238. package/dist/esm/placeholder/loosely-lazy/wait-context.js +9 -0
  239. package/dist/esm/resource-timing/common/types.js +0 -0
  240. package/dist/esm/resource-timing/common/utils/config.js +62 -0
  241. package/dist/esm/resource-timing/common/utils/resource-timing-buffer.js +104 -0
  242. package/dist/esm/resource-timing/index.js +3 -0
  243. package/dist/esm/resource-timing/main.js +134 -0
  244. package/dist/esm/resource-timing/utils.js +4 -0
  245. package/dist/esm/round-number/index.js +5 -0
  246. package/dist/esm/route-name/index.js +6 -0
  247. package/dist/esm/route-name-context/index.js +5 -0
  248. package/dist/esm/segment/index.js +2 -0
  249. package/dist/esm/segment/segment-highlight.js +30 -0
  250. package/dist/esm/segment/segment.js +235 -0
  251. package/dist/esm/set-interaction-error/index.js +11 -0
  252. package/dist/esm/short-id/index.js +9 -0
  253. package/dist/esm/ssr/index.js +59 -0
  254. package/dist/esm/trace-interaction/index.js +41 -0
  255. package/dist/esm/trace-pageload/index.js +50 -0
  256. package/dist/esm/trace-press/index.js +27 -0
  257. package/dist/esm/trace-redirect/index.js +10 -0
  258. package/dist/esm/trace-transition/index.js +49 -0
  259. package/dist/esm/trace-transition/utils/generate-span-id/index.js +5 -0
  260. package/dist/esm/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
  261. package/dist/esm/typing-performance-tracing/index.js +255 -0
  262. package/dist/esm/use-press-tracing/index.js +12 -0
  263. package/dist/esm/vc/index.js +9 -0
  264. package/dist/esm/vc/vc-observer/attachAbortListeners.js +34 -0
  265. package/dist/esm/vc/vc-observer/getViewport.js +20 -0
  266. package/dist/esm/vc/vc-observer/index.js +555 -0
  267. package/dist/esm/vc/vc-observer/media-wrapper/index.js +7 -0
  268. package/dist/esm/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
  269. package/dist/esm/vc/vc-observer/observers/index.js +263 -0
  270. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +176 -0
  271. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
  272. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
  273. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
  274. package/dist/esm/vc/vc-observer/observers/types.js +1 -0
  275. package/dist/types/additional-payload/index.d.ts +2 -0
  276. package/dist/types/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
  277. package/dist/types/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
  278. package/dist/types/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
  279. package/dist/types/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
  280. package/dist/types/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
  281. package/dist/types/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
  282. package/dist/types/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
  283. package/dist/types/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
  284. package/dist/types/bundle-eval-timing/index.d.ts +16 -0
  285. package/dist/types/coinflip/index.d.ts +8 -0
  286. package/dist/types/common/common/types.d.ts +201 -0
  287. package/dist/types/common/constants.d.ts +1 -0
  288. package/dist/types/common/index.d.ts +5 -0
  289. package/dist/types/common/vc/types.d.ts +91 -0
  290. package/dist/types/config/index.d.ts +91 -0
  291. package/dist/types/create-payload/common/types.d.ts +4 -0
  292. package/dist/types/create-payload/common/utils/index.d.ts +3 -0
  293. package/dist/types/create-payload/index.d.ts +2969 -0
  294. package/dist/types/create-post-interaction-log-payload/index.d.ts +45 -0
  295. package/dist/types/custom-data/index.d.ts +5 -0
  296. package/dist/types/custom-data/types.d.ts +4 -0
  297. package/dist/types/custom-mark/index.d.ts +10 -0
  298. package/dist/types/custom-spans/index.d.ts +1 -0
  299. package/dist/types/custom-timings/index.d.ts +19 -0
  300. package/dist/types/experience-trace-id-context/index.d.ts +10 -0
  301. package/dist/types/experience-trace-id-context/types.d.ts +8 -0
  302. package/dist/types/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
  303. package/dist/types/feature-flags-accessed/common/constants.d.ts +1 -0
  304. package/dist/types/feature-flags-accessed/common/types.d.ts +2 -0
  305. package/dist/types/feature-flags-accessed/common/utils/index.d.ts +3 -0
  306. package/dist/types/feature-flags-accessed/index.d.ts +14 -0
  307. package/dist/types/generate-id/index.d.ts +2 -0
  308. package/dist/types/global-error-handler/index.d.ts +3 -0
  309. package/dist/types/hidden-timing/index.d.ts +7 -0
  310. package/dist/types/initial-page-load-extra-timing/index.d.ts +9 -0
  311. package/dist/types/interaction-context/index.d.ts +33 -0
  312. package/dist/types/interaction-id-context/index.d.ts +9 -0
  313. package/dist/types/interaction-metrics/common/constants.d.ts +3 -0
  314. package/dist/types/interaction-metrics/index.d.ts +65 -1
  315. package/dist/types/interaction-metrics/post-interaction-log.d.ts +69 -0
  316. package/dist/types/interaction-metrics-init/index.d.ts +11 -0
  317. package/dist/types/label/UFOLabel.d.ts +13 -0
  318. package/dist/types/label/index.d.ts +2 -0
  319. package/dist/types/load-hold/UFOLoadHold.d.ts +53 -0
  320. package/dist/types/load-hold/index.d.ts +2 -0
  321. package/dist/types/placeholder/Placeholder.d.ts +13 -0
  322. package/dist/types/placeholder/index.d.ts +2 -0
  323. package/dist/types/placeholder/loosely-lazy/index.d.ts +3 -0
  324. package/dist/types/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
  325. package/dist/types/placeholder/loosely-lazy/types.d.ts +20 -0
  326. package/dist/types/placeholder/loosely-lazy/wait-context.d.ts +3 -0
  327. package/dist/types/resource-timing/common/types.d.ts +41 -0
  328. package/dist/types/resource-timing/common/utils/config.d.ts +3 -0
  329. package/dist/types/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
  330. package/dist/types/resource-timing/index.d.ts +4 -0
  331. package/dist/types/resource-timing/main.d.ts +2 -0
  332. package/dist/types/resource-timing/utils.d.ts +1 -0
  333. package/dist/types/round-number/index.d.ts +1 -0
  334. package/dist/types/route-name/index.d.ts +4 -0
  335. package/dist/types/route-name-context/index.d.ts +5 -0
  336. package/dist/types/segment/index.d.ts +2 -0
  337. package/dist/types/segment/segment-highlight.d.ts +6 -0
  338. package/dist/types/segment/segment.d.ts +8 -0
  339. package/dist/types/set-interaction-error/index.d.ts +4 -0
  340. package/dist/types/short-id/index.d.ts +1 -0
  341. package/dist/types/ssr/index.d.ts +21 -0
  342. package/dist/types/trace-interaction/index.d.ts +2 -0
  343. package/dist/types/trace-pageload/index.d.ts +2 -0
  344. package/dist/types/trace-press/index.d.ts +1 -0
  345. package/dist/types/trace-redirect/index.d.ts +1 -0
  346. package/dist/types/trace-transition/index.d.ts +2 -0
  347. package/dist/types/trace-transition/utils/generate-span-id/index.d.ts +1 -0
  348. package/dist/types/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
  349. package/dist/types/typing-performance-tracing/index.d.ts +2 -0
  350. package/dist/types/use-press-tracing/index.d.ts +1 -0
  351. package/dist/types/vc/index.d.ts +2 -0
  352. package/dist/types/vc/vc-observer/attachAbortListeners.d.ts +6 -0
  353. package/dist/types/vc/vc-observer/getViewport.d.ts +2 -0
  354. package/dist/types/vc/vc-observer/index.d.ts +98 -0
  355. package/dist/types/vc/vc-observer/media-wrapper/index.d.ts +7 -0
  356. package/dist/types/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
  357. package/dist/types/vc/vc-observer/observers/index.d.ts +39 -0
  358. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
  359. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
  360. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
  361. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
  362. package/dist/types/vc/vc-observer/observers/types.d.ts +11 -0
  363. package/dist/types-ts4.5/additional-payload/index.d.ts +2 -0
  364. package/dist/types-ts4.5/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
  365. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
  366. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
  367. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
  368. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
  369. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
  370. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
  371. package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
  372. package/dist/types-ts4.5/bundle-eval-timing/index.d.ts +16 -0
  373. package/dist/types-ts4.5/coinflip/index.d.ts +8 -0
  374. package/dist/types-ts4.5/common/common/types.d.ts +201 -0
  375. package/dist/types-ts4.5/common/constants.d.ts +1 -0
  376. package/dist/types-ts4.5/common/index.d.ts +5 -0
  377. package/dist/types-ts4.5/common/vc/types.d.ts +91 -0
  378. package/dist/types-ts4.5/config/index.d.ts +95 -0
  379. package/dist/types-ts4.5/create-payload/common/types.d.ts +4 -0
  380. package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +3 -0
  381. package/dist/types-ts4.5/create-payload/index.d.ts +2969 -0
  382. package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +45 -0
  383. package/dist/types-ts4.5/custom-data/index.d.ts +5 -0
  384. package/dist/types-ts4.5/custom-data/types.d.ts +4 -0
  385. package/dist/types-ts4.5/custom-mark/index.d.ts +10 -0
  386. package/dist/types-ts4.5/custom-spans/index.d.ts +1 -0
  387. package/dist/types-ts4.5/custom-timings/index.d.ts +19 -0
  388. package/dist/types-ts4.5/experience-trace-id-context/index.d.ts +10 -0
  389. package/dist/types-ts4.5/experience-trace-id-context/types.d.ts +8 -0
  390. package/dist/types-ts4.5/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
  391. package/dist/types-ts4.5/feature-flags-accessed/common/constants.d.ts +1 -0
  392. package/dist/types-ts4.5/feature-flags-accessed/common/types.d.ts +2 -0
  393. package/dist/types-ts4.5/feature-flags-accessed/common/utils/index.d.ts +3 -0
  394. package/dist/types-ts4.5/feature-flags-accessed/index.d.ts +14 -0
  395. package/dist/types-ts4.5/generate-id/index.d.ts +2 -0
  396. package/dist/types-ts4.5/global-error-handler/index.d.ts +3 -0
  397. package/dist/types-ts4.5/hidden-timing/index.d.ts +7 -0
  398. package/dist/types-ts4.5/initial-page-load-extra-timing/index.d.ts +9 -0
  399. package/dist/types-ts4.5/interaction-context/index.d.ts +33 -0
  400. package/dist/types-ts4.5/interaction-id-context/index.d.ts +9 -0
  401. package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -0
  402. package/dist/types-ts4.5/interaction-metrics/index.d.ts +65 -1
  403. package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +69 -0
  404. package/dist/types-ts4.5/interaction-metrics-init/index.d.ts +11 -0
  405. package/dist/types-ts4.5/label/UFOLabel.d.ts +13 -0
  406. package/dist/types-ts4.5/label/index.d.ts +2 -0
  407. package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +53 -0
  408. package/dist/types-ts4.5/load-hold/index.d.ts +2 -0
  409. package/dist/types-ts4.5/placeholder/Placeholder.d.ts +13 -0
  410. package/dist/types-ts4.5/placeholder/index.d.ts +2 -0
  411. package/dist/types-ts4.5/placeholder/loosely-lazy/index.d.ts +3 -0
  412. package/dist/types-ts4.5/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
  413. package/dist/types-ts4.5/placeholder/loosely-lazy/types.d.ts +20 -0
  414. package/dist/types-ts4.5/placeholder/loosely-lazy/wait-context.d.ts +3 -0
  415. package/dist/types-ts4.5/resource-timing/common/types.d.ts +41 -0
  416. package/dist/types-ts4.5/resource-timing/common/utils/config.d.ts +3 -0
  417. package/dist/types-ts4.5/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
  418. package/dist/types-ts4.5/resource-timing/index.d.ts +4 -0
  419. package/dist/types-ts4.5/resource-timing/main.d.ts +2 -0
  420. package/dist/types-ts4.5/resource-timing/utils.d.ts +1 -0
  421. package/dist/types-ts4.5/round-number/index.d.ts +1 -0
  422. package/dist/types-ts4.5/route-name/index.d.ts +4 -0
  423. package/dist/types-ts4.5/route-name-context/index.d.ts +5 -0
  424. package/dist/types-ts4.5/segment/index.d.ts +2 -0
  425. package/dist/types-ts4.5/segment/segment-highlight.d.ts +6 -0
  426. package/dist/types-ts4.5/segment/segment.d.ts +8 -0
  427. package/dist/types-ts4.5/set-interaction-error/index.d.ts +4 -0
  428. package/dist/types-ts4.5/short-id/index.d.ts +1 -0
  429. package/dist/types-ts4.5/ssr/index.d.ts +21 -0
  430. package/dist/types-ts4.5/trace-interaction/index.d.ts +2 -0
  431. package/dist/types-ts4.5/trace-pageload/index.d.ts +2 -0
  432. package/dist/types-ts4.5/trace-press/index.d.ts +1 -0
  433. package/dist/types-ts4.5/trace-redirect/index.d.ts +1 -0
  434. package/dist/types-ts4.5/trace-transition/index.d.ts +2 -0
  435. package/dist/types-ts4.5/trace-transition/utils/generate-span-id/index.d.ts +1 -0
  436. package/dist/types-ts4.5/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
  437. package/dist/types-ts4.5/typing-performance-tracing/index.d.ts +2 -0
  438. package/dist/types-ts4.5/use-press-tracing/index.d.ts +1 -0
  439. package/dist/types-ts4.5/vc/index.d.ts +2 -0
  440. package/dist/types-ts4.5/vc/vc-observer/attachAbortListeners.d.ts +6 -0
  441. package/dist/types-ts4.5/vc/vc-observer/getViewport.d.ts +2 -0
  442. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +98 -0
  443. package/dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts +7 -0
  444. package/dist/types-ts4.5/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
  445. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +39 -0
  446. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
  447. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
  448. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
  449. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
  450. package/dist/types-ts4.5/vc/vc-observer/observers/types.d.ts +11 -0
  451. package/experience-trace-id-context/package.json +15 -0
  452. package/feature-flags-accessed/package.json +15 -0
  453. package/generate-id/package.json +15 -0
  454. package/global-error-handler/package.json +15 -0
  455. package/hidden-timing/package.json +15 -0
  456. package/initial-page-load-extra-timing/package.json +15 -0
  457. package/interaction-context/package.json +15 -0
  458. package/interaction-id-context/package.json +15 -0
  459. package/interaction-metrics-init/package.json +15 -0
  460. package/label/package.json +15 -0
  461. package/load-hold/package.json +15 -0
  462. package/package.json +55 -3
  463. package/placeholder/package.json +15 -0
  464. package/resource-timing/package.json +15 -0
  465. package/round-number/package.json +15 -0
  466. package/route-name/package.json +15 -0
  467. package/route-name-context/package.json +15 -0
  468. package/segment/package.json +15 -0
  469. package/set-interaction-error/package.json +15 -0
  470. package/short-id/package.json +15 -0
  471. package/ssr/package.json +15 -0
  472. package/ssr-scripts/package.json +15 -0
  473. package/trace-interaction/package.json +15 -0
  474. package/trace-pageload/package.json +15 -0
  475. package/trace-press/package.json +15 -0
  476. package/trace-redirect/package.json +15 -0
  477. package/trace-transition/package.json +15 -0
  478. package/typing-performance-tracing/package.json +15 -0
  479. package/use-press-tracing/package.json +15 -0
  480. package/vc/media/package.json +15 -0
  481. package/vc/package.json +15 -0
  482. package/dist/types/common/types.d.ts +0 -17
  483. package/dist/types-ts4.5/common/types.d.ts +0 -17
  484. /package/dist/cjs/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
  485. /package/dist/es2019/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
  486. /package/dist/{esm/common/types.js → es2019/common/index.js} +0 -0
@@ -0,0 +1,200 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import { REACT_UFO_VERSION } from '../common/constants';
6
+ import { getConfig } from '../config';
7
+ import { isSegmentLabel, sanitizeUfoName } from '../create-payload/common/utils';
8
+ import { getPageVisibilityState } from '../hidden-timing';
9
+ function getParentStack(labelStack) {
10
+ if (!labelStack || labelStack.length <= 1) {
11
+ return null;
12
+ }
13
+ return labelStack.slice(0, labelStack.length - 1);
14
+ }
15
+ function getSegmentId(labelStack) {
16
+ if (!labelStack) {
17
+ return null;
18
+ }
19
+ var leafLabelStack = labelStack[labelStack.length - 1];
20
+ if (isSegmentLabel(leafLabelStack)) {
21
+ return leafLabelStack.segmentId;
22
+ }
23
+ var parentStack = getParentStack(labelStack);
24
+ if (!parentStack) {
25
+ return null;
26
+ }
27
+ return getSegmentId(parentStack);
28
+ }
29
+ function getParentSegmentId(labelStack) {
30
+ return getSegmentId(getParentStack(labelStack));
31
+ }
32
+
33
+ /**
34
+ * Whenever a render happen, all parent segment have timing reported
35
+ * This method tries to reduce that noise
36
+ */
37
+ function removeCascadingParentTimingReport(reactProfilerTimings) {
38
+ var timingIndex = new Map();
39
+ reactProfilerTimings.forEach(function (timing) {
40
+ var segmentId = getSegmentId(timing.labelStack);
41
+ if (segmentId) {
42
+ var _timingIndex$get;
43
+ var timingArray = (_timingIndex$get = timingIndex.get(segmentId)) !== null && _timingIndex$get !== void 0 ? _timingIndex$get : [];
44
+ timingIndex.set(segmentId, timingArray);
45
+ timingArray.push(timing);
46
+ }
47
+ });
48
+ reactProfilerTimings.forEach(function (timing) {
49
+ var parentSegmentId = getParentSegmentId(timing.labelStack);
50
+ if (parentSegmentId) {
51
+ var parentTimings = timingIndex.get(parentSegmentId);
52
+ var filteredParentTimings = parentTimings === null || parentTimings === void 0 ? void 0 : parentTimings.filter(function (parentTiming) {
53
+ if (parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration) {
54
+ return false;
55
+ }
56
+ return true;
57
+ });
58
+ if (filteredParentTimings) {
59
+ timingIndex.set(parentSegmentId, filteredParentTimings);
60
+ } else {
61
+ timingIndex.delete(parentSegmentId);
62
+ }
63
+ }
64
+ });
65
+ return _toConsumableArray(timingIndex.values()).flatMap(function (v) {
66
+ return v;
67
+ });
68
+ }
69
+ function transformReactProfilerTimings(reactProfilerTimings) {
70
+ var filtered = removeCascadingParentTimingReport(reactProfilerTimings !== null && reactProfilerTimings !== void 0 ? reactProfilerTimings : []);
71
+ var reactProfilerTimingsMap = filtered.reduce(function (result, _ref) {
72
+ var labelStack = _ref.labelStack,
73
+ startTime = _ref.startTime,
74
+ commitTime = _ref.commitTime,
75
+ actualDuration = _ref.actualDuration,
76
+ type = _ref.type;
77
+ if (labelStack && type !== 'nested-update') {
78
+ var label = labelStack.map(function (ls) {
79
+ return ls.name;
80
+ }).join('/');
81
+ var start = Math.round(startTime);
82
+ var end = Math.round(commitTime);
83
+ var timing = result.get(label) || {
84
+ labelStack: label,
85
+ startTime: start,
86
+ endTime: end,
87
+ mountCount: 0,
88
+ rerenderCount: 1,
89
+ renderDuration: 0
90
+ };
91
+ if (start < timing.startTime) {
92
+ timing.startTime = Math.round(start);
93
+ }
94
+ if (end > timing.endTime) {
95
+ timing.endTime = Math.round(end);
96
+ }
97
+ if (type === 'mount') {
98
+ timing.mountCount += 1;
99
+ }
100
+ if (type === 'update') {
101
+ timing.rerenderCount += 1;
102
+ }
103
+ timing.renderDuration += Math.round(actualDuration);
104
+ result.set(label, timing);
105
+ }
106
+ return result;
107
+ }, new Map());
108
+ return _toConsumableArray(reactProfilerTimingsMap.values());
109
+ }
110
+ export default function createPostInteractionLogPayload(_ref2) {
111
+ var _window$location;
112
+ var lastInteractionFinish = _ref2.lastInteractionFinish,
113
+ reactProfilerTimings = _ref2.reactProfilerTimings,
114
+ lastInteractionFinishVCResult = _ref2.lastInteractionFinishVCResult,
115
+ postInteractionFinishVCResult = _ref2.postInteractionFinishVCResult;
116
+ var config = getConfig();
117
+ if (!config) {
118
+ throw Error('UFO Configuration not provided');
119
+ }
120
+ var ufoName = sanitizeUfoName(lastInteractionFinish.ufoName);
121
+ var pageVisibilityState = getPageVisibilityState(lastInteractionFinish.start, lastInteractionFinish.end);
122
+ if (pageVisibilityState !== 'visible') {
123
+ return null;
124
+ }
125
+ var maxEndTimeFromProfiler = reactProfilerTimings ? Math.max.apply(Math, _toConsumableArray(reactProfilerTimings.map(function (t) {
126
+ return t.commitTime;
127
+ }))) : lastInteractionFinish.end;
128
+ var revisedEndTime = Math.round(maxEndTimeFromProfiler);
129
+ var revisedTtai = Math.round(maxEndTimeFromProfiler - lastInteractionFinish.start);
130
+ var lastInteractionFinishStart = Math.round(lastInteractionFinish.start);
131
+ var lastInteractionFinishEnd = Math.round(lastInteractionFinish.end);
132
+ var lastInteractionFinishTTAI = Math.round(lastInteractionFinish.end - lastInteractionFinish.start);
133
+ var lastInteractionFinishVC90 = null;
134
+ if (lastInteractionFinishVCResult !== null && lastInteractionFinishVCResult !== void 0 && lastInteractionFinishVCResult['ufo:vc:state']) {
135
+ var _lastInteractionFinis;
136
+ var lastInteractionFinishVCMetrics = lastInteractionFinishVCResult === null || lastInteractionFinishVCResult === void 0 ? void 0 : lastInteractionFinishVCResult['metrics:vc'];
137
+ lastInteractionFinishVC90 = (_lastInteractionFinis = lastInteractionFinishVCMetrics[90]) !== null && _lastInteractionFinis !== void 0 ? _lastInteractionFinis : null;
138
+ }
139
+ var postInteractionFinishVCRatios = {};
140
+ var revisedVC90 = null;
141
+ var postInteractionFinishVCUpdates = [];
142
+ if (postInteractionFinishVCResult !== null && postInteractionFinishVCResult !== void 0 && postInteractionFinishVCResult['ufo:vc:state']) {
143
+ postInteractionFinishVCRatios = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:ratios'];
144
+ postInteractionFinishVCUpdates = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:updates'];
145
+ var postInteractionFinishVCMetrics = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['metrics:vc'];
146
+ if (typeof lastInteractionFinishVC90 === 'number') {
147
+ var _postInteractionFinis;
148
+ revisedVC90 = (_postInteractionFinis = postInteractionFinishVCMetrics[90]) !== null && _postInteractionFinis !== void 0 ? _postInteractionFinis : null;
149
+ }
150
+ }
151
+ var lateMutations = postInteractionFinishVCUpdates.filter(function (entry) {
152
+ return entry.time > lastInteractionFinish.end;
153
+ }).flatMap(function (_ref3) {
154
+ var time = _ref3.time,
155
+ elements = _ref3.elements;
156
+ return Array.from(new Set(elements)).map(function (element) {
157
+ return {
158
+ time: time,
159
+ element: element,
160
+ viewportHeatmapPercentage: postInteractionFinishVCRatios[element]
161
+ };
162
+ });
163
+ });
164
+ return {
165
+ actionSubject: 'experience',
166
+ action: 'measured',
167
+ eventType: 'operational',
168
+ source: 'measured',
169
+ tags: ['observability'],
170
+ attributes: {
171
+ properties: {
172
+ // basic
173
+ 'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
174
+ 'event:product': config.product,
175
+ 'event:schema': '1.0.0',
176
+ 'event:source': {
177
+ name: 'react-ufo/web',
178
+ version: REACT_UFO_VERSION,
179
+ payloadSource: 'platform'
180
+ },
181
+ 'event:region': config.region || 'unknown',
182
+ 'experience:key': 'custom.post-interaction-logs',
183
+ postInteractionLog: {
184
+ lastInteractionFinish: _objectSpread(_objectSpread({}, lastInteractionFinish), {}, {
185
+ ufoName: ufoName,
186
+ start: lastInteractionFinishStart,
187
+ end: lastInteractionFinishEnd,
188
+ ttai: lastInteractionFinishTTAI,
189
+ vc90: lastInteractionFinishVC90
190
+ }),
191
+ revisedEndTime: revisedEndTime,
192
+ revisedTtai: revisedTtai,
193
+ revisedVC90: revisedVC90,
194
+ lateMutations: lateMutations,
195
+ reactProfilerTimings: transformReactProfilerTimings(reactProfilerTimings)
196
+ }
197
+ }
198
+ }
199
+ };
200
+ }
@@ -0,0 +1,23 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import UFOInteractionContext from '../interaction-context';
3
+ import { getInteractionId } from '../interaction-id-context';
4
+ import { addCustomData } from '../interaction-metrics';
5
+ export default function UFOCustomData(_ref) {
6
+ var data = _ref.data;
7
+ var interactionContext = useContext(UFOInteractionContext);
8
+ useMemo(function () {
9
+ if (!interactionContext) {
10
+ return;
11
+ }
12
+ interactionContext.addCustomData(data);
13
+ }, [data, interactionContext]);
14
+ return null;
15
+ }
16
+ export function addUFOCustomData(data) {
17
+ var interactionId = getInteractionId();
18
+ var currentInteractionId = interactionId.current;
19
+ if (!currentInteractionId) {
20
+ return;
21
+ }
22
+ addCustomData(currentInteractionId, [], data);
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import UFOInteractionContext from '../interaction-context';
3
+ import { getInteractionId } from '../interaction-id-context';
4
+ import { addMark } from '../interaction-metrics';
5
+ export default function UFOCustomMark(_ref) {
6
+ var name = _ref.name,
7
+ timestamp = _ref.timestamp;
8
+ var interactionContext = useContext(UFOInteractionContext);
9
+ useMemo(function () {
10
+ if (interactionContext != null) {
11
+ interactionContext.addMark(name, timestamp);
12
+ }
13
+ }, [interactionContext, name, timestamp]);
14
+ return null;
15
+ }
16
+ export function UFOCustomMarks(_ref2) {
17
+ var data = _ref2.data;
18
+ var interactionContext = useContext(UFOInteractionContext);
19
+ useMemo(function () {
20
+ if (interactionContext != null && data != null) {
21
+ Object.keys(data).forEach(function (i) {
22
+ interactionContext.addMark(i, data[i]);
23
+ });
24
+ }
25
+ }, [data, interactionContext]);
26
+ return null;
27
+ }
28
+ export function addUFOCustomMark(name, timestamp) {
29
+ var interactionId = getInteractionId();
30
+ var currentInteractionId = interactionId.current;
31
+ if (!currentInteractionId) {
32
+ return;
33
+ }
34
+ var time = timestamp || performance.now();
35
+ addMark(currentInteractionId, 'custom', name, [], time);
36
+ }
@@ -0,0 +1,8 @@
1
+ import { addSpanToAll } from '../interaction-metrics';
2
+ export function addCustomSpans(name, start) {
3
+ var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
4
+ var size = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
5
+ addSpanToAll('custom', name, [{
6
+ name: 'custom'
7
+ }], start, end, size);
8
+ }
@@ -0,0 +1,56 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import UFOInteractionContext from '../interaction-context';
3
+ import { getInteractionId } from '../interaction-id-context';
4
+ import { addCustomTiming, getCurrentInteractionType } from '../interaction-metrics';
5
+ export function getBm3Timings(marks, timingConfigs) {
6
+ var bm3Timings = {};
7
+ if (!marks || !timingConfigs) {
8
+ return bm3Timings;
9
+ }
10
+ timingConfigs.forEach(function (item) {
11
+ if (!item.startMark || !item.endMark) {
12
+ return;
13
+ }
14
+ var startTime = marks[item.startMark];
15
+ if (!startTime) {
16
+ return;
17
+ }
18
+ var endTime = marks[item.endMark];
19
+ if (!endTime) {
20
+ return;
21
+ }
22
+ bm3Timings[item.key] = {
23
+ startTime: startTime,
24
+ endTime: endTime
25
+ };
26
+ });
27
+ return bm3Timings;
28
+ }
29
+ export function UFOBM3TimingsToUFO(_ref) {
30
+ var marks = _ref.marks,
31
+ timings = _ref.timings;
32
+ var interactionContext = useContext(UFOInteractionContext);
33
+ var interactionId = getInteractionId().current;
34
+ useMemo(function () {
35
+ if (interactionContext != null && interactionId != null && marks != null && timings != null) {
36
+ var interactionType = getCurrentInteractionType(interactionId);
37
+ if (interactionType === 'press') {
38
+ return;
39
+ }
40
+ var bm3Timings = getBm3Timings(marks, timings);
41
+ interactionContext.addCustomTimings(bm3Timings);
42
+ }
43
+ }, [interactionContext, interactionId, marks, timings]);
44
+ return null;
45
+ }
46
+ export function addBM3TimingsToUFO(marks, timingsConfig) {
47
+ var interactionId = getInteractionId().current;
48
+ if (interactionId) {
49
+ var interactionType = getCurrentInteractionType(interactionId);
50
+ if (interactionType === 'press') {
51
+ return;
52
+ }
53
+ var bm3Timings = getBm3Timings(marks, timingsConfig);
54
+ addCustomTiming(interactionId, [], bm3Timings);
55
+ }
56
+ }
@@ -0,0 +1,34 @@
1
+ import { makeTraceHttpRequestHeaders } from './utils/make-trace-http-request-headers';
2
+ var state = {
3
+ context: null
4
+ };
5
+ export var generateSpanId = function generateSpanId() {
6
+ return Array.from(new Array(16), function () {
7
+ return Math.floor(Math.random() * 16).toString(16);
8
+ }).join('');
9
+ };
10
+ export var setInteractionActiveTrace = function setInteractionActiveTrace(interactionId, experienceType) {
11
+ setActiveTrace(interactionId.replace(/-/g, ''), generateSpanId(), experienceType);
12
+ };
13
+ export var setActiveTrace = function setActiveTrace(traceId, spanId, type) {
14
+ state.context = {
15
+ traceId: traceId,
16
+ spanId: spanId,
17
+ type: type
18
+ };
19
+ };
20
+ export var getActiveTrace = function getActiveTrace() {
21
+ return state.context || undefined;
22
+ };
23
+ export var clearActiveTrace = function clearActiveTrace() {
24
+ state.context = null;
25
+ };
26
+ export var getActiveTraceHttpRequestHeaders = function getActiveTraceHttpRequestHeaders(_url) {
27
+ if (state.context === null) {
28
+ return null;
29
+ }
30
+ var _state$context = state.context,
31
+ traceId = _state$context.traceId,
32
+ spanId = _state$context.spanId;
33
+ return makeTraceHttpRequestHeaders(traceId, spanId);
34
+ };
File without changes
@@ -0,0 +1,6 @@
1
+ export var makeTraceHttpRequestHeaders = function makeTraceHttpRequestHeaders(traceId, spanId) {
2
+ return {
3
+ 'X-B3-TraceId': traceId,
4
+ 'X-B3-SpanId': spanId
5
+ };
6
+ };
@@ -0,0 +1 @@
1
+ export var NON_BOOLEAN_VALUE = 'non_boolean';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import { NON_BOOLEAN_VALUE } from '../constants';
3
+ var startsAsObject = function startsAsObject(value) {
4
+ try {
5
+ if (value.charAt(0) === '{') {
6
+ return true;
7
+ }
8
+ } catch (e) {
9
+ return false;
10
+ }
11
+ return false;
12
+ };
13
+ var isObject = function isObject(value) {
14
+ return value && _typeof(value) === 'object' && value.constructor === Object;
15
+ };
16
+ var isString = function isString(input) {
17
+ var result;
18
+ try {
19
+ result = typeof input === 'string' || input instanceof String;
20
+ } catch (err) {
21
+ // swallow any errors
22
+ result = false;
23
+ }
24
+ return result;
25
+ };
26
+ export var shouldRedactValue = function shouldRedactValue(value) {
27
+ return isString(value) && startsAsObject(value) || isObject(value);
28
+ };
29
+ export var redactValue = function redactValue(featureFlagValue) {
30
+ return shouldRedactValue(featureFlagValue) ? NON_BOOLEAN_VALUE : featureFlagValue;
31
+ };
@@ -0,0 +1,21 @@
1
+ import { redactValue } from './common/utils';
2
+ export { redactValue } from './common/utils';
3
+ export var allFeatureFlagsAccessed = new Map();
4
+ export var currentFeatureFlagsAccessed = new Map();
5
+
6
+ /**
7
+ * Used for tracking accessed feature flags in "@atlassian/jira-feature-flagging".
8
+ * */
9
+ export var addFeatureFlagAccessed = function addFeatureFlagAccessed(featureFlagName, featureFlagValue) {
10
+ try {
11
+ // Inform Criterion about FF being accessed
12
+ if (globalThis.__CRITERION__ && typeof globalThis.__CRITERION__.addFeatureFlagAccessed === 'function') {
13
+ globalThis.__CRITERION__.addFeatureFlagAccessed(featureFlagName, featureFlagValue);
14
+ }
15
+ } catch (_e) {
16
+ // ignore the criterion error
17
+ }
18
+ var value = redactValue(featureFlagValue);
19
+ allFeatureFlagsAccessed.set(featureFlagName, value);
20
+ currentFeatureFlagsAccessed.set(featureFlagName, value);
21
+ };
@@ -0,0 +1,6 @@
1
+ var id = 0;
2
+
3
+ /** Get a new string id each time it's called */
4
+ export default function generateId() {
5
+ return String(id++);
6
+ }
@@ -0,0 +1,67 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import { bind } from 'bind-event-listener';
3
+ var shouldInitilizeGlobalErrorHandler = true;
4
+ var errors = [];
5
+ var push = function push(name, labelStack, errorType, errorMessage, errorStack) {
6
+ errors.push({
7
+ name: name,
8
+ labelStack: labelStack,
9
+ errorType: errorType,
10
+ errorMessage: errorMessage,
11
+ errorStack: errorStack
12
+ });
13
+ };
14
+ export var sinkErrorHandler = function sinkErrorHandler(sinkFunc) {
15
+ push = sinkFunc;
16
+ errors.forEach(function (e) {
17
+ sinkFunc(e.name, e.labelStack, e.errorType, e.errorMessage, e.errorStack);
18
+ });
19
+ errors.length = 0;
20
+ };
21
+ var handleError = function handleError(e) {
22
+ var _e$error;
23
+ if (((_e$error = e.error) === null || _e$error === void 0 ? void 0 : _e$error.UFOhasCaught) === undefined) {
24
+ try {
25
+ if (e.error instanceof Error) {
26
+ push('GlobalErrorHandler', null, e.error.name, e.error.message, e.error.stack);
27
+ } else if (e.error) {
28
+ var hint = JSON.stringify(e.error).slice(0, 50);
29
+ push('GlobalErrorHandler', null, '', "Non error object thrown: ".concat(hint), undefined);
30
+ } else if (e.message !== undefined) {
31
+ var _hint = e.message.slice(0, 50);
32
+ push('GlobalErrorHandler', null, '', "Non error object thrown: ".concat(_hint), undefined);
33
+ }
34
+ if (e.error && _typeof(e.error) === 'object') {
35
+ e.error.UFOhasCaught = true;
36
+ }
37
+ // eslint-disable-next-line no-empty
38
+ } catch (e) {}
39
+ }
40
+ };
41
+ var handlePromiseRejection = function handlePromiseRejection(e) {
42
+ if (e.reason instanceof Error) {
43
+ push('GlobalErrorHandler', null, e.reason.name, e.reason.message, e.reason.stack);
44
+ } else if (e.reason) {
45
+ try {
46
+ var hint = JSON.stringify(e.reason).slice(0, 50);
47
+ push('GlobalErrorHandler', null, '', "Non error object thrown: ".concat(hint), undefined);
48
+ // eslint-disable-next-line no-empty
49
+ } catch (e) {}
50
+ }
51
+ };
52
+ var setupUFOGlobalErrorHandler = function setupUFOGlobalErrorHandler() {
53
+ if (shouldInitilizeGlobalErrorHandler) {
54
+ bind(window, {
55
+ type: 'error',
56
+ listener: function listener(e) {
57
+ return handleError(e);
58
+ }
59
+ });
60
+ bind(window, {
61
+ type: 'unhandledrejection',
62
+ listener: handlePromiseRejection
63
+ });
64
+ shouldInitilizeGlobalErrorHandler = false;
65
+ }
66
+ };
67
+ export default setupUFOGlobalErrorHandler;
@@ -0,0 +1,87 @@
1
+ import { bind } from 'bind-event-listener';
2
+ var timings = [];
3
+ var wasHiddenFlag;
4
+ var setupFlag = false;
5
+ function isPageHidden() {
6
+ if ('visibilityState' in document) {
7
+ return document.visibilityState === 'hidden';
8
+ } else {
9
+ // @ts-expect-error - Property 'hidden' does not exist on type 'never'.
10
+ return document.hidden;
11
+ }
12
+ }
13
+ var SIZE = 50;
14
+ var insertIndex = 0;
15
+ function pushHidden(isPageHiddenFlag, time) {
16
+ timings[insertIndex] = {
17
+ time: time !== null && time !== void 0 ? time : performance.now(),
18
+ hidden: isPageHiddenFlag
19
+ };
20
+ insertIndex = (insertIndex + 1) % SIZE;
21
+ wasHiddenFlag = isPageHiddenFlag;
22
+ }
23
+ function handleChange() {
24
+ var isPageHiddenFlag = isPageHidden();
25
+ if (isPageHiddenFlag) {
26
+ if (!wasHiddenFlag) {
27
+ pushHidden(isPageHiddenFlag);
28
+ }
29
+ wasHiddenFlag = true;
30
+ } else {
31
+ if (wasHiddenFlag) {
32
+ pushHidden(isPageHiddenFlag);
33
+ }
34
+ wasHiddenFlag = false;
35
+ }
36
+ }
37
+ function setup() {
38
+ bind(window, {
39
+ type: 'pageshow',
40
+ listener: handleChange
41
+ });
42
+ bind(window, {
43
+ type: 'pagehide',
44
+ listener: handleChange
45
+ });
46
+ bind(document, {
47
+ type: 'visibilitychange',
48
+ listener: handleChange
49
+ });
50
+ }
51
+ export function setupHiddenTimingCapture() {
52
+ if (!setupFlag) {
53
+ var isPageHiddenFlag = isPageHidden();
54
+ pushHidden(isPageHiddenFlag, 0);
55
+ setup();
56
+ setupFlag = true;
57
+ }
58
+ }
59
+ export function getPageVisibilityState(start, end) {
60
+ // Desirable default value is visible
61
+ if (timings.length === 0) {
62
+ return 'visible';
63
+ }
64
+ var currentSize = timings.length;
65
+ var hiddenState = 'mixed';
66
+ var startIdx = insertIndex;
67
+ var endIdx = insertIndex;
68
+
69
+ // currentSize is capped at SIZE.
70
+ for (var i = 0; i < currentSize; i++) {
71
+ var tmpIdx = (insertIndex + i) % currentSize;
72
+ if (timings[tmpIdx].time <= end) {
73
+ endIdx = tmpIdx;
74
+ if (timings[tmpIdx].time <= start) {
75
+ startIdx = tmpIdx;
76
+ }
77
+ }
78
+ }
79
+ if (endIdx - startIdx === 0) {
80
+ if (timings[startIdx].hidden) {
81
+ hiddenState = 'hidden';
82
+ } else {
83
+ hiddenState = 'visible';
84
+ }
85
+ }
86
+ return hiddenState;
87
+ }
@@ -0,0 +1,42 @@
1
+ var timings = [];
2
+ export function addTimingFromPerformanceMark(name, startMark, stopMark) {
3
+ var cleanStart = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
4
+ var cleanStop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
5
+ timings.push({
6
+ name: name,
7
+ startMark: startMark,
8
+ stopMark: stopMark,
9
+ cleanStart: cleanStart,
10
+ cleanStop: cleanStop
11
+ });
12
+ }
13
+ export function getTimings() {
14
+ var reportedTimingsObj = {};
15
+ timings.forEach(function (_ref) {
16
+ var name = _ref.name,
17
+ startMark = _ref.startMark,
18
+ stopMark = _ref.stopMark,
19
+ cleanStart = _ref.cleanStart,
20
+ cleanStop = _ref.cleanStop;
21
+ var startEntryList = performance.getEntriesByName(startMark);
22
+ var stopEntryList = performance.getEntriesByName(stopMark);
23
+ if ((startEntryList === null || startEntryList === void 0 ? void 0 : startEntryList.length) > 0 && (stopEntryList === null || stopEntryList === void 0 ? void 0 : stopEntryList.length) > 0) {
24
+ var startEntry = startEntryList[startEntryList.length - 1];
25
+ var stopEntry = stopEntryList[stopEntryList.length - 1];
26
+ var startTime = startEntry.startTime;
27
+ var duration = stopEntry.startTime - startTime;
28
+ var timing = {
29
+ startTime: Math.round(startTime),
30
+ duration: Math.round(duration)
31
+ };
32
+ reportedTimingsObj[name] = timing;
33
+ }
34
+ if (cleanStart) {
35
+ performance.clearMarks(startMark);
36
+ }
37
+ if (cleanStop) {
38
+ performance.clearMarks(stopMark);
39
+ }
40
+ });
41
+ return reportedTimingsObj;
42
+ }
@@ -0,0 +1,6 @@
1
+ import { useContext } from 'react';
2
+ import InteractionContext from '@atlaskit/interaction-context';
3
+ export default InteractionContext;
4
+ export function useInteractionContext() {
5
+ return useContext(InteractionContext);
6
+ }
@@ -0,0 +1,22 @@
1
+ import { createContext } from 'react';
2
+
3
+ // Same structure as react's useRef.
4
+ // This allows modals to use a ref to scope their value
5
+ // const id = useRef(null);
6
+ // <InteractionIDContext.Provider value={id}>...<
7
+
8
+ // The default InteractionID object is a global singleton
9
+ // It's the one that holds the root value used in routing,
10
+ // and is overwritten when we have new interactions start.
11
+ export var DefaultInteractionID = {
12
+ current: null
13
+ };
14
+
15
+ // We use a context to allow modals to have their own lifecycle
16
+ export default /*#__PURE__*/createContext(DefaultInteractionID);
17
+ export var getInteractionId = function getInteractionId() {
18
+ return DefaultInteractionID;
19
+ };
20
+ export var useInteractionId = function useInteractionId() {
21
+ return DefaultInteractionID;
22
+ };
@@ -0,0 +1,2 @@
1
+ var interactions = new Map();
2
+ export default interactions;