@kubesense/kubesense-browser-rum-core 1.8.0 → 2.0.0-beta.1

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 (922) hide show
  1. package/LICENSE +1 -1
  2. package/cjs/boot/preStartRum.d.ts +4 -3
  3. package/cjs/boot/preStartRum.js +229 -204
  4. package/cjs/boot/preStartRum.js.map +1 -1
  5. package/cjs/boot/rumPublicApi.d.ts +190 -51
  6. package/cjs/boot/rumPublicApi.js +267 -164
  7. package/cjs/boot/rumPublicApi.js.map +1 -1
  8. package/cjs/boot/startRum.d.ts +42 -31
  9. package/cjs/boot/startRum.js +157 -150
  10. package/cjs/boot/startRum.js.map +1 -1
  11. package/cjs/browser/cookieObservable.d.ts +1 -5
  12. package/cjs/browser/cookieObservable.js +30 -34
  13. package/cjs/browser/cookieObservable.js.map +1 -1
  14. package/cjs/browser/domMutationObservable.d.ts +3 -3
  15. package/cjs/browser/domMutationObservable.js +29 -53
  16. package/cjs/browser/domMutationObservable.js.map +1 -1
  17. package/cjs/browser/htmlDomUtils.d.ts +5 -0
  18. package/cjs/browser/htmlDomUtils.js +38 -28
  19. package/cjs/browser/htmlDomUtils.js.map +1 -1
  20. package/cjs/browser/locationChangeObservable.d.ts +1 -2
  21. package/cjs/browser/locationChangeObservable.js +44 -45
  22. package/cjs/browser/locationChangeObservable.js.map +1 -1
  23. package/cjs/browser/performanceObservable.d.ts +4 -4
  24. package/cjs/browser/performanceObservable.js +50 -114
  25. package/cjs/browser/performanceObservable.js.map +1 -1
  26. package/cjs/browser/performanceUtils.d.ts +13 -1
  27. package/cjs/browser/performanceUtils.js +63 -37
  28. package/cjs/browser/performanceUtils.js.map +1 -1
  29. package/cjs/browser/scroll.js +17 -28
  30. package/cjs/browser/scroll.js.map +1 -1
  31. package/cjs/browser/viewportObservable.d.ts +2 -3
  32. package/cjs/browser/viewportObservable.js +29 -31
  33. package/cjs/browser/viewportObservable.js.map +1 -1
  34. package/cjs/browser/windowOpenObservable.js +11 -7
  35. package/cjs/browser/windowOpenObservable.js.map +1 -1
  36. package/cjs/domain/action/actionCollection.d.ts +11 -12
  37. package/cjs/domain/action/actionCollection.js +82 -89
  38. package/cjs/domain/action/actionCollection.js.map +1 -1
  39. package/cjs/domain/action/actionNameConstants.js +10 -9
  40. package/cjs/domain/action/actionNameConstants.js.map +1 -1
  41. package/cjs/domain/action/clickChain.js +51 -54
  42. package/cjs/domain/action/clickChain.js.map +1 -1
  43. package/cjs/domain/action/computeFrustration.js +30 -62
  44. package/cjs/domain/action/computeFrustration.js.map +1 -1
  45. package/cjs/domain/action/frustrationIgnore.d.ts +9 -0
  46. package/cjs/domain/action/frustrationIgnore.js +32 -0
  47. package/cjs/domain/action/frustrationIgnore.js.map +1 -0
  48. package/cjs/domain/action/getActionNameFromElement.js +141 -217
  49. package/cjs/domain/action/getActionNameFromElement.js.map +1 -1
  50. package/cjs/domain/action/interactionSelectorCache.d.ts +1 -1
  51. package/cjs/domain/action/interactionSelectorCache.js +17 -18
  52. package/cjs/domain/action/interactionSelectorCache.js.map +1 -1
  53. package/cjs/domain/action/isActionChildEvent.d.ts +2 -0
  54. package/cjs/domain/action/isActionChildEvent.js +8 -0
  55. package/cjs/domain/action/isActionChildEvent.js.map +1 -0
  56. package/cjs/domain/action/listenActionEvents.d.ts +2 -3
  57. package/cjs/domain/action/listenActionEvents.js +51 -55
  58. package/cjs/domain/action/listenActionEvents.js.map +1 -1
  59. package/cjs/domain/action/trackClickActions.d.ts +15 -21
  60. package/cjs/domain/action/trackClickActions.js +188 -226
  61. package/cjs/domain/action/trackClickActions.js.map +1 -1
  62. package/cjs/domain/action/trackManualActions.d.ts +45 -0
  63. package/cjs/domain/action/trackManualActions.js +48 -0
  64. package/cjs/domain/action/trackManualActions.js.map +1 -0
  65. package/cjs/domain/assembly.d.ts +1 -2
  66. package/cjs/domain/assembly.js +80 -95
  67. package/cjs/domain/assembly.js.map +1 -1
  68. package/cjs/domain/configuration/configuration.d.ts +575 -81
  69. package/cjs/domain/configuration/configuration.js +464 -199
  70. package/cjs/domain/configuration/configuration.js.map +1 -1
  71. package/cjs/domain/configuration/index.d.ts +1 -0
  72. package/cjs/domain/configuration/index.js +27 -21
  73. package/cjs/domain/configuration/jsonPathParser.js +125 -139
  74. package/cjs/domain/configuration/jsonPathParser.js.map +1 -1
  75. package/cjs/domain/configuration/remoteConfiguration.d.ts +18 -5
  76. package/cjs/domain/configuration/remoteConfiguration.js +268 -226
  77. package/cjs/domain/configuration/remoteConfiguration.js.map +1 -1
  78. package/cjs/domain/configuration/remoteConfiguration.types.d.ts +49 -0
  79. package/cjs/domain/configuration/remoteConfigurationCache.d.ts +42 -0
  80. package/cjs/domain/configuration/remoteConfigurationCache.js +95 -0
  81. package/cjs/domain/configuration/remoteConfigurationCache.js.map +1 -0
  82. package/cjs/domain/configuration/remoteSdkConfiguration.d.ts +11 -2
  83. package/cjs/domain/configuration/remoteSdkConfiguration.js +185 -117
  84. package/cjs/domain/configuration/remoteSdkConfiguration.js.map +1 -1
  85. package/cjs/domain/configuration/sessionReplayRoutes.d.ts +1 -6
  86. package/cjs/domain/configuration/sessionReplayRoutes.js +20 -63
  87. package/cjs/domain/configuration/sessionReplayRoutes.js.map +1 -1
  88. package/cjs/domain/contexts/ciVisibilityContext.d.ts +2 -4
  89. package/cjs/domain/contexts/ciVisibilityContext.js +36 -32
  90. package/cjs/domain/contexts/ciVisibilityContext.js.map +1 -1
  91. package/cjs/domain/contexts/connectivityContext.d.ts +2 -2
  92. package/cjs/domain/contexts/connectivityContext.js +10 -9
  93. package/cjs/domain/contexts/connectivityContext.js.map +1 -1
  94. package/cjs/domain/contexts/defaultContext.d.ts +3 -3
  95. package/cjs/domain/contexts/defaultContext.js +28 -32
  96. package/cjs/domain/contexts/defaultContext.js.map +1 -1
  97. package/cjs/domain/contexts/displayContext.d.ts +2 -3
  98. package/cjs/domain/contexts/displayContext.js +22 -26
  99. package/cjs/domain/contexts/displayContext.js.map +1 -1
  100. package/cjs/domain/contexts/featureFlagContext.d.ts +2 -2
  101. package/cjs/domain/contexts/featureFlagContext.js +38 -50
  102. package/cjs/domain/contexts/featureFlagContext.js.map +1 -1
  103. package/cjs/domain/contexts/internalContext.d.ts +2 -3
  104. package/cjs/domain/contexts/internalContext.js +26 -22
  105. package/cjs/domain/contexts/internalContext.js.map +1 -1
  106. package/cjs/domain/contexts/pageStateHistory.d.ts +3 -4
  107. package/cjs/domain/contexts/pageStateHistory.js +76 -96
  108. package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
  109. package/cjs/domain/contexts/sessionContext.d.ts +9 -3
  110. package/cjs/domain/contexts/sessionContext.js +31 -45
  111. package/cjs/domain/contexts/sessionContext.js.map +1 -1
  112. package/cjs/domain/contexts/sourceCodeMfeContext.d.ts +10 -0
  113. package/cjs/domain/contexts/sourceCodeMfeContext.js +35 -0
  114. package/cjs/domain/contexts/sourceCodeMfeContext.js.map +1 -0
  115. package/cjs/domain/contexts/syntheticsContext.d.ts +2 -2
  116. package/cjs/domain/contexts/syntheticsContext.js +19 -23
  117. package/cjs/domain/contexts/syntheticsContext.js.map +1 -1
  118. package/cjs/domain/contexts/trackingConsentContext.d.ts +2 -2
  119. package/cjs/domain/contexts/trackingConsentContext.js +10 -12
  120. package/cjs/domain/contexts/trackingConsentContext.js.map +1 -1
  121. package/cjs/domain/contexts/urlContexts.d.ts +4 -3
  122. package/cjs/domain/contexts/urlContexts.js +65 -61
  123. package/cjs/domain/contexts/urlContexts.js.map +1 -1
  124. package/cjs/domain/contexts/userAgentDataContext.d.ts +2 -2
  125. package/cjs/domain/contexts/userAgentDataContext.js +20 -29
  126. package/cjs/domain/contexts/userAgentDataContext.js.map +1 -1
  127. package/cjs/domain/contexts/viewHistory.d.ts +5 -2
  128. package/cjs/domain/contexts/viewHistory.js +41 -45
  129. package/cjs/domain/contexts/viewHistory.js.map +1 -1
  130. package/cjs/domain/discardNegativeDuration.d.ts +1 -1
  131. package/cjs/domain/discardNegativeDuration.js +6 -5
  132. package/cjs/domain/discardNegativeDuration.js.map +1 -1
  133. package/cjs/domain/error/errorCollection.d.ts +3 -3
  134. package/cjs/domain/error/errorCollection.js +67 -68
  135. package/cjs/domain/error/errorCollection.js.map +1 -1
  136. package/cjs/domain/error/trackReportError.d.ts +1 -2
  137. package/cjs/domain/error/trackReportError.js +10 -14
  138. package/cjs/domain/error/trackReportError.js.map +1 -1
  139. package/cjs/domain/event/eventCollection.d.ts +2 -1
  140. package/cjs/domain/event/eventCollection.js +21 -22
  141. package/cjs/domain/event/eventCollection.js.map +1 -1
  142. package/cjs/domain/eventTracker.d.ts +37 -0
  143. package/cjs/domain/eventTracker.js +94 -0
  144. package/cjs/domain/eventTracker.js.map +1 -0
  145. package/cjs/domain/extractRegexMatch.d.ts +5 -0
  146. package/cjs/domain/extractRegexMatch.js +16 -0
  147. package/cjs/domain/extractRegexMatch.js.map +1 -0
  148. package/cjs/domain/getComposedPathSelector.d.ts +22 -0
  149. package/cjs/domain/getComposedPathSelector.js +95 -0
  150. package/cjs/domain/getComposedPathSelector.js.map +1 -0
  151. package/cjs/domain/getSelectorFromElement.d.ts +18 -6
  152. package/cjs/domain/getSelectorFromElement.js +199 -191
  153. package/cjs/domain/getSelectorFromElement.js.map +1 -1
  154. package/cjs/domain/getSessionReplayUrl.d.ts +2 -2
  155. package/cjs/domain/getSessionReplayUrl.js +17 -30
  156. package/cjs/domain/getSessionReplayUrl.js.map +1 -1
  157. package/cjs/domain/hooks.d.ts +26 -17
  158. package/cjs/domain/hooks.js +12 -5
  159. package/cjs/domain/hooks.js.map +1 -1
  160. package/cjs/domain/lifeCycle.d.ts +26 -12
  161. package/cjs/domain/lifeCycle.js +28 -5
  162. package/cjs/domain/lifeCycle.js.map +1 -1
  163. package/cjs/domain/limitModification.d.ts +5 -1
  164. package/cjs/domain/limitModification.js +32 -36
  165. package/cjs/domain/limitModification.js.map +1 -1
  166. package/cjs/domain/longTask/longTaskCollection.d.ts +0 -13
  167. package/cjs/domain/longTask/longTaskCollection.js +75 -87
  168. package/cjs/domain/longTask/longTaskCollection.js.map +1 -1
  169. package/cjs/domain/plugins.d.ts +37 -14
  170. package/cjs/domain/plugins.js +22 -13
  171. package/cjs/domain/plugins.js.map +1 -1
  172. package/cjs/domain/privacy.d.ts +6 -1
  173. package/cjs/domain/privacy.js +143 -286
  174. package/cjs/domain/privacy.js.map +1 -1
  175. package/cjs/domain/privacyConstants.js +43 -34
  176. package/cjs/domain/privacyConstants.js.map +1 -1
  177. package/cjs/domain/requestCollection.d.ts +6 -5
  178. package/cjs/domain/requestCollection.js +82 -105
  179. package/cjs/domain/requestCollection.js.map +1 -1
  180. package/cjs/domain/resource/graphql.d.ts +1 -1
  181. package/cjs/domain/resource/graphql.js +85 -86
  182. package/cjs/domain/resource/graphql.js.map +1 -1
  183. package/cjs/domain/resource/requestRegistry.js +30 -38
  184. package/cjs/domain/resource/requestRegistry.js.map +1 -1
  185. package/cjs/domain/resource/resourceCollection.d.ts +5 -3
  186. package/cjs/domain/resource/resourceCollection.js +241 -175
  187. package/cjs/domain/resource/resourceCollection.js.map +1 -1
  188. package/cjs/domain/resource/resourceUtils.d.ts +13 -13
  189. package/cjs/domain/resource/resourceUtils.js +323 -221
  190. package/cjs/domain/resource/resourceUtils.js.map +1 -1
  191. package/cjs/domain/resource/trackManualResources.d.ts +55 -0
  192. package/cjs/domain/resource/trackManualResources.js +53 -0
  193. package/cjs/domain/resource/trackManualResources.js.map +1 -0
  194. package/cjs/domain/resource/webSocketCollection.d.ts +46 -0
  195. package/cjs/domain/resource/webSocketCollection.js +163 -0
  196. package/cjs/domain/resource/webSocketCollection.js.map +1 -0
  197. package/cjs/domain/session/session.types.d.ts +4 -0
  198. package/cjs/domain/sessionReplayState.d.ts +8 -0
  199. package/cjs/domain/sessionReplayState.js +19 -0
  200. package/cjs/domain/sessionReplayState.js.map +1 -0
  201. package/cjs/domain/startCustomerDataTelemetry.js +39 -43
  202. package/cjs/domain/startCustomerDataTelemetry.js.map +1 -1
  203. package/cjs/domain/tracing/getDocumentTraceId.d.ts +1 -1
  204. package/cjs/domain/tracing/getDocumentTraceId.js +42 -63
  205. package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -1
  206. package/cjs/domain/tracing/identifier.js +13 -46
  207. package/cjs/domain/tracing/identifier.js.map +1 -1
  208. package/cjs/domain/tracing/tracer.d.ts +2 -5
  209. package/cjs/domain/tracing/tracer.js +110 -150
  210. package/cjs/domain/tracing/tracer.js.map +1 -1
  211. package/cjs/domain/trackEventCounts.js +43 -48
  212. package/cjs/domain/trackEventCounts.js.map +1 -1
  213. package/cjs/domain/view/bfCacheSupport.d.ts +1 -2
  214. package/cjs/domain/view/bfCacheSupport.js +10 -11
  215. package/cjs/domain/view/bfCacheSupport.js.map +1 -1
  216. package/cjs/domain/view/trackViewEventCounts.js +14 -13
  217. package/cjs/domain/view/trackViewEventCounts.js.map +1 -1
  218. package/cjs/domain/view/trackViews.d.ts +8 -2
  219. package/cjs/domain/view/trackViews.js +221 -270
  220. package/cjs/domain/view/trackViews.js.map +1 -1
  221. package/cjs/domain/view/viewCollection.d.ts +4 -3
  222. package/cjs/domain/view/viewCollection.js +124 -148
  223. package/cjs/domain/view/viewCollection.js.map +1 -1
  224. package/cjs/domain/view/viewDiff.d.ts +22 -0
  225. package/cjs/domain/view/viewDiff.js +62 -0
  226. package/cjs/domain/view/viewDiff.js.map +1 -0
  227. package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.js +20 -22
  228. package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.js.map +1 -1
  229. package/cjs/domain/view/viewMetrics/interactionCountPolyfill.d.ts +1 -0
  230. package/cjs/domain/view/viewMetrics/interactionCountPolyfill.js +35 -33
  231. package/cjs/domain/view/viewMetrics/interactionCountPolyfill.js.map +1 -1
  232. package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.d.ts +1 -1
  233. package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.js +14 -13
  234. package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.js.map +1 -1
  235. package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.d.ts +4 -2
  236. package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.js +51 -34
  237. package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.js.map +1 -1
  238. package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.d.ts +1 -1
  239. package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.js +106 -122
  240. package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.js.map +1 -1
  241. package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.d.ts +2 -3
  242. package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.js +26 -34
  243. package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.js.map +1 -1
  244. package/cjs/domain/view/viewMetrics/trackFirstHidden.d.ts +2 -3
  245. package/cjs/domain/view/viewMetrics/trackFirstHidden.js +31 -31
  246. package/cjs/domain/view/viewMetrics/trackFirstHidden.js.map +1 -1
  247. package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.d.ts +1 -3
  248. package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.js +33 -38
  249. package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.js.map +1 -1
  250. package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.d.ts +10 -1
  251. package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.js +202 -144
  252. package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.js.map +1 -1
  253. package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.d.ts +6 -1
  254. package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.js +65 -55
  255. package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.js.map +1 -1
  256. package/cjs/domain/view/viewMetrics/trackLoadingTime.d.ts +2 -1
  257. package/cjs/domain/view/viewMetrics/trackLoadingTime.js +42 -46
  258. package/cjs/domain/view/viewMetrics/trackLoadingTime.js.map +1 -1
  259. package/cjs/domain/view/viewMetrics/trackNavigationTimings.d.ts +2 -3
  260. package/cjs/domain/view/viewMetrics/trackNavigationTimings.js +28 -36
  261. package/cjs/domain/view/viewMetrics/trackNavigationTimings.js.map +1 -1
  262. package/cjs/domain/view/viewMetrics/trackScrollMetrics.d.ts +3 -4
  263. package/cjs/domain/view/viewMetrics/trackScrollMetrics.js +63 -72
  264. package/cjs/domain/view/viewMetrics/trackScrollMetrics.js.map +1 -1
  265. package/cjs/domain/vital/vitalCollection.d.ts +44 -20
  266. package/cjs/domain/vital/vitalCollection.js +81 -109
  267. package/cjs/domain/vital/vitalCollection.js.map +1 -1
  268. package/cjs/domain/waitPageActivityEnd.d.ts +1 -4
  269. package/cjs/domain/waitPageActivityEnd.js +99 -119
  270. package/cjs/domain/waitPageActivityEnd.js.map +1 -1
  271. package/cjs/domainContext.types.d.ts +21 -13
  272. package/cjs/index.d.ts +11 -10
  273. package/cjs/index.js +84 -62
  274. package/cjs/rawRumEvent.types.d.ts +79 -13
  275. package/cjs/rawRumEvent.types.js +40 -27
  276. package/cjs/rawRumEvent.types.js.map +1 -1
  277. package/cjs/rumEvent.types.d.ts +906 -669
  278. package/cjs/transport/formDataTransport.js +43 -41
  279. package/cjs/transport/formDataTransport.js.map +1 -1
  280. package/cjs/transport/startRumBatch.d.ts +27 -3
  281. package/cjs/transport/startRumBatch.js +132 -31
  282. package/cjs/transport/startRumBatch.js.map +1 -1
  283. package/cjs/transport/startRumEventBridge.js +10 -8
  284. package/cjs/transport/startRumEventBridge.js.map +1 -1
  285. package/esm/boot/preStartRum.mjs +233 -0
  286. package/esm/boot/preStartRum.mjs.map +1 -0
  287. package/esm/boot/rumPublicApi.mjs +271 -0
  288. package/esm/boot/rumPublicApi.mjs.map +1 -0
  289. package/esm/boot/startRum.mjs +159 -0
  290. package/esm/boot/startRum.mjs.map +1 -0
  291. package/esm/browser/cookieObservable.mjs +34 -0
  292. package/esm/browser/cookieObservable.mjs.map +1 -0
  293. package/esm/browser/domMutationObservable.mjs +33 -0
  294. package/esm/browser/domMutationObservable.mjs.map +1 -0
  295. package/esm/browser/htmlDomUtils.mjs +48 -0
  296. package/esm/browser/htmlDomUtils.mjs.map +1 -0
  297. package/esm/browser/locationChangeObservable.mjs +50 -0
  298. package/esm/browser/locationChangeObservable.mjs.map +1 -0
  299. package/esm/browser/performanceObservable.mjs +60 -0
  300. package/esm/browser/performanceObservable.mjs.map +1 -0
  301. package/esm/browser/performanceUtils.mjs +64 -0
  302. package/esm/browser/performanceUtils.mjs.map +1 -0
  303. package/esm/browser/scroll.mjs +21 -0
  304. package/esm/browser/scroll.mjs.map +1 -0
  305. package/esm/browser/viewportObservable.mjs +33 -0
  306. package/esm/browser/viewportObservable.mjs.map +1 -0
  307. package/esm/browser/windowOpenObservable.mjs +14 -0
  308. package/esm/browser/windowOpenObservable.mjs.map +1 -0
  309. package/esm/domain/action/actionCollection.mjs +89 -0
  310. package/esm/domain/action/actionCollection.mjs.map +1 -0
  311. package/esm/domain/action/actionNameConstants.mjs +11 -0
  312. package/esm/domain/action/actionNameConstants.mjs.map +1 -0
  313. package/esm/domain/action/clickChain.mjs +57 -0
  314. package/esm/domain/action/clickChain.mjs.map +1 -0
  315. package/esm/domain/action/computeFrustration.mjs +36 -0
  316. package/esm/domain/action/computeFrustration.mjs.map +1 -0
  317. package/esm/domain/action/frustrationIgnore.mjs +31 -0
  318. package/esm/domain/action/frustrationIgnore.mjs.map +1 -0
  319. package/esm/domain/action/getActionNameFromElement.mjs +163 -0
  320. package/esm/domain/action/getActionNameFromElement.mjs.map +1 -0
  321. package/esm/domain/action/interactionSelectorCache.mjs +19 -0
  322. package/esm/domain/action/interactionSelectorCache.mjs.map +1 -0
  323. package/esm/domain/action/isActionChildEvent.mjs +8 -0
  324. package/esm/domain/action/isActionChildEvent.mjs.map +1 -0
  325. package/esm/domain/action/listenActionEvents.mjs +57 -0
  326. package/esm/domain/action/listenActionEvents.mjs.map +1 -0
  327. package/esm/domain/action/trackClickActions.mjs +198 -0
  328. package/esm/domain/action/trackClickActions.mjs.map +1 -0
  329. package/esm/domain/action/trackManualActions.mjs +48 -0
  330. package/esm/domain/action/trackManualActions.mjs.map +1 -0
  331. package/esm/domain/assembly.mjs +87 -0
  332. package/esm/domain/assembly.mjs.map +1 -0
  333. package/esm/domain/configuration/configuration.mjs +474 -0
  334. package/esm/domain/configuration/configuration.mjs.map +1 -0
  335. package/esm/domain/configuration/index.mjs +6 -0
  336. package/esm/domain/configuration/jsonPathParser.mjs +145 -0
  337. package/esm/domain/configuration/jsonPathParser.mjs.map +1 -0
  338. package/esm/domain/configuration/remoteConfiguration.mjs +279 -0
  339. package/esm/domain/configuration/remoteConfiguration.mjs.map +1 -0
  340. package/esm/domain/configuration/remoteConfigurationCache.mjs +92 -0
  341. package/esm/domain/configuration/remoteConfigurationCache.mjs.map +1 -0
  342. package/esm/domain/configuration/remoteSdkConfiguration.mjs +208 -0
  343. package/esm/domain/configuration/remoteSdkConfiguration.mjs.map +1 -0
  344. package/esm/domain/configuration/sessionReplayRoutes.mjs +26 -0
  345. package/esm/domain/configuration/sessionReplayRoutes.mjs.map +1 -0
  346. package/esm/domain/contexts/ciVisibilityContext.mjs +37 -0
  347. package/esm/domain/contexts/ciVisibilityContext.mjs.map +1 -0
  348. package/esm/domain/contexts/connectivityContext.mjs +12 -0
  349. package/esm/domain/contexts/connectivityContext.mjs.map +1 -0
  350. package/esm/domain/contexts/defaultContext.mjs +30 -0
  351. package/esm/domain/contexts/defaultContext.mjs.map +1 -0
  352. package/esm/domain/contexts/displayContext.mjs +24 -0
  353. package/esm/domain/contexts/displayContext.mjs.map +1 -0
  354. package/esm/domain/contexts/featureFlagContext.mjs +40 -0
  355. package/esm/domain/contexts/featureFlagContext.mjs.map +1 -0
  356. package/esm/domain/contexts/internalContext.mjs +30 -0
  357. package/esm/domain/contexts/internalContext.mjs.map +1 -0
  358. package/esm/domain/contexts/pageStateHistory.mjs +82 -0
  359. package/esm/domain/contexts/pageStateHistory.mjs.map +1 -0
  360. package/esm/domain/contexts/sessionContext.mjs +33 -0
  361. package/esm/domain/contexts/sessionContext.mjs.map +1 -0
  362. package/esm/domain/contexts/sourceCodeMfeContext.mjs +35 -0
  363. package/esm/domain/contexts/sourceCodeMfeContext.mjs.map +1 -0
  364. package/esm/domain/contexts/syntheticsContext.mjs +21 -0
  365. package/esm/domain/contexts/syntheticsContext.mjs.map +1 -0
  366. package/esm/domain/contexts/trackingConsentContext.mjs +12 -0
  367. package/esm/domain/contexts/trackingConsentContext.mjs.map +1 -0
  368. package/esm/domain/contexts/urlContexts.mjs +67 -0
  369. package/esm/domain/contexts/urlContexts.mjs.map +1 -0
  370. package/esm/domain/contexts/userAgentDataContext.mjs +22 -0
  371. package/esm/domain/contexts/userAgentDataContext.mjs.map +1 -0
  372. package/esm/domain/contexts/viewHistory.mjs +43 -0
  373. package/esm/domain/contexts/viewHistory.mjs.map +1 -0
  374. package/esm/domain/discardNegativeDuration.mjs +9 -0
  375. package/esm/domain/discardNegativeDuration.mjs.map +1 -0
  376. package/esm/domain/error/errorCollection.mjs +72 -0
  377. package/esm/domain/error/errorCollection.mjs.map +1 -0
  378. package/esm/domain/error/trackReportError.mjs +12 -0
  379. package/esm/domain/error/trackReportError.mjs.map +1 -0
  380. package/esm/domain/event/eventCollection.mjs +26 -0
  381. package/esm/domain/event/eventCollection.mjs.map +1 -0
  382. package/esm/domain/eventTracker.mjs +93 -0
  383. package/esm/domain/eventTracker.mjs.map +1 -0
  384. package/esm/domain/extractRegexMatch.mjs +16 -0
  385. package/esm/domain/extractRegexMatch.mjs.map +1 -0
  386. package/esm/domain/getComposedPathSelector.mjs +93 -0
  387. package/esm/domain/getComposedPathSelector.mjs.map +1 -0
  388. package/esm/domain/getSelectorFromElement.mjs +218 -0
  389. package/esm/domain/getSelectorFromElement.mjs.map +1 -0
  390. package/esm/domain/getSessionReplayUrl.mjs +20 -0
  391. package/esm/domain/getSessionReplayUrl.mjs.map +1 -0
  392. package/esm/domain/hooks.mjs +13 -0
  393. package/esm/domain/hooks.mjs.map +1 -0
  394. package/esm/domain/lifeCycle.mjs +28 -0
  395. package/esm/domain/lifeCycle.mjs.map +1 -0
  396. package/esm/domain/limitModification.mjs +42 -0
  397. package/esm/domain/limitModification.mjs.map +1 -0
  398. package/esm/domain/longTask/longTaskCollection.mjs +79 -0
  399. package/esm/domain/longTask/longTaskCollection.mjs.map +1 -0
  400. package/esm/domain/plugins.mjs +23 -0
  401. package/esm/domain/plugins.mjs.map +1 -0
  402. package/esm/domain/privacy.mjs +161 -0
  403. package/esm/domain/privacy.mjs.map +1 -0
  404. package/esm/domain/privacyConstants.mjs +36 -0
  405. package/esm/domain/privacyConstants.mjs.map +1 -0
  406. package/esm/domain/requestCollection.mjs +86 -0
  407. package/esm/domain/requestCollection.mjs.map +1 -0
  408. package/esm/domain/resource/graphql.mjs +93 -0
  409. package/esm/domain/resource/graphql.mjs.map +1 -0
  410. package/esm/domain/resource/requestRegistry.mjs +32 -0
  411. package/esm/domain/resource/requestRegistry.mjs.map +1 -0
  412. package/esm/domain/resource/resourceCollection.mjs +256 -0
  413. package/esm/domain/resource/resourceCollection.mjs.map +1 -0
  414. package/esm/domain/resource/resourceUtils.mjs +349 -0
  415. package/esm/domain/resource/resourceUtils.mjs.map +1 -0
  416. package/esm/domain/resource/trackManualResources.mjs +53 -0
  417. package/esm/domain/resource/trackManualResources.mjs.map +1 -0
  418. package/esm/domain/resource/webSocketCollection.mjs +160 -0
  419. package/esm/domain/resource/webSocketCollection.mjs.map +1 -0
  420. package/esm/domain/sessionReplayState.mjs +18 -0
  421. package/esm/domain/sessionReplayState.mjs.map +1 -0
  422. package/esm/domain/startCustomerDataTelemetry.mjs +51 -0
  423. package/esm/domain/startCustomerDataTelemetry.mjs.map +1 -0
  424. package/esm/domain/tracing/getDocumentTraceId.mjs +50 -0
  425. package/esm/domain/tracing/getDocumentTraceId.mjs.map +1 -0
  426. package/esm/domain/tracing/identifier.mjs +20 -0
  427. package/esm/domain/tracing/identifier.mjs.map +1 -0
  428. package/esm/domain/tracing/tracer.mjs +120 -0
  429. package/esm/domain/tracing/tracer.mjs.map +1 -0
  430. package/esm/domain/trackEventCounts.mjs +45 -0
  431. package/esm/domain/trackEventCounts.mjs.map +1 -0
  432. package/esm/domain/view/bfCacheSupport.mjs +12 -0
  433. package/esm/domain/view/bfCacheSupport.mjs.map +1 -0
  434. package/esm/domain/view/trackViewEventCounts.mjs +17 -0
  435. package/esm/domain/view/trackViewEventCounts.mjs.map +1 -0
  436. package/esm/domain/view/trackViews.mjs +230 -0
  437. package/esm/domain/view/trackViews.mjs.map +1 -0
  438. package/esm/domain/view/viewCollection.mjs +129 -0
  439. package/esm/domain/view/viewCollection.mjs.map +1 -0
  440. package/esm/domain/view/viewDiff.mjs +61 -0
  441. package/esm/domain/view/viewDiff.mjs.map +1 -0
  442. package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.mjs +30 -0
  443. package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.mjs.map +1 -0
  444. package/esm/domain/view/viewMetrics/interactionCountPolyfill.mjs +45 -0
  445. package/esm/domain/view/viewMetrics/interactionCountPolyfill.mjs.map +1 -0
  446. package/esm/domain/view/viewMetrics/trackBfcacheMetrics.mjs +18 -0
  447. package/esm/domain/view/viewMetrics/trackBfcacheMetrics.mjs.map +1 -0
  448. package/esm/domain/view/viewMetrics/trackCommonViewMetrics.mjs +54 -0
  449. package/esm/domain/view/viewMetrics/trackCommonViewMetrics.mjs.map +1 -0
  450. package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.mjs +117 -0
  451. package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.mjs.map +1 -0
  452. package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.mjs +29 -0
  453. package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.mjs.map +1 -0
  454. package/esm/domain/view/viewMetrics/trackFirstHidden.mjs +33 -0
  455. package/esm/domain/view/viewMetrics/trackFirstHidden.mjs.map +1 -0
  456. package/esm/domain/view/viewMetrics/trackInitialViewMetrics.mjs +36 -0
  457. package/esm/domain/view/viewMetrics/trackInitialViewMetrics.mjs.map +1 -0
  458. package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.mjs +210 -0
  459. package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.mjs.map +1 -0
  460. package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.mjs +70 -0
  461. package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.mjs.map +1 -0
  462. package/esm/domain/view/viewMetrics/trackLoadingTime.mjs +46 -0
  463. package/esm/domain/view/viewMetrics/trackLoadingTime.mjs.map +1 -0
  464. package/esm/domain/view/viewMetrics/trackNavigationTimings.mjs +35 -0
  465. package/esm/domain/view/viewMetrics/trackNavigationTimings.mjs.map +1 -0
  466. package/esm/domain/view/viewMetrics/trackScrollMetrics.mjs +66 -0
  467. package/esm/domain/view/viewMetrics/trackScrollMetrics.mjs.map +1 -0
  468. package/esm/domain/vital/vitalCollection.mjs +85 -0
  469. package/esm/domain/vital/vitalCollection.mjs.map +1 -0
  470. package/esm/domain/waitPageActivityEnd.mjs +107 -0
  471. package/esm/domain/waitPageActivityEnd.mjs.map +1 -0
  472. package/esm/index.mjs +23 -0
  473. package/esm/rawRumEvent.types.mjs +42 -0
  474. package/esm/rawRumEvent.types.mjs.map +1 -0
  475. package/esm/transport/formDataTransport.mjs +48 -0
  476. package/esm/transport/formDataTransport.mjs.map +1 -0
  477. package/esm/transport/startRumBatch.mjs +132 -0
  478. package/esm/transport/startRumBatch.mjs.map +1 -0
  479. package/esm/transport/startRumEventBridge.mjs +13 -0
  480. package/esm/transport/startRumEventBridge.mjs.map +1 -0
  481. package/package.json +19 -11
  482. package/src/boot/preStartRum.ts +216 -88
  483. package/src/boot/rumPublicApi.ts +358 -119
  484. package/src/boot/startRum.ts +88 -84
  485. package/src/browser/cookieObservable.ts +19 -28
  486. package/src/browser/domMutationObservable.ts +7 -12
  487. package/src/browser/htmlDomUtils.ts +15 -0
  488. package/src/browser/locationChangeObservable.ts +23 -12
  489. package/src/browser/performanceObservable.ts +23 -73
  490. package/src/browser/performanceUtils.ts +52 -4
  491. package/src/browser/viewportObservable.ts +4 -6
  492. package/src/domain/action/actionCollection.ts +94 -87
  493. package/src/domain/action/clickChain.ts +11 -10
  494. package/src/domain/action/computeFrustration.ts +19 -5
  495. package/src/domain/action/frustrationIgnore.ts +54 -0
  496. package/src/domain/action/getActionNameFromElement.ts +27 -61
  497. package/src/domain/action/interactionSelectorCache.ts +2 -2
  498. package/src/domain/action/isActionChildEvent.ts +6 -0
  499. package/src/domain/action/listenActionEvents.ts +2 -11
  500. package/src/domain/action/trackClickActions.ts +92 -82
  501. package/src/domain/action/trackManualActions.ts +104 -0
  502. package/src/domain/assembly.ts +57 -70
  503. package/src/domain/configuration/configuration.ts +587 -208
  504. package/src/domain/configuration/index.ts +1 -0
  505. package/src/domain/configuration/remoteConfiguration.ts +152 -29
  506. package/src/domain/configuration/remoteConfiguration.types.ts +51 -1
  507. package/src/domain/configuration/remoteConfigurationCache.ts +153 -0
  508. package/src/domain/configuration/remoteSdkConfiguration.ts +131 -13
  509. package/src/domain/configuration/sessionReplayRoutes.ts +2 -47
  510. package/src/domain/contexts/ciVisibilityContext.ts +23 -12
  511. package/src/domain/contexts/connectivityContext.ts +7 -10
  512. package/src/domain/contexts/defaultContext.ts +11 -14
  513. package/src/domain/contexts/displayContext.ts +8 -12
  514. package/src/domain/contexts/featureFlagContext.ts +5 -4
  515. package/src/domain/contexts/internalContext.ts +3 -3
  516. package/src/domain/contexts/pageStateHistory.ts +20 -31
  517. package/src/domain/contexts/sessionContext.ts +16 -22
  518. package/src/domain/contexts/sourceCodeMfeContext.ts +53 -0
  519. package/src/domain/contexts/syntheticsContext.ts +7 -17
  520. package/src/domain/contexts/trackingConsentContext.ts +7 -4
  521. package/src/domain/contexts/urlContexts.ts +13 -9
  522. package/src/domain/contexts/userAgentDataContext.ts +12 -13
  523. package/src/domain/contexts/viewHistory.ts +4 -3
  524. package/src/domain/discardNegativeDuration.ts +1 -1
  525. package/src/domain/error/errorCollection.ts +12 -22
  526. package/src/domain/error/trackReportError.ts +4 -7
  527. package/src/domain/event/eventCollection.ts +4 -2
  528. package/src/domain/eventTracker.ts +169 -0
  529. package/src/domain/extractRegexMatch.ts +15 -0
  530. package/src/domain/getComposedPathSelector.ts +130 -0
  531. package/src/domain/getSelectorFromElement.ts +125 -31
  532. package/src/domain/getSessionReplayUrl.ts +4 -13
  533. package/src/domain/hooks.ts +34 -21
  534. package/src/domain/lifeCycle.ts +21 -8
  535. package/src/domain/limitModification.ts +20 -4
  536. package/src/domain/longTask/longTaskCollection.ts +18 -47
  537. package/src/domain/plugins.ts +54 -25
  538. package/src/domain/privacy.ts +16 -24
  539. package/src/domain/requestCollection.ts +108 -97
  540. package/src/domain/resource/graphql.ts +71 -25
  541. package/src/domain/resource/requestRegistry.ts +1 -3
  542. package/src/domain/resource/resourceCollection.ts +319 -137
  543. package/src/domain/resource/resourceUtils.ts +24 -26
  544. package/src/domain/resource/trackManualResources.ts +121 -0
  545. package/src/domain/resource/webSocketCollection.ts +281 -0
  546. package/src/domain/session/session.types.ts +5 -0
  547. package/src/domain/sessionReplayState.ts +36 -0
  548. package/src/domain/startCustomerDataTelemetry.ts +2 -2
  549. package/src/domain/tracing/getDocumentTraceId.ts +5 -4
  550. package/src/domain/tracing/identifier.ts +6 -37
  551. package/src/domain/tracing/tracer.ts +22 -21
  552. package/src/domain/tracing/tracer.types.ts +3 -3
  553. package/src/domain/view/bfCacheSupport.ts +1 -6
  554. package/src/domain/view/trackViews.ts +40 -37
  555. package/src/domain/view/viewCollection.ts +29 -23
  556. package/src/domain/view/viewDiff.ts +115 -0
  557. package/src/domain/view/viewMetrics/interactionCountPolyfill.ts +13 -2
  558. package/src/domain/view/viewMetrics/trackBfcacheMetrics.ts +1 -1
  559. package/src/domain/view/viewMetrics/trackCommonViewMetrics.ts +27 -6
  560. package/src/domain/view/viewMetrics/trackCumulativeLayoutShift.ts +5 -3
  561. package/src/domain/view/viewMetrics/trackFirstContentfulPaint.ts +4 -9
  562. package/src/domain/view/viewMetrics/trackFirstHidden.ts +2 -8
  563. package/src/domain/view/viewMetrics/trackInitialViewMetrics.ts +4 -13
  564. package/src/domain/view/viewMetrics/trackInteractionToNextPaint.ts +180 -35
  565. package/src/domain/view/viewMetrics/trackLargestContentfulPaint.ts +47 -6
  566. package/src/domain/view/viewMetrics/trackLoadingTime.ts +4 -3
  567. package/src/domain/view/viewMetrics/trackNavigationTimings.ts +10 -18
  568. package/src/domain/view/viewMetrics/trackScrollMetrics.ts +23 -37
  569. package/src/domain/vital/vitalCollection.ts +83 -102
  570. package/src/domain/waitPageActivityEnd.ts +7 -11
  571. package/src/domainContext.types.ts +23 -15
  572. package/src/index.ts +17 -11
  573. package/src/rawRumEvent.types.ts +80 -26
  574. package/src/rumEvent.types.ts +730 -505
  575. package/src/transport/formDataTransport.ts +16 -6
  576. package/src/transport/startRumBatch.ts +181 -24
  577. package/cjs/browser/firstInputPolyfill.d.ts +0 -8
  578. package/cjs/browser/firstInputPolyfill.js +0 -68
  579. package/cjs/browser/firstInputPolyfill.js.map +0 -1
  580. package/cjs/domain/configuration/index.js.map +0 -1
  581. package/cjs/domain/configuration/remoteConfiguration.types.js +0 -7
  582. package/cjs/domain/configuration/remoteConfiguration.types.js.map +0 -1
  583. package/cjs/domain/error/trackConsoleError.d.ts +0 -4
  584. package/cjs/domain/error/trackConsoleError.js +0 -13
  585. package/cjs/domain/error/trackConsoleError.js.map +0 -1
  586. package/cjs/domain/resource/matchRequestResourceEntry.d.ts +0 -16
  587. package/cjs/domain/resource/matchRequestResourceEntry.js +0 -49
  588. package/cjs/domain/resource/matchRequestResourceEntry.js.map +0 -1
  589. package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.d.ts +0 -4
  590. package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.js +0 -24
  591. package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.js.map +0 -1
  592. package/cjs/domain/rumSessionManager.d.ts +0 -36
  593. package/cjs/domain/rumSessionManager.js +0 -77
  594. package/cjs/domain/rumSessionManager.js.map +0 -1
  595. package/cjs/domain/sampler/sampler.d.ts +0 -10
  596. package/cjs/domain/sampler/sampler.js +0 -63
  597. package/cjs/domain/sampler/sampler.js.map +0 -1
  598. package/cjs/domain/tracing/sampler.d.ts +0 -10
  599. package/cjs/domain/tracing/sampler.js +0 -69
  600. package/cjs/domain/tracing/sampler.js.map +0 -1
  601. package/cjs/domain/tracing/tracer.types.js +0 -3
  602. package/cjs/domain/tracing/tracer.types.js.map +0 -1
  603. package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.d.ts +0 -6
  604. package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js +0 -44
  605. package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js.map +0 -1
  606. package/cjs/domain/view/viewMetrics/trackFirstInput.d.ts +0 -19
  607. package/cjs/domain/view/viewMetrics/trackFirstInput.js +0 -43
  608. package/cjs/domain/view/viewMetrics/trackFirstInput.js.map +0 -1
  609. package/cjs/domainContext.types.js +0 -6
  610. package/cjs/domainContext.types.js.map +0 -1
  611. package/cjs/index.js.map +0 -1
  612. package/cjs/rumEvent.types.js +0 -7
  613. package/cjs/rumEvent.types.js.map +0 -1
  614. package/esm/boot/preStartRum.d.ts +0 -7
  615. package/esm/boot/preStartRum.js +0 -205
  616. package/esm/boot/preStartRum.js.map +0 -1
  617. package/esm/boot/rumPublicApi.d.ts +0 -409
  618. package/esm/boot/rumPublicApi.js +0 -165
  619. package/esm/boot/rumPublicApi.js.map +0 -1
  620. package/esm/boot/startRum.d.ts +0 -109
  621. package/esm/boot/startRum.js +0 -149
  622. package/esm/boot/startRum.js.map +0 -1
  623. package/esm/browser/cookieObservable.d.ts +0 -8
  624. package/esm/browser/cookieObservable.js +0 -35
  625. package/esm/browser/cookieObservable.js.map +0 -1
  626. package/esm/browser/domMutationObservable.d.ts +0 -27
  627. package/esm/browser/domMutationObservable.js +0 -54
  628. package/esm/browser/domMutationObservable.js.map +0 -1
  629. package/esm/browser/firstInputPolyfill.d.ts +0 -8
  630. package/esm/browser/firstInputPolyfill.js +0 -65
  631. package/esm/browser/firstInputPolyfill.js.map +0 -1
  632. package/esm/browser/htmlDomUtils.d.ts +0 -13
  633. package/esm/browser/htmlDomUtils.js +0 -36
  634. package/esm/browser/htmlDomUtils.js.map +0 -1
  635. package/esm/browser/locationChangeObservable.d.ts +0 -7
  636. package/esm/browser/locationChangeObservable.js +0 -48
  637. package/esm/browser/locationChangeObservable.js.map +0 -1
  638. package/esm/browser/performanceObservable.d.ts +0 -174
  639. package/esm/browser/performanceObservable.js +0 -121
  640. package/esm/browser/performanceObservable.js.map +0 -1
  641. package/esm/browser/performanceUtils.d.ts +0 -7
  642. package/esm/browser/performanceUtils.js +0 -38
  643. package/esm/browser/performanceUtils.js.map +0 -1
  644. package/esm/browser/scroll.d.ts +0 -2
  645. package/esm/browser/scroll.js +0 -29
  646. package/esm/browser/scroll.js.map +0 -1
  647. package/esm/browser/viewportObservable.d.ts +0 -10
  648. package/esm/browser/viewportObservable.js +0 -32
  649. package/esm/browser/viewportObservable.js.map +0 -1
  650. package/esm/browser/windowOpenObservable.d.ts +0 -5
  651. package/esm/browser/windowOpenObservable.js +0 -7
  652. package/esm/browser/windowOpenObservable.js.map +0 -1
  653. package/esm/domain/action/actionCollection.d.ts +0 -21
  654. package/esm/domain/action/actionCollection.js +0 -93
  655. package/esm/domain/action/actionCollection.js.map +0 -1
  656. package/esm/domain/action/actionNameConstants.d.ts +0 -18
  657. package/esm/domain/action/actionNameConstants.js +0 -8
  658. package/esm/domain/action/actionNameConstants.js.map +0 -1
  659. package/esm/domain/action/clickChain.d.ts +0 -8
  660. package/esm/domain/action/clickChain.js +0 -57
  661. package/esm/domain/action/clickChain.js.map +0 -1
  662. package/esm/domain/action/computeFrustration.d.ts +0 -6
  663. package/esm/domain/action/computeFrustration.js +0 -65
  664. package/esm/domain/action/computeFrustration.js.map +0 -1
  665. package/esm/domain/action/getActionNameFromElement.d.ts +0 -4
  666. package/esm/domain/action/getActionNameFromElement.js +0 -236
  667. package/esm/domain/action/getActionNameFromElement.js.map +0 -1
  668. package/esm/domain/action/interactionSelectorCache.d.ts +0 -5
  669. package/esm/domain/action/interactionSelectorCache.js +0 -18
  670. package/esm/domain/action/interactionSelectorCache.js.map +0 -1
  671. package/esm/domain/action/listenActionEvents.d.ts +0 -19
  672. package/esm/domain/action/listenActionEvents.js +0 -58
  673. package/esm/domain/action/listenActionEvents.js.map +0 -1
  674. package/esm/domain/action/trackClickActions.d.ts +0 -81
  675. package/esm/domain/action/trackClickActions.js +0 -232
  676. package/esm/domain/action/trackClickActions.js.map +0 -1
  677. package/esm/domain/assembly.d.ts +0 -5
  678. package/esm/domain/assembly.js +0 -99
  679. package/esm/domain/assembly.js.map +0 -1
  680. package/esm/domain/configuration/configuration.d.ts +0 -358
  681. package/esm/domain/configuration/configuration.js +0 -209
  682. package/esm/domain/configuration/configuration.js.map +0 -1
  683. package/esm/domain/configuration/index.d.ts +0 -4
  684. package/esm/domain/configuration/index.js +0 -5
  685. package/esm/domain/configuration/index.js.map +0 -1
  686. package/esm/domain/configuration/jsonPathParser.d.ts +0 -28
  687. package/esm/domain/configuration/jsonPathParser.js +0 -156
  688. package/esm/domain/configuration/jsonPathParser.js.map +0 -1
  689. package/esm/domain/configuration/remoteConfiguration.d.ts +0 -39
  690. package/esm/domain/configuration/remoteConfiguration.js +0 -236
  691. package/esm/domain/configuration/remoteConfiguration.js.map +0 -1
  692. package/esm/domain/configuration/remoteConfiguration.types.d.ts +0 -138
  693. package/esm/domain/configuration/remoteConfiguration.types.js +0 -6
  694. package/esm/domain/configuration/remoteConfiguration.types.js.map +0 -1
  695. package/esm/domain/configuration/remoteSdkConfiguration.d.ts +0 -18
  696. package/esm/domain/configuration/remoteSdkConfiguration.js +0 -137
  697. package/esm/domain/configuration/remoteSdkConfiguration.js.map +0 -1
  698. package/esm/domain/configuration/sessionReplayRoutes.d.ts +0 -35
  699. package/esm/domain/configuration/sessionReplayRoutes.js +0 -65
  700. package/esm/domain/configuration/sessionReplayRoutes.js.map +0 -1
  701. package/esm/domain/contexts/ciVisibilityContext.d.ts +0 -12
  702. package/esm/domain/contexts/ciVisibilityContext.js +0 -30
  703. package/esm/domain/contexts/ciVisibilityContext.js.map +0 -1
  704. package/esm/domain/contexts/connectivityContext.d.ts +0 -2
  705. package/esm/domain/contexts/connectivityContext.js +0 -8
  706. package/esm/domain/contexts/connectivityContext.js.map +0 -1
  707. package/esm/domain/contexts/defaultContext.d.ts +0 -4
  708. package/esm/domain/contexts/defaultContext.js +0 -31
  709. package/esm/domain/contexts/defaultContext.js.map +0 -1
  710. package/esm/domain/contexts/displayContext.d.ts +0 -6
  711. package/esm/domain/contexts/displayContext.js +0 -25
  712. package/esm/domain/contexts/displayContext.js.map +0 -1
  713. package/esm/domain/contexts/featureFlagContext.d.ts +0 -19
  714. package/esm/domain/contexts/featureFlagContext.js +0 -49
  715. package/esm/domain/contexts/featureFlagContext.js.map +0 -1
  716. package/esm/domain/contexts/internalContext.d.ts +0 -12
  717. package/esm/domain/contexts/internalContext.js +0 -23
  718. package/esm/domain/contexts/internalContext.js.map +0 -1
  719. package/esm/domain/contexts/pageStateHistory.d.ts +0 -23
  720. package/esm/domain/contexts/pageStateHistory.js +0 -100
  721. package/esm/domain/contexts/pageStateHistory.js.map +0 -1
  722. package/esm/domain/contexts/sessionContext.d.ts +0 -5
  723. package/esm/domain/contexts/sessionContext.js +0 -44
  724. package/esm/domain/contexts/sessionContext.js.map +0 -1
  725. package/esm/domain/contexts/syntheticsContext.d.ts +0 -2
  726. package/esm/domain/contexts/syntheticsContext.js +0 -22
  727. package/esm/domain/contexts/syntheticsContext.js.map +0 -1
  728. package/esm/domain/contexts/trackingConsentContext.d.ts +0 -3
  729. package/esm/domain/contexts/trackingConsentContext.js +0 -11
  730. package/esm/domain/contexts/trackingConsentContext.js.map +0 -1
  731. package/esm/domain/contexts/urlContexts.d.ts +0 -22
  732. package/esm/domain/contexts/urlContexts.js +0 -60
  733. package/esm/domain/contexts/urlContexts.js.map +0 -1
  734. package/esm/domain/contexts/userAgentDataContext.d.ts +0 -2
  735. package/esm/domain/contexts/userAgentDataContext.js +0 -28
  736. package/esm/domain/contexts/userAgentDataContext.js.map +0 -1
  737. package/esm/domain/contexts/viewHistory.d.ts +0 -17
  738. package/esm/domain/contexts/viewHistory.js +0 -44
  739. package/esm/domain/contexts/viewHistory.js.map +0 -1
  740. package/esm/domain/discardNegativeDuration.d.ts +0 -2
  741. package/esm/domain/discardNegativeDuration.js +0 -5
  742. package/esm/domain/discardNegativeDuration.js.map +0 -1
  743. package/esm/domain/error/errorCollection.d.ts +0 -17
  744. package/esm/domain/error/errorCollection.js +0 -70
  745. package/esm/domain/error/errorCollection.js.map +0 -1
  746. package/esm/domain/error/trackConsoleError.d.ts +0 -4
  747. package/esm/domain/error/trackConsoleError.js +0 -10
  748. package/esm/domain/error/trackConsoleError.js.map +0 -1
  749. package/esm/domain/error/trackReportError.d.ts +0 -5
  750. package/esm/domain/error/trackReportError.js +0 -13
  751. package/esm/domain/error/trackReportError.js.map +0 -1
  752. package/esm/domain/event/eventCollection.d.ts +0 -10
  753. package/esm/domain/event/eventCollection.js +0 -24
  754. package/esm/domain/event/eventCollection.js.map +0 -1
  755. package/esm/domain/getSelectorFromElement.d.ts +0 -64
  756. package/esm/domain/getSelectorFromElement.js +0 -213
  757. package/esm/domain/getSelectorFromElement.js.map +0 -1
  758. package/esm/domain/getSessionReplayUrl.d.ts +0 -9
  759. package/esm/domain/getSessionReplayUrl.js +0 -30
  760. package/esm/domain/getSessionReplayUrl.js.map +0 -1
  761. package/esm/domain/hooks.d.ts +0 -23
  762. package/esm/domain/hooks.js +0 -3
  763. package/esm/domain/hooks.js.map +0 -1
  764. package/esm/domain/lifeCycle.d.ts +0 -73
  765. package/esm/domain/lifeCycle.js +0 -3
  766. package/esm/domain/lifeCycle.js.map +0 -1
  767. package/esm/domain/limitModification.d.ts +0 -8
  768. package/esm/domain/limitModification.js +0 -43
  769. package/esm/domain/limitModification.js.map +0 -1
  770. package/esm/domain/longTask/longTaskCollection.d.ts +0 -18
  771. package/esm/domain/longTask/longTaskCollection.js +0 -87
  772. package/esm/domain/longTask/longTaskCollection.js.map +0 -1
  773. package/esm/domain/plugins.d.ts +0 -40
  774. package/esm/domain/plugins.js +0 -12
  775. package/esm/domain/plugins.js.map +0 -1
  776. package/esm/domain/privacy.d.ts +0 -44
  777. package/esm/domain/privacy.js +0 -302
  778. package/esm/domain/privacy.js.map +0 -1
  779. package/esm/domain/privacyConstants.d.ts +0 -23
  780. package/esm/domain/privacyConstants.js +0 -35
  781. package/esm/domain/privacyConstants.js.map +0 -1
  782. package/esm/domain/requestCollection.d.ts +0 -54
  783. package/esm/domain/requestCollection.js +0 -106
  784. package/esm/domain/requestCollection.js.map +0 -1
  785. package/esm/domain/resource/graphql.d.ts +0 -23
  786. package/esm/domain/resource/graphql.js +0 -91
  787. package/esm/domain/resource/graphql.js.map +0 -1
  788. package/esm/domain/resource/matchRequestResourceEntry.d.ts +0 -16
  789. package/esm/domain/resource/matchRequestResourceEntry.js +0 -46
  790. package/esm/domain/resource/matchRequestResourceEntry.js.map +0 -1
  791. package/esm/domain/resource/requestRegistry.d.ts +0 -9
  792. package/esm/domain/resource/requestRegistry.js +0 -37
  793. package/esm/domain/resource/requestRegistry.js.map +0 -1
  794. package/esm/domain/resource/resourceCollection.d.ts +0 -7
  795. package/esm/domain/resource/resourceCollection.js +0 -187
  796. package/esm/domain/resource/resourceCollection.js.map +0 -1
  797. package/esm/domain/resource/resourceUtils.d.ts +0 -55
  798. package/esm/domain/resource/resourceUtils.js +0 -244
  799. package/esm/domain/resource/resourceUtils.js.map +0 -1
  800. package/esm/domain/resource/retrieveInitialDocumentResourceTiming.d.ts +0 -4
  801. package/esm/domain/resource/retrieveInitialDocumentResourceTiming.js +0 -21
  802. package/esm/domain/resource/retrieveInitialDocumentResourceTiming.js.map +0 -1
  803. package/esm/domain/rumSessionManager.d.ts +0 -36
  804. package/esm/domain/rumSessionManager.js +0 -72
  805. package/esm/domain/rumSessionManager.js.map +0 -1
  806. package/esm/domain/sampler/sampler.d.ts +0 -10
  807. package/esm/domain/sampler/sampler.js +0 -58
  808. package/esm/domain/sampler/sampler.js.map +0 -1
  809. package/esm/domain/startCustomerDataTelemetry.d.ts +0 -4
  810. package/esm/domain/startCustomerDataTelemetry.js +0 -52
  811. package/esm/domain/startCustomerDataTelemetry.js.map +0 -1
  812. package/esm/domain/tracing/getDocumentTraceId.d.ts +0 -12
  813. package/esm/domain/tracing/getDocumentTraceId.js +0 -68
  814. package/esm/domain/tracing/getDocumentTraceId.js.map +0 -1
  815. package/esm/domain/tracing/identifier.d.ts +0 -13
  816. package/esm/domain/tracing/identifier.js +0 -50
  817. package/esm/domain/tracing/identifier.js.map +0 -1
  818. package/esm/domain/tracing/sampler.d.ts +0 -10
  819. package/esm/domain/tracing/sampler.js +0 -64
  820. package/esm/domain/tracing/sampler.js.map +0 -1
  821. package/esm/domain/tracing/tracer.d.ts +0 -30
  822. package/esm/domain/tracing/tracer.js +0 -156
  823. package/esm/domain/tracing/tracer.js.map +0 -1
  824. package/esm/domain/tracing/tracer.types.d.ts +0 -12
  825. package/esm/domain/tracing/tracer.types.js +0 -2
  826. package/esm/domain/tracing/tracer.types.js.map +0 -1
  827. package/esm/domain/trackEventCounts.d.ts +0 -17
  828. package/esm/domain/trackEventCounts.js +0 -47
  829. package/esm/domain/trackEventCounts.js.map +0 -1
  830. package/esm/domain/view/bfCacheSupport.d.ts +0 -2
  831. package/esm/domain/view/bfCacheSupport.js +0 -10
  832. package/esm/domain/view/bfCacheSupport.js.map +0 -1
  833. package/esm/domain/view/trackViewEventCounts.d.ts +0 -5
  834. package/esm/domain/view/trackViewEventCounts.js +0 -13
  835. package/esm/domain/view/trackViewEventCounts.js.map +0 -1
  836. package/esm/domain/view/trackViews.d.ts +0 -65
  837. package/esm/domain/view/trackViews.js +0 -278
  838. package/esm/domain/view/trackViews.js.map +0 -1
  839. package/esm/domain/view/viewCollection.d.ts +0 -18
  840. package/esm/domain/view/viewCollection.js +0 -150
  841. package/esm/domain/view/viewCollection.js.map +0 -1
  842. package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.d.ts +0 -6
  843. package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.js +0 -28
  844. package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.js.map +0 -1
  845. package/esm/domain/view/viewMetrics/interactionCountPolyfill.d.ts +0 -18
  846. package/esm/domain/view/viewMetrics/interactionCountPolyfill.js +0 -39
  847. package/esm/domain/view/viewMetrics/interactionCountPolyfill.js.map +0 -1
  848. package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.d.ts +0 -6
  849. package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js +0 -41
  850. package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js.map +0 -1
  851. package/esm/domain/view/viewMetrics/trackBfcacheMetrics.d.ts +0 -8
  852. package/esm/domain/view/viewMetrics/trackBfcacheMetrics.js +0 -14
  853. package/esm/domain/view/viewMetrics/trackBfcacheMetrics.js.map +0 -1
  854. package/esm/domain/view/viewMetrics/trackCommonViewMetrics.d.ts +0 -21
  855. package/esm/domain/view/viewMetrics/trackCommonViewMetrics.js +0 -34
  856. package/esm/domain/view/viewMetrics/trackCommonViewMetrics.js.map +0 -1
  857. package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.d.ts +0 -37
  858. package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.js +0 -130
  859. package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.js.map +0 -1
  860. package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.d.ts +0 -13
  861. package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.js +0 -34
  862. package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.js.map +0 -1
  863. package/esm/domain/view/viewMetrics/trackFirstHidden.d.ts +0 -10
  864. package/esm/domain/view/viewMetrics/trackFirstHidden.js +0 -30
  865. package/esm/domain/view/viewMetrics/trackFirstHidden.js.map +0 -1
  866. package/esm/domain/view/viewMetrics/trackFirstInput.d.ts +0 -19
  867. package/esm/domain/view/viewMetrics/trackFirstInput.js +0 -40
  868. package/esm/domain/view/viewMetrics/trackFirstInput.js.map +0 -1
  869. package/esm/domain/view/viewMetrics/trackInitialViewMetrics.d.ts +0 -15
  870. package/esm/domain/view/viewMetrics/trackInitialViewMetrics.js +0 -38
  871. package/esm/domain/view/viewMetrics/trackInitialViewMetrics.js.map +0 -1
  872. package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.d.ts +0 -25
  873. package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.js +0 -149
  874. package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.js.map +0 -1
  875. package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.d.ts +0 -18
  876. package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.js +0 -57
  877. package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.js.map +0 -1
  878. package/esm/domain/view/viewMetrics/trackLoadingTime.d.ts +0 -14
  879. package/esm/domain/view/viewMetrics/trackLoadingTime.js +0 -47
  880. package/esm/domain/view/viewMetrics/trackLoadingTime.js.map +0 -1
  881. package/esm/domain/view/viewMetrics/trackNavigationTimings.d.ts +0 -14
  882. package/esm/domain/view/viewMetrics/trackNavigationTimings.js +0 -40
  883. package/esm/domain/view/viewMetrics/trackNavigationTimings.js.map +0 -1
  884. package/esm/domain/view/viewMetrics/trackScrollMetrics.d.ts +0 -25
  885. package/esm/domain/view/viewMetrics/trackScrollMetrics.js +0 -72
  886. package/esm/domain/view/viewMetrics/trackScrollMetrics.js.map +0 -1
  887. package/esm/domain/vital/vitalCollection.d.ts +0 -55
  888. package/esm/domain/vital/vitalCollection.js +0 -107
  889. package/esm/domain/vital/vitalCollection.js.map +0 -1
  890. package/esm/domain/waitPageActivityEnd.d.ts +0 -54
  891. package/esm/domain/waitPageActivityEnd.js +0 -123
  892. package/esm/domain/waitPageActivityEnd.js.map +0 -1
  893. package/esm/domainContext.types.d.ts +0 -39
  894. package/esm/domainContext.types.js +0 -5
  895. package/esm/domainContext.types.js.map +0 -1
  896. package/esm/index.d.ts +0 -42
  897. package/esm/index.js +0 -22
  898. package/esm/index.js.map +0 -1
  899. package/esm/rawRumEvent.types.d.ts +0 -326
  900. package/esm/rawRumEvent.types.js +0 -31
  901. package/esm/rawRumEvent.types.js.map +0 -1
  902. package/esm/rumEvent.types.d.ts +0 -2038
  903. package/esm/rumEvent.types.js +0 -6
  904. package/esm/rumEvent.types.js.map +0 -1
  905. package/esm/transport/formDataTransport.d.ts +0 -16
  906. package/esm/transport/formDataTransport.js +0 -43
  907. package/esm/transport/formDataTransport.js.map +0 -1
  908. package/esm/transport/startRumBatch.d.ts +0 -5
  909. package/esm/transport/startRumBatch.js +0 -30
  910. package/esm/transport/startRumBatch.js.map +0 -1
  911. package/esm/transport/startRumEventBridge.d.ts +0 -2
  912. package/esm/transport/startRumEventBridge.js +0 -8
  913. package/esm/transport/startRumEventBridge.js.map +0 -1
  914. package/src/browser/firstInputPolyfill.ts +0 -87
  915. package/src/domain/error/trackConsoleError.ts +0 -14
  916. package/src/domain/resource/matchRequestResourceEntry.ts +0 -68
  917. package/src/domain/resource/retrieveInitialDocumentResourceTiming.ts +0 -27
  918. package/src/domain/rumSessionManager.ts +0 -134
  919. package/src/domain/sampler/sampler.ts +0 -63
  920. package/src/domain/tracing/sampler.ts +0 -69
  921. package/src/domain/view/viewMetrics/startInitialViewMetricsTelemetry.ts +0 -70
  922. package/src/domain/view/viewMetrics/trackFirstInput.ts +0 -59
@@ -0,0 +1,145 @@
1
+ //#region src/domain/configuration/jsonPathParser.ts
2
+ /**
3
+ * Extract selectors from a simple JSON path expression, return [] for an invalid path
4
+ *
5
+ * Supports:
6
+ * - Dot notation: `foo.bar.baz`
7
+ * - Bracket notation: `['foo']["bar"]`
8
+ * - Array indices: `items[0]`, `data['users'][1]`
9
+ *
10
+ * Examples:
11
+ * parseJsonPath("['foo'].bar[12]")
12
+ * => ['foo', 'bar', '12']
13
+ *
14
+ * parseJsonPath("['foo")
15
+ * => []
16
+ */
17
+ function parseJsonPath(path) {
18
+ const selectors = [];
19
+ let previousToken = 0;
20
+ let currentToken;
21
+ const parsingContext = {
22
+ quote: void 0,
23
+ escapeSequence: void 0
24
+ };
25
+ let currentSelector = "";
26
+ for (const char of path) {
27
+ currentToken = ALLOWED_NEXT_TOKENS[previousToken].find((token) => TOKEN_PREDICATE[token](char, parsingContext));
28
+ if (!currentToken) return [];
29
+ if (parsingContext.escapeSequence !== void 0 && currentToken !== 12) {
30
+ if (!isValidEscapeSequence(parsingContext.escapeSequence)) return [];
31
+ currentSelector += resolveEscapeSequence(parsingContext.escapeSequence);
32
+ parsingContext.escapeSequence = void 0;
33
+ }
34
+ if (ALLOWED_SELECTOR_TOKENS.includes(currentToken)) currentSelector += char;
35
+ else if (ALLOWED_SELECTOR_DELIMITER_TOKENS.includes(currentToken) && currentSelector !== "") {
36
+ selectors.push(currentSelector);
37
+ currentSelector = "";
38
+ } else if (currentToken === 12) parsingContext.escapeSequence = parsingContext.escapeSequence ? `${parsingContext.escapeSequence}${char}` : char;
39
+ else if (currentToken === 8) parsingContext.quote = char;
40
+ else if (currentToken === 9) parsingContext.quote = void 0;
41
+ previousToken = currentToken;
42
+ }
43
+ if (!ALLOWED_NEXT_TOKENS[previousToken].includes(1)) return [];
44
+ if (currentSelector !== "") selectors.push(currentSelector);
45
+ return selectors;
46
+ }
47
+ const NAME_SHORTHAND_FIRST_CHAR_REGEX = /[a-zA-Z_$]/;
48
+ const NAME_SHORTHAND_CHAR_REGEX = /[a-zA-Z0-9_$]/;
49
+ const DIGIT_REGEX = /[0-9]/;
50
+ const UNICODE_CHAR_REGEX = /[a-fA-F0-9]/;
51
+ const QUOTE_CHARS = "'\"";
52
+ const TOKEN_PREDICATE = {
53
+ [0]: () => false,
54
+ [1]: () => false,
55
+ [2]: (char) => NAME_SHORTHAND_FIRST_CHAR_REGEX.test(char),
56
+ [3]: (char) => NAME_SHORTHAND_CHAR_REGEX.test(char),
57
+ [4]: (char) => char === ".",
58
+ [5]: (char) => char === "[",
59
+ [6]: (char) => char === "]",
60
+ [7]: (char) => DIGIT_REGEX.test(char),
61
+ [8]: (char) => QUOTE_CHARS.includes(char),
62
+ [9]: (char, parsingContext) => char === parsingContext.quote,
63
+ [10]: () => true,
64
+ [11]: (char) => char === "\\",
65
+ [12]: (char, parsingContext) => {
66
+ if (parsingContext.escapeSequence === void 0) return `${parsingContext.quote}/\\bfnrtu`.includes(char);
67
+ else if (parsingContext.escapeSequence.startsWith("u") && parsingContext.escapeSequence.length < 5) return UNICODE_CHAR_REGEX.test(char);
68
+ return false;
69
+ }
70
+ };
71
+ const ALLOWED_NEXT_TOKENS = {
72
+ [0]: [2, 5],
73
+ [1]: [],
74
+ [2]: [
75
+ 3,
76
+ 4,
77
+ 5,
78
+ 1
79
+ ],
80
+ [3]: [
81
+ 3,
82
+ 4,
83
+ 5,
84
+ 1
85
+ ],
86
+ [4]: [2],
87
+ [5]: [8, 7],
88
+ [6]: [
89
+ 4,
90
+ 5,
91
+ 1
92
+ ],
93
+ [7]: [7, 6],
94
+ [8]: [
95
+ 11,
96
+ 9,
97
+ 10
98
+ ],
99
+ [9]: [6],
100
+ [10]: [
101
+ 11,
102
+ 9,
103
+ 10
104
+ ],
105
+ [11]: [12],
106
+ [12]: [
107
+ 12,
108
+ 11,
109
+ 9,
110
+ 10
111
+ ]
112
+ };
113
+ const ALLOWED_SELECTOR_TOKENS = [
114
+ 2,
115
+ 3,
116
+ 7,
117
+ 10
118
+ ];
119
+ const ALLOWED_SELECTOR_DELIMITER_TOKENS = [
120
+ 4,
121
+ 5,
122
+ 6
123
+ ];
124
+ function isValidEscapeSequence(escapeSequence) {
125
+ return "\"'/\\bfnrt".includes(escapeSequence) || escapeSequence.startsWith("u") && escapeSequence.length === 5;
126
+ }
127
+ const ESCAPED_CHARS = {
128
+ "\"": "\"",
129
+ "'": "'",
130
+ "/": "/",
131
+ "\\": "\\",
132
+ b: "\b",
133
+ f: "\f",
134
+ n: "\n",
135
+ r: "\r",
136
+ t: " "
137
+ };
138
+ function resolveEscapeSequence(escapeSequence) {
139
+ if (escapeSequence.startsWith("u")) return String.fromCharCode(parseInt(escapeSequence.slice(1), 16));
140
+ return ESCAPED_CHARS[escapeSequence];
141
+ }
142
+ //#endregion
143
+ export { parseJsonPath };
144
+
145
+ //# sourceMappingURL=jsonPathParser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonPathParser.mjs","names":[],"sources":["../../../src/domain/configuration/jsonPathParser.ts"],"sourcesContent":["/**\n * Terminology inspired from https://www.rfc-editor.org/rfc/rfc9535.html\n *\n * jsonpath-query = segment*\n * segment = .name-shorthand / bracketed-selection\n * bracketed-selection = ['name-selector'] / [\"name-selector\"] / [index-selector]\n *\n * Useful references:\n * - https://goessner.net/articles/JsonPath/\n * - https://jsonpath.com/\n * - https://github.com/jsonpath-standard\n */\n\ninterface ParsingContext {\n quote: string | undefined\n escapeSequence: string | undefined\n}\n\n/**\n * Extract selectors from a simple JSON path expression, return [] for an invalid path\n *\n * Supports:\n * - Dot notation: `foo.bar.baz`\n * - Bracket notation: `['foo'][\"bar\"]`\n * - Array indices: `items[0]`, `data['users'][1]`\n *\n * Examples:\n * parseJsonPath(\"['foo'].bar[12]\")\n * => ['foo', 'bar', '12']\n *\n * parseJsonPath(\"['foo\")\n * => []\n */\nexport function parseJsonPath(path: string): string[] {\n const selectors: string[] = []\n let previousToken = Token.START\n let currentToken: Token | undefined\n const parsingContext: ParsingContext = { quote: undefined, escapeSequence: undefined }\n let currentSelector = ''\n for (const char of path) {\n // find which kind of token is this char\n currentToken = ALLOWED_NEXT_TOKENS[previousToken].find((token) => TOKEN_PREDICATE[token](char, parsingContext))\n if (!currentToken) {\n return []\n }\n if (parsingContext.escapeSequence !== undefined && currentToken !== Token.ESCAPE_SEQUENCE_CHAR) {\n if (!isValidEscapeSequence(parsingContext.escapeSequence)) {\n return []\n }\n currentSelector += resolveEscapeSequence(parsingContext.escapeSequence)\n parsingContext.escapeSequence = undefined\n }\n if (ALLOWED_SELECTOR_TOKENS.includes(currentToken)) {\n // buffer the char if it belongs to the selector\n // ex: foo['bar']\n // ^ ^\n currentSelector += char\n } else if (ALLOWED_SELECTOR_DELIMITER_TOKENS.includes(currentToken) && currentSelector !== '') {\n // close the current path part if we have reach a path part delimiter\n // ex: foo.bar['qux']\n // ^ ^ ^\n selectors.push(currentSelector)\n currentSelector = ''\n } else if (currentToken === Token.ESCAPE_SEQUENCE_CHAR) {\n parsingContext.escapeSequence = parsingContext.escapeSequence ? `${parsingContext.escapeSequence}${char}` : char\n } else if (currentToken === Token.QUOTE_START) {\n parsingContext.quote = char\n } else if (currentToken === Token.QUOTE_END) {\n parsingContext.quote = undefined\n }\n previousToken = currentToken\n }\n if (!ALLOWED_NEXT_TOKENS[previousToken].includes(Token.END)) {\n return []\n }\n if (currentSelector !== '') {\n selectors.push(currentSelector)\n }\n return selectors\n}\n\n/**\n * List of all tokens in the path\n *\n * @example foo.bar['qu\\'x'][0]\n * | | | | |\n * Token sequence: | | | | |\n * 1. START (before first char) <-+ | | | |\n * 2. NAME_SHORTHAND_FIRST_CHAR: f | | | |\n * 3. NAME_SHORTHAND_CHAR: oo | | | |\n * 4. DOT: . <------------------------+ | | |\n * 5. NAME_SHORTHAND_FIRST_CHAR: b | | |\n * 6. NAME_SHORTHAND_CHAR: ar | | |\n * 7. BRACKET_START: [ <------------------+ | |\n * 8. QUOTE_START: ' | |\n * 9. NAME_SELECTOR_CHAR: qu | |\n * 10. ESCAPE: \\ | |\n * 11. ESCAPABLE_CHAR: ' | |\n * 12. NAME_SELECTOR_CHAR: x | |\n * 13. QUOTE_END: ' | |\n * 14. BRACKET_END: ] | |\n * 15. BRACKET_START: [ <--------------------------+ |\n * 16. DIGIT: 0 |\n * 17. BRACKET_END: ] |\n * 18. END (after last char) <------------------------+\n */\nconst enum Token {\n START,\n END,\n\n NAME_SHORTHAND_FIRST_CHAR,\n NAME_SHORTHAND_CHAR,\n DOT,\n\n BRACKET_START,\n BRACKET_END,\n DIGIT,\n\n QUOTE_START,\n QUOTE_END,\n NAME_SELECTOR_CHAR,\n ESCAPE,\n ESCAPE_SEQUENCE_CHAR,\n}\n\nconst NAME_SHORTHAND_FIRST_CHAR_REGEX = /[a-zA-Z_$]/\nconst NAME_SHORTHAND_CHAR_REGEX = /[a-zA-Z0-9_$]/\nconst DIGIT_REGEX = /[0-9]/\nconst UNICODE_CHAR_REGEX = /[a-fA-F0-9]/\nconst QUOTE_CHARS = '\\'\"'\n\nconst TOKEN_PREDICATE: { [token in Token]: (char: string, parsingContext: ParsingContext) => boolean } = {\n // no char should match to START or END\n [Token.START]: () => false,\n [Token.END]: () => false,\n\n [Token.NAME_SHORTHAND_FIRST_CHAR]: (char) => NAME_SHORTHAND_FIRST_CHAR_REGEX.test(char),\n [Token.NAME_SHORTHAND_CHAR]: (char) => NAME_SHORTHAND_CHAR_REGEX.test(char),\n [Token.DOT]: (char) => char === '.',\n\n [Token.BRACKET_START]: (char) => char === '[',\n [Token.BRACKET_END]: (char) => char === ']',\n [Token.DIGIT]: (char) => DIGIT_REGEX.test(char),\n\n [Token.QUOTE_START]: (char) => QUOTE_CHARS.includes(char),\n [Token.QUOTE_END]: (char, parsingContext) => char === parsingContext.quote,\n [Token.NAME_SELECTOR_CHAR]: () => true, // any char can be used in name selector\n [Token.ESCAPE]: (char) => char === '\\\\',\n [Token.ESCAPE_SEQUENCE_CHAR]: (char, parsingContext) => {\n if (parsingContext.escapeSequence === undefined) {\n // see https://www.rfc-editor.org/rfc/rfc9535.html#name-semantics-3\n return `${parsingContext.quote}/\\\\bfnrtu`.includes(char)\n } else if (parsingContext.escapeSequence.startsWith('u') && parsingContext.escapeSequence.length < 5) {\n return UNICODE_CHAR_REGEX.test(char)\n }\n return false\n },\n}\n\nconst ALLOWED_NEXT_TOKENS: { [token in Token]: Token[] } = {\n [Token.START]: [Token.NAME_SHORTHAND_FIRST_CHAR, Token.BRACKET_START],\n [Token.END]: [],\n\n [Token.NAME_SHORTHAND_FIRST_CHAR]: [Token.NAME_SHORTHAND_CHAR, Token.DOT, Token.BRACKET_START, Token.END],\n [Token.NAME_SHORTHAND_CHAR]: [Token.NAME_SHORTHAND_CHAR, Token.DOT, Token.BRACKET_START, Token.END],\n [Token.DOT]: [Token.NAME_SHORTHAND_FIRST_CHAR],\n\n [Token.BRACKET_START]: [Token.QUOTE_START, Token.DIGIT],\n [Token.BRACKET_END]: [Token.DOT, Token.BRACKET_START, Token.END],\n [Token.DIGIT]: [Token.DIGIT, Token.BRACKET_END],\n\n [Token.QUOTE_START]: [Token.ESCAPE, Token.QUOTE_END, Token.NAME_SELECTOR_CHAR],\n [Token.QUOTE_END]: [Token.BRACKET_END],\n [Token.NAME_SELECTOR_CHAR]: [Token.ESCAPE, Token.QUOTE_END, Token.NAME_SELECTOR_CHAR],\n [Token.ESCAPE]: [Token.ESCAPE_SEQUENCE_CHAR],\n [Token.ESCAPE_SEQUENCE_CHAR]: [Token.ESCAPE_SEQUENCE_CHAR, Token.ESCAPE, Token.QUOTE_END, Token.NAME_SELECTOR_CHAR],\n}\n\n// foo['bar\\n'][12]\n// ^^ ^ ^^ ^\nconst ALLOWED_SELECTOR_TOKENS = [\n Token.NAME_SHORTHAND_FIRST_CHAR,\n Token.NAME_SHORTHAND_CHAR,\n Token.DIGIT,\n Token.NAME_SELECTOR_CHAR,\n]\n\n// foo.bar['qux']\n// ^ ^ ^\nconst ALLOWED_SELECTOR_DELIMITER_TOKENS = [Token.DOT, Token.BRACKET_START, Token.BRACKET_END]\n\nfunction isValidEscapeSequence(escapeSequence: string): boolean {\n return '\"\\'/\\\\bfnrt'.includes(escapeSequence) || (escapeSequence.startsWith('u') && escapeSequence.length === 5)\n}\n\nconst ESCAPED_CHARS: { [key: string]: string } = {\n '\"': '\"',\n \"'\": \"'\",\n '/': '/',\n '\\\\': '\\\\',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t',\n}\n\nfunction resolveEscapeSequence(escapeSequence: string): string {\n if (escapeSequence.startsWith('u')) {\n // build Unicode char from code\n return String.fromCharCode(parseInt(escapeSequence.slice(1), 16))\n }\n return ESCAPED_CHARS[escapeSequence]\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAgB,cAAc,MAAwB;CACpD,MAAM,YAAsB,CAAC;CAC7B,IAAI,gBAAA;CACJ,IAAI;CACJ,MAAM,iBAAiC;EAAE,OAAO,KAAA;EAAW,gBAAgB,KAAA;CAAU;CACrF,IAAI,kBAAkB;CACtB,KAAK,MAAM,QAAQ,MAAM;EAEvB,eAAe,oBAAoB,cAAc,CAAC,MAAM,UAAU,gBAAgB,MAAM,CAAC,MAAM,cAAc,CAAC;EAC9G,IAAI,CAAC,cACH,OAAO,CAAC;EAEV,IAAI,eAAe,mBAAmB,KAAA,KAAa,iBAAA,IAA6C;GAC9F,IAAI,CAAC,sBAAsB,eAAe,cAAc,GACtD,OAAO,CAAC;GAEV,mBAAmB,sBAAsB,eAAe,cAAc;GACtE,eAAe,iBAAiB,KAAA;EAClC;EACA,IAAI,wBAAwB,SAAS,YAAY,GAI/C,mBAAmB;OACd,IAAI,kCAAkC,SAAS,YAAY,KAAK,oBAAoB,IAAI;GAI7F,UAAU,KAAK,eAAe;GAC9B,kBAAkB;EACpB,OAAO,IAAI,iBAAA,IACT,eAAe,iBAAiB,eAAe,iBAAiB,GAAG,eAAe,iBAAiB,SAAS;OACvG,IAAI,iBAAA,GACT,eAAe,QAAQ;OAClB,IAAI,iBAAA,GACT,eAAe,QAAQ,KAAA;EAEzB,gBAAgB;CAClB;CACA,IAAI,CAAC,oBAAoB,cAAc,CAAC,SAAA,CAAkB,GAC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,eAAe,WAAW,GAAG,KAAK,eAAe,WAAW;AAChH;AAEA,MAAM,gBAA2C;CAC/C,MAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;AAEA,SAAS,sBAAsB,gBAAgC;CAC7D,IAAI,eAAe,WAAW,GAAG,GAE/B,OAAO,OAAO,aAAa,SAAS,eAAe,MAAM,CAAC,GAAG,EAAE,CAAC;CAElE,OAAO,cAAc;AACvB"}
@@ -0,0 +1,279 @@
1
+ import { extractRegexMatch } from "../extractRegexMatch.mjs";
2
+ import { parseJsonPath } from "./jsonPathParser.mjs";
3
+ import { CACHE_STATUS_TO_METRIC_MAP, createConfigurationCache } from "./remoteConfigurationCache.mjs";
4
+ import { isIndexableObject } from "@kubesense/kubesense-js-core/util";
5
+ import { TelemetryMetrics, addTelemetryMetrics, display, fetch, getCookie, mapValues } from "@kubesense/kubesense-browser-core";
6
+ import { monitorError } from "@kubesense/kubesense-js-core/monitor";
7
+ import { buildEndpointUrl } from "@kubesense/kubesense-js-core/transport";
8
+ //#region src/domain/configuration/remoteConfiguration.ts
9
+ const REMOTE_CONFIGURATION_VERSION = "v1";
10
+ const SUPPORTED_RUM_FIELDS = [
11
+ "applicationId",
12
+ "service",
13
+ "env",
14
+ "version",
15
+ "sessionSampleRate",
16
+ "sessionReplaySampleRate",
17
+ "telemetrySampleRate",
18
+ "trackAnonymousUser",
19
+ "trackUserInteractions",
20
+ "trackResources",
21
+ "trackLongTasks",
22
+ "traceContextInjection",
23
+ "actionNameAttribute",
24
+ "defaultPrivacyLevel",
25
+ "enablePrivacyForActionName",
26
+ "traceSampleRate",
27
+ "trackSessionAcrossSubdomains",
28
+ "allowedTracingUrls",
29
+ "allowedTrackingOrigins"
30
+ ];
31
+ async function fetchAndApplyRemoteConfiguration(initConfiguration, supportedContextManagers) {
32
+ let rumInitConfiguration;
33
+ const metrics = initMetrics();
34
+ const fetchResult = await fetchRemoteConfiguration(initConfiguration);
35
+ if (!fetchResult.ok) {
36
+ metrics.increment("fetch", "failure");
37
+ display.error(fetchResult.error);
38
+ } else {
39
+ metrics.increment("fetch", "success");
40
+ rumInitConfiguration = applyRemoteConfiguration(initConfiguration, fetchResult.value, supportedContextManagers, metrics);
41
+ }
42
+ addTelemetryMetrics(TelemetryMetrics.REMOTE_CONFIGURATION_METRIC_NAME, { metrics: metrics.get() });
43
+ return rumInitConfiguration;
44
+ }
45
+ function applyRemoteConfiguration(initConfiguration, remoteConfiguration, supportedContextManagers, metrics) {
46
+ const appliedConfiguration = { ...initConfiguration };
47
+ if (remoteConfiguration.rum) {
48
+ const rumRemoteConfiguration = remoteConfiguration.rum;
49
+ SUPPORTED_RUM_FIELDS.forEach((option) => {
50
+ if (option in rumRemoteConfiguration) appliedConfiguration[option] = resolveConfigurationProperty(rumRemoteConfiguration[option]);
51
+ });
52
+ Object.keys(supportedContextManagers).forEach((context) => {
53
+ if (rumRemoteConfiguration[context] !== void 0) resolveContextProperty(supportedContextManagers[context], rumRemoteConfiguration[context]);
54
+ });
55
+ }
56
+ if (remoteConfiguration.profiling?.sampleRate !== void 0) appliedConfiguration.profilingSampleRate = remoteConfiguration.profiling.sampleRate;
57
+ return appliedConfiguration;
58
+ function resolveConfigurationProperty(property) {
59
+ if (Array.isArray(property)) return property.map(resolveConfigurationProperty);
60
+ if (isIndexableObject(property)) {
61
+ if (isSerializedOption(property)) {
62
+ const type = property.rcSerializedType;
63
+ switch (type) {
64
+ case "string": return property.value;
65
+ case "regex": return resolveRegex(property.value);
66
+ case "dynamic": return resolveDynamicOption(property);
67
+ default:
68
+ display.error(`Unsupported remote configuration: "rcSerializedType": "${type}"`);
69
+ return;
70
+ }
71
+ }
72
+ return mapValues(property, resolveConfigurationProperty);
73
+ }
74
+ return property;
75
+ }
76
+ function resolveContextProperty(contextManager, contextItems) {
77
+ contextItems.forEach(({ key, value }) => {
78
+ contextManager.setContextProperty(key, resolveConfigurationProperty(value));
79
+ });
80
+ }
81
+ function resolveDynamicOption(property) {
82
+ const strategy = property.strategy;
83
+ let resolvedValue;
84
+ switch (strategy) {
85
+ case "cookie":
86
+ resolvedValue = resolveCookieValue(property);
87
+ break;
88
+ case "dom":
89
+ resolvedValue = resolveDomValue(property);
90
+ break;
91
+ case "js":
92
+ resolvedValue = resolveJsValue(property);
93
+ break;
94
+ case "localStorage":
95
+ resolvedValue = resolveLocalStorageValue(property);
96
+ break;
97
+ default:
98
+ display.error(`Unsupported remote configuration: "strategy": "${strategy}"`);
99
+ return;
100
+ }
101
+ const extractor = property.extractor;
102
+ if (extractor !== void 0 && typeof resolvedValue === "string") return extractValue(extractor, resolvedValue);
103
+ return resolvedValue;
104
+ }
105
+ function resolveCookieValue({ name }) {
106
+ const value = getCookie(name);
107
+ metrics.increment("cookie", value !== void 0 ? "success" : "missing");
108
+ return value;
109
+ }
110
+ function resolveLocalStorageValue({ key }) {
111
+ let value;
112
+ try {
113
+ value = localStorage.getItem(key);
114
+ } catch {
115
+ metrics.increment("localStorage", "failure");
116
+ return;
117
+ }
118
+ metrics.increment("localStorage", value !== null ? "success" : "missing");
119
+ return value ?? void 0;
120
+ }
121
+ function resolveDomValue({ selector, attribute }) {
122
+ let element;
123
+ try {
124
+ element = document.querySelector(selector);
125
+ } catch {
126
+ display.error(`Invalid selector in the remote configuration: '${selector}'`);
127
+ metrics.increment("dom", "failure");
128
+ return;
129
+ }
130
+ if (!element) {
131
+ metrics.increment("dom", "missing");
132
+ return;
133
+ }
134
+ if (isForbidden(element, attribute)) {
135
+ display.error(`Forbidden element selected by the remote configuration: '${selector}'`);
136
+ metrics.increment("dom", "failure");
137
+ return;
138
+ }
139
+ const domValue = attribute !== void 0 ? element.getAttribute(attribute) : element.textContent;
140
+ if (domValue === null) {
141
+ metrics.increment("dom", "missing");
142
+ return;
143
+ }
144
+ metrics.increment("dom", "success");
145
+ return domValue;
146
+ }
147
+ function isForbidden(element, attribute) {
148
+ return element.getAttribute("type") === "password" && attribute === "value";
149
+ }
150
+ function resolveJsValue({ path }) {
151
+ let current = window;
152
+ const pathParts = parseJsonPath(path);
153
+ if (pathParts.length === 0) {
154
+ display.error(`Invalid JSON path in the remote configuration: '${path}'`);
155
+ metrics.increment("js", "failure");
156
+ return;
157
+ }
158
+ for (const pathPart of pathParts) {
159
+ if (!(pathPart in current)) {
160
+ metrics.increment("js", "missing");
161
+ return;
162
+ }
163
+ try {
164
+ current = current[pathPart];
165
+ } catch (e) {
166
+ display.error(`Error accessing: '${path}'`, e);
167
+ metrics.increment("js", "failure");
168
+ return;
169
+ }
170
+ }
171
+ metrics.increment("js", "success");
172
+ return current;
173
+ }
174
+ }
175
+ function initMetrics() {
176
+ const metrics = { fetch: {} };
177
+ return {
178
+ get: () => metrics,
179
+ increment: (metricName, type) => {
180
+ if (!metrics[metricName]) metrics[metricName] = {};
181
+ if (!metrics[metricName][type]) metrics[metricName][type] = 0;
182
+ metrics[metricName][type] = metrics[metricName][type] + 1;
183
+ }
184
+ };
185
+ }
186
+ function isSerializedOption(value) {
187
+ return "rcSerializedType" in value;
188
+ }
189
+ function resolveRegex(pattern) {
190
+ try {
191
+ return new RegExp(pattern);
192
+ } catch {
193
+ display.error(`Invalid regex in the remote configuration: '${pattern}'`);
194
+ }
195
+ }
196
+ function extractValue(extractor, candidate) {
197
+ const resolvedExtractor = resolveRegex(extractor.value);
198
+ if (resolvedExtractor === void 0) return;
199
+ return extractRegexMatch(candidate, resolvedExtractor);
200
+ }
201
+ /**
202
+ * Reads the CDN publish time. `Last-Modified` is a CORS-safelisted response header, so it is
203
+ * readable cross-origin without the CDN having to expose it explicitly. It carries an HTTP-date,
204
+ * so the value is only accurate to the second.
205
+ */
206
+ function parseLastModified(response) {
207
+ const header = response.headers?.get("last-modified");
208
+ if (!header) return;
209
+ const timestamp = new Date(header).getTime();
210
+ return isNaN(timestamp) ? void 0 : timestamp;
211
+ }
212
+ async function fetchRemoteConfiguration(configuration) {
213
+ let response;
214
+ try {
215
+ response = await fetch(buildEndpoint(configuration));
216
+ } catch {
217
+ response = void 0;
218
+ }
219
+ if (!response?.ok) return {
220
+ ok: false,
221
+ error: /* @__PURE__ */ new Error("Error fetching the remote configuration.")
222
+ };
223
+ const remoteConfiguration = await response.json();
224
+ if (remoteConfiguration.rum || remoteConfiguration.profiling) return {
225
+ ok: true,
226
+ value: remoteConfiguration,
227
+ lastModified: parseLastModified(response)
228
+ };
229
+ return {
230
+ ok: false,
231
+ error: /* @__PURE__ */ new Error("No remote configuration for RUM.")
232
+ };
233
+ }
234
+ function getRemoteConfigurationId(configuration) {
235
+ return configuration.remoteConfiguration?.id ?? configuration.remoteConfigurationId;
236
+ }
237
+ function buildEndpoint(configuration) {
238
+ if (configuration.remoteConfigurationProxy) return configuration.remoteConfigurationProxy;
239
+ const id = getRemoteConfigurationId(configuration);
240
+ return buildEndpointUrl({
241
+ kubesenseRumEndpoint: configuration.kubesenseRumEndpoint,
242
+ path: `/${REMOTE_CONFIGURATION_VERSION}/${encodeURIComponent(id)}.json`,
243
+ subdomain: "sdk-configuration"
244
+ });
245
+ }
246
+ function doBackgroundCacheSync(initConfiguration, cache, metrics) {
247
+ fetchRemoteConfiguration(initConfiguration).then((fetchResult) => {
248
+ if (!fetchResult.ok) {
249
+ metrics.increment("fetch", "failure");
250
+ display.error(fetchResult.error);
251
+ } else {
252
+ metrics.increment("fetch", "success");
253
+ cache.write(fetchResult.value, fetchResult.lastModified);
254
+ }
255
+ }).catch(monitorError).finally(() => {
256
+ addTelemetryMetrics(TelemetryMetrics.REMOTE_CONFIGURATION_METRIC_NAME, { metrics: metrics.get() });
257
+ });
258
+ }
259
+ /**
260
+ * Returns `undefined` when RUM must not start, which only happens with `required: true` and no
261
+ * usable cache entry.
262
+ */
263
+ function getRemoteConfiguration(initConfiguration, supportedContextManagers) {
264
+ const configurationCache = createConfigurationCache({ remoteConfigurationId: getRemoteConfigurationId(initConfiguration) });
265
+ const metrics = initMetrics();
266
+ const cacheResult = configurationCache.read();
267
+ metrics.increment("cache", CACHE_STATUS_TO_METRIC_MAP[cacheResult.status]);
268
+ doBackgroundCacheSync(initConfiguration, configurationCache, metrics);
269
+ if (cacheResult.status === "hit") return {
270
+ metadata: configurationCache.stampFirstApplied(cacheResult),
271
+ initConfiguration: applyRemoteConfiguration(initConfiguration, cacheResult.config, supportedContextManagers, metrics)
272
+ };
273
+ if (initConfiguration.remoteConfiguration?.required) return;
274
+ return { initConfiguration };
275
+ }
276
+ //#endregion
277
+ export { applyRemoteConfiguration, buildEndpoint, fetchAndApplyRemoteConfiguration, fetchRemoteConfiguration, getRemoteConfiguration, getRemoteConfigurationId, initMetrics };
278
+
279
+ //# sourceMappingURL=remoteConfiguration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteConfiguration.mjs","names":[],"sources":["../../../src/domain/configuration/remoteConfiguration.ts"],"sourcesContent":["import type { createContextManager, Context } from '@kubesense/kubesense-browser-core'\nimport {\n display,\n mapValues,\n getCookie,\n addTelemetryMetrics,\n TelemetryMetrics,\n fetch,\n} from '@kubesense/kubesense-browser-core'\nimport { monitorError } from '@kubesense/kubesense-js-core/monitor'\nimport { isIndexableObject } from '@kubesense/kubesense-js-core/util'\nimport { buildEndpointUrl } from '@kubesense/kubesense-js-core/transport'\nimport { extractRegexMatch } from '../extractRegexMatch'\nimport type { RumInitConfiguration } from './configuration'\nimport type { RumSdkConfig, DynamicOption, ContextItem } from './remoteConfiguration.types'\nimport { parseJsonPath } from './jsonPathParser'\nimport type { RemoteConfigurationMetadata } from './remoteConfigurationCache'\nimport { CACHE_STATUS_TO_METRIC_MAP, createConfigurationCache } from './remoteConfigurationCache'\n\nexport type RemoteConfiguration = RumSdkConfig\nexport type RumRemoteConfiguration = Exclude<RemoteConfiguration['rum'], undefined>\nconst REMOTE_CONFIGURATION_VERSION = 'v1'\nconst SUPPORTED_RUM_FIELDS: Array<keyof RumInitConfiguration> = [\n 'applicationId',\n 'service',\n 'env',\n 'version',\n 'sessionSampleRate',\n 'sessionReplaySampleRate',\n 'telemetrySampleRate',\n 'trackAnonymousUser',\n 'trackUserInteractions',\n 'trackResources',\n 'trackLongTasks',\n 'traceContextInjection',\n 'actionNameAttribute',\n 'defaultPrivacyLevel',\n 'enablePrivacyForActionName',\n 'traceSampleRate',\n 'trackSessionAcrossSubdomains',\n 'allowedTracingUrls',\n 'allowedTrackingOrigins',\n]\n\n// type needed for switch on union\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ntype SerializedRegex = { rcSerializedType: 'regex'; value: string }\ntype SerializedOption = { rcSerializedType: 'string'; value: string } | SerializedRegex | DynamicOption\n\ninterface SupportedContextManagers {\n user: ReturnType<typeof createContextManager>\n context: ReturnType<typeof createContextManager>\n}\n\nexport interface RemoteConfigurationMetrics extends Context {\n fetch: RemoteConfigurationMetricCounters\n cache?: RemoteConfigurationMetricCounters\n cookie?: RemoteConfigurationMetricCounters\n dom?: RemoteConfigurationMetricCounters\n js?: RemoteConfigurationMetricCounters\n localStorage?: RemoteConfigurationMetricCounters\n}\n\ninterface RemoteConfigurationMetricCounters {\n success?: number\n missing?: number\n failure?: number\n [key: string]: number | undefined\n}\n\nexport async function fetchAndApplyRemoteConfiguration(\n initConfiguration: RumInitConfiguration,\n supportedContextManagers: SupportedContextManagers\n) {\n let rumInitConfiguration: RumInitConfiguration | undefined\n const metrics = initMetrics()\n const fetchResult = await fetchRemoteConfiguration(initConfiguration)\n if (!fetchResult.ok) {\n metrics.increment('fetch', 'failure')\n display.error(fetchResult.error)\n } else {\n metrics.increment('fetch', 'success')\n rumInitConfiguration = applyRemoteConfiguration(\n initConfiguration,\n fetchResult.value,\n supportedContextManagers,\n metrics\n )\n }\n // monitor-until: forever\n addTelemetryMetrics(TelemetryMetrics.REMOTE_CONFIGURATION_METRIC_NAME, { metrics: metrics.get() })\n return rumInitConfiguration\n}\n\nexport function applyRemoteConfiguration(\n initConfiguration: RumInitConfiguration,\n remoteConfiguration: RemoteConfiguration,\n supportedContextManagers: SupportedContextManagers,\n metrics: ReturnType<typeof initMetrics>\n): RumInitConfiguration {\n // intents:\n // - explicitly set each supported field to limit risk in case an attacker can create configurations\n // - check the existence in the remote config to avoid clearing a provided init field\n const appliedConfiguration = { ...initConfiguration } as RumInitConfiguration & { [key: string]: unknown }\n if (remoteConfiguration.rum) {\n const rumRemoteConfiguration = remoteConfiguration.rum as RumRemoteConfiguration & { [key: string]: unknown }\n SUPPORTED_RUM_FIELDS.forEach((option: string) => {\n if (option in rumRemoteConfiguration) {\n appliedConfiguration[option] = resolveConfigurationProperty(rumRemoteConfiguration[option])\n }\n })\n ;(Object.keys(supportedContextManagers) as Array<keyof SupportedContextManagers>).forEach((context) => {\n if (rumRemoteConfiguration[context] !== undefined) {\n resolveContextProperty(supportedContextManagers[context], rumRemoteConfiguration[context])\n }\n })\n }\n if (remoteConfiguration.profiling?.sampleRate !== undefined) {\n appliedConfiguration.profilingSampleRate = remoteConfiguration.profiling.sampleRate\n }\n return appliedConfiguration\n\n // share context to access metrics\n\n function resolveConfigurationProperty(property: unknown): unknown {\n if (Array.isArray(property)) {\n return property.map(resolveConfigurationProperty)\n }\n if (isIndexableObject(property)) {\n if (isSerializedOption(property)) {\n const type = property.rcSerializedType\n switch (type) {\n case 'string':\n return property.value\n case 'regex':\n return resolveRegex(property.value)\n case 'dynamic':\n return resolveDynamicOption(property)\n default:\n display.error(`Unsupported remote configuration: \"rcSerializedType\": \"${type as string}\"`)\n return\n }\n }\n return mapValues(property, resolveConfigurationProperty)\n }\n return property\n }\n\n function resolveContextProperty(\n contextManager: ReturnType<typeof createContextManager>,\n contextItems: ContextItem[]\n ) {\n contextItems.forEach(({ key, value }) => {\n contextManager.setContextProperty(key, resolveConfigurationProperty(value))\n })\n }\n\n function resolveDynamicOption(property: DynamicOption) {\n const strategy = property.strategy\n let resolvedValue: unknown\n switch (strategy) {\n case 'cookie':\n resolvedValue = resolveCookieValue(property)\n break\n case 'dom':\n resolvedValue = resolveDomValue(property)\n break\n case 'js':\n resolvedValue = resolveJsValue(property)\n break\n case 'localStorage':\n resolvedValue = resolveLocalStorageValue(property)\n break\n default:\n display.error(`Unsupported remote configuration: \"strategy\": \"${strategy as string}\"`)\n return\n }\n const extractor = property.extractor\n if (extractor !== undefined && typeof resolvedValue === 'string') {\n return extractValue(extractor, resolvedValue)\n }\n return resolvedValue\n }\n\n function resolveCookieValue({ name }: { name: string }) {\n const value = getCookie(name)\n metrics.increment('cookie', value !== undefined ? 'success' : 'missing')\n return value\n }\n\n function resolveLocalStorageValue({ key }: { key: string }) {\n let value: string | null\n try {\n value = localStorage.getItem(key)\n } catch {\n metrics.increment('localStorage', 'failure')\n return\n }\n metrics.increment('localStorage', value !== null ? 'success' : 'missing')\n return value ?? undefined\n }\n\n function resolveDomValue({ selector, attribute }: { selector: string; attribute?: string }) {\n let element: Element | null\n try {\n element = document.querySelector(selector)\n } catch {\n display.error(`Invalid selector in the remote configuration: '${selector}'`)\n metrics.increment('dom', 'failure')\n return\n }\n if (!element) {\n metrics.increment('dom', 'missing')\n return\n }\n if (isForbidden(element, attribute)) {\n display.error(`Forbidden element selected by the remote configuration: '${selector}'`)\n metrics.increment('dom', 'failure')\n return\n }\n const domValue = attribute !== undefined ? element.getAttribute(attribute) : element.textContent\n if (domValue === null) {\n metrics.increment('dom', 'missing')\n return\n }\n metrics.increment('dom', 'success')\n return domValue\n }\n\n function isForbidden(element: Element, attribute: string | undefined) {\n return element.getAttribute('type') === 'password' && attribute === 'value'\n }\n\n function resolveJsValue({ path }: { path: string }): unknown {\n let current = window as unknown as { [key: string]: unknown }\n const pathParts = parseJsonPath(path)\n if (pathParts.length === 0) {\n display.error(`Invalid JSON path in the remote configuration: '${path}'`)\n metrics.increment('js', 'failure')\n return\n }\n for (const pathPart of pathParts) {\n if (!(pathPart in current)) {\n metrics.increment('js', 'missing')\n return\n }\n try {\n current = current[pathPart] as { [key: string]: unknown }\n } catch (e) {\n display.error(`Error accessing: '${path}'`, e)\n metrics.increment('js', 'failure')\n return\n }\n }\n metrics.increment('js', 'success')\n return current\n }\n}\n\nexport function initMetrics() {\n const metrics: RemoteConfigurationMetrics = { fetch: {} }\n return {\n get: () => metrics,\n increment: (\n metricName: 'fetch' | 'cache' | DynamicOption['strategy'],\n type: keyof RemoteConfigurationMetricCounters\n ) => {\n if (!metrics[metricName]) {\n metrics[metricName] = {}\n }\n if (!metrics[metricName][type]) {\n metrics[metricName][type] = 0\n }\n metrics[metricName][type] = metrics[metricName][type] + 1\n },\n }\n}\n\nfunction isSerializedOption(value: object): value is SerializedOption {\n return 'rcSerializedType' in value\n}\n\nfunction resolveRegex(pattern: string): RegExp | undefined {\n try {\n return new RegExp(pattern)\n } catch {\n display.error(`Invalid regex in the remote configuration: '${pattern}'`)\n }\n}\n\nfunction extractValue(extractor: SerializedRegex, candidate: string) {\n const resolvedExtractor = resolveRegex(extractor.value)\n if (resolvedExtractor === undefined) {\n return\n }\n return extractRegexMatch(candidate, resolvedExtractor)\n}\n\ntype FetchRemoteConfigurationResult =\n { ok: true; value: RemoteConfiguration; lastModified?: number } | { ok: false; error: Error }\n\n/**\n * Reads the CDN publish time. `Last-Modified` is a CORS-safelisted response header, so it is\n * readable cross-origin without the CDN having to expose it explicitly. It carries an HTTP-date,\n * so the value is only accurate to the second.\n */\nfunction parseLastModified(response: Response): number | undefined {\n const header = response.headers?.get('last-modified')\n if (!header) {\n return\n }\n const timestamp = new Date(header).getTime()\n\n return isNaN(timestamp) ? undefined : timestamp\n}\n\nexport async function fetchRemoteConfiguration(\n configuration: RumInitConfiguration\n): Promise<FetchRemoteConfigurationResult> {\n let response: Response | undefined\n try {\n response = await fetch(buildEndpoint(configuration))\n } catch {\n response = undefined\n }\n if (!response?.ok) {\n return {\n ok: false,\n error: new Error('Error fetching the remote configuration.'),\n }\n }\n const remoteConfiguration: RemoteConfiguration = await response.json()\n if (remoteConfiguration.rum || remoteConfiguration.profiling) {\n return {\n ok: true,\n value: remoteConfiguration,\n lastModified: parseLastModified(response),\n }\n }\n return {\n ok: false,\n error: new Error('No remote configuration for RUM.'),\n }\n}\n\nexport function getRemoteConfigurationId(configuration: RumInitConfiguration): string | undefined {\n return configuration.remoteConfiguration?.id ?? configuration.remoteConfigurationId\n}\n\nexport function buildEndpoint(configuration: RumInitConfiguration) {\n if (configuration.remoteConfigurationProxy) {\n return configuration.remoteConfigurationProxy\n }\n const id = getRemoteConfigurationId(configuration)!\n return buildEndpointUrl({\n kubesenseRumEndpoint: configuration.kubesenseRumEndpoint,\n path: `/${REMOTE_CONFIGURATION_VERSION}/${encodeURIComponent(id)}.json`,\n subdomain: 'sdk-configuration',\n })\n}\n\nfunction doBackgroundCacheSync(\n initConfiguration: RumInitConfiguration,\n cache: ReturnType<typeof createConfigurationCache>,\n metrics: ReturnType<typeof initMetrics>\n) {\n fetchRemoteConfiguration(initConfiguration)\n .then((fetchResult) => {\n if (!fetchResult.ok) {\n metrics.increment('fetch', 'failure')\n display.error(fetchResult.error)\n } else {\n metrics.increment('fetch', 'success')\n cache.write(fetchResult.value, fetchResult.lastModified)\n }\n })\n .catch(monitorError)\n .finally(() => {\n // monitor-until: forever\n addTelemetryMetrics(TelemetryMetrics.REMOTE_CONFIGURATION_METRIC_NAME, { metrics: metrics.get() })\n })\n}\n\nexport interface ResolvedRemoteConfiguration {\n initConfiguration: RumInitConfiguration\n /** Only set when a cached configuration was applied, and reported on configuration telemetry. */\n metadata?: RemoteConfigurationMetadata\n}\n\n/**\n * Returns `undefined` when RUM must not start, which only happens with `required: true` and no\n * usable cache entry.\n */\nexport function getRemoteConfiguration(\n initConfiguration: RumInitConfiguration,\n supportedContextManagers: SupportedContextManagers\n): ResolvedRemoteConfiguration | undefined {\n const configurationCache = createConfigurationCache({\n remoteConfigurationId: getRemoteConfigurationId(initConfiguration)!,\n })\n const metrics = initMetrics()\n\n const cacheResult = configurationCache.read()\n\n metrics.increment('cache', CACHE_STATUS_TO_METRIC_MAP[cacheResult.status])\n\n doBackgroundCacheSync(initConfiguration, configurationCache, metrics)\n\n if (cacheResult.status === 'hit') {\n return {\n // Stamping is synchronous, so it always lands before the background sync above can write.\n metadata: configurationCache.stampFirstApplied(cacheResult),\n initConfiguration: applyRemoteConfiguration(\n initConfiguration,\n cacheResult.config,\n supportedContextManagers,\n metrics\n ),\n }\n }\n\n if (initConfiguration.remoteConfiguration?.required) {\n return\n }\n\n return { initConfiguration }\n}\n"],"mappings":";;;;;;;;AAqBA,MAAM,+BAA+B;AACrC,MAAM,uBAA0D;CAC9D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA4BA,eAAsB,iCACpB,mBACA,0BACA;CACA,IAAI;CACJ,MAAM,UAAU,YAAY;CAC5B,MAAM,cAAc,MAAM,yBAAyB,iBAAiB;CACpE,IAAI,CAAC,YAAY,IAAI;EACnB,QAAQ,UAAU,SAAS,SAAS;EACpC,QAAQ,MAAM,YAAY,KAAK;CACjC,OAAO;EACL,QAAQ,UAAU,SAAS,SAAS;EACpC,uBAAuB,yBACrB,mBACA,YAAY,OACZ,0BACA,OACF;CACF;CAEA,oBAAoB,iBAAiB,kCAAkC,EAAE,SAAS,QAAQ,IAAI,EAAE,CAAC;CACjG,OAAO;AACT;AAEA,SAAgB,yBACd,mBACA,qBACA,0BACA,SACsB;CAItB,MAAM,uBAAuB,EAAE,GAAG,kBAAkB;CACpD,IAAI,oBAAoB,KAAK;EAC3B,MAAM,yBAAyB,oBAAoB;EACnD,qBAAqB,SAAS,WAAmB;GAC/C,IAAI,UAAU,wBACZ,qBAAqB,UAAU,6BAA6B,uBAAuB,OAAO;EAE9F,CAAC;EACA,OAAQ,KAAK,wBAAwB,CAAC,CAA2C,SAAS,YAAY;GACrG,IAAI,uBAAuB,aAAa,KAAA,GACtC,uBAAuB,yBAAyB,UAAU,uBAAuB,QAAQ;EAE7F,CAAC;CACH;CACA,IAAI,oBAAoB,WAAW,eAAe,KAAA,GAChD,qBAAqB,sBAAsB,oBAAoB,UAAU;CAE3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StampNow } from "@kubesense/kubesense-js-core/time";
2
+ import { isIndexableObject } from "@kubesense/kubesense-js-core/util";
3
+ import { generateUUID, tryJsonParse } from "@kubesense/kubesense-browser-core";
4
+ const CACHE_KEY_PREFIX = "dd_rc_";
5
+ const CACHE_STATUS_TO_METRIC_MAP = {
6
+ hit: "success",
7
+ miss: "missing",
8
+ error: "failure"
9
+ };
10
+ function buildCacheKey(remoteConfigurationId) {
11
+ return `${CACHE_KEY_PREFIX}${remoteConfigurationId}`;
12
+ }
13
+ function isValidCacheEntry(value) {
14
+ if (typeof value !== "object" || value === null) return false;
15
+ const hasVersion = "version" in value && value.version === 3;
16
+ const hasConfig = "config" in value && typeof value.config === "object" && value.config !== null;
17
+ const hasMetadata = "metadata" in value && isIndexableObject(value.metadata) && typeof value.metadata.syncId === "string" && typeof value.metadata.lastSynced === "number";
18
+ return hasVersion && hasConfig && hasMetadata;
19
+ }
20
+ function persist(key, entry) {
21
+ try {
22
+ localStorage.setItem(key, JSON.stringify(entry));
23
+ } catch {}
24
+ }
25
+ function createConfigurationCache({ remoteConfigurationId }) {
26
+ const key = buildCacheKey(remoteConfigurationId);
27
+ return {
28
+ read() {
29
+ let raw;
30
+ try {
31
+ raw = localStorage.getItem(key);
32
+ } catch {
33
+ return { status: "error" };
34
+ }
35
+ if (raw === null) return { status: "miss" };
36
+ const parsed = tryJsonParse(raw);
37
+ if (parsed === void 0) {
38
+ this.remove();
39
+ return { status: "error" };
40
+ }
41
+ if (!isValidCacheEntry(parsed)) {
42
+ this.remove();
43
+ return { status: "error" };
44
+ }
45
+ return {
46
+ status: "hit",
47
+ config: parsed.config,
48
+ metadata: parsed.metadata
49
+ };
50
+ },
51
+ remove() {
52
+ try {
53
+ localStorage.removeItem(key);
54
+ } catch {}
55
+ },
56
+ write(config, lastModified) {
57
+ const cached = this.read();
58
+ if (cached.status === "hit" && JSON.stringify(cached.config) === JSON.stringify(config)) return;
59
+ persist(key, {
60
+ version: 3,
61
+ config,
62
+ metadata: {
63
+ lastModified,
64
+ lastSynced: timeStampNow(),
65
+ syncId: generateUUID()
66
+ }
67
+ });
68
+ },
69
+ /**
70
+ * Records when this configuration version was first put into effect. Stamped on the first page
71
+ * load that applies it, then reused by every later one, so the reported value marks a fixed
72
+ * point in time instead of drifting with each page load.
73
+ */
74
+ stampFirstApplied(cached) {
75
+ if (cached.metadata.firstApplied !== void 0) return cached.metadata;
76
+ const metadata = {
77
+ ...cached.metadata,
78
+ firstApplied: timeStampNow()
79
+ };
80
+ persist(key, {
81
+ version: 3,
82
+ config: cached.config,
83
+ metadata
84
+ });
85
+ return metadata;
86
+ }
87
+ };
88
+ }
89
+ //#endregion
90
+ export { CACHE_KEY_PREFIX, CACHE_STATUS_TO_METRIC_MAP, buildCacheKey, createConfigurationCache };
91
+
92
+ //# sourceMappingURL=remoteConfigurationCache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteConfigurationCache.mjs","names":[],"sources":["../../../src/domain/configuration/remoteConfigurationCache.ts"],"sourcesContent":["import { timeStampNow } from '@kubesense/kubesense-js-core/time'\nimport { generateUUID, tryJsonParse } from '@kubesense/kubesense-browser-core'\nimport { isIndexableObject } from '@kubesense/kubesense-js-core/util'\nimport type { TimeStamp } from '@kubesense/kubesense-js-core/time'\nimport type { RemoteConfiguration } from './remoteConfiguration'\n\nexport const CACHE_VERSION = 3\nexport const CACHE_KEY_PREFIX = 'dd_rc_'\n\n/**\n * Sync metadata for the cached configuration version, reported on configuration telemetry to\n * measure how long a published configuration takes to take effect.\n */\nexport interface RemoteConfigurationMetadata {\n /** CDN publish time, from the `last-modified` response header. */\n lastModified?: number\n /** When the SDK fetched the version currently cached. */\n lastSynced: TimeStamp\n /** When this version was first applied. Stamped once, then reused on every later page load. */\n firstApplied?: TimeStamp\n /** Identifies one sync, so repeat page loads from a device collapse into a single unit. */\n syncId: string\n}\n\ninterface CachedRemoteConfiguration {\n version: number\n config: RemoteConfiguration\n metadata: RemoteConfigurationMetadata\n}\n\nexport type CacheReadStatus = 'hit' | 'miss' | 'error'\n\nexport interface CacheHitResult {\n status: Extract<CacheReadStatus, 'hit'>\n config: RemoteConfiguration\n metadata: RemoteConfigurationMetadata\n}\n\nexport type CacheReadResult =\n | {\n status: Exclude<CacheReadStatus, 'hit'>\n }\n | CacheHitResult\n\nexport const CACHE_STATUS_TO_METRIC_MAP: Record<CacheReadStatus, 'success' | 'missing' | 'failure'> = {\n hit: 'success',\n miss: 'missing',\n error: 'failure',\n}\n\nexport function buildCacheKey(remoteConfigurationId: string): string {\n return `${CACHE_KEY_PREFIX}${remoteConfigurationId}`\n}\n\nfunction isValidCacheEntry(value: unknown): value is CachedRemoteConfiguration {\n if (typeof value !== 'object' || value === null) {\n return false\n }\n\n const hasVersion = 'version' in value && value.version === CACHE_VERSION\n const hasConfig = 'config' in value && typeof value.config === 'object' && value.config !== null\n const hasMetadata =\n 'metadata' in value &&\n isIndexableObject(value.metadata) &&\n typeof value.metadata.syncId === 'string' &&\n typeof value.metadata.lastSynced === 'number'\n\n return hasVersion && hasConfig && hasMetadata\n}\n\nfunction persist(key: string, entry: CachedRemoteConfiguration) {\n try {\n localStorage.setItem(key, JSON.stringify(entry))\n } catch {\n // Ignore\n }\n}\n\nexport function createConfigurationCache({ remoteConfigurationId }: { remoteConfigurationId: string }) {\n const key = buildCacheKey(remoteConfigurationId)\n\n return {\n read(): CacheReadResult {\n let raw: string | null\n\n try {\n raw = localStorage.getItem(key)\n } catch {\n return { status: 'error' }\n }\n\n if (raw === null) {\n return { status: 'miss' }\n }\n\n const parsed = tryJsonParse(raw)\n if (parsed === undefined) {\n this.remove()\n\n return { status: 'error' }\n }\n\n if (!isValidCacheEntry(parsed)) {\n this.remove()\n\n return { status: 'error' }\n }\n\n return { status: 'hit', config: parsed.config, metadata: parsed.metadata }\n },\n remove() {\n try {\n localStorage.removeItem(key)\n } catch {\n // Ignore\n }\n },\n write(config: RemoteConfiguration, lastModified?: number) {\n const cached = this.read()\n\n // Only a payload change counts as a sync. The SDK sends no `If-None-Match`, so it never\n // observes a 304 and cannot otherwise tell a genuine sync from a repeated fetch of the same\n // version. Skipping the write here is also what keeps `firstApplied` alive across refetches.\n // TODO: compare on `ETag` instead once the CDN exposes it through\n // `Access-Control-Expose-Headers`. The stringify compare is key-order sensitive, which holds\n // only because both sides come from `JSON.parse` of the same CDN payload.\n if (cached.status === 'hit' && JSON.stringify(cached.config) === JSON.stringify(config)) {\n return\n }\n\n persist(key, {\n version: CACHE_VERSION,\n config,\n metadata: { lastModified, lastSynced: timeStampNow(), syncId: generateUUID() },\n })\n },\n /**\n * Records when this configuration version was first put into effect. Stamped on the first page\n * load that applies it, then reused by every later one, so the reported value marks a fixed\n * point in time instead of drifting with each page load.\n */\n stampFirstApplied(cached: CacheHitResult): RemoteConfigurationMetadata {\n if (cached.metadata.firstApplied !== undefined) {\n return cached.metadata\n }\n\n const metadata: RemoteConfigurationMetadata = { ...cached.metadata, firstApplied: timeStampNow() }\n persist(key, { version: CACHE_VERSION, config: cached.config, metadata })\n\n return metadata\n },\n }\n}\n"],"mappings":";;;AAOA,MAAa,mBAAmB;AAqChC,MAAa,6BAAyF;CACpG,KAAK;CACL,MAAM;CACN,OAAO;AACT;AAEA,SAAgB,cAAc,uBAAuC;CACnE,OAAO,GAAG,mBAAmB;AAC/B;AAEA,SAAS,kBAAkB,OAAoD;CAC7E,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAGT,MAAM,aAAa,aAAa,SAAS,MAAM,YAAA;CAC/C,MAAM,YAAY,YAAY,SAAS,OAAO,MAAM,WAAW,YAAY,MAAM,WAAW;CAC5F,MAAM,cACJ,cAAc,SACd,kBAAkB,MAAM,QAAQ,KAChC,OAAO,MAAM,SAAS,WAAW,YACjC,OAAO,MAAM,SAAS,eAAe;CAEvC,OAAO,cAAc,aAAa;AACpC;AAEA,SAAS,QAAQ,KAAa,OAAkC;CAC9D,IAAI;EACF,aAAa,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;CACj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