@nathanclaire/edge-telemetry-sdk 3.0.0 → 5.0.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 (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +985 -185
  3. package/dist/appLifecycle-DS_fEclk.cjs +2 -0
  4. package/dist/appLifecycle-DS_fEclk.cjs.map +1 -0
  5. package/dist/appLifecycle-PffQ4vC1.js +24 -0
  6. package/dist/appLifecycle-PffQ4vC1.js.map +1 -0
  7. package/dist/autoTaps.native-By9I4Kr2.cjs +2 -0
  8. package/dist/autoTaps.native-By9I4Kr2.cjs.map +1 -0
  9. package/dist/autoTaps.native-DQCXevD7.js +66 -0
  10. package/dist/autoTaps.native-DQCXevD7.js.map +1 -0
  11. package/dist/crashHandler.web-6KvedEB-.cjs +2 -0
  12. package/dist/crashHandler.web-6KvedEB-.cjs.map +1 -0
  13. package/dist/crashHandler.web-BUlSXYoS.js +30 -0
  14. package/dist/crashHandler.web-BUlSXYoS.js.map +1 -0
  15. package/dist/crashHandlerNative.native-CFVQ5UcO.cjs +2 -0
  16. package/dist/crashHandlerNative.native-CFVQ5UcO.cjs.map +1 -0
  17. package/dist/crashHandlerNative.native-DsCRd-oN.js +39 -0
  18. package/dist/crashHandlerNative.native-DsCRd-oN.js.map +1 -0
  19. package/dist/deviceInfo.native-D5gNBG7m.cjs +2 -0
  20. package/dist/deviceInfo.native-D5gNBG7m.cjs.map +1 -0
  21. package/dist/deviceInfo.native-DiiHrnI3.js +53 -0
  22. package/dist/deviceInfo.native-DiiHrnI3.js.map +1 -0
  23. package/dist/deviceInfo.web-BHsjVveq.js +41 -0
  24. package/dist/deviceInfo.web-BHsjVveq.js.map +1 -0
  25. package/dist/deviceInfo.web-DGCUHAnv.cjs +2 -0
  26. package/dist/deviceInfo.web-DGCUHAnv.cjs.map +1 -0
  27. package/dist/deviceState.native-BEysbZ6O.js +58 -0
  28. package/dist/deviceState.native-BEysbZ6O.js.map +1 -0
  29. package/dist/deviceState.native-CrQMy11_.cjs +2 -0
  30. package/dist/deviceState.native-CrQMy11_.cjs.map +1 -0
  31. package/dist/deviceState.web-ByaQm9Ry.js +14 -0
  32. package/dist/deviceState.web-ByaQm9Ry.js.map +1 -0
  33. package/dist/deviceState.web-CSfUgHDU.cjs +2 -0
  34. package/dist/deviceState.web-CSfUgHDU.cjs.map +1 -0
  35. package/dist/frameTracker-9j0en6Zm.cjs +2 -0
  36. package/dist/frameTracker-9j0en6Zm.cjs.map +1 -0
  37. package/dist/frameTracker-BzXnxSkb.js +53 -0
  38. package/dist/frameTracker-BzXnxSkb.js.map +1 -0
  39. package/dist/httpAttributes-BWXOr4eP.js +70 -0
  40. package/dist/httpAttributes-BWXOr4eP.js.map +1 -0
  41. package/dist/httpAttributes-COY0_kiF.cjs +2 -0
  42. package/dist/httpAttributes-COY0_kiF.cjs.map +1 -0
  43. package/dist/index.native.cjs +1 -1
  44. package/dist/index.native.cjs.map +1 -1
  45. package/dist/index.native.d.ts +1 -1
  46. package/dist/index.native.js +173 -81
  47. package/dist/index.native.js.map +1 -1
  48. package/dist/index.web.cjs +1 -1
  49. package/dist/index.web.cjs.map +1 -1
  50. package/dist/index.web.d.ts +1 -1
  51. package/dist/index.web.js +107 -39
  52. package/dist/index.web.js.map +1 -1
  53. package/dist/interactionWeb.web-BWBjmovb.js +109 -0
  54. package/dist/interactionWeb.web-BWBjmovb.js.map +1 -0
  55. package/dist/interactionWeb.web-CKDJLD9r.cjs +2 -0
  56. package/dist/interactionWeb.web-CKDJLD9r.cjs.map +1 -0
  57. package/dist/interceptFetchWeb.web-DjSR_Rft.js +62 -0
  58. package/dist/interceptFetchWeb.web-DjSR_Rft.js.map +1 -0
  59. package/dist/interceptFetchWeb.web-ZHw6IQkU.cjs +2 -0
  60. package/dist/interceptFetchWeb.web-ZHw6IQkU.cjs.map +1 -0
  61. package/dist/interceptHttpNative.native-C5scIcgY.cjs +2 -0
  62. package/dist/interceptHttpNative.native-C5scIcgY.cjs.map +1 -0
  63. package/dist/interceptHttpNative.native-vF_Fksjk.js +18 -0
  64. package/dist/interceptHttpNative.native-vF_Fksjk.js.map +1 -0
  65. package/dist/loadingTime-Cj5Oh8lT.cjs +2 -0
  66. package/dist/loadingTime-Cj5Oh8lT.cjs.map +1 -0
  67. package/dist/loadingTime-DMc0zTY8.js +70 -0
  68. package/dist/loadingTime-DMc0zTY8.js.map +1 -0
  69. package/dist/memoryNative.native-CK3QFVjY.cjs +2 -0
  70. package/dist/memoryNative.native-CK3QFVjY.cjs.map +1 -0
  71. package/dist/memoryNative.native-DkA6f7id.js +54 -0
  72. package/dist/memoryNative.native-DkA6f7id.js.map +1 -0
  73. package/dist/nativeSender-Dt1HLaLi.js +37 -0
  74. package/dist/nativeSender-Dt1HLaLi.js.map +1 -0
  75. package/dist/nativeSender-hCgUa7Vz.cjs +2 -0
  76. package/dist/nativeSender-hCgUa7Vz.cjs.map +1 -0
  77. package/dist/navigationRef-CVIv0aIK.js +30 -0
  78. package/dist/navigationRef-CVIv0aIK.js.map +1 -0
  79. package/dist/navigationRef-CfIbeXX8.cjs +2 -0
  80. package/dist/navigationRef-CfIbeXX8.cjs.map +1 -0
  81. package/dist/navigationWeb.web-CRHpr5zl.js +51 -0
  82. package/dist/navigationWeb.web-CRHpr5zl.js.map +1 -0
  83. package/dist/navigationWeb.web-DwWjL80b.cjs +2 -0
  84. package/dist/navigationWeb.web-DwWjL80b.cjs.map +1 -0
  85. package/dist/{networkChange-CUO1hRLj.cjs → networkChange-2FGIQM-N.cjs} +2 -2
  86. package/dist/networkChange-2FGIQM-N.cjs.map +1 -0
  87. package/dist/{networkChange-D39hdSb0.js → networkChange-QA0893vW.js} +2 -2
  88. package/dist/networkChange-QA0893vW.js.map +1 -0
  89. package/dist/networkInfo.native-CcJ3JVRF.js +31 -0
  90. package/dist/networkInfo.native-CcJ3JVRF.js.map +1 -0
  91. package/dist/networkInfo.native-whB2wf6a.cjs +2 -0
  92. package/dist/networkInfo.native-whB2wf6a.cjs.map +1 -0
  93. package/dist/{networkInfo.web-twcNn_hc.js → networkInfo.web-CcUpXMUK.js} +4 -4
  94. package/dist/networkInfo.web-CcUpXMUK.js.map +1 -0
  95. package/dist/networkInfo.web-DfO-BUFx.cjs +2 -0
  96. package/dist/networkInfo.web-DfO-BUFx.cjs.map +1 -0
  97. package/dist/react-bqe7KPOf.cjs +4 -0
  98. package/dist/react-bqe7KPOf.cjs.map +1 -0
  99. package/dist/react-urNtDGTL.js +413 -0
  100. package/dist/react-urNtDGTL.js.map +1 -0
  101. package/dist/runtimeReady.native-CxFl1rQR.js +35 -0
  102. package/dist/runtimeReady.native-CxFl1rQR.js.map +1 -0
  103. package/dist/runtimeReady.native-zueSbsEv.cjs +2 -0
  104. package/dist/runtimeReady.native-zueSbsEv.cjs.map +1 -0
  105. package/dist/runtimeReady.web-JuE239Tg.js +25 -0
  106. package/dist/runtimeReady.web-JuE239Tg.js.map +1 -0
  107. package/dist/runtimeReady.web-vhAJFU61.cjs +2 -0
  108. package/dist/runtimeReady.web-vhAJFU61.cjs.map +1 -0
  109. package/dist/seedRuntimeReady-BlRdf3pR.js +10 -0
  110. package/dist/seedRuntimeReady-BlRdf3pR.js.map +1 -0
  111. package/dist/seedRuntimeReady-CbjqbWCd.cjs +2 -0
  112. package/dist/seedRuntimeReady-CbjqbWCd.cjs.map +1 -0
  113. package/dist/src/adapters/appLifecycle.d.ts +11 -4
  114. package/dist/src/adapters/batch.d.ts +46 -0
  115. package/dist/src/adapters/crashCapture.d.ts +42 -9
  116. package/dist/src/adapters/deviceState.d.ts +9 -0
  117. package/dist/src/adapters/failedEvents.d.ts +43 -0
  118. package/dist/src/adapters/frameAggregate.d.ts +19 -12
  119. package/dist/src/adapters/frameTracker.d.ts +30 -0
  120. package/dist/src/adapters/hangDetector.d.ts +41 -0
  121. package/dist/src/adapters/httpAttributes.d.ts +18 -0
  122. package/dist/src/adapters/loadingTime.d.ts +67 -0
  123. package/dist/src/adapters/manualSpans.d.ts +41 -0
  124. package/dist/src/adapters/native/autoTaps.native.d.ts +15 -0
  125. package/dist/src/adapters/native/deviceState.native.d.ts +15 -0
  126. package/dist/src/adapters/native/interceptHttpNative.native.d.ts +18 -0
  127. package/dist/src/adapters/native/memoryNative.native.d.ts +15 -11
  128. package/dist/src/adapters/native/networkInfo.native.d.ts +1 -1
  129. package/dist/src/adapters/native/runtimeReady.native.d.ts +17 -0
  130. package/dist/src/adapters/native/store.native.d.ts +10 -0
  131. package/dist/src/adapters/nativeSender.d.ts +2 -2
  132. package/dist/src/adapters/navigationRef.d.ts +29 -0
  133. package/dist/src/adapters/networkChange.d.ts +2 -2
  134. package/dist/src/adapters/seedRuntimeReady.d.ts +8 -0
  135. package/dist/src/adapters/traceHeader.d.ts +33 -0
  136. package/dist/src/adapters/traceManager.d.ts +144 -0
  137. package/dist/src/adapters/uiInteraction.d.ts +111 -0
  138. package/dist/src/adapters/viewManager.d.ts +177 -0
  139. package/dist/src/adapters/viewport.d.ts +15 -0
  140. package/dist/src/adapters/web/deviceState.web.d.ts +10 -0
  141. package/dist/src/adapters/web/interactionWeb.web.d.ts +36 -0
  142. package/dist/src/adapters/web/interceptFetchWeb.web.d.ts +3 -11
  143. package/dist/src/adapters/web/navigationWeb.web.d.ts +13 -7
  144. package/dist/src/adapters/web/runtimeReady.web.d.ts +5 -0
  145. package/dist/src/adapters/web/store.web.d.ts +12 -0
  146. package/dist/src/adapters/web/webVitals.web.d.ts +56 -0
  147. package/dist/src/adapters/webSender.d.ts +2 -2
  148. package/dist/src/adapters/webVitals.d.ts +25 -0
  149. package/dist/src/adapters/xhrIntercept.d.ts +55 -0
  150. package/dist/src/core/beforeSend.d.ts +20 -0
  151. package/dist/src/core/breadcrumbs.d.ts +10 -0
  152. package/dist/src/core/debug.d.ts +7 -0
  153. package/dist/src/core/memoryStore.d.ts +23 -0
  154. package/dist/src/core/store.d.ts +41 -0
  155. package/dist/src/core/telemetry.d.ts +422 -42
  156. package/dist/src/core/userProfile.d.ts +19 -0
  157. package/dist/src/core/utils/json.d.ts +7 -0
  158. package/dist/src/core/utils/uuid.d.ts +10 -1
  159. package/dist/src/createTelemetry.native.d.ts +10 -1
  160. package/dist/src/createTelemetry.web.d.ts +9 -1
  161. package/dist/src/golden.helper.d.ts +4 -0
  162. package/dist/src/index.base.d.ts +93 -3
  163. package/dist/src/index.native.d.ts +7 -27
  164. package/dist/src/index.web.d.ts +7 -23
  165. package/dist/src/react.d.ts +45 -0
  166. package/dist/src/telemetryNative.native.d.ts +79 -0
  167. package/dist/src/telemetryWeb.web.d.ts +59 -0
  168. package/dist/store.native-BbS76uWV.cjs +2 -0
  169. package/dist/store.native-BbS76uWV.cjs.map +1 -0
  170. package/dist/store.native-MlWyGgBp.js +32 -0
  171. package/dist/store.native-MlWyGgBp.js.map +1 -0
  172. package/dist/store.web-BzKaP57Z.cjs +2 -0
  173. package/dist/store.web-BzKaP57Z.cjs.map +1 -0
  174. package/dist/store.web-rhh0NOfs.js +31 -0
  175. package/dist/store.web-rhh0NOfs.js.map +1 -0
  176. package/dist/telemetry-60sfWkh0.js +1754 -0
  177. package/dist/telemetry-60sfWkh0.js.map +1 -0
  178. package/dist/telemetry-CW63glwb.cjs +2 -0
  179. package/dist/telemetry-CW63glwb.cjs.map +1 -0
  180. package/dist/uiInteraction-BIDOMcrL.js +109 -0
  181. package/dist/uiInteraction-BIDOMcrL.js.map +1 -0
  182. package/dist/uiInteraction-DxlwCVSn.cjs +2 -0
  183. package/dist/uiInteraction-DxlwCVSn.cjs.map +1 -0
  184. package/dist/viewport-9JcVIXYF.cjs +2 -0
  185. package/dist/viewport-9JcVIXYF.cjs.map +1 -0
  186. package/dist/viewport-GWTEBt2K.js +15 -0
  187. package/dist/viewport-GWTEBt2K.js.map +1 -0
  188. package/dist/web-vitals.attribution-DAvBvdng.cjs +2 -0
  189. package/dist/web-vitals.attribution-DAvBvdng.cjs.map +1 -0
  190. package/dist/web-vitals.attribution-DcoMtvlY.js +488 -0
  191. package/dist/web-vitals.attribution-DcoMtvlY.js.map +1 -0
  192. package/dist/webSender-DA087xb5.cjs +2 -0
  193. package/dist/webSender-DA087xb5.cjs.map +1 -0
  194. package/dist/webSender-g4rs5TIg.js +44 -0
  195. package/dist/webSender-g4rs5TIg.js.map +1 -0
  196. package/dist/webVitals.web-DRTDK6s5.js +100 -0
  197. package/dist/webVitals.web-DRTDK6s5.js.map +1 -0
  198. package/dist/webVitals.web-DvScDIjX.cjs +2 -0
  199. package/dist/webVitals.web-DvScDIjX.cjs.map +1 -0
  200. package/dist/xhrIntercept-9uAkQh3N.js +55 -0
  201. package/dist/xhrIntercept-9uAkQh3N.js.map +1 -0
  202. package/dist/xhrIntercept-xG1Yl5RI.cjs +2 -0
  203. package/dist/xhrIntercept-xG1Yl5RI.cjs.map +1 -0
  204. package/docs/migration-v4.md +190 -0
  205. package/docs/migration-v5.md +178 -0
  206. package/package.json +22 -6
  207. package/dist/appLifecycle-Cynw0kAv.js +0 -14
  208. package/dist/appLifecycle-Cynw0kAv.js.map +0 -1
  209. package/dist/appLifecycle-DvJIt7ym.cjs +0 -2
  210. package/dist/appLifecycle-DvJIt7ym.cjs.map +0 -1
  211. package/dist/batch-CLBFgYPC.cjs +0 -2
  212. package/dist/batch-CLBFgYPC.cjs.map +0 -1
  213. package/dist/batch-DLG_gtOm.js +0 -12
  214. package/dist/batch-DLG_gtOm.js.map +0 -1
  215. package/dist/crashCapture-BYTM4FLC.cjs +0 -2
  216. package/dist/crashCapture-BYTM4FLC.cjs.map +0 -1
  217. package/dist/crashCapture-D_rkkBVa.js +0 -31
  218. package/dist/crashCapture-D_rkkBVa.js.map +0 -1
  219. package/dist/crashHandler.web-BSxDpFTo.cjs +0 -2
  220. package/dist/crashHandler.web-BSxDpFTo.cjs.map +0 -1
  221. package/dist/crashHandler.web-D59bmhg9.js +0 -32
  222. package/dist/crashHandler.web-D59bmhg9.js.map +0 -1
  223. package/dist/crashHandlerNative.native-DeAFze4E.cjs +0 -2
  224. package/dist/crashHandlerNative.native-DeAFze4E.cjs.map +0 -1
  225. package/dist/crashHandlerNative.native-d7qJkzA6.js +0 -41
  226. package/dist/crashHandlerNative.native-d7qJkzA6.js.map +0 -1
  227. package/dist/debug-DsvQ9y3W.js +0 -68
  228. package/dist/debug-DsvQ9y3W.js.map +0 -1
  229. package/dist/debug-rnOOxFpN.cjs +0 -2
  230. package/dist/debug-rnOOxFpN.cjs.map +0 -1
  231. package/dist/deviceInfo.native-7hbRYixR.cjs +0 -2
  232. package/dist/deviceInfo.native-7hbRYixR.cjs.map +0 -1
  233. package/dist/deviceInfo.native-D2k0LDhI.js +0 -1171
  234. package/dist/deviceInfo.native-D2k0LDhI.js.map +0 -1
  235. package/dist/deviceInfo.web-ByNAlEJh.cjs +0 -2
  236. package/dist/deviceInfo.web-ByNAlEJh.cjs.map +0 -1
  237. package/dist/deviceInfo.web-DzQyEku6.js +0 -40
  238. package/dist/deviceInfo.web-DzQyEku6.js.map +0 -1
  239. package/dist/frameAggregate-C_HoVFcK.cjs +0 -2
  240. package/dist/frameAggregate-C_HoVFcK.cjs.map +0 -1
  241. package/dist/frameAggregate-Cwh1juw1.js +0 -17
  242. package/dist/frameAggregate-Cwh1juw1.js.map +0 -1
  243. package/dist/frameDropsNative.native-CP7zrXDf.js +0 -23
  244. package/dist/frameDropsNative.native-CP7zrXDf.js.map +0 -1
  245. package/dist/frameDropsNative.native-DKqEDqip.cjs +0 -2
  246. package/dist/frameDropsNative.native-DKqEDqip.cjs.map +0 -1
  247. package/dist/frameDropsWeb.web-C9Lt3Fuj.js +0 -22
  248. package/dist/frameDropsWeb.web-C9Lt3Fuj.js.map +0 -1
  249. package/dist/frameDropsWeb.web-azpwQCUz.cjs +0 -2
  250. package/dist/frameDropsWeb.web-azpwQCUz.cjs.map +0 -1
  251. package/dist/httpAttributes-BV50UKQU.js +0 -19
  252. package/dist/httpAttributes-BV50UKQU.js.map +0 -1
  253. package/dist/httpAttributes-xXOD9trQ.cjs +0 -2
  254. package/dist/httpAttributes-xXOD9trQ.cjs.map +0 -1
  255. package/dist/interaction-CH8yoY5-.js +0 -23
  256. package/dist/interaction-CH8yoY5-.js.map +0 -1
  257. package/dist/interaction-DcNFBW7a.cjs +0 -2
  258. package/dist/interaction-DcNFBW7a.cjs.map +0 -1
  259. package/dist/interceptFetchNative.native-VlhtMG-U.js +0 -49
  260. package/dist/interceptFetchNative.native-VlhtMG-U.js.map +0 -1
  261. package/dist/interceptFetchNative.native-jEAldH14.cjs +0 -2
  262. package/dist/interceptFetchNative.native-jEAldH14.cjs.map +0 -1
  263. package/dist/interceptFetchWeb.web-DFzZliik.cjs +0 -2
  264. package/dist/interceptFetchWeb.web-DFzZliik.cjs.map +0 -1
  265. package/dist/interceptFetchWeb.web-DfsMfoRP.js +0 -77
  266. package/dist/interceptFetchWeb.web-DfsMfoRP.js.map +0 -1
  267. package/dist/memoryNative.native-BWLh2S9L.js +0 -48
  268. package/dist/memoryNative.native-BWLh2S9L.js.map +0 -1
  269. package/dist/memoryNative.native-DCXSOd4Q.cjs +0 -2
  270. package/dist/memoryNative.native-DCXSOd4Q.cjs.map +0 -1
  271. package/dist/memoryWeb.web-B3YuV-cB.js +0 -48
  272. package/dist/memoryWeb.web-B3YuV-cB.js.map +0 -1
  273. package/dist/memoryWeb.web-CheXAcJn.cjs +0 -2
  274. package/dist/memoryWeb.web-CheXAcJn.cjs.map +0 -1
  275. package/dist/nativeSender-BE_mzw_S.js +0 -70
  276. package/dist/nativeSender-BE_mzw_S.js.map +0 -1
  277. package/dist/nativeSender-DyAUGY7c.cjs +0 -2
  278. package/dist/nativeSender-DyAUGY7c.cjs.map +0 -1
  279. package/dist/navigationNative.native-3tO5JxSd.cjs +0 -2
  280. package/dist/navigationNative.native-3tO5JxSd.cjs.map +0 -1
  281. package/dist/navigationNative.native-BUCGPQX2.js +0 -25
  282. package/dist/navigationNative.native-BUCGPQX2.js.map +0 -1
  283. package/dist/navigationTracker-B2GMwyKk.cjs +0 -2
  284. package/dist/navigationTracker-B2GMwyKk.cjs.map +0 -1
  285. package/dist/navigationTracker-Cts68dgG.js +0 -19
  286. package/dist/navigationTracker-Cts68dgG.js.map +0 -1
  287. package/dist/navigationWeb.web-B0necr5j.cjs +0 -2
  288. package/dist/navigationWeb.web-B0necr5j.cjs.map +0 -1
  289. package/dist/navigationWeb.web-CORzE_Id.js +0 -46
  290. package/dist/navigationWeb.web-CORzE_Id.js.map +0 -1
  291. package/dist/networkChange-CUO1hRLj.cjs.map +0 -1
  292. package/dist/networkChange-D39hdSb0.js.map +0 -1
  293. package/dist/networkInfo.native-BK5fpAOL.js +0 -343
  294. package/dist/networkInfo.native-BK5fpAOL.js.map +0 -1
  295. package/dist/networkInfo.native-cxuw93Uy.cjs +0 -2
  296. package/dist/networkInfo.native-cxuw93Uy.cjs.map +0 -1
  297. package/dist/networkInfo.web-DJmw1sNK.cjs +0 -2
  298. package/dist/networkInfo.web-DJmw1sNK.cjs.map +0 -1
  299. package/dist/networkInfo.web-twcNn_hc.js.map +0 -1
  300. package/dist/src/adapters/interaction.d.ts +0 -17
  301. package/dist/src/adapters/native/frameDropsNative.native.d.ts +0 -16
  302. package/dist/src/adapters/native/interceptFetchNative.native.d.ts +0 -23
  303. package/dist/src/adapters/native/navigationNative.native.d.ts +0 -12
  304. package/dist/src/adapters/navigationTracker.d.ts +0 -6
  305. package/dist/src/adapters/screenTiming.d.ts +0 -9
  306. package/dist/src/adapters/web/frameDropsWeb.web.d.ts +0 -16
  307. package/dist/src/adapters/web/memoryWeb.web.d.ts +0 -26
  308. package/dist/telemetry-Co4MYdwa.cjs +0 -2
  309. package/dist/telemetry-Co4MYdwa.cjs.map +0 -1
  310. package/dist/telemetry-KI0x4gzC.js +0 -389
  311. package/dist/telemetry-KI0x4gzC.js.map +0 -1
  312. package/dist/v4-BysszJq8.js +0 -31
  313. package/dist/v4-BysszJq8.js.map +0 -1
  314. package/dist/v4-CqdK_b8Y.cjs +0 -2
  315. package/dist/v4-CqdK_b8Y.cjs.map +0 -1
  316. package/dist/webSender-B27tmT1w.js +0 -42
  317. package/dist/webSender-B27tmT1w.js.map +0 -1
  318. package/dist/webSender-BWi4x1df.cjs +0 -2
  319. package/dist/webSender-BWi4x1df.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webSender-g4rs5TIg.js","sources":["../src/adapters/webSender.ts"],"sourcesContent":["import { debug } from \"../core/debug\";\nimport type { TelemetryEvent, Sender } from \"../core/telemetry\";\nimport type { SyncStore } from \"../core/store\";\nimport { webStore } from \"./web/store.web\";\nimport { decodeFailed, encodeFailed, FAILED_EVENTS_KEY } from \"./failedEvents\";\nimport { buildBatch, buildHeaders, DEFAULT_ENDPOINT, replayGroups, sendWithRetry } from \"./batch\";\n\n// The offline queue goes through the Store port (#89), and on web it stays SYNCHRONOUS\n// on purpose. onFailure() runs on the unload path; a synchronous set() has landed before\n// the function returns, which is what closes the crash-loss window here rather than\n// merely narrowing it. Do not make these helpers async.\n// Returns how many rows the §9.4 cap evicted, for core's `sdk.events_dropped`.\nfunction persistFailed(store: SyncStore, events: TelemetryEvent[]): number {\n const existing = decodeFailed(store.get(FAILED_EVENTS_KEY));\n const { json, dropped } = encodeFailed(existing, events);\n const written = store.set(FAILED_EVENTS_KEY, json);\n // Storage refusing (incognito, quota, partitioned iframe) is an outcome, not an error:\n // the batch is already lost, and throwing here would only lose the next one too.\n if (written.status === \"unavailable\") {\n debug.warn(\"Telemetry could not persist failed events: storage unavailable\");\n }\n return dropped;\n}\n\n// Read the queue and clear it in one step, so a replay that fails again re-persists\n// rather than double-sending on the next launch.\nfunction takeFailed(store: SyncStore): TelemetryEvent[] {\n const read = store.get(FAILED_EVENTS_KEY);\n // Clear on any hit, including a payload that decoded to nothing: a half-written queue\n // is unreplayable, and keying the removal off the decoded length would make it\n // permanent as well — re-read and re-dropped on every launch, forever.\n if (read.status === \"hit\") store.remove(FAILED_EVENTS_KEY);\n return decodeFailed(read);\n}\n\n// fetch({ keepalive: true }) rather than navigator.sendBeacon: the beacon\n// API cannot set the required credential header. keepalive preserves the\n// survives-page-unload property we relied on sendBeacon for. Linear backoff.\nconst post = (endpoint: string, apiKey: string | undefined, events: TelemetryEvent[], retryCount: number) =>\n sendWithRetry(() => fetch(endpoint, {\n method: \"POST\",\n headers: buildHeaders(apiKey),\n body: buildBatch(events),\n keepalive: true,\n }), retryCount, attempt => attempt * 500);\n\nexport function webSender(\n endpoint: string = DEFAULT_ENDPOINT,\n apiKey?: string,\n store: SyncStore = webStore(),\n retryCount: number = 3,\n): Sender {\n return {\n async send(events: TelemetryEvent[]) {\n // Retry + backoff here; persistence on final failure is the core flush()'s\n // job via onFailure() — kept single, so a failed batch isn't persisted twice.\n await post(endpoint, apiKey, events, retryCount);\n },\n async onFailure(events: TelemetryEvent[]) {\n return persistFailed(store, events);\n },\n // Web had no replay hook at all and no caller for its standalone twin, so the\n // queue only ever grew (#113). Same single path as native now: core calls this\n // once per launch from its constructor.\n //\n // No `guardedDrain()` here, unlike native, and the store's SYNC guarantee is\n // exactly why: `takeFailed()` has cleared the key before this function first\n // yields, so a second concurrent caller reads a miss and returns. The race the\n // guard exists for cannot be constructed on a `SyncStore` — and a guard whose\n // bucket is permanently empty is eventually read as one that is working.\n async replayFailed() {\n const stored = takeFailed(store);\n if (stored.length === 0) return;\n debug.log(\"Replaying failed events, count:\", stored.length);\n // One POST per identity, so a prior launch's rows ride that launch's `app` block.\n // A failure re-persists exactly one copy of what is unsent: this path never goes\n // through core's flush(), so onFailure() does not also persist it. A 4xx group is\n // dropped, never kept (§2.5).\n await replayGroups(stored, events => post(endpoint, apiKey, events, retryCount), events => persistFailed(store, events));\n },\n };\n}\n"],"names":["persistFailed","store","events","existing","decodeFailed","FAILED_EVENTS_KEY","json","dropped","encodeFailed","debug","takeFailed","read","post","endpoint","apiKey","retryCount","sendWithRetry","buildHeaders","buildBatch","attempt","webSender","DEFAULT_ENDPOINT","webStore","stored","replayGroups"],"mappings":";;;AAYA,SAASA,EAAcC,GAAkB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 const a = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, n = (e) => typeof e == "string" && e !== "" ? e : void 0;
2
+ function d(e) {
3
+ return n(e.target) ?? n(e.largestShiftTarget) ?? n(e.interactionTarget);
4
+ }
5
+ function c(e) {
6
+ return e === void 0 ? void 0 : e.split("?")[0];
7
+ }
8
+ function p(e) {
9
+ const t = e.attribution ?? {}, s = {
10
+ "vital.rating": e.rating,
11
+ // ⚠ Load-bearing, not decoration: a `back-forward-cache` LCP is ~0 ms and will
12
+ // silently drag a p75 down if the population is not separable.
13
+ "vital.navigation_type": e.navigationType
14
+ }, o = d(t);
15
+ o !== void 0 && (s["vital.target"] = o);
16
+ const l = n(t.loadState);
17
+ l !== void 0 && (s["vital.load_state"] = l);
18
+ const r = (u, i) => {
19
+ i !== void 0 && (s[u] = i);
20
+ };
21
+ switch (e.name) {
22
+ case "LCP":
23
+ r("lcp.time_to_first_byte", a(t.timeToFirstByte)), r("lcp.resource_load_delay", a(t.resourceLoadDelay)), r("lcp.resource_load_duration", a(t.resourceLoadDuration)), r("lcp.element_render_delay", a(t.elementRenderDelay)), r("lcp.url", c(n(t.url)));
24
+ break;
25
+ case "INP":
26
+ r("inp.input_delay", a(t.inputDelay)), r("inp.processing_duration", a(t.processingDuration)), r("inp.presentation_delay", a(t.presentationDelay)), r("inp.interaction_type", n(t.interactionType));
27
+ break;
28
+ case "CLS":
29
+ r("cls.largest_shift_value", a(t.largestShiftValue));
30
+ break;
31
+ }
32
+ return s;
33
+ }
34
+ class h {
35
+ constructor(t) {
36
+ this.telemetry = t, this.held = /* @__PURE__ */ new Map(), this.emitted = /* @__PURE__ */ new Map(), this.started = !1, this.stopped = !1;
37
+ }
38
+ /**
39
+ * Idempotent: a second call must not double-subscribe and double every vital row.
40
+ *
41
+ * LCP, FCP and TTFB fire once on the initial load, so they emit straight from the callback.
42
+ *
43
+ * ⚠ **CLS and INP subscribe with `reportAllChanges: true` as a running-value subscription,
44
+ * not an emission trigger.** The latest value is held in memory and shipped at the
45
+ * `ViewManager`'s background boundary — the library's default page-hide report loses both
46
+ * on a closed tab, because that report races the document's own teardown.
47
+ *
48
+ * ⚠ **All five are page-load-scoped, not view-scoped.** `LCP`, `FCP` and `TTFB` physically
49
+ * cannot recur on a soft navigation, so `view.id` on a vital row is always the *initial*
50
+ * view's. It is a real join key, it is just not "the view this happened in" for CLS and INP:
51
+ * `GROUP BY view.name` over vitals reads **"by entry point"**. Documented, not engineered
52
+ * around — view-scoping would need the Chrome-only Soft Navigations API.
53
+ */
54
+ async start() {
55
+ if (this.started || this.stopped) return;
56
+ this.started = !0;
57
+ const { onLCP: t, onFCP: s, onTTFB: o, onCLS: l, onINP: r } = await import("./web-vitals.attribution-DcoMtvlY.js");
58
+ if (this.stopped) return;
59
+ t((i) => {
60
+ this.emit(i);
61
+ }), s((i) => {
62
+ this.emit(i);
63
+ }), o((i) => {
64
+ this.emit(i);
65
+ });
66
+ const u = (i) => {
67
+ this.held.set(i.name, i);
68
+ };
69
+ l(u, { reportAllChanges: !0 }), r(u, { reportAllChanges: !0 }), this.unsubscribe = this.telemetry.views.onBoundary((i) => i === "resume" ? this.drain() : void 0);
70
+ }
71
+ /**
72
+ * `shutdown()`'s teardown (#160): no boundary may `logMetric` after it. The library's own
73
+ * observers have no detach API, so `emit` is gated instead — a late LCP is dropped too.
74
+ */
75
+ stop() {
76
+ this.stopped = !0, this.unsubscribe?.(), this.held.clear();
77
+ }
78
+ /**
79
+ * Awaited inside `beginView` while the departing view is still current, so the rows carry
80
+ * the view they were accumulated under. A name whose running value has not moved since its
81
+ * last row is skipped — a tab hidden twice with no shifts in between is not two CLS
82
+ * samples, and the library's own report has the same no-delta-no-report property.
83
+ *
84
+ * Keying on `value` alone is exact for both held vitals, not a shortcut: CLS is cumulative,
85
+ * so *any* shift moves it, and INP only changes when a worse interaction happens. An
86
+ * unchanged value therefore means the attribution is unchanged too.
87
+ */
88
+ async drain() {
89
+ for (const [t, s] of this.held)
90
+ this.emitted.get(t) !== s.value && (this.emitted.set(t, s.value), await this.emit(s));
91
+ }
92
+ emit(t) {
93
+ if (!this.stopped)
94
+ return this.telemetry.logMetric(`perf.${t.name.toLowerCase()}`, t.value, p(t));
95
+ }
96
+ }
97
+ export {
98
+ h as WebVitalsTracker
99
+ };
100
+ //# sourceMappingURL=webVitals.web-DRTDK6s5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webVitals.web-DRTDK6s5.js","sources":["../src/adapters/webVitals.ts","../src/adapters/web/webVitals.web.ts"],"sourcesContent":["// §5.3's attribute shaping for the five Core Web Vitals — the pure half, so the rules are\n// unit-tested against plain objects and the `.web.ts` half is left with nothing but the\n// library subscription. Shared-file, but web-only in practice: `TelemetryNative` never\n// imports it, which is what keeps `web-vitals` out of the native bundle entirely.\n\n/** The five names. All are already on `ALLOWED_NAMES`, and all ride the **metric** path. */\nexport type VitalName = \"LCP\" | \"FCP\" | \"CLS\" | \"INP\" | \"TTFB\";\n\n/**\n * Structurally typed against `web-vitals/attribution`'s metric, so this module compiles and\n * tests without the library and cannot pull it into a shared import graph.\n */\nexport type VitalMetric = {\n name: string;\n value: number;\n rating: string;\n navigationType: string;\n // `any`, not `unknown`: `web-vitals`' concrete `LCPAttribution` &c. have no index\n // signature, so a `Record<string, unknown>` here rejects every one of them at the\n // subscription. Everything downstream of this field is read through `num`/`str`.\n attribution?: Record<string, any>;\n};\n\nconst num = (v: unknown): number | undefined =>\n typeof v === \"number\" && Number.isFinite(v) ? v : undefined;\n\nconst str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v !== \"\" ? v : undefined;\n\n/**\n * `vital.target` is the raw CSS selector the library derived — LCP's `target`, CLS's\n * `largestShiftTarget`, INP's `interactionTarget`; **absent on FCP and TTFB**, which have no\n * element.\n *\n * ⚠ §4.6's action-name ladder was rejected for it on the record: the role gate blanks `<img>`,\n * `<h1>` and banners, which is most vital targets, and un-gating the ladder would rebuild the\n * `textContent` hole the gate exists to close. A selector is developer-authored structure —\n * tags, ids, classes — never user content. It is still **the least sanitized key on the wire**,\n * which is the reason `beforeSend` covers metrics at all.\n */\nfunction target(a: Record<string, unknown>): string | undefined {\n return str(a.target) ?? str(a.largestShiftTarget) ?? str(a.interactionTarget);\n}\n\n/**\n * §5.3: `lcp.url` is **query-stripped**, and query-stripped only — the contract is the authority\n * on every wire key's value discipline, and a fragment never leaves the browser anyway.\n */\nfunction stripQuery(url?: string): string | undefined {\n return url === undefined ? undefined : url.split(\"?\")[0];\n}\n\n/**\n * Build a vital row's attribute bag: four shared keys plus the per-vital ones (§5.3).\n *\n * ⚠ **LCP's four phases sum exactly to `value`** — that is the library's own guarantee and a\n * testable claim, which is why `lcp.time_to_first_byte` deliberately duplicates the `TTFB` row\n * rather than forcing a cross-row join to decompose one number.\n *\n * Everything the library did not produce is **omitted**, never nulled: `vital.target` and\n * `vital.load_state` are absent on the vitals that have no element and no load state, and the\n * SDK's absent-means-nothing discipline is what tells that apart from a zero.\n */\nexport function vitalAttributes(m: VitalMetric): Record<string, any> {\n const a: Record<string, unknown> = m.attribution ?? {};\n const out: Record<string, any> = {\n \"vital.rating\": m.rating,\n // ⚠ Load-bearing, not decoration: a `back-forward-cache` LCP is ~0 ms and will\n // silently drag a p75 down if the population is not separable.\n \"vital.navigation_type\": m.navigationType,\n };\n const t = target(a);\n if (t !== undefined) out[\"vital.target\"] = t;\n const load = str(a.loadState);\n if (load !== undefined) out[\"vital.load_state\"] = load;\n\n const put = (key: string, v: number | string | undefined) => {\n if (v !== undefined) out[key] = v;\n };\n\n switch (m.name) {\n case \"LCP\":\n put(\"lcp.time_to_first_byte\", num(a.timeToFirstByte));\n put(\"lcp.resource_load_delay\", num(a.resourceLoadDelay));\n put(\"lcp.resource_load_duration\", num(a.resourceLoadDuration));\n put(\"lcp.element_render_delay\", num(a.elementRenderDelay));\n put(\"lcp.url\", stripQuery(str(a.url)));\n break;\n case \"INP\":\n put(\"inp.input_delay\", num(a.inputDelay));\n put(\"inp.processing_duration\", num(a.processingDuration));\n put(\"inp.presentation_delay\", num(a.presentationDelay));\n put(\"inp.interaction_type\", str(a.interactionType));\n break;\n case \"CLS\":\n put(\"cls.largest_shift_value\", num(a.largestShiftValue));\n break;\n // TTFB and FCP carry no per-vital keys (§5.3).\n }\n return out;\n}\n","// §5.3 / #106 — the five Core Web Vitals, **web only**, on the **metric** path. An event named\n// `LCP` would land its name in the performance-events table and lose its number; the metric\n// path promotes `value` and `unit` for free.\n//\n// `web-vitals/attribution` is a bundled web-only dependency, imported from this `.web.ts` file\n// and nowhere else — that is what keeps it out of `index.native` entirely and means consumers\n// install nothing. Hand-rolling was rejected on session-windowed CLS (the naive sum is wrong\n// *and plausible*) and percentile INP.\n\nimport { vitalAttributes, type VitalMetric } from \"../webVitals\";\nimport type { ViewLoadType } from \"../viewManager\";\n\n/**\n * All this tracker needs of core. Structural, so it is testable without a `Telemetry`.\n */\ntype VitalsEmitter = {\n logMetric(name: string, value: number, data?: Record<string, any>): unknown;\n views: { onBoundary(fn: (successorLoadType: ViewLoadType) => unknown): () => void };\n};\n\nexport class WebVitalsTracker {\n /** The running values, held rather than emitted — see `start()`. */\n private held = new Map<string, VitalMetric>();\n /** What each held name last shipped, so an unchanged value does not re-ship at every hide. */\n private emitted = new Map<string, number>();\n private started = false;\n private stopped = false;\n private unsubscribe?: () => void;\n\n constructor(private telemetry: VitalsEmitter) { }\n\n /**\n * Idempotent: a second call must not double-subscribe and double every vital row.\n *\n * LCP, FCP and TTFB fire once on the initial load, so they emit straight from the callback.\n *\n * ⚠ **CLS and INP subscribe with `reportAllChanges: true` as a running-value subscription,\n * not an emission trigger.** The latest value is held in memory and shipped at the\n * `ViewManager`'s background boundary — the library's default page-hide report loses both\n * on a closed tab, because that report races the document's own teardown.\n *\n * ⚠ **All five are page-load-scoped, not view-scoped.** `LCP`, `FCP` and `TTFB` physically\n * cannot recur on a soft navigation, so `view.id` on a vital row is always the *initial*\n * view's. It is a real join key, it is just not \"the view this happened in\" for CLS and INP:\n * `GROUP BY view.name` over vitals reads **\"by entry point\"**. Documented, not engineered\n * around — view-scoping would need the Chrome-only Soft Navigations API.\n */\n async start(): Promise<void> {\n if (this.started || this.stopped) return;\n this.started = true;\n\n const { onLCP, onFCP, onTTFB, onCLS, onINP } = await import(\"web-vitals/attribution\");\n\n // `shutdown()` may land while the import above is in flight.\n if (this.stopped) return;\n\n onLCP(m => void this.emit(m));\n onFCP(m => void this.emit(m));\n onTTFB(m => void this.emit(m));\n\n const hold = (m: VitalMetric) => { this.held.set(m.name, m); };\n onCLS(hold, { reportAllChanges: true });\n onINP(hold, { reportAllChanges: true });\n\n // `\"resume\"` is the background boundary's successor load type. A route change fires\n // here too and is deliberately ignored: these are page-load-scoped values.\n this.unsubscribe = this.telemetry.views.onBoundary(lt => (lt === \"resume\" ? this.drain() : undefined));\n }\n\n /**\n * `shutdown()`'s teardown (#160): no boundary may `logMetric` after it. The library's own\n * observers have no detach API, so `emit` is gated instead — a late LCP is dropped too.\n */\n stop(): void {\n this.stopped = true;\n this.unsubscribe?.();\n this.held.clear();\n }\n\n /**\n * Awaited inside `beginView` while the departing view is still current, so the rows carry\n * the view they were accumulated under. A name whose running value has not moved since its\n * last row is skipped — a tab hidden twice with no shifts in between is not two CLS\n * samples, and the library's own report has the same no-delta-no-report property.\n *\n * Keying on `value` alone is exact for both held vitals, not a shortcut: CLS is cumulative,\n * so *any* shift moves it, and INP only changes when a worse interaction happens. An\n * unchanged value therefore means the attribution is unchanged too.\n */\n private async drain(): Promise<void> {\n for (const [name, m] of this.held) {\n if (this.emitted.get(name) === m.value) continue;\n this.emitted.set(name, m.value);\n await this.emit(m);\n }\n }\n\n private emit(m: VitalMetric): unknown {\n if (this.stopped) return;\n // `metric.unit` is stamped by core's METRIC_UNIT map — `ms` for four of them and\n // **`score` for CLS**, without which a 0.08 renders as a flat zero line beside an\n // LCP of 4000 in the same `value` column.\n return this.telemetry.logMetric(`perf.${m.name.toLowerCase()}`, m.value, vitalAttributes(m));\n }\n}\n"],"names":["num","v","str","target","a","stripQuery","url","vitalAttributes","m","out","t","load","put","key","WebVitalsTracker","telemetry","onLCP","onFCP","onTTFB","onCLS","onINP","hold","lt","name"],"mappings":"AAuBA,MAAMA,IAAM,CAACC,MACT,OAAOA,KAAM,YAAY,OAAO,SAASA,CAAC,IAAIA,IAAI,QAEhDC,IAAM,CAACD,MACT,OAAOA,KAAM,YAAYA,MAAM,KAAKA,IAAI;AAa5C,SAASE,EAAOC,GAAgD;AAC5D,SAAOF,EAAIE,EAAE,MAAM,KAAKF,EAAIE,EAAE,kBAAkB,KAAKF,EAAIE,EAAE,iBAAiB;AAChF;AAMA,SAASC,EAAWC,GAAkC;AAClD,SAAOA,MAAQ,SAAY,SAAYA,EAAI,MAAM,GAAG,EAAE,CAAC;AAC3D;AAaO,SAASC,EAAgBC,GAAqC;AACjE,QAAMJ,IAA6BI,EAAE,eAAe,CAAA,GAC9CC,IAA2B;AAAA,IAC7B,gBAAgBD,EAAE;AAAA;AAAA;AAAA,IAGlB,yBAAyBA,EAAE;AAAA,EAAA,GAEzBE,IAAIP,EAAOC,CAAC;AAClB,EAAIM,MAAM,WAAWD,EAAI,cAAc,IAAIC;AAC3C,QAAMC,IAAOT,EAAIE,EAAE,SAAS;AAC5B,EAAIO,MAAS,WAAWF,EAAI,kBAAkB,IAAIE;AAElD,QAAMC,IAAM,CAACC,GAAaZ,MAAmC;AACzD,IAAIA,MAAM,WAAWQ,EAAII,CAAG,IAAIZ;AAAA,EACpC;AAEA,UAAQO,EAAE,MAAA;AAAA,IACN,KAAK;AACD,MAAAI,EAAI,0BAA0BZ,EAAII,EAAE,eAAe,CAAC,GACpDQ,EAAI,2BAA2BZ,EAAII,EAAE,iBAAiB,CAAC,GACvDQ,EAAI,8BAA8BZ,EAAII,EAAE,oBAAoB,CAAC,GAC7DQ,EAAI,4BAA4BZ,EAAII,EAAE,kBAAkB,CAAC,GACzDQ,EAAI,WAAWP,EAAWH,EAAIE,EAAE,GAAG,CAAC,CAAC;AACrC;AAAA,IACJ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,GAItC,KAAK,cAAc,KAAK,UAAU,MAAM,WAAW,CAAAC,MAAOA,MAAO,WAAW,KAAK,MAAA,IAAU,MAAU;AAAA,EACzG;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAa;AACT,SAAK,UAAU,IACf,KAAK,cAAA,GACL,KAAK,KAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAc,QAAuB;AACjC,eAAW,CAACC,GAAMf,CAAC,KAAK,KAAK;AACzB,MAAI,KAAK,QAAQ,IAAIe,CAAI,MAAMf,EAAE,UACjC,KAAK,QAAQ,IAAIe,GAAMf,EAAE,KAAK,GAC9B,MAAM,KAAK,KAAKA,CAAC;AAAA,EAEzB;AAAA,EAEQ,KAAKA,GAAyB;AAClC,QAAI,MAAK;AAIT,aAAO,KAAK,UAAU,UAAU,QAAQA,EAAE,KAAK,YAAA,CAAa,IAAIA,EAAE,OAAOD,EAAgBC,CAAC,CAAC;AAAA,EAC/F;AACJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,n=e=>typeof e=="string"&&e!==""?e:void 0;function d(e){return n(e.target)??n(e.largestShiftTarget)??n(e.interactionTarget)}function c(e){return e===void 0?void 0:e.split("?")[0]}function p(e){const t=e.attribution??{},s={"vital.rating":e.rating,"vital.navigation_type":e.navigationType},o=d(t);o!==void 0&&(s["vital.target"]=o);const l=n(t.loadState);l!==void 0&&(s["vital.load_state"]=l);const r=(u,i)=>{i!==void 0&&(s[u]=i)};switch(e.name){case"LCP":r("lcp.time_to_first_byte",a(t.timeToFirstByte)),r("lcp.resource_load_delay",a(t.resourceLoadDelay)),r("lcp.resource_load_duration",a(t.resourceLoadDuration)),r("lcp.element_render_delay",a(t.elementRenderDelay)),r("lcp.url",c(n(t.url)));break;case"INP":r("inp.input_delay",a(t.inputDelay)),r("inp.processing_duration",a(t.processingDuration)),r("inp.presentation_delay",a(t.presentationDelay)),r("inp.interaction_type",n(t.interactionType));break;case"CLS":r("cls.largest_shift_value",a(t.largestShiftValue));break}return s}class h{constructor(t){this.telemetry=t,this.held=new Map,this.emitted=new Map,this.started=!1,this.stopped=!1}async start(){if(this.started||this.stopped)return;this.started=!0;const{onLCP:t,onFCP:s,onTTFB:o,onCLS:l,onINP:r}=await Promise.resolve().then(()=>require("./web-vitals.attribution-DAvBvdng.cjs"));if(this.stopped)return;t(i=>{this.emit(i)}),s(i=>{this.emit(i)}),o(i=>{this.emit(i)});const u=i=>{this.held.set(i.name,i)};l(u,{reportAllChanges:!0}),r(u,{reportAllChanges:!0}),this.unsubscribe=this.telemetry.views.onBoundary(i=>i==="resume"?this.drain():void 0)}stop(){this.stopped=!0,this.unsubscribe?.(),this.held.clear()}async drain(){for(const[t,s]of this.held)this.emitted.get(t)!==s.value&&(this.emitted.set(t,s.value),await this.emit(s))}emit(t){if(!this.stopped)return this.telemetry.logMetric(`perf.${t.name.toLowerCase()}`,t.value,p(t))}}exports.WebVitalsTracker=h;
2
+ //# sourceMappingURL=webVitals.web-DvScDIjX.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webVitals.web-DvScDIjX.cjs","sources":["../src/adapters/webVitals.ts","../src/adapters/web/webVitals.web.ts"],"sourcesContent":["// §5.3's attribute shaping for the five Core Web Vitals — the pure half, so the rules are\n// unit-tested against plain objects and the `.web.ts` half is left with nothing but the\n// library subscription. Shared-file, but web-only in practice: `TelemetryNative` never\n// imports it, which is what keeps `web-vitals` out of the native bundle entirely.\n\n/** The five names. All are already on `ALLOWED_NAMES`, and all ride the **metric** path. */\nexport type VitalName = \"LCP\" | \"FCP\" | \"CLS\" | \"INP\" | \"TTFB\";\n\n/**\n * Structurally typed against `web-vitals/attribution`'s metric, so this module compiles and\n * tests without the library and cannot pull it into a shared import graph.\n */\nexport type VitalMetric = {\n name: string;\n value: number;\n rating: string;\n navigationType: string;\n // `any`, not `unknown`: `web-vitals`' concrete `LCPAttribution` &c. have no index\n // signature, so a `Record<string, unknown>` here rejects every one of them at the\n // subscription. Everything downstream of this field is read through `num`/`str`.\n attribution?: Record<string, any>;\n};\n\nconst num = (v: unknown): number | undefined =>\n typeof v === \"number\" && Number.isFinite(v) ? v : undefined;\n\nconst str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v !== \"\" ? v : undefined;\n\n/**\n * `vital.target` is the raw CSS selector the library derived — LCP's `target`, CLS's\n * `largestShiftTarget`, INP's `interactionTarget`; **absent on FCP and TTFB**, which have no\n * element.\n *\n * ⚠ §4.6's action-name ladder was rejected for it on the record: the role gate blanks `<img>`,\n * `<h1>` and banners, which is most vital targets, and un-gating the ladder would rebuild the\n * `textContent` hole the gate exists to close. A selector is developer-authored structure —\n * tags, ids, classes — never user content. It is still **the least sanitized key on the wire**,\n * which is the reason `beforeSend` covers metrics at all.\n */\nfunction target(a: Record<string, unknown>): string | undefined {\n return str(a.target) ?? str(a.largestShiftTarget) ?? str(a.interactionTarget);\n}\n\n/**\n * §5.3: `lcp.url` is **query-stripped**, and query-stripped only — the contract is the authority\n * on every wire key's value discipline, and a fragment never leaves the browser anyway.\n */\nfunction stripQuery(url?: string): string | undefined {\n return url === undefined ? undefined : url.split(\"?\")[0];\n}\n\n/**\n * Build a vital row's attribute bag: four shared keys plus the per-vital ones (§5.3).\n *\n * ⚠ **LCP's four phases sum exactly to `value`** — that is the library's own guarantee and a\n * testable claim, which is why `lcp.time_to_first_byte` deliberately duplicates the `TTFB` row\n * rather than forcing a cross-row join to decompose one number.\n *\n * Everything the library did not produce is **omitted**, never nulled: `vital.target` and\n * `vital.load_state` are absent on the vitals that have no element and no load state, and the\n * SDK's absent-means-nothing discipline is what tells that apart from a zero.\n */\nexport function vitalAttributes(m: VitalMetric): Record<string, any> {\n const a: Record<string, unknown> = m.attribution ?? {};\n const out: Record<string, any> = {\n \"vital.rating\": m.rating,\n // ⚠ Load-bearing, not decoration: a `back-forward-cache` LCP is ~0 ms and will\n // silently drag a p75 down if the population is not separable.\n \"vital.navigation_type\": m.navigationType,\n };\n const t = target(a);\n if (t !== undefined) out[\"vital.target\"] = t;\n const load = str(a.loadState);\n if (load !== undefined) out[\"vital.load_state\"] = load;\n\n const put = (key: string, v: number | string | undefined) => {\n if (v !== undefined) out[key] = v;\n };\n\n switch (m.name) {\n case \"LCP\":\n put(\"lcp.time_to_first_byte\", num(a.timeToFirstByte));\n put(\"lcp.resource_load_delay\", num(a.resourceLoadDelay));\n put(\"lcp.resource_load_duration\", num(a.resourceLoadDuration));\n put(\"lcp.element_render_delay\", num(a.elementRenderDelay));\n put(\"lcp.url\", stripQuery(str(a.url)));\n break;\n case \"INP\":\n put(\"inp.input_delay\", num(a.inputDelay));\n put(\"inp.processing_duration\", num(a.processingDuration));\n put(\"inp.presentation_delay\", num(a.presentationDelay));\n put(\"inp.interaction_type\", str(a.interactionType));\n break;\n case \"CLS\":\n put(\"cls.largest_shift_value\", num(a.largestShiftValue));\n break;\n // TTFB and FCP carry no per-vital keys (§5.3).\n }\n return out;\n}\n","// §5.3 / #106 — the five Core Web Vitals, **web only**, on the **metric** path. An event named\n// `LCP` would land its name in the performance-events table and lose its number; the metric\n// path promotes `value` and `unit` for free.\n//\n// `web-vitals/attribution` is a bundled web-only dependency, imported from this `.web.ts` file\n// and nowhere else — that is what keeps it out of `index.native` entirely and means consumers\n// install nothing. Hand-rolling was rejected on session-windowed CLS (the naive sum is wrong\n// *and plausible*) and percentile INP.\n\nimport { vitalAttributes, type VitalMetric } from \"../webVitals\";\nimport type { ViewLoadType } from \"../viewManager\";\n\n/**\n * All this tracker needs of core. Structural, so it is testable without a `Telemetry`.\n */\ntype VitalsEmitter = {\n logMetric(name: string, value: number, data?: Record<string, any>): unknown;\n views: { onBoundary(fn: (successorLoadType: ViewLoadType) => unknown): () => void };\n};\n\nexport class WebVitalsTracker {\n /** The running values, held rather than emitted — see `start()`. */\n private held = new Map<string, VitalMetric>();\n /** What each held name last shipped, so an unchanged value does not re-ship at every hide. */\n private emitted = new Map<string, number>();\n private started = false;\n private stopped = false;\n private unsubscribe?: () => void;\n\n constructor(private telemetry: VitalsEmitter) { }\n\n /**\n * Idempotent: a second call must not double-subscribe and double every vital row.\n *\n * LCP, FCP and TTFB fire once on the initial load, so they emit straight from the callback.\n *\n * ⚠ **CLS and INP subscribe with `reportAllChanges: true` as a running-value subscription,\n * not an emission trigger.** The latest value is held in memory and shipped at the\n * `ViewManager`'s background boundary — the library's default page-hide report loses both\n * on a closed tab, because that report races the document's own teardown.\n *\n * ⚠ **All five are page-load-scoped, not view-scoped.** `LCP`, `FCP` and `TTFB` physically\n * cannot recur on a soft navigation, so `view.id` on a vital row is always the *initial*\n * view's. It is a real join key, it is just not \"the view this happened in\" for CLS and INP:\n * `GROUP BY view.name` over vitals reads **\"by entry point\"**. Documented, not engineered\n * around — view-scoping would need the Chrome-only Soft Navigations API.\n */\n async start(): Promise<void> {\n if (this.started || this.stopped) return;\n this.started = true;\n\n const { onLCP, onFCP, onTTFB, onCLS, onINP } = await import(\"web-vitals/attribution\");\n\n // `shutdown()` may land while the import above is in flight.\n if (this.stopped) return;\n\n onLCP(m => void this.emit(m));\n onFCP(m => void this.emit(m));\n onTTFB(m => void this.emit(m));\n\n const hold = (m: VitalMetric) => { this.held.set(m.name, m); };\n onCLS(hold, { reportAllChanges: true });\n onINP(hold, { reportAllChanges: true });\n\n // `\"resume\"` is the background boundary's successor load type. A route change fires\n // here too and is deliberately ignored: these are page-load-scoped values.\n this.unsubscribe = this.telemetry.views.onBoundary(lt => (lt === \"resume\" ? this.drain() : undefined));\n }\n\n /**\n * `shutdown()`'s teardown (#160): no boundary may `logMetric` after it. The library's own\n * observers have no detach API, so `emit` is gated instead — a late LCP is dropped too.\n */\n stop(): void {\n this.stopped = true;\n this.unsubscribe?.();\n this.held.clear();\n }\n\n /**\n * Awaited inside `beginView` while the departing view is still current, so the rows carry\n * the view they were accumulated under. A name whose running value has not moved since its\n * last row is skipped — a tab hidden twice with no shifts in between is not two CLS\n * samples, and the library's own report has the same no-delta-no-report property.\n *\n * Keying on `value` alone is exact for both held vitals, not a shortcut: CLS is cumulative,\n * so *any* shift moves it, and INP only changes when a worse interaction happens. An\n * unchanged value therefore means the attribution is unchanged too.\n */\n private async drain(): Promise<void> {\n for (const [name, m] of this.held) {\n if (this.emitted.get(name) === m.value) continue;\n this.emitted.set(name, m.value);\n await this.emit(m);\n }\n }\n\n private emit(m: VitalMetric): unknown {\n if (this.stopped) return;\n // `metric.unit` is stamped by core's METRIC_UNIT map — `ms` for four of them and\n // **`score` for CLS**, without which a 0.08 renders as a flat zero line beside an\n // LCP of 4000 in the same `value` column.\n return this.telemetry.logMetric(`perf.${m.name.toLowerCase()}`, m.value, vitalAttributes(m));\n }\n}\n"],"names":["num","v","str","target","a","stripQuery","url","vitalAttributes","m","out","t","load","put","key","WebVitalsTracker","telemetry","onLCP","onFCP","onTTFB","onCLS","onINP","hold","lt","name"],"mappings":"gFAuBA,MAAMA,EAAOC,GACT,OAAOA,GAAM,UAAY,OAAO,SAASA,CAAC,EAAIA,EAAI,OAEhDC,EAAOD,GACT,OAAOA,GAAM,UAAYA,IAAM,GAAKA,EAAI,OAa5C,SAASE,EAAOC,EAAgD,CAC5D,OAAOF,EAAIE,EAAE,MAAM,GAAKF,EAAIE,EAAE,kBAAkB,GAAKF,EAAIE,EAAE,iBAAiB,CAChF,CAMA,SAASC,EAAWC,EAAkC,CAClD,OAAOA,IAAQ,OAAY,OAAYA,EAAI,MAAM,GAAG,EAAE,CAAC,CAC3D,CAaO,SAASC,EAAgBC,EAAqC,CACjE,MAAMJ,EAA6BI,EAAE,aAAe,CAAA,EAC9CC,EAA2B,CAC7B,eAAgBD,EAAE,OAGlB,wBAAyBA,EAAE,cAAA,EAEzBE,EAAIP,EAAOC,CAAC,EACdM,IAAM,SAAWD,EAAI,cAAc,EAAIC,GAC3C,MAAMC,EAAOT,EAAIE,EAAE,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U,KAAK,KAAKA,CAAC,EAAC,EAC5BU,EAAOV,GAAA,CAAU,KAAK,KAAKA,CAAC,EAAC,EAE7B,MAAMa,EAAQb,GAAmB,CAAE,KAAK,KAAK,IAAIA,EAAE,KAAMA,CAAC,CAAG,EAC7DW,EAAME,EAAM,CAAE,iBAAkB,EAAA,CAAM,EACtCD,EAAMC,EAAM,CAAE,iBAAkB,EAAA,CAAM,EAItC,KAAK,YAAc,KAAK,UAAU,MAAM,WAAWC,GAAOA,IAAO,SAAW,KAAK,MAAA,EAAU,MAAU,CACzG,CAMA,MAAa,CACT,KAAK,QAAU,GACf,KAAK,cAAA,EACL,KAAK,KAAK,MAAA,CACd,CAYA,MAAc,OAAuB,CACjC,SAAW,CAACC,EAAMf,CAAC,IAAK,KAAK,KACrB,KAAK,QAAQ,IAAIe,CAAI,IAAMf,EAAE,QACjC,KAAK,QAAQ,IAAIe,EAAMf,EAAE,KAAK,EAC9B,MAAM,KAAK,KAAKA,CAAC,EAEzB,CAEQ,KAAKA,EAAyB,CAClC,GAAI,MAAK,QAIT,OAAO,KAAK,UAAU,UAAU,QAAQA,EAAE,KAAK,YAAA,CAAa,GAAIA,EAAE,MAAOD,EAAgBC,CAAC,CAAC,CAC/F,CACJ"}
@@ -0,0 +1,55 @@
1
+ import { i as d, b as c, c as h } from "./httpAttributes-BWXOr4eP.js";
2
+ import { g as l } from "./react-urNtDGTL.js";
3
+ const a = "__edgeTelemetryXhrPatched";
4
+ function f(r, s) {
5
+ if (s[a]) return () => {
6
+ };
7
+ const p = s.prototype.open, i = s.prototype.send, n = s.prototype.setRequestHeader;
8
+ return s.prototype.open = function(o, t) {
9
+ return this._telemetryRequest?.settled?.(), this._telemetryRequest = { method: o, url: String(t), start: 0 }, p.apply(this, arguments);
10
+ }, n && (s.prototype.setRequestHeader = function(o, t) {
11
+ return this._telemetryRequest && String(o).toLowerCase() === l && (this._telemetryRequest.consumerTraceparent = t), n.apply(this, arguments);
12
+ }), s.prototype.send = function(o) {
13
+ const t = this._telemetryRequest;
14
+ if (!t) return i.apply(this, arguments);
15
+ if (r.isEnabled?.() === !1)
16
+ return this._telemetryRequest = void 0, i.apply(this, arguments);
17
+ if (t.start = Date.now(), t.body = o, !d(t.url, r.getEndpoint?.())) {
18
+ t.settled = r.views.requestStarted(t.start), t.snap = r.snapshot();
19
+ const e = r.trace.requestTrace(t.start, {
20
+ url: t.url,
21
+ sampled: r.isSampled(),
22
+ consumerTraceparent: t.consumerTraceparent
23
+ });
24
+ t.span = e.finish, t.discardRoot = e.discard, e.header && n && n.call(this, l, e.header);
25
+ }
26
+ this._telemetryListening || (this._telemetryListening = !0, this.addEventListener("loadend", () => {
27
+ const e = this._telemetryRequest;
28
+ if (!e || (e.settled?.(), d(e.url, r.getEndpoint?.()))) return;
29
+ const u = Date.now();
30
+ r.log("http.request", {
31
+ ...c({
32
+ url: e.url,
33
+ method: e.method,
34
+ statusCode: this.status,
35
+ durationMs: u - e.start,
36
+ error: this.status === 0 ? "Network error" : null,
37
+ requestBody: e.body,
38
+ responseSize: h(this.getResponseHeader?.("content-length"))
39
+ }),
40
+ ...e.span?.(u)
41
+ }, e.snap);
42
+ }));
43
+ try {
44
+ return i.apply(this, arguments);
45
+ } catch (e) {
46
+ throw t.settled?.(), t.discardRoot?.(), e;
47
+ }
48
+ }, s[a] = !0, () => {
49
+ s.prototype.open = p, s.prototype.send = i, n && (s.prototype.setRequestHeader = n), delete s[a];
50
+ };
51
+ }
52
+ export {
53
+ f as p
54
+ };
55
+ //# sourceMappingURL=xhrIntercept-9uAkQh3N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xhrIntercept-9uAkQh3N.js","sources":["../src/adapters/xhrIntercept.ts"],"sourcesContent":["import { Telemetry } from \"../core/telemetry\";\nimport type { LogSnapshot } from \"../core/telemetry\";\nimport { buildHttpAttributes, contentLengthSize, isCollectorUrl } from \"./httpAttributes\";\nimport type { TraceAttributes } from \"./traceManager\";\nimport { TRACEPARENT } from \"./traceHeader\";\n\n// Double-patching is the exact defect #95 exists to kill: two patches mean two `loadend`\n// listeners and two `http.request` events per call. `trackNetworkRequests()` is public and the\n// entry ctors already call it once, so a second call must be a no-op. The flag rides the\n// constructor, not the prototype, so it never leaks onto an instance.\nconst PATCHED = \"__edgeTelemetryXhrPatched\";\n\ninterface PendingRequest {\n method: string;\n url: string;\n start: number;\n body?: unknown;\n /**\n * Closes this request's contribution to §4.5.2's network settle. Bound at `send()` to the\n * view that was live *then*, so a response landing after a route change belongs to the view\n * it started in and does not hold the arriving one open.\n */\n settled?: (endedAt?: number) => void;\n /**\n * §6.3's Tier 1 keys, captured at `send()` so the parent is the root live *then* and\n * `span.start_time` is the send. Called at `loadend` to stamp `span.duration_ms` off\n * the same pair of timestamps `http.duration_ms` uses.\n */\n span?: (endedAt: number) => TraceAttributes;\n /** Drops the `request` root this send minted — only for a synchronous `send()` throw. */\n discardRoot?: () => void;\n /**\n * §6.4's ownership flag: the consumer's own `traceparent`, recorded **at their write\n * time** in the `setRequestHeader` patch. Never inferred from the value's shape — an\n * SDK-minted and a consumer-minted header are byte-identical by construction — and reset\n * by `open()`, which per spec clears the author request headers anyway.\n */\n consumerTraceparent?: string;\n /**\n * §3.1's attribution freeze: `session.id`, `session.start_time` and `view.id` as they\n * were at `send()`. The 4-hour cap can rotate a session *while this request is in\n * flight*, which would otherwise put S1's trace on an S2 row. No `at` — the row still\n * reports its completion timestamp (§4.4).\n */\n snap?: LogSnapshot;\n}\n\ninterface PatchedXhr extends XMLHttpRequest {\n _telemetryRequest?: PendingRequest;\n _telemetryListening?: boolean;\n}\n\ntype XhrCtor = { prototype: PatchedXhr; [PATCHED]?: boolean };\n\n/**\n * Patches an `XMLHttpRequest` prototype so every completed request emits one `http.request`.\n * Shared because the native build is XHR-*only* (§4.4: RN's `global.fetch` is XHR underneath,\n * so patching both emits two events per call) while the web build patches XHR alongside its\n * own `fetch` patch — same emit rules, two different sets of callers.\n *\n * @returns the unpatch, so `stop()` can restore the prototype.\n */\nexport function patchXHR(telemetry: Telemetry, xhr: XhrCtor): () => void {\n if (xhr[PATCHED]) return () => { };\n\n const origOpen = xhr.prototype.open;\n const origSend = xhr.prototype.send;\n // May legitimately be absent on a minimal XHR polyfill; when it is, there is no way to\n // observe a consumer header and no way to write ours, so tracing simply stays dark.\n const origSetRequestHeader = xhr.prototype.setRequestHeader;\n\n // `arguments` is forwarded verbatim on both hooks: the SDK reports on the request, it never\n // reshapes the one it passes on. That is the only reason for the two casts in this file.\n xhr.prototype.open = function (this: PatchedXhr, method: string, url: string | URL) {\n // An XHR may be legally re-opened before the previous request finished — and the old\n // PendingRequest is about to be dropped. Release its settle hold first, or the view it\n // started in can never go quiet and reports `abandoned` for the rest of its life.\n this._telemetryRequest?.settled?.();\n this._telemetryRequest = { method, url: String(url), start: 0 };\n return origOpen.apply(this, arguments as any);\n };\n\n if (origSetRequestHeader) {\n xhr.prototype.setRequestHeader = function (this: PatchedXhr, name: string, value: string) {\n // Read-scope (§6.4): **exactly one header name, for exactly one purpose** — a\n // presence check. Names are compared case-insensitively; no other header is\n // inspected, logged or forwarded, and this one is passed straight through.\n if (this._telemetryRequest && String(name).toLowerCase() === TRACEPARENT) {\n this._telemetryRequest.consumerTraceparent = value;\n }\n return origSetRequestHeader.apply(this, arguments as any);\n };\n }\n\n xhr.prototype.send = function (this: PatchedXhr, body?: Document | XMLHttpRequestBodyInit | null) {\n const req = this._telemetryRequest;\n if (!req) return origSend.apply(this, arguments as any); // send() without open() — let it throw its own way\n // Disabled (#172): pass through untouched — no settle hold, no root, no header.\n if (telemetry.isEnabled?.() === false) { this._telemetryRequest = undefined; return origSend.apply(this, arguments as any); }\n req.start = Date.now();\n req.body = body;\n // The collector's own POST is out of scope for settle exactly as it is for\n // `http.request` — checked here as well as at loadend, because the view must not be\n // held open by the SDK's own traffic (§4.5.2).\n if (!isCollectorUrl(req.url, telemetry.getEndpoint?.())) {\n req.settled = telemetry.views.requestStarted(req.start);\n req.snap = telemetry.snapshot();\n // Mints a `request` root when nothing is live, and extends the live one otherwise\n // (§6.2), and resolves §6.5's outcome ladder. Same gate as settle: the SDK's own\n // POST neither holds a view open, starts an action, nor carries an outcome.\n // No `noCors` — `mode` is a fetch concept XHR cannot express, so `skipped_no_cors`\n // needs no platform branch to stay fetch-only.\n const trace = telemetry.trace.requestTrace(req.start, {\n url: req.url,\n sampled: telemetry.isSampled(),\n consumerTraceparent: req.consumerTraceparent,\n });\n req.span = trace.finish;\n req.discardRoot = trace.discard;\n // Written through the *original*, so our own write can never be misread as the\n // consumer's on a later inspection — and only ever when their flag is unset, so\n // there is no SDK-owned header for never-strip to have to protect.\n if (trace.header && origSetRequestHeader) {\n origSetRequestHeader.call(this, TRACEPARENT, trace.header);\n }\n }\n\n // One listener per *instance*, not per send: an XHR may be legally reused, and adding\n // a listener on every send() would emit N events on the Nth one. The handler reads\n // `_telemetryRequest` at fire time, so one listener serves every reuse.\n if (!this._telemetryListening) {\n this._telemetryListening = true;\n this.addEventListener(\"loadend\", () => {\n const done = this._telemetryRequest;\n if (!done) return;\n done.settled?.();\n // Invariant: an http.request never describes the SDK's own collector POST.\n if (isCollectorUrl(done.url, telemetry.getEndpoint?.())) return;\n\n const end = Date.now();\n telemetry.log(\"http.request\", {\n ...buildHttpAttributes({\n url: done.url,\n method: done.method,\n statusCode: this.status,\n durationMs: end - done.start,\n error: this.status === 0 ? \"Network error\" : null,\n requestBody: done.body,\n responseSize: contentLengthSize(this.getResponseHeader?.(\"content-length\")),\n }),\n ...done.span?.(end),\n }, done.snap);\n });\n }\n\n try {\n return origSend.apply(this, arguments as any);\n } catch (err) {\n // A send() that throws never reaches `loadend`, so nothing else would ever close\n // this hold. The fetch half gets this from its `finally`; XHR needs it spelled out.\n req.settled?.();\n // …and nothing would ever describe a root it minted (#160): the next request must\n // mint its own rather than join an action that never happened.\n req.discardRoot?.();\n throw err;\n }\n };\n\n xhr[PATCHED] = true;\n return () => {\n xhr.prototype.open = origOpen;\n xhr.prototype.send = origSend;\n if (origSetRequestHeader) xhr.prototype.setRequestHeader = origSetRequestHeader;\n delete xhr[PATCHED];\n };\n}\n"],"names":["PATCHED","patchXHR","telemetry","xhr","origOpen","origSend","origSetRequestHeader","method","url","name","value","TRACEPARENT","body","req","isCollectorUrl","trace","done","end","buildHttpAttributes","contentLengthSize","err"],"mappings":";;AAUA,MAAMA,IAAU;AAoDT,SAASC,EAASC,GAAsBC,GAA0B;AACrE,MAAIA,EAAIH,CAAO,EAAG,QAAO,MAAM;AAAA,EAAE;AAEjC,QAAMI,IAAWD,EAAI,UAAU,MACzBE,IAAWF,EAAI,UAAU,MAGzBG,IAAuBH,EAAI,UAAU;AAI3C,SAAAA,EAAI,UAAU,OAAO,SAA4BI,GAAgBC,GAAmB;AAIhF,gBAAK,mBAAmB,UAAA,GACxB,KAAK,oBAAoB,EAAE,QAAAD,GAAQ,KAAK,OAAOC,CAAG,GAAG,OAAO,EAAA,GACrDJ,EAAS,MAAM,MAAM,SAAgB;AAAA,EAChD,GAEIE,MACAH,EAAI,UAAU,mBAAmB,SAA4BM,GAAcC,GAAe;AAItF,WAAI,KAAK,qBAAqB,OAAOD,CAAI,EAAE,YAAA,MAAkBE,MACzD,KAAK,kBAAkB,sBAAsBD,IAE1CJ,EAAqB,MAAM,MAAM,SAAgB;AAAA,EAC5D,IAGJH,EAAI,UAAU,OAAO,SAA4BS,GAAiD;AAC9F,UAAMC,IAAM,KAAK;AACjB,QAAI,CAACA,EAAK,QAAOR,EAAS,MAAM,MAAM,SAAgB;AAEtD,QAAIH,EAAU,YAAA,MAAkB;AAAS,kBAAK,oBAAoB,QAAkBG,EAAS,MAAM,MAAM,SAAgB;AAMzH,QALAQ,EAAI,QAAQ,KAAK,IAAA,GACjBA,EAAI,OAAOD,GAIP,CAACE,EAAeD,EAAI,KAAKX,EAAU,cAAA,CAAe,GAAG;AACrD,MAAAW,EAAI,UAAUX,EAAU,MAAM,eAAeW,EAAI,KAAK,GACtDA,EAAI,OAAOX,EAAU,SAAA;AAMrB,YAA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@ -0,0 +1,2 @@
1
+ "use strict";const a=require("./httpAttributes-COY0_kiF.cjs"),c=require("./react-bqe7KPOf.cjs"),u="__edgeTelemetryXhrPatched";function l(r,s){if(s[u])return()=>{};const p=s.prototype.open,i=s.prototype.send,n=s.prototype.setRequestHeader;return s.prototype.open=function(o,t){return this._telemetryRequest?.settled?.(),this._telemetryRequest={method:o,url:String(t),start:0},p.apply(this,arguments)},n&&(s.prototype.setRequestHeader=function(o,t){return this._telemetryRequest&&String(o).toLowerCase()===c.TRACEPARENT&&(this._telemetryRequest.consumerTraceparent=t),n.apply(this,arguments)}),s.prototype.send=function(o){const t=this._telemetryRequest;if(!t)return i.apply(this,arguments);if(r.isEnabled?.()===!1)return this._telemetryRequest=void 0,i.apply(this,arguments);if(t.start=Date.now(),t.body=o,!a.isCollectorUrl(t.url,r.getEndpoint?.())){t.settled=r.views.requestStarted(t.start),t.snap=r.snapshot();const e=r.trace.requestTrace(t.start,{url:t.url,sampled:r.isSampled(),consumerTraceparent:t.consumerTraceparent});t.span=e.finish,t.discardRoot=e.discard,e.header&&n&&n.call(this,c.TRACEPARENT,e.header)}this._telemetryListening||(this._telemetryListening=!0,this.addEventListener("loadend",()=>{const e=this._telemetryRequest;if(!e||(e.settled?.(),a.isCollectorUrl(e.url,r.getEndpoint?.())))return;const d=Date.now();r.log("http.request",{...a.buildHttpAttributes({url:e.url,method:e.method,statusCode:this.status,durationMs:d-e.start,error:this.status===0?"Network error":null,requestBody:e.body,responseSize:a.contentLengthSize(this.getResponseHeader?.("content-length"))}),...e.span?.(d)},e.snap)}));try{return i.apply(this,arguments)}catch(e){throw t.settled?.(),t.discardRoot?.(),e}},s[u]=!0,()=>{s.prototype.open=p,s.prototype.send=i,n&&(s.prototype.setRequestHeader=n),delete s[u]}}exports.patchXHR=l;
2
+ //# sourceMappingURL=xhrIntercept-xG1Yl5RI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xhrIntercept-xG1Yl5RI.cjs","sources":["../src/adapters/xhrIntercept.ts"],"sourcesContent":["import { Telemetry } from \"../core/telemetry\";\nimport type { LogSnapshot } from \"../core/telemetry\";\nimport { buildHttpAttributes, contentLengthSize, isCollectorUrl } from \"./httpAttributes\";\nimport type { TraceAttributes } from \"./traceManager\";\nimport { TRACEPARENT } from \"./traceHeader\";\n\n// Double-patching is the exact defect #95 exists to kill: two patches mean two `loadend`\n// listeners and two `http.request` events per call. `trackNetworkRequests()` is public and the\n// entry ctors already call it once, so a second call must be a no-op. The flag rides the\n// constructor, not the prototype, so it never leaks onto an instance.\nconst PATCHED = \"__edgeTelemetryXhrPatched\";\n\ninterface PendingRequest {\n method: string;\n url: string;\n start: number;\n body?: unknown;\n /**\n * Closes this request's contribution to §4.5.2's network settle. Bound at `send()` to the\n * view that was live *then*, so a response landing after a route change belongs to the view\n * it started in and does not hold the arriving one open.\n */\n settled?: (endedAt?: number) => void;\n /**\n * §6.3's Tier 1 keys, captured at `send()` so the parent is the root live *then* and\n * `span.start_time` is the send. Called at `loadend` to stamp `span.duration_ms` off\n * the same pair of timestamps `http.duration_ms` uses.\n */\n span?: (endedAt: number) => TraceAttributes;\n /** Drops the `request` root this send minted — only for a synchronous `send()` throw. */\n discardRoot?: () => void;\n /**\n * §6.4's ownership flag: the consumer's own `traceparent`, recorded **at their write\n * time** in the `setRequestHeader` patch. Never inferred from the value's shape — an\n * SDK-minted and a consumer-minted header are byte-identical by construction — and reset\n * by `open()`, which per spec clears the author request headers anyway.\n */\n consumerTraceparent?: string;\n /**\n * §3.1's attribution freeze: `session.id`, `session.start_time` and `view.id` as they\n * were at `send()`. The 4-hour cap can rotate a session *while this request is in\n * flight*, which would otherwise put S1's trace on an S2 row. No `at` — the row still\n * reports its completion timestamp (§4.4).\n */\n snap?: LogSnapshot;\n}\n\ninterface PatchedXhr extends XMLHttpRequest {\n _telemetryRequest?: PendingRequest;\n _telemetryListening?: boolean;\n}\n\ntype XhrCtor = { prototype: PatchedXhr; [PATCHED]?: boolean };\n\n/**\n * Patches an `XMLHttpRequest` prototype so every completed request emits one `http.request`.\n * Shared because the native build is XHR-*only* (§4.4: RN's `global.fetch` is XHR underneath,\n * so patching both emits two events per call) while the web build patches XHR alongside its\n * own `fetch` patch — same emit rules, two different sets of callers.\n *\n * @returns the unpatch, so `stop()` can restore the prototype.\n */\nexport function patchXHR(telemetry: Telemetry, xhr: XhrCtor): () => void {\n if (xhr[PATCHED]) return () => { };\n\n const origOpen = xhr.prototype.open;\n const origSend = xhr.prototype.send;\n // May legitimately be absent on a minimal XHR polyfill; when it is, there is no way to\n // observe a consumer header and no way to write ours, so tracing simply stays dark.\n const origSetRequestHeader = xhr.prototype.setRequestHeader;\n\n // `arguments` is forwarded verbatim on both hooks: the SDK reports on the request, it never\n // reshapes the one it passes on. That is the only reason for the two casts in this file.\n xhr.prototype.open = function (this: PatchedXhr, method: string, url: string | URL) {\n // An XHR may be legally re-opened before the previous request finished — and the old\n // PendingRequest is about to be dropped. Release its settle hold first, or the view it\n // started in can never go quiet and reports `abandoned` for the rest of its life.\n this._telemetryRequest?.settled?.();\n this._telemetryRequest = { method, url: String(url), start: 0 };\n return origOpen.apply(this, arguments as any);\n };\n\n if (origSetRequestHeader) {\n xhr.prototype.setRequestHeader = function (this: PatchedXhr, name: string, value: string) {\n // Read-scope (§6.4): **exactly one header name, for exactly one purpose** — a\n // presence check. Names are compared case-insensitively; no other header is\n // inspected, logged or forwarded, and this one is passed straight through.\n if (this._telemetryRequest && String(name).toLowerCase() === TRACEPARENT) {\n this._telemetryRequest.consumerTraceparent = value;\n }\n return origSetRequestHeader.apply(this, arguments as any);\n };\n }\n\n xhr.prototype.send = function (this: PatchedXhr, body?: Document | XMLHttpRequestBodyInit | null) {\n const req = this._telemetryRequest;\n if (!req) return origSend.apply(this, arguments as any); // send() without open() — let it throw its own way\n // Disabled (#172): pass through untouched — no settle hold, no root, no header.\n if (telemetry.isEnabled?.() === false) { this._telemetryRequest = undefined; return origSend.apply(this, arguments as any); }\n req.start = Date.now();\n req.body = body;\n // The collector's own POST is out of scope for settle exactly as it is for\n // `http.request` — checked here as well as at loadend, because the view must not be\n // held open by the SDK's own traffic (§4.5.2).\n if (!isCollectorUrl(req.url, telemetry.getEndpoint?.())) {\n req.settled = telemetry.views.requestStarted(req.start);\n req.snap = telemetry.snapshot();\n // Mints a `request` root when nothing is live, and extends the live one otherwise\n // (§6.2), and resolves §6.5's outcome ladder. Same gate as settle: the SDK's own\n // POST neither holds a view open, starts an action, nor carries an outcome.\n // No `noCors` — `mode` is a fetch concept XHR cannot express, so `skipped_no_cors`\n // needs no platform branch to stay fetch-only.\n const trace = telemetry.trace.requestTrace(req.start, {\n url: req.url,\n sampled: telemetry.isSampled(),\n consumerTraceparent: req.consumerTraceparent,\n });\n req.span = trace.finish;\n req.discardRoot = trace.discard;\n // Written through the *original*, so our own write can never be misread as the\n // consumer's on a later inspection — and only ever when their flag is unset, so\n // there is no SDK-owned header for never-strip to have to protect.\n if (trace.header && origSetRequestHeader) {\n origSetRequestHeader.call(this, TRACEPARENT, trace.header);\n }\n }\n\n // One listener per *instance*, not per send: an XHR may be legally reused, and adding\n // a listener on every send() would emit N events on the Nth one. The handler reads\n // `_telemetryRequest` at fire time, so one listener serves every reuse.\n if (!this._telemetryListening) {\n this._telemetryListening = true;\n this.addEventListener(\"loadend\", () => {\n const done = this._telemetryRequest;\n if (!done) return;\n done.settled?.();\n // Invariant: an http.request never describes the SDK's own collector POST.\n if (isCollectorUrl(done.url, telemetry.getEndpoint?.())) return;\n\n const end = Date.now();\n telemetry.log(\"http.request\", {\n ...buildHttpAttributes({\n url: done.url,\n method: done.method,\n statusCode: this.status,\n durationMs: end - done.start,\n error: this.status === 0 ? \"Network error\" : null,\n requestBody: done.body,\n responseSize: contentLengthSize(this.getResponseHeader?.(\"content-length\")),\n }),\n ...done.span?.(end),\n }, done.snap);\n });\n }\n\n try {\n return origSend.apply(this, arguments as any);\n } catch (err) {\n // A send() that throws never reaches `loadend`, so nothing else would ever close\n // this hold. The fetch half gets this from its `finally`; XHR needs it spelled out.\n req.settled?.();\n // …and nothing would ever describe a root it minted (#160): the next request must\n // mint its own rather than join an action that never happened.\n req.discardRoot?.();\n throw err;\n }\n };\n\n xhr[PATCHED] = true;\n return () => {\n xhr.prototype.open = origOpen;\n xhr.prototype.send = origSend;\n if (origSetRequestHeader) xhr.prototype.setRequestHeader = origSetRequestHeader;\n delete xhr[PATCHED];\n };\n}\n"],"names":["PATCHED","patchXHR","telemetry","xhr","origOpen","origSend","origSetRequestHeader","method","url","name","value","TRACEPARENT","body","req","isCollectorUrl","trace","done","end","buildHttpAttributes","contentLengthSize","err"],"mappings":"gGAUMA,EAAU,4BAoDT,SAASC,EAASC,EAAsBC,EAA0B,CACrE,GAAIA,EAAIH,CAAO,EAAG,MAAO,IAAM,CAAE,EAEjC,MAAMI,EAAWD,EAAI,UAAU,KACzBE,EAAWF,EAAI,UAAU,KAGzBG,EAAuBH,EAAI,UAAU,iBAI3C,OAAAA,EAAI,UAAU,KAAO,SAA4BI,EAAgBC,EAAmB,CAIhF,YAAK,mBAAmB,UAAA,EACxB,KAAK,kBAAoB,CAAE,OAAAD,EAAQ,IAAK,OAAOC,CAAG,EAAG,MAAO,CAAA,EACrDJ,EAAS,MAAM,KAAM,SAAgB,CAChD,EAEIE,IACAH,EAAI,UAAU,iBAAmB,SAA4BM,EAAcC,EAAe,CAItF,OAAI,KAAK,mBAAqB,OAAOD,CAAI,EAAE,YAAA,IAAkBE,gBACzD,KAAK,kBAAkB,oBAAsBD,GAE1CJ,EAAqB,MAAM,KAAM,SAAgB,CAC5D,GAGJH,EAAI,UAAU,KAAO,SAA4BS,EAAiD,CAC9F,MAAMC,EAAM,KAAK,kBACjB,GAAI,CAACA,EAAK,OAAOR,EAAS,MAAM,KAAM,SAAgB,EAEtD,GAAIH,EAAU,YAAA,IAAkB,GAAS,YAAK,kBAAoB,OAAkBG,EAAS,MAAM,KAAM,SAAgB,EAMzH,GALAQ,EAAI,MAAQ,KAAK,IAAA,EACj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AmBG,GAC3D,OAAOH,EAAIH,CAAO,CACtB,CACJ"}
@@ -0,0 +1,190 @@
1
+ # Migrating to v4 — @nathanclaire/edge-telemetry-sdk (React Native)
2
+
3
+ **Ships with the release, not after it.** **Exactly one of the twenty discontinuities below is
4
+ visible at compile time** — #2, the accessor return shapes. (The six `@deprecated` `UserProfile`
5
+ fields are the other compile-time-visible change, but they are **not one of the twenty**; they sit
6
+ outside the list, which is why the table below numbers them `—`.) The remaining **nineteen**
7
+ surface at runtime or in a chart — which is exactly why this note has to arrive with the release
8
+ rather than trailing it.
9
+
10
+ `docs/backend-wire-contract.md` §12 is authoritative for this list; where it and this note
11
+ disagree, the contract wins. `CLAUDE.md` explains the behaviour behind each entry.
12
+
13
+ ---
14
+
15
+ ## Read this first
16
+
17
+ - ⚠ **You are almost certainly on 3.0.0, not 3.1.0.** `3.0.1` and `3.1.0` exist in the
18
+ [CHANGELOG](../CHANGELOG.md) but **were never published to npm** — `npm view
19
+ @nathanclaire/edge-telemetry-sdk versions` returns `["3.0.0"]`. So the twenty discontinuities
20
+ below, which are counted from 3.1.0, are **not the whole delta for you**: 3.0.1 and 3.1.0
21
+ arrive inside this upgrade too. The one that matters is 3.1.0's respelling of seven Context
22
+ keys from camelCase to their contract spelling (`app.packageName` → `app.package_name` and
23
+ six others). Those columns were never filling for you and start filling now — a step at this
24
+ release boundary that is a *fix landing*, not a v4 regression. Nothing about it breaks a
25
+ build.
26
+ - **Two changes break a build.** #2 (accessor return shapes) and the six `@deprecated`
27
+ `UserProfile` fields — the latter outside the twenty. Both are compile-time visible; fix them
28
+ and your app builds.
29
+ - **Nineteen changes break a chart** — every entry of the twenty except #2. No compile error, no
30
+ runtime error, no log line: a saved filter quietly returns zero rows, or a series steps at the
31
+ release boundary.
32
+ - **Every one of them is separable only by `sdk.version`.** ⚠ That key is absent from the bag on
33
+ essentially all historical rows, so splitting a *historical* series on it does not work.
34
+ Promoting it going forward is the only version of this that does.
35
+ - **One action item for most consumers:** if you called `setUserProfile()`, `setUserDetails()`,
36
+ `updateUserProfile()`, `setUserName()` or `setUserContact()` and never called `identify()`,
37
+ your profile data now reaches the wire **not at all** — those five record state, and only
38
+ `identify()` emits `user.profile.update`. Add one `identify()` call. See #6.
39
+
40
+ ---
41
+
42
+ ## Compile-time visible (2)
43
+
44
+ | # | Change | What breaks | Fix |
45
+ |---|---|---|---|
46
+ | 2 | `getDeviceInfo()` / `getNetworkInfo()` return shapes changed | destructuring the old camelCase keys | read the new snake_case shape; the `DeviceInfo` type is not importable, so this is structural only |
47
+ | — | Six `UserProfile` fields are `@deprecated` (live until v6 — removal deferred at v5) | `fullName`, `firstName`, `lastName`, `avatar`, `createdAt`, `updatedAt` warn | `fullName` still works and still builds `user.name`; the other five have no wire key and no reader — drop them |
48
+
49
+ ---
50
+
51
+ ## Shipped in 3.1.0, ahead of v4 (3)
52
+
53
+ | # | Change | Effect |
54
+ |---|---|---|
55
+ | 1 | Seven camelCase Context keys respelled to snake_case | any bag query on the old spellings returns **zero rows**; five columns start filling; every `rum_apps` series **steps** here |
56
+ | 2 | `getDeviceInfo()` / `getNetworkInfo()` return shapes change | **compile-time visible** — the map's first consumer API break |
57
+ | 3 | `app.packageName` → `app.package_name` | stops an active cross-tenant corruption; does **not** migrate history |
58
+
59
+ ---
60
+
61
+ ## v4 — keys that disappear (6)
62
+
63
+ | # | Change | Effect |
64
+ |---|---|---|
65
+ | 4 | **`http.url` removed** | ⚠ empties `rum_http_requests.url`, a populated production column in the 2nd most-queried table. Replaced by `http.host` + `http.route` — **not** a query-strip; the identifier lives in the path |
66
+ | 5 | **`http.path` removed** | not a rename a `COALESCE` papers over — raw values vs normalized templates |
67
+ | 6 | `user.name` / `user.email` / `user.phone` leave the Context block | any bag query filtering **events** on them returns zero rows; they ride `user.profile.update` **only**, and only when you call `identify()` |
68
+ | 7 | Six `user.*` wire keys vanish outright | `fullName`, `firstName`, `lastName`, `avatar`, `createdAt`, `updatedAt` |
69
+ | 8 | `device.iosDeviceName` vanishes | PII removal. `device.fingerprint` goes with it — see #20 |
70
+ | 9 | **Web loses `memory_usage` entirely** | the metric's presence was browser detection wearing a memory label (`performance.memory` is Chromium-only). `TelemetryWeb` has no `trackMemoryUsage` method at all |
71
+
72
+ ---
73
+
74
+ ## v4 — values that change under an unchanged key (7)
75
+
76
+ These are the dangerous ones: the key still exists, the query still runs, the number is different.
77
+
78
+ | # | Change | Effect |
79
+ |---|---|---|
80
+ | 10 | `sdk.platform`: `react-native` → `react-native-{Platform.OS}` | ⚠ a saved filter on `sdk.platform = 'react-native'` returns **zero rows** — the worst way for a chart to fail. ⚠ **Not** a closed three-value enum: `ios` / `android` / `web` are what the two builds emit today, but RN-Windows would emit `react-native-windows` |
81
+ | 11 | `memory.type`: `"heap"` → `"rss"` | ⚠ on a **promoted column**, with real v3 Hermes data to be silently compared against. RSS counts native allocations — images, native views — which are what actually get a process OOM-killed |
82
+ | 12 | `http.request_size`: UTF-16 units → **UTF-8 bytes** | any non-ASCII traffic's payload-size series steps up **2–3×** |
83
+ | 13 | `session.id` gains a `_web` suffix on the web build | value shape changes; nothing parses it |
84
+ | 14 | `error.source` re-cuts `crash.cause` | ⚠ a **migration table, not a rename** — do not map the four old values on positionally. `ConsoleWarn` is deleted (a warning is a breadcrumb); `cross_origin` is new. All five `crash.*` keys become dotted `error.*` |
85
+ | 15 | `http.method` uppercased | a saved filter on `'post'` returns zero rows — a **correction** |
86
+ | 16 | `frame.dropped_count` values move on 90/120 Hz devices | a **correction**: v3 budgeted against a hardcoded 60 Hz and undercounted. `frame.target_fps` is now measured; `frame.target_hz` is gone |
87
+
88
+ ---
89
+
90
+ ## v4 — counts that step (4)
91
+
92
+ | # | Change | Effect |
93
+ |---|---|---|
94
+ | 17 | **Session counts drop sharply** | resume-across-process-death replaces per-launch minting, and RN native processes are killed constantly. A resumed session emits **no** `session.started`, so count launches from `app.start`, not from `session.reason` |
95
+ | 18 | **Every native device gets a new `device.id`** | device counts double across the boundary **once**, with no v3↔v4 device join available. `device.id` is now SDK-minted and never rotates |
96
+ | 19 | **`user.id` vanishes from anonymous traffic** | any "users" chart that does not filter drops to the **identified population**. `COUNT(DISTINCT device.id)` is anonymous reach; `COUNT(DISTINCT user.id)` is known-user reach |
97
+ | 20 | **RN-Android device counts step up** | previously-merged handsets un-merge as `device.fingerprint` stops being sent — a **correction** of a real undercount, and the only entry where the v3 numbers were wrong in that direction |
98
+
99
+ ---
100
+
101
+ ## Arrival changes, not content changes
102
+
103
+ Not counted among the twenty, but they change what ingest sees:
104
+
105
+ - **Burst arrival**, ~25×-larger and 3×-rarer POSTs (`batchSize` 50 / 30 s).
106
+ - **At-least-once duplicates** until the `(session_id, event_sequence)` dedup index exists. ⚠ This
107
+ is a **rollout-ordering question**: the index should land **before or with** the SDK. Until it
108
+ does, replay inflates every aggregate.
109
+ - Two volume moves that are not breaks but will look like incidents: `http.request` goes **zero →
110
+ everything** for axios-based tenants (native now patches XHR, the one chokepoint axios uses), and
111
+ `screen.duration` volume goes **up** for React Navigation consumers at the exact moment it is
112
+ deprecated.
113
+
114
+ ---
115
+
116
+ ## Four event names retired
117
+
118
+ ⚠ **Instructions, not omissions.** These are off the allowlist and unreachable — a `log()` call
119
+ using one is rewritten to `custom_event`. Build nothing for them.
120
+
121
+ | Name | Why it is gone |
122
+ |---|---|
123
+ | `user.interaction` | superseded by `ui.interaction` (§4.6). Android's own contract already says not to build a table for it |
124
+ | `page_load` | its job is done three times over: *a page load happened* → `view` with `view.load_type: initial_load`; *how long* → `view.loading_time`; *why slow* → TTFB/FCP/LCP with the phase splits |
125
+ | `resource_timing` | per-asset rows: hundreds per asset-heavy view, in a namespace with no column, on one platform of four. A single such view would exceed the 500-event in-memory queue on its own |
126
+ | `long_task` | `PerformanceLongTaskTiming` and `long-animation-frame` are **both Chromium-only**, so a "bare `longtask` fallback" buys Chrome 58–122, not one non-Chromium user. Jank detection is already universal via `frame_render_time`; the user-visible consequence is measured by INP's phase split |
127
+
128
+ The last three were **allowlisted but never produced**, so they add nothing to the migration
129
+ story — no chart exists on any of them.
130
+
131
+ ---
132
+
133
+ ## Columns RN will never write
134
+
135
+ So nobody builds an ANR panel that shows an empty slice forever. Contract §10.1/§10.3.
136
+
137
+ | Table | Columns | Why |
138
+ |---|---|---|
139
+ | `rum_crash_events` / `rum_errors` | `anr_duration_ms`, `hang_duration_ms`, `crash_thread`, `crash_is_main_thread` | crash capture is **JS-level only**. A signal handler has no JS `Error` to derive `error.*` from and cannot read the trace carrier |
140
+ | `rum_crash_events` | `error_context`, `product_id`, `error_code`, `user_action`, `severity_level` | Android's positional `trackError` overloads. RN ships one method — `captureError(err, context)` — and `context` carries them at no fixed spelling |
141
+ | `rum_crash_events` | `crash_hash` | ⚠ `NOT NULL` with no producer, **by design** — backend-computed. No fingerprint ships on the wire: grouping algorithms change, which is a backfill server-side and an app-store rollout SDK-side |
142
+ | `rum_ui_interactions` | `ui_direction` | `ui.type` is closed at `click` \| `tap`. Gesture capture is out of scope — do not size this column for RN |
143
+ | `rum_ui_interactions` | `ui_screen` | dropped deliberately; `view.name` on the Context block supersedes it |
144
+ | `rum_screen_durations` | every row, **on web** | web has never emitted `screen.duration` and will not |
145
+ | `rum_sessions` | `duration_ms`, `event_count`, `metric_count`, `screen_count`, `visited_screens`, `is_first_session`, `total_sessions` | all derived server-side |
146
+ | `rum_performance_events` | `memory_usage_mb`, `memory_pressure_level`, `memory_timestamp` | RN emits `memory_usage` on the **metric** path; these live on the **event** path |
147
+ | `rum_performance_metrics` / `rum_performance_events` | `frame_build_duration_ms`, `frame_raster_duration_ms`, `frame_type`, `frame_dropped`, `frame_total_duration_ms`, `frame_severity` | a model difference, not a spelling one |
148
+ | `rum_devices` | `fingerprint` | **deliberately stopped** — zero analytics readers, and sending it corrupts device identity |
149
+ | `rum_navigations` / `rum_navigation_events` | `has_arguments` | not adopted; `navigation` is deprecated anyway |
150
+ | `rum_trace_spans`, `rum_user_actions` | **every column** | RN writes neither table. The trace surface lands on `rum_telemetry_events` and `rum_http_requests` |
151
+ | — | any `resource.*` / `long_task` key, `metric_name = 'page_load'` | retired above |
152
+
153
+ **Plus the 35 allowlist keys `extract.go` reads that RN never sends** — the largest single group of
154
+ empty columns, and the one most likely to be mistaken for a capture bug. Enumerate them with the
155
+ command in contract Appendix A; every one stays NULL for RN traffic.
156
+
157
+ **Deferred as one bundle, not refused:** `device.cpu_cores`, `device.thermal_status`,
158
+ `device.battery_level`, `device.battery_charging`, `device.power_save`, `app.exit` and its keys,
159
+ native signal/ANR/hang capture, and a synchronous crash store. The rule is that **anything needing
160
+ the SDK's first native module defers and is priced against the whole native surface** — Kotlin and
161
+ Swift sources in a repo whose CI runs only `npm ci`, a TurboModule spec, and an Expo config plugin,
162
+ without which Expo Go consumers cannot install a package that is pure JS today.
163
+
164
+ ⚠ **The JS dirty-flag approximation of `app.exit` is rejected on the record** and must not come
165
+ back as the cheap win: it detects abnormal termination without naming the cause, and on mobile the
166
+ dominant cause is the user force-quitting, which is not a fault. The metric would not be thin — it
167
+ would **invert**, scoring healthy apps with engaged users worst.
168
+
169
+ ---
170
+
171
+ ## Five deliberate departures from Android
172
+
173
+ RN adopts Android's key names wherever the concept already exists — `trace.*`, `span.*`,
174
+ `rum.action.id`, `traceparent.outcome`, `navigation.*`, `screen.*`, `ui.*`, the bag-first storage
175
+ model and the promotion rule. These five diverge **on purpose**. Recorded here so the next person
176
+ diffing the two SDKs does not file a decision as drift. Contract §13.
177
+
178
+ | # | Departure | The argument in one line |
179
+ |---|---|---|
180
+ | 1 | **`error.*` dotted, not Android's undotted `message` / `cause` / `is_fatal`** | RN's bag is one flat namespace shared with 124 keys and `log()` flattens caller data into it, so `message` and `cause` would collide with userland |
181
+ | 2 | **`sessionSampleRate`, not Android's `traceSampleRate`** | Android's is per-*trace* and pinned at `1.0`; a per-trace sampler produces orphan children |
182
+ | 3 | **`http.route`, not a normalized `http.path`** | one column, two dialects, and nothing in the data to separate them |
183
+ | 4 | **`user.id` omitted on anonymous traffic; `device.id` carries anonymous identity** | Android mints both ids the same way into the same store, so its two columns carry one fact. The departure is in *naming*, not storage |
184
+ | 5 | **`user.*` profile keys leave the Context block for `user.profile.update`** | Android persists its profile; RN's is in-memory, and shipping PII on every event to fill a table that needs it once is indefensible |
185
+
186
+ Smaller stated divergences, each in place: `injected_unwired` dropped; `b3` declined; hostname
187
+ matching ignores the port while `http.host` keeps it (**do not join them**); allowlist validation is
188
+ `__DEV__`-gated rather than an unconditional `require`; malformed consumer `traceparent` headers are
189
+ left alone rather than repaired; `ui.screen` dropped; `error.handled` dropped; breadcrumb cap 20
190
+ against Android's 50; `app.start.js_ready_ms` rather than `duration_ms`.