@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
@@ -1,4 +1,48 @@
1
- import { ScreenTimingTracker } from '../adapters/screenTiming';
1
+ import { ViewManager, ViewNameSource } from '../adapters/viewManager';
2
+ import { TraceManager } from '../adapters/traceManager';
3
+ import { HangDetector } from '../adapters/hangDetector';
4
+ import { OpenSpan, TaskOutcome } from '../adapters/manualSpans';
5
+ import { ErrorSource } from '../adapters/crashCapture';
6
+ import { Store } from './store';
7
+ import { BeforeSend } from './beforeSend';
8
+ import { Orientation } from '../adapters/viewport';
9
+ export type { BeforeSend } from './beforeSend';
10
+ export type { Orientation };
11
+ /** `sdk.drop_reason` (§11). `rejected` is a 4xx-dropped batch (§2.5, #162). */
12
+ export type DropReason = "queue_full" | "store_full" | "rejected";
13
+ /**
14
+ * §4.7's two error names. Both book `sdk.error_count` and `view.error_count` — a closed
15
+ * enumeration, not resource failures and not `console.warn`. Only `app.crash` gets the
16
+ * dedicated crash path and the eviction reprieve, which is the whole point of the split:
17
+ * `COUNT(event_name='app.crash')` must stay a crash count nobody can forget to filter.
18
+ */
19
+ export declare const isErrorName: (name?: string) => boolean;
20
+ export declare function evictIndex(events: TelemetryEvent[]): number;
21
+ /** Store key for the self-minted, persisted `device.id` (#91). */
22
+ export declare const DEVICE_ID_KEY = "telemetry_device_id";
23
+ /** Store key for the resumable session record (#92). */
24
+ export declare const SESSION_KEY = "telemetry_session";
25
+ /** Why a session started/ended. `launch` is internal only — it ships as no `session.reason` (catalogue #179). */
26
+ export type SessionReason = "launch" | "timeout" | "max_duration" | "manual";
27
+ export type SessionEndReason = Exclude<SessionReason, "launch">;
28
+ /**
29
+ * §4.6's mint/emit split, for the one event that has one. A `ui.interaction` is emitted
30
+ * after its dead-click window, so its wire `timestamp` and its `view.id` / `view.name` /
31
+ * `session.id` are snapshotted at the click and replayed here — otherwise a tap that
32
+ * navigates is booked against the view it opened.
33
+ */
34
+ export type LogSnapshot = {
35
+ /**
36
+ * Epoch ms of the click. Becomes the row's `timestamp`. **Omitted by a span-carrying row
37
+ * that is not deferred** — an `http.request` freezes its *attribution* at send but still
38
+ * reports the completion time §4.4 gives it.
39
+ */
40
+ at?: number;
41
+ viewId: string;
42
+ sessionId: string;
43
+ /** Epoch ms — `session.start_time` freezes with the id it belongs to (§3.1). */
44
+ sessionStart: number;
45
+ };
2
46
  export type TelemetryEvent = {
3
47
  type: 'event' | 'metric';
4
48
  eventName?: string;
@@ -9,7 +53,13 @@ export type TelemetryEvent = {
9
53
  };
10
54
  export interface Sender {
11
55
  send(events: TelemetryEvent[]): Promise<void>;
12
- onFailure?(events: TelemetryEvent[]): Promise<void>;
56
+ /**
57
+ * Persist a batch that could not be sent. Returns how many rows the offline store's
58
+ * cap cost, so core can book them as `sdk.drop_reason = "store_full"` (§9.4) — the
59
+ * counter lives on the Context block, which only core assembles. `void` is still a
60
+ * valid return: a consumer's own sender is not obliged to have a cap.
61
+ */
62
+ onFailure?(events: TelemetryEvent[]): Promise<number | void>;
13
63
  replayFailed?(): Promise<void>;
14
64
  }
15
65
  export interface CrashHandlerOptions {
@@ -20,13 +70,7 @@ export interface CrashHandler {
20
70
  }
21
71
  export interface NetworkInfo {
22
72
  type?: string;
23
- isConnected?: boolean;
24
- }
25
- export interface WebExtraNetworkInfo {
26
- type?: string;
27
- isConnected?: boolean;
28
- downlink?: number;
29
- effectiveType?: string;
73
+ is_connected?: boolean;
30
74
  }
31
75
  export interface NetworkInfoHandler {
32
76
  start(telemetry: Telemetry): Promise<NetworkInfo>;
@@ -43,7 +87,21 @@ export interface NetworkHandler {
43
87
  start(): Promise<void>;
44
88
  }
45
89
  export interface MemoryHandler {
46
- recordMemoryUsage(): Promise<void>;
90
+ start(): Promise<void>;
91
+ /** Torn down by `shutdown()`: unlike the rAF-driven trackers this one owns a timer. */
92
+ stop?(): void;
93
+ }
94
+ /**
95
+ * #173's device state. `battery()` is synchronous on purpose — a cached last read — so no
96
+ * failure row ever awaits a native call. Native implements all of it; web only `accessibility`.
97
+ */
98
+ export interface DeviceStateHandler {
99
+ battery?(): Record<string, number | boolean>;
100
+ refresh?(): Promise<void>;
101
+ start?(): void;
102
+ stop?(): void;
103
+ /** Read once per session, onto `session.started`. A failed read omits only its own key. */
104
+ accessibility(): Promise<Record<string, number | boolean>>;
47
105
  }
48
106
  export interface NavigationHandler {
49
107
  start(): Promise<void>;
@@ -52,35 +110,44 @@ export interface DeviceInfo {
52
110
  app: {
53
111
  name: string;
54
112
  version: string;
55
- buildNumber?: string;
56
- packageName?: string;
113
+ build_number?: string;
114
+ package_name?: string;
57
115
  };
58
116
  device: {
59
- id: string;
60
117
  platform: string;
61
- platformVersion?: string;
118
+ platform_version?: string;
62
119
  model?: string;
63
120
  manufacturer?: string;
64
121
  brand?: string;
65
- androidSdk?: string;
66
- androidRelease?: string;
67
- fingerprint?: string;
122
+ android_sdk?: number;
123
+ android_release?: string;
68
124
  hardware?: string;
69
125
  product?: string;
70
- iosSystemName?: string;
71
- iosDeviceName?: string;
126
+ system_name?: string;
127
+ cpu_abi?: string;
128
+ low_ram?: boolean;
129
+ screen_density?: number;
130
+ screen_width_px?: number;
131
+ screen_height_px?: number;
132
+ orientation?: Orientation;
72
133
  };
73
134
  }
74
135
  export interface UserProfile {
75
136
  userId?: string;
137
+ /** @deprecated Removed in v6 — use `identify({ name })`. Still the source of `user.name`. */
76
138
  fullName?: string;
139
+ /** @deprecated Removed in v6 — never reached the wire; `identify()` could not set it. */
77
140
  firstName?: string;
141
+ /** @deprecated Removed in v6 — never reached the wire; `identify()` could not set it. */
78
142
  lastName?: string;
79
143
  email?: string;
80
144
  phone?: string;
145
+ /** @deprecated Removed in v6 — no column and no reader; `user.avatar` is off the wire (§3.4). */
81
146
  avatar?: string;
82
147
  customAttributes?: Record<string, any>;
148
+ /** @deprecated Removed in v6 — in-memory only, so it meant "first identify() this process" (§3.4). */
83
149
  createdAt?: number;
150
+ /** @deprecated Removed in v6 — byte-identical to `createdAt` for any one-identify() app (§3.4). */
84
151
  updatedAt?: number;
85
152
  }
86
153
  type Opts = {
@@ -89,11 +156,19 @@ type Opts = {
89
156
  flushIntervalMs?: number;
90
157
  endpoint?: string;
91
158
  sessionId?: string;
92
- userId?: string | null;
159
+ userId?: string;
93
160
  sdkVersion?: string;
94
161
  platform?: string;
162
+ traceLaunchStart?: number;
95
163
  deviceInfoHandler?: DeviceInfoHandler;
164
+ deviceStateHandler?: DeviceStateHandler;
96
165
  networkInfoHandler?: NetworkInfoHandler;
166
+ store?: Store;
167
+ beforeSend?: BeforeSend;
168
+ sessionSampleRate?: number;
169
+ traceHostAllowlist?: string[];
170
+ buildId?: string;
171
+ enabled?: boolean;
97
172
  };
98
173
  /**
99
174
  * Telemetry core: queueing, batching, retries, auto-replay and session/user management.
@@ -107,16 +182,28 @@ export declare class Telemetry {
107
182
  private intervalId;
108
183
  private endpoint?;
109
184
  private crashHandler?;
110
- private navigationTracker?;
111
- screens: ScreenTimingTracker;
112
- currentScreen?: string;
185
+ readonly views: ViewManager;
186
+ readonly trace: TraceManager;
187
+ webInteractions?: {
188
+ start(): void;
189
+ };
190
+ webVitals?: {
191
+ start(): Promise<void>;
192
+ stop(): void;
193
+ };
194
+ readonly hangs?: HangDetector;
195
+ readonly deviceState?: DeviceStateHandler;
113
196
  private networkInfoHandler;
197
+ private networkStarted;
114
198
  private deviceInfoHandler;
199
+ readonly store: Store;
115
200
  private frameDropsHandler?;
116
201
  private networkHandler?;
117
202
  private memoryHandler?;
118
203
  private navigationHandler?;
119
204
  private userId?;
205
+ private deviceIdEphemeral;
206
+ private deviceIdPromise?;
120
207
  private userProfile?;
121
208
  private sessionId;
122
209
  private sessionStart;
@@ -126,43 +213,238 @@ export declare class Telemetry {
126
213
  private breadcrumbs;
127
214
  private lastActivity?;
128
215
  private sessionSequence;
216
+ private eventSequence;
129
217
  private sessionEventCount;
130
218
  private errorCount;
219
+ private readonly configuredSampleRate;
220
+ private sampleRate;
221
+ private sampled;
222
+ private readonly beforeSend?;
223
+ /** `app.build_id` (§4.8). Empty string is *not* a build id — it is an unset one. */
224
+ private readonly buildId?;
225
+ private hookDropped;
226
+ private hookFailed;
227
+ private eventsDropped;
228
+ private dropReason?;
229
+ private crashPersistedThrough;
230
+ private appStartEmitted;
231
+ /** `app.start.js_ready_ms` (§4.3, #171) — native only; the entry's reader, run at emit. */
232
+ jsReadyMs?: () => number | undefined;
233
+ /** `app.start.duration_ms` (#179) — the entry's reader; resolves `undefined` when unknown. */
234
+ appStartMs?: () => Promise<number | undefined>;
235
+ private readonly spans;
236
+ private finalizing;
237
+ private enabled;
238
+ private pendingStart;
131
239
  constructor(opts?: Opts);
240
+ /**
241
+ * §4.7 — report a handled error. Accepts `unknown` on purpose: half of real `catch`
242
+ * blocks receive a string or an axios rejection object, and a consumer should not have
243
+ * to prove to TypeScript that it is an `Error` before reporting it.
244
+ *
245
+ * Emits `app.error`, **never** `app.crash`. There is deliberately no public path to
246
+ * `app.crash` — a consumer's own code must not be able to manufacture rows in the one
247
+ * table an unfiltered crash-free rate is read from.
248
+ *
249
+ * `source` is SDK-internal (`captureConsole` passes `"console"`); the public wrappers
250
+ * forward two arguments, so a consumer can only ever produce `"reported"`. Routing the
251
+ * console path through here rather than through `log()` directly is what keeps the
252
+ * `error.fatal` rule in one place.
253
+ */
254
+ captureError(error: unknown, context?: Record<string, any>, source?: ErrorSource): Promise<void>;
255
+ /**
256
+ * Extend the breadcrumb trail without emitting anything. §4.7 demotes `console.warn` to
257
+ * exactly this — React's dev-mode warnings were the bulk of v3's `app.crash` volume.
258
+ *
259
+ * Also the public `addBreadcrumb()` (#167) — one path, so the SDK's own crumbs and the
260
+ * host's obey the same bounds (`boundCrumb`). Shows on `app.crash` and `app.hang`.
261
+ */
262
+ addBreadcrumb(name: string, data?: Record<string, any>): void;
263
+ /**
264
+ * `startNewSession()` (#167) — logout/login. The same finalize + started pair as an idle
265
+ * or max-duration rotation, with `session.reason: manual` on both.
266
+ */
267
+ startNewSession(): Promise<void>;
132
268
  trackErrors(crashHandler: CrashHandler, options?: CrashHandlerOptions): void;
133
269
  getDeviceInfo(deviceInfoHandler: DeviceInfoHandler): void;
270
+ /** Starts the network tracker once; later calls are no-ops, so listeners never stack. */
134
271
  getNetworkInfo(networkInfoHandler: NetworkInfoHandler): void;
135
272
  trackFrameDrops(frameDropsHandler: FrameDropsHandler): void;
136
273
  trackNetworkRequests(networkHandler: NetworkHandler): void;
274
+ /** The offline replay and the flush timer — at construction, and again at each `enable()`. */
275
+ private startDelivery;
276
+ isEnabled(): boolean;
277
+ /**
278
+ * The consent kill-switch (#172). Synchronous: the flag is off before this returns. The
279
+ * in-memory queue, the offline store and the session record are dropped — an opt-out
280
+ * means nothing is sent **and nothing is kept**, open spans included — and every timer
281
+ * stops; the rAF loop keeps running but `logMetric` discards its samples. While off the
282
+ * network patches pass through untouched. `device.id` is kept: it is not telemetry, and
283
+ * minting a new one at re-consent would read as a new install.
284
+ */
285
+ disable(): void;
286
+ /**
287
+ * Resume collection (#172) and run the lazy session-expiry check — a session can expire
288
+ * while disabled. A dark-started process announces its session here (`session.started`,
289
+ * unless a live record resumes) and never emits `app.start`.
290
+ */
291
+ enable(): Promise<void>;
137
292
  trackMemoryUsage(memoryHandler: MemoryHandler): void;
138
293
  autoTrackNavigation(navigationHandler?: NavigationHandler): void;
294
+ /**
295
+ * The per-session sample roll (§3.6). Never per-event: per-event sampling punches
296
+ * holes that desynchronise the per-view counters by a random factor per view.
297
+ *
298
+ * `Math.random()` is deliberate here where `randomHex` refuses it — this decides one
299
+ * boolean that dies with the session, not an id that persists forever, and a biased
300
+ * PRNG costs a fraction of a percent of sample accuracy rather than a permanent
301
+ * identity collision.
302
+ */
303
+ private rollSample;
304
+ /** §3.3 / §4.7's platform split, from the entry's declared `platform` opt — never a global. */
305
+ private isNativePlatform;
139
306
  private generateSessionId;
140
307
  setSessionId(id: string): void;
141
308
  getSessionId(): string;
309
+ /**
310
+ * Freeze the identity a deferred row must report (§4.6). Read **synchronously at the
311
+ * moment the thing happened**, so a `log()` that lands after a route change or a session
312
+ * rotation still books the click where it occurred.
313
+ */
314
+ snapshot(at?: number): LogSnapshot;
142
315
  /** Collector endpoint, so fetch/XHR adapters can skip self-capturing the SDK's own POST. */
143
316
  getEndpoint(): string | undefined;
144
- startNewSession(): void;
145
- /** Emit session.started for the current session (init / resume). */
146
- startSession(): Promise<void>;
147
- /** Finalize the current session: journey summary + sdk.error_count, then an immediate flush. */
148
- finalizeSession(): Promise<void>;
317
+ /**
318
+ * Sampling stays **session-level** (§6.5): an unsampled session injects no header at
319
+ * all — not a `flags=00` id. Read by the interceptors, which sit outside `log()`'s own
320
+ * sampled-out early return and so need the decision directly.
321
+ */
322
+ isSampled(): boolean;
323
+ /**
324
+ * The entry's one call at init (§4.2): resume the durable session when the gap is
325
+ * inside the idle window, otherwise close the stale one out and start fresh.
326
+ *
327
+ * Process death, tab close, hard reload and bfcache restore all land here, and all
328
+ * four **resume** — which is why a resumed session must not re-emit `session.started`
329
+ * (§4.1), or `COUNT(session.started)` stops equalling session count.
330
+ */
331
+ resumeOrStartSession(): Promise<void>;
332
+ private hydrateAndAnnounce;
333
+ /**
334
+ * `app.start` (§4.3/§6.2): once per process, a **root** of `trace.root_type = launch`,
335
+ * carrying the launch root minted in the constructor. Idempotent because the web build
336
+ * re-runs `resumeOrStartSession()` on a bfcache restore, which is a resumed process and
337
+ * not a new one.
338
+ */
339
+ private emitAppStart;
340
+ /**
341
+ * Read the durable record and adopt it. Adoption happens even when the session has
342
+ * expired: `session.finalized` has to ship under the *old* `session.id` and
343
+ * `session.start_time` before the fresh one takes over.
344
+ */
345
+ private hydrateSession;
346
+ /**
347
+ * Another tab wrote the shared session record (#161, web's `storage` event). Two tabs keep
348
+ * their own in-memory `lastActivity`, so without this one can idle-expire a session the
349
+ * other is still using, or both can finalize the same `session.id`.
350
+ *
351
+ * Same id: fold in the other tab's progress — activity and the ordinals only ever move
352
+ * forward, so `max` is the merge. A different id is the other tab's rotation: this tab's
353
+ * live view is emitted under the session it belongs to, then the successor session is
354
+ * adopted **silently** — its `session.started` already shipped from the tab that rotated,
355
+ * and the retired one's `session.finalized` too, which is the whole point.
356
+ *
357
+ * Shared core, no platform branch: the entry decides what feeds it.
358
+ */
359
+ adoptSessionRecord(raw: string | null | undefined): Promise<void>;
360
+ /**
361
+ * Which boundary, if any, the current session has crossed. Idle is checked first:
362
+ * when a long session has also gone quiet, the reason it ended is that the user left.
363
+ *
364
+ * Inert until `lastActivity` is set, so a bare `new Telemetry()` that never started a
365
+ * session never rotates one.
366
+ */
367
+ private expiryReason;
368
+ /**
369
+ * Write the session through the `Store` so the next process can resume it.
370
+ *
371
+ * ponytail: one write per event. Web's is a synchronous `localStorage` write; native's
372
+ * is an AsyncStorage round-trip — debounce here if it ever shows up in a trace.
373
+ */
374
+ private persistSession;
375
+ /** Emit session.started for the current session. */
376
+ startSession(reason: SessionReason): Promise<void>;
377
+ /**
378
+ * Finalize the current session: journey summary + sdk.error_count, then an immediate flush.
379
+ *
380
+ * The backend discards `duration_ms` and `event_count` and derives both (§4.2) — they
381
+ * stay on the wire because the event survives as the carrier for `session.reason` and
382
+ * `sdk.error_count`, neither of which is derivable. Duration is stamped from
383
+ * `lastActivity`, never `now`: a lazily-detected rotation must report 2 minutes of use,
384
+ * not the 6 idle hours that followed it.
385
+ */
386
+ finalizeSession(reason: SessionEndReason): Promise<void>;
387
+ /** Every span frozen to the session being left ships `abandoned` under it — before the switch. */
388
+ private abandonSpans;
149
389
  /** Begin a fresh session: new id/start, reset per-session counters, emit session.started. */
150
- newSession(): Promise<void>;
151
- /** Idle/boundary rotation: finalize the old session then start a fresh one (the pair). */
152
- rotateSession(): Promise<void>;
390
+ newSession(reason: SessionReason): Promise<void>;
391
+ /**
392
+ * Open a manual span — **synchronously**, so the trace keys, `view.id` and `session.id`
393
+ * freeze at the call (§3.1). Inert (`undefined`, reported through `debug()`) for a blank
394
+ * name or past 32 open spans; never throws. Refreshes `lastActivity` but is not an
395
+ * action: `view.action_count` counts `ui.interaction` only.
396
+ *
397
+ * On a session that has already expired the freeze waits for the rotation the start
398
+ * itself triggers, so a journey begun after a long idle belongs to the new session
399
+ * rather than being `abandoned` by the very next row.
400
+ */
401
+ startSpan(name: unknown, attrs?: Record<string, unknown>, at?: number): OpenSpan | undefined;
402
+ /**
403
+ * Close a span by name and emit its one `task.complete`. An unknown or already-closed
404
+ * name is a no-op. With `only`, the close is a handle's, and a superseded handle cannot
405
+ * close the span that replaced it.
406
+ */
407
+ endSpan(name: unknown, outcome?: TaskOutcome, attrs?: Record<string, unknown>, at?: number, only?: OpenSpan, reason?: unknown): Promise<void>;
408
+ private emitTask;
409
+ /** Boundary rotation: finalize the old session then start a fresh one (the pair). */
410
+ rotateSession(reason: SessionEndReason): Promise<void>;
411
+ /** Truncated at source (§3.2): the collector caps at 255 and we must not be the one over. */
153
412
  setUserId(id: string): void;
154
- getUserId(): string | undefined | null;
155
- generateUserId(): string;
413
+ getUserId(): string | undefined;
414
+ /**
415
+ * The SDK-owned `device.id` (§3.2/§3.3): self-minted, written through the `Store`,
416
+ * uninstall-scoped, stable across process restarts, and never rotated by login,
417
+ * logout or a profile clear.
418
+ *
419
+ * The platform suffix is the entry's (ios|android|web), not the device-info adapter's:
420
+ * this id is persisted forever, so it must not depend on a call that can throw on first run.
421
+ *
422
+ * `getUniqueId()` is deliberately not used — it already carries two lifetimes on RN
423
+ * alone (ANDROID_ID survives reinstall, identifierForVendor does not), so one identity
424
+ * column would mean two things.
425
+ *
426
+ * When the Store reports `unavailable` — incognito, a partitioned iframe, ITP
427
+ * eviction, a full disk — the id lives for one process only and `device.id_ephemeral`
428
+ * rides the Context block to say so, because that population is otherwise
429
+ * indistinguishable from real installs and reads as traffic growth.
430
+ */
431
+ private getDeviceId;
156
432
  /**
157
433
  * Set complete user profile information
158
434
  */
159
435
  setUserProfile(profile: Partial<UserProfile>): void;
160
436
  /**
161
- * EdgeRum-style identify(): attach host-app identity (name/email/phone) to subsequent
162
- * events and emit one `user.profile.update`. The SDK-owned anonymous `user.id` is
163
- * preserved — identify never changes it. (#31)
437
+ * EdgeRum-style identify(): record the host-app profile and emit the one event that
438
+ * carries it — `user.profile.update` (§4.10, #107). The PII is no longer on the
439
+ * Context block of every event.
440
+ *
441
+ * `userId` is optional and new in v4: the one call that sends a profile should also
442
+ * set the key that profile attaches to, since `user.id` is consumer-supplied (§3.2)
443
+ * and an unkeyed profile has nothing to upsert on. Omitting it leaves `user.id`
444
+ * exactly as it was — identify never mints one.
164
445
  */
165
446
  identify(profile: {
447
+ userId?: string;
166
448
  name?: string;
167
449
  email?: string;
168
450
  phone?: string;
@@ -205,7 +487,34 @@ export declare class Telemetry {
205
487
  * Log a named event. Keeps existing signature compatibility.
206
488
  * Automatically attaches userId and sessionId to every queued event.
207
489
  */
208
- log(name: string, data?: Record<string, any>): Promise<void>;
490
+ log(name: string, data?: Record<string, any>, snapshot?: LogSnapshot): Promise<void>;
491
+ /** §2.5 4xx: drop the batch, book it, and tell a dev once — it is usually a wrong apiKey. */
492
+ private reject;
493
+ /** §2.5 429: halt the drain until `X-RateLimit-Reset`, 1 s when the header is absent. */
494
+ private holdFor;
495
+ /**
496
+ * The crash path (§2 / §9.4): persist the whole queue, then send **one** batch reordered
497
+ * so the crash rides in it. Not a drain — a dying process gets one round trip.
498
+ *
499
+ * ⚠ The web/native asymmetry is real and is not fixed here. On web the `Store` is
500
+ * synchronous `localStorage`, so the persist has *landed* by the time the next line runs
501
+ * and the loss window closes. On native it is an AsyncStorage round-trip that a SIGKILL
502
+ * can outrun, so the window only narrows. Awaiting harder does not change that; the
503
+ * asymmetry is the `Store` port's whole point (`core/store.ts`).
504
+ *
505
+ * The persisted copy is a safety copy, not a handoff: the queue is left intact, because
506
+ * an `app.crash` is not always fatal — `window.onerror` fires and the page keeps running
507
+ * — and the process usually lives on. A successful send therefore
508
+ * leaves a duplicate on disk to replay next launch — which is what `event.sequence` and
509
+ * the backend's `(session_id, event_sequence)` dedup exist for (§2.4).
510
+ *
511
+ * *One* duplicate. Each row is written at most once by this path, watermarked on
512
+ * `event.sequence`: a chatty app crash-flushes often, and re-persisting the whole queue
513
+ * each time would fill the store with copies of
514
+ * its own backlog and book `store_full` drops that are not loss — corrupting the very
515
+ * counter this change adds.
516
+ */
517
+ private flushCrash;
209
518
  /**
210
519
  * Build the v3 Context block that rides on every event AND metric: the flattened
211
520
  * device/network snapshot, the caller's data, identity + session + sdk fields, and the
@@ -218,16 +527,87 @@ export declare class Telemetry {
218
527
  * don't extend the breadcrumb trail and don't count as session activity — a periodic sampler
219
528
  * (memory/frames) must not keep a session alive and defeat the 30-min idle rotation.
220
529
  */
221
- logMetric(metricName: string, value: number, data?: Record<string, any>): Promise<void>;
530
+ logMetric(metricName: string, value: number, data?: Record<string, any>, unitOverride?: string, hostName?: string): Promise<void>;
531
+ /**
532
+ * The single enqueue point: neither the sample decision nor `beforeSend` can be
533
+ * bypassed by a future emit path, and the hook runs *before* the queue — which is
534
+ * what keeps scrubbed fields off disk when a send fails and the batch is persisted.
535
+ *
536
+ * The sample check is repeated by log()/logMetric() ahead of `collectContext()`, so
537
+ * a sampled-out session does no work per event; this one is the backstop that makes
538
+ * the guarantee structural rather than a convention two call sites happen to follow.
539
+ *
540
+ * The two counters are separate on purpose: "my volume is down 40%" has to
541
+ * distinguish *my rule is too broad* from *my rule is crashing*, and one merged
542
+ * counter answers neither.
543
+ */
544
+ private enqueue;
545
+ /**
546
+ * Hold the in-memory queue at its cap (§9.4), booking what it costs.
547
+ *
548
+ * The count lands on the *next* event's Context block, not this one's — `collectContext()`
549
+ * has already run by the time we get here. That is §3.7's stated behaviour, not a bug.
550
+ */
551
+ private capQueue;
552
+ /**
553
+ * Book dropped rows against the monotonic counter and the reason that shipped last.
554
+ * Takes `Sender.onFailure`'s return shape as-is — a sender with no cap returns nothing.
555
+ */
556
+ private recordDrop;
222
557
  private flattenWithPrefix;
223
558
  /**
224
- * Explicit metric helper (optional convenience) — routes through the v3 metric path.
559
+ * The public metric path (#167), sent as `custom.metric` with the host's name in
560
+ * `metric.name` (processor #41). The SDK's own names stay **reserved**, and no cap on distinct
561
+ * names. A non-finite value is dropped, never shipped as a fabricated number. `unit`
562
+ * becomes `metric.unit`, stamped after `data` so an attribute cannot mislabel it.
563
+ */
564
+ recordMetric(name: string, value: number, data?: Record<string, any>, opts?: {
565
+ unit?: string;
566
+ }): Promise<void> | undefined;
567
+ /**
568
+ * §2.4's draining flush (#162): batches go **sequentially** until the queue is empty,
569
+ * stopping at the first failure, at most `DRAIN_MAX_BATCHES` per call and paced to the
570
+ * collector's 10 req/s burst. Sequential because parallel batches are how a cold backend
571
+ * gets stampeded by a replay. Retry + backoff live in the Sender (`sendWithRetry`).
572
+ *
573
+ * A call landing while a drain is in flight joins it rather than starting a second loop:
574
+ * the interval and the batch-full trigger both fire `flush()` unawaited, and two loops
575
+ * would interleave their sends and break the pacing.
225
576
  */
226
- recordMetric(name: string, value: number, data?: Record<string, any>): Promise<void>;
227
577
  flush(): Promise<void>;
578
+ private draining?;
579
+ /** Epoch ms before which no batch may be sent — a 429's `X-RateLimit-Reset` (§2.5). */
580
+ private holdUntil;
581
+ private drain;
582
+ /**
583
+ * §2.5's status table, for a batch the sender gave up on.
584
+ *
585
+ * | 4xx | dropped — no persist — booked `rejected`, one `__DEV__` warning per process |
586
+ * | 429 | requeued at the front; the drain halts until `X-RateLimit-Reset` |
587
+ * | 5xx / network | persisted through the sender, or requeued when it cannot persist |
588
+ *
589
+ * A wrong credential is the realistic 4xx, and persisting it would make it terminal: the
590
+ * drain halts at batch 1 on every launch forever while the store fills and evicts.
591
+ */
592
+ private onSendFailure;
593
+ /**
594
+ * Book an acknowledged (2xx) batch. `session.sequence` orders a session's batches (#29),
595
+ * and it is persisted because a resumed session restarting at 0 would emit duplicate
596
+ * (session.id, session.sequence) pairs and stop ordering anything (#92).
597
+ */
598
+ private ackBatch;
228
599
  getQueue(): TelemetryEvent[];
229
600
  shutdown(): Promise<void>;
230
601
  getEventCount(): number;
231
- recordRouteChange(from: string, to: string): void | undefined;
602
+ /**
603
+ * A route change (§4.5): rung 2 of the name ladder. The two deprecated feeds it used to
604
+ * emit alongside — `navigation` and `screen.duration` — are gone in v5 (#163).
605
+ */
606
+ recordRouteChange(to: string): Promise<void>;
607
+ /**
608
+ * Feed the name ladder (§4.5.1). Rungs 1 and 2 arrive unnormalized; rung 3's caller
609
+ * normalizes before calling. Whether this re-stamps the current view or mints a
610
+ * successor is the ladder's decision, not the caller's.
611
+ */
612
+ enterView(name: string, source: ViewNameSource): Promise<void>;
232
613
  }
233
- export {};
@@ -0,0 +1,19 @@
1
+ import { UserProfile } from './telemetry';
2
+ export declare const NAME_CAP = 255;
3
+ export declare const EMAIL_CAP = 255;
4
+ export declare const PHONE_CAP = 50;
5
+ export declare const CUSTOM_MAX_KEYS = 64;
6
+ export declare const CUSTOM_KEY_CAP = 64;
7
+ export declare const CUSTOM_VALUE_CAP = 255;
8
+ /**
9
+ * A primitive rides as itself; anything else is stringified and truncated. A value that
10
+ * cannot be stringified — a cycle, a throwing `toJSON` — drops the key rather than the
11
+ * process. Consumer keys pass through **verbatim, casing included** (§4.10): the SDK
12
+ * imposes no normalization here, so an over-long key is dropped, never truncated.
13
+ */
14
+ export declare function customValue(value: unknown): string | number | boolean | undefined;
15
+ /**
16
+ * The wire keys for `user.profile.update`. `user.id` is not here — it rides the Context
17
+ * block, where it is present on this event by construction.
18
+ */
19
+ export declare function buildProfileAttributes(profile: UserProfile | undefined): Record<string, any>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `JSON.stringify` that returns `undefined` instead of throwing — a cycle, a `toJSON` that
3
+ * threw, a `BigInt`. Shared by `user.custom.*`'s bag rule (§4.10) and `flattenWithPrefix`'s
4
+ * depth cap: both exist so a bad consumer payload is a dropped key rather than an exception
5
+ * raised inside the SDK, in the host app's own call stack.
6
+ */
7
+ export declare function stringifyOrDrop(value: unknown): string | undefined;
@@ -1,2 +1,11 @@
1
- export declare function generateId(): string;
1
+ /**
2
+ * Wire-contract ids carry a 16-hex-char (64-bit) random segment (§3.3) — except W3C
3
+ * `trace.id`, which is 32 (§6.1). The length is the caller's; the entropy source is not.
4
+ *
5
+ * Entropy is `crypto.getRandomValues`, not `Math.random()` (#91): `device.id` is now
6
+ * persisted, so a collision is *permanent* — two handsets merge into one device row and
7
+ * one rate-limit bucket forever — where a session collision was transient. RN has no
8
+ * WebCrypto of its own; the native entry imports `react-native-get-random-values`
9
+ * (already a dependency) to install it before the first id is minted.
10
+ */
2
11
  export declare function randomHex(length?: number): string;
@@ -1,4 +1,6 @@
1
- import { TelemetryNative } from './index.native';
1
+ import { TelemetryNative } from './telemetryNative.native';
2
+ import { Store } from './core/store';
3
+ import { BeforeSend } from './core/beforeSend';
2
4
  export type TelemetryOpts = {
3
5
  apiKey: string;
4
6
  sender?: any;
@@ -7,6 +9,13 @@ export type TelemetryOpts = {
7
9
  endpoint?: string;
8
10
  captureConsole?: boolean;
9
11
  debug?: boolean;
12
+ store?: Store;
13
+ beforeSend?: BeforeSend;
14
+ sessionSampleRate?: number;
15
+ traceHostAllowlist?: string[];
16
+ buildId?: string;
17
+ enabled?: boolean;
18
+ autoTrackTaps?: boolean;
10
19
  };
11
20
  export declare function assertApiKey(apiKey?: string): void;
12
21
  /**
@@ -1,4 +1,6 @@
1
- import { TelemetryWeb } from './index.web';
1
+ import { TelemetryWeb } from './telemetryWeb.web';
2
+ import { SyncStore } from './core/store';
3
+ import { BeforeSend } from './core/beforeSend';
2
4
  export type TelemetryOpts = {
3
5
  apiKey: string;
4
6
  sender?: any;
@@ -7,6 +9,12 @@ export type TelemetryOpts = {
7
9
  endpoint?: string;
8
10
  captureConsole?: boolean;
9
11
  debug?: boolean;
12
+ store?: SyncStore;
13
+ beforeSend?: BeforeSend;
14
+ sessionSampleRate?: number;
15
+ traceHostAllowlist?: string[];
16
+ buildId?: string;
17
+ enabled?: boolean;
10
18
  };
11
19
  export declare function assertApiKey(apiKey?: string): void;
12
20
  /**