@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.
- package/LICENSE +21 -0
- package/README.md +985 -185
- package/dist/appLifecycle-DS_fEclk.cjs +2 -0
- package/dist/appLifecycle-DS_fEclk.cjs.map +1 -0
- package/dist/appLifecycle-PffQ4vC1.js +24 -0
- package/dist/appLifecycle-PffQ4vC1.js.map +1 -0
- package/dist/autoTaps.native-By9I4Kr2.cjs +2 -0
- package/dist/autoTaps.native-By9I4Kr2.cjs.map +1 -0
- package/dist/autoTaps.native-DQCXevD7.js +66 -0
- package/dist/autoTaps.native-DQCXevD7.js.map +1 -0
- package/dist/crashHandler.web-6KvedEB-.cjs +2 -0
- package/dist/crashHandler.web-6KvedEB-.cjs.map +1 -0
- package/dist/crashHandler.web-BUlSXYoS.js +30 -0
- package/dist/crashHandler.web-BUlSXYoS.js.map +1 -0
- package/dist/crashHandlerNative.native-CFVQ5UcO.cjs +2 -0
- package/dist/crashHandlerNative.native-CFVQ5UcO.cjs.map +1 -0
- package/dist/crashHandlerNative.native-DsCRd-oN.js +39 -0
- package/dist/crashHandlerNative.native-DsCRd-oN.js.map +1 -0
- package/dist/deviceInfo.native-D5gNBG7m.cjs +2 -0
- package/dist/deviceInfo.native-D5gNBG7m.cjs.map +1 -0
- package/dist/deviceInfo.native-DiiHrnI3.js +53 -0
- package/dist/deviceInfo.native-DiiHrnI3.js.map +1 -0
- package/dist/deviceInfo.web-BHsjVveq.js +41 -0
- package/dist/deviceInfo.web-BHsjVveq.js.map +1 -0
- package/dist/deviceInfo.web-DGCUHAnv.cjs +2 -0
- package/dist/deviceInfo.web-DGCUHAnv.cjs.map +1 -0
- package/dist/deviceState.native-BEysbZ6O.js +58 -0
- package/dist/deviceState.native-BEysbZ6O.js.map +1 -0
- package/dist/deviceState.native-CrQMy11_.cjs +2 -0
- package/dist/deviceState.native-CrQMy11_.cjs.map +1 -0
- package/dist/deviceState.web-ByaQm9Ry.js +14 -0
- package/dist/deviceState.web-ByaQm9Ry.js.map +1 -0
- package/dist/deviceState.web-CSfUgHDU.cjs +2 -0
- package/dist/deviceState.web-CSfUgHDU.cjs.map +1 -0
- package/dist/frameTracker-9j0en6Zm.cjs +2 -0
- package/dist/frameTracker-9j0en6Zm.cjs.map +1 -0
- package/dist/frameTracker-BzXnxSkb.js +53 -0
- package/dist/frameTracker-BzXnxSkb.js.map +1 -0
- package/dist/httpAttributes-BWXOr4eP.js +70 -0
- package/dist/httpAttributes-BWXOr4eP.js.map +1 -0
- package/dist/httpAttributes-COY0_kiF.cjs +2 -0
- package/dist/httpAttributes-COY0_kiF.cjs.map +1 -0
- package/dist/index.native.cjs +1 -1
- package/dist/index.native.cjs.map +1 -1
- package/dist/index.native.d.ts +1 -1
- package/dist/index.native.js +173 -81
- package/dist/index.native.js.map +1 -1
- package/dist/index.web.cjs +1 -1
- package/dist/index.web.cjs.map +1 -1
- package/dist/index.web.d.ts +1 -1
- package/dist/index.web.js +107 -39
- package/dist/index.web.js.map +1 -1
- package/dist/interactionWeb.web-BWBjmovb.js +109 -0
- package/dist/interactionWeb.web-BWBjmovb.js.map +1 -0
- package/dist/interactionWeb.web-CKDJLD9r.cjs +2 -0
- package/dist/interactionWeb.web-CKDJLD9r.cjs.map +1 -0
- package/dist/interceptFetchWeb.web-DjSR_Rft.js +62 -0
- package/dist/interceptFetchWeb.web-DjSR_Rft.js.map +1 -0
- package/dist/interceptFetchWeb.web-ZHw6IQkU.cjs +2 -0
- package/dist/interceptFetchWeb.web-ZHw6IQkU.cjs.map +1 -0
- package/dist/interceptHttpNative.native-C5scIcgY.cjs +2 -0
- package/dist/interceptHttpNative.native-C5scIcgY.cjs.map +1 -0
- package/dist/interceptHttpNative.native-vF_Fksjk.js +18 -0
- package/dist/interceptHttpNative.native-vF_Fksjk.js.map +1 -0
- package/dist/loadingTime-Cj5Oh8lT.cjs +2 -0
- package/dist/loadingTime-Cj5Oh8lT.cjs.map +1 -0
- package/dist/loadingTime-DMc0zTY8.js +70 -0
- package/dist/loadingTime-DMc0zTY8.js.map +1 -0
- package/dist/memoryNative.native-CK3QFVjY.cjs +2 -0
- package/dist/memoryNative.native-CK3QFVjY.cjs.map +1 -0
- package/dist/memoryNative.native-DkA6f7id.js +54 -0
- package/dist/memoryNative.native-DkA6f7id.js.map +1 -0
- package/dist/nativeSender-Dt1HLaLi.js +37 -0
- package/dist/nativeSender-Dt1HLaLi.js.map +1 -0
- package/dist/nativeSender-hCgUa7Vz.cjs +2 -0
- package/dist/nativeSender-hCgUa7Vz.cjs.map +1 -0
- package/dist/navigationRef-CVIv0aIK.js +30 -0
- package/dist/navigationRef-CVIv0aIK.js.map +1 -0
- package/dist/navigationRef-CfIbeXX8.cjs +2 -0
- package/dist/navigationRef-CfIbeXX8.cjs.map +1 -0
- package/dist/navigationWeb.web-CRHpr5zl.js +51 -0
- package/dist/navigationWeb.web-CRHpr5zl.js.map +1 -0
- package/dist/navigationWeb.web-DwWjL80b.cjs +2 -0
- package/dist/navigationWeb.web-DwWjL80b.cjs.map +1 -0
- package/dist/{networkChange-CUO1hRLj.cjs → networkChange-2FGIQM-N.cjs} +2 -2
- package/dist/networkChange-2FGIQM-N.cjs.map +1 -0
- package/dist/{networkChange-D39hdSb0.js → networkChange-QA0893vW.js} +2 -2
- package/dist/networkChange-QA0893vW.js.map +1 -0
- package/dist/networkInfo.native-CcJ3JVRF.js +31 -0
- package/dist/networkInfo.native-CcJ3JVRF.js.map +1 -0
- package/dist/networkInfo.native-whB2wf6a.cjs +2 -0
- package/dist/networkInfo.native-whB2wf6a.cjs.map +1 -0
- package/dist/{networkInfo.web-twcNn_hc.js → networkInfo.web-CcUpXMUK.js} +4 -4
- package/dist/networkInfo.web-CcUpXMUK.js.map +1 -0
- package/dist/networkInfo.web-DfO-BUFx.cjs +2 -0
- package/dist/networkInfo.web-DfO-BUFx.cjs.map +1 -0
- package/dist/react-bqe7KPOf.cjs +4 -0
- package/dist/react-bqe7KPOf.cjs.map +1 -0
- package/dist/react-urNtDGTL.js +413 -0
- package/dist/react-urNtDGTL.js.map +1 -0
- package/dist/runtimeReady.native-CxFl1rQR.js +35 -0
- package/dist/runtimeReady.native-CxFl1rQR.js.map +1 -0
- package/dist/runtimeReady.native-zueSbsEv.cjs +2 -0
- package/dist/runtimeReady.native-zueSbsEv.cjs.map +1 -0
- package/dist/runtimeReady.web-JuE239Tg.js +25 -0
- package/dist/runtimeReady.web-JuE239Tg.js.map +1 -0
- package/dist/runtimeReady.web-vhAJFU61.cjs +2 -0
- package/dist/runtimeReady.web-vhAJFU61.cjs.map +1 -0
- package/dist/seedRuntimeReady-BlRdf3pR.js +10 -0
- package/dist/seedRuntimeReady-BlRdf3pR.js.map +1 -0
- package/dist/seedRuntimeReady-CbjqbWCd.cjs +2 -0
- package/dist/seedRuntimeReady-CbjqbWCd.cjs.map +1 -0
- package/dist/src/adapters/appLifecycle.d.ts +11 -4
- package/dist/src/adapters/batch.d.ts +46 -0
- package/dist/src/adapters/crashCapture.d.ts +42 -9
- package/dist/src/adapters/deviceState.d.ts +9 -0
- package/dist/src/adapters/failedEvents.d.ts +43 -0
- package/dist/src/adapters/frameAggregate.d.ts +19 -12
- package/dist/src/adapters/frameTracker.d.ts +30 -0
- package/dist/src/adapters/hangDetector.d.ts +41 -0
- package/dist/src/adapters/httpAttributes.d.ts +18 -0
- package/dist/src/adapters/loadingTime.d.ts +67 -0
- package/dist/src/adapters/manualSpans.d.ts +41 -0
- package/dist/src/adapters/native/autoTaps.native.d.ts +15 -0
- package/dist/src/adapters/native/deviceState.native.d.ts +15 -0
- package/dist/src/adapters/native/interceptHttpNative.native.d.ts +18 -0
- package/dist/src/adapters/native/memoryNative.native.d.ts +15 -11
- package/dist/src/adapters/native/networkInfo.native.d.ts +1 -1
- package/dist/src/adapters/native/runtimeReady.native.d.ts +17 -0
- package/dist/src/adapters/native/store.native.d.ts +10 -0
- package/dist/src/adapters/nativeSender.d.ts +2 -2
- package/dist/src/adapters/navigationRef.d.ts +29 -0
- package/dist/src/adapters/networkChange.d.ts +2 -2
- package/dist/src/adapters/seedRuntimeReady.d.ts +8 -0
- package/dist/src/adapters/traceHeader.d.ts +33 -0
- package/dist/src/adapters/traceManager.d.ts +144 -0
- package/dist/src/adapters/uiInteraction.d.ts +111 -0
- package/dist/src/adapters/viewManager.d.ts +177 -0
- package/dist/src/adapters/viewport.d.ts +15 -0
- package/dist/src/adapters/web/deviceState.web.d.ts +10 -0
- package/dist/src/adapters/web/interactionWeb.web.d.ts +36 -0
- package/dist/src/adapters/web/interceptFetchWeb.web.d.ts +3 -11
- package/dist/src/adapters/web/navigationWeb.web.d.ts +13 -7
- package/dist/src/adapters/web/runtimeReady.web.d.ts +5 -0
- package/dist/src/adapters/web/store.web.d.ts +12 -0
- package/dist/src/adapters/web/webVitals.web.d.ts +56 -0
- package/dist/src/adapters/webSender.d.ts +2 -2
- package/dist/src/adapters/webVitals.d.ts +25 -0
- package/dist/src/adapters/xhrIntercept.d.ts +55 -0
- package/dist/src/core/beforeSend.d.ts +20 -0
- package/dist/src/core/breadcrumbs.d.ts +10 -0
- package/dist/src/core/debug.d.ts +7 -0
- package/dist/src/core/memoryStore.d.ts +23 -0
- package/dist/src/core/store.d.ts +41 -0
- package/dist/src/core/telemetry.d.ts +422 -42
- package/dist/src/core/userProfile.d.ts +19 -0
- package/dist/src/core/utils/json.d.ts +7 -0
- package/dist/src/core/utils/uuid.d.ts +10 -1
- package/dist/src/createTelemetry.native.d.ts +10 -1
- package/dist/src/createTelemetry.web.d.ts +9 -1
- package/dist/src/golden.helper.d.ts +4 -0
- package/dist/src/index.base.d.ts +93 -3
- package/dist/src/index.native.d.ts +7 -27
- package/dist/src/index.web.d.ts +7 -23
- package/dist/src/react.d.ts +45 -0
- package/dist/src/telemetryNative.native.d.ts +79 -0
- package/dist/src/telemetryWeb.web.d.ts +59 -0
- package/dist/store.native-BbS76uWV.cjs +2 -0
- package/dist/store.native-BbS76uWV.cjs.map +1 -0
- package/dist/store.native-MlWyGgBp.js +32 -0
- package/dist/store.native-MlWyGgBp.js.map +1 -0
- package/dist/store.web-BzKaP57Z.cjs +2 -0
- package/dist/store.web-BzKaP57Z.cjs.map +1 -0
- package/dist/store.web-rhh0NOfs.js +31 -0
- package/dist/store.web-rhh0NOfs.js.map +1 -0
- package/dist/telemetry-60sfWkh0.js +1754 -0
- package/dist/telemetry-60sfWkh0.js.map +1 -0
- package/dist/telemetry-CW63glwb.cjs +2 -0
- package/dist/telemetry-CW63glwb.cjs.map +1 -0
- package/dist/uiInteraction-BIDOMcrL.js +109 -0
- package/dist/uiInteraction-BIDOMcrL.js.map +1 -0
- package/dist/uiInteraction-DxlwCVSn.cjs +2 -0
- package/dist/uiInteraction-DxlwCVSn.cjs.map +1 -0
- package/dist/viewport-9JcVIXYF.cjs +2 -0
- package/dist/viewport-9JcVIXYF.cjs.map +1 -0
- package/dist/viewport-GWTEBt2K.js +15 -0
- package/dist/viewport-GWTEBt2K.js.map +1 -0
- package/dist/web-vitals.attribution-DAvBvdng.cjs +2 -0
- package/dist/web-vitals.attribution-DAvBvdng.cjs.map +1 -0
- package/dist/web-vitals.attribution-DcoMtvlY.js +488 -0
- package/dist/web-vitals.attribution-DcoMtvlY.js.map +1 -0
- package/dist/webSender-DA087xb5.cjs +2 -0
- package/dist/webSender-DA087xb5.cjs.map +1 -0
- package/dist/webSender-g4rs5TIg.js +44 -0
- package/dist/webSender-g4rs5TIg.js.map +1 -0
- package/dist/webVitals.web-DRTDK6s5.js +100 -0
- package/dist/webVitals.web-DRTDK6s5.js.map +1 -0
- package/dist/webVitals.web-DvScDIjX.cjs +2 -0
- package/dist/webVitals.web-DvScDIjX.cjs.map +1 -0
- package/dist/xhrIntercept-9uAkQh3N.js +55 -0
- package/dist/xhrIntercept-9uAkQh3N.js.map +1 -0
- package/dist/xhrIntercept-xG1Yl5RI.cjs +2 -0
- package/dist/xhrIntercept-xG1Yl5RI.cjs.map +1 -0
- package/docs/migration-v4.md +190 -0
- package/docs/migration-v5.md +178 -0
- package/package.json +22 -6
- package/dist/appLifecycle-Cynw0kAv.js +0 -14
- package/dist/appLifecycle-Cynw0kAv.js.map +0 -1
- package/dist/appLifecycle-DvJIt7ym.cjs +0 -2
- package/dist/appLifecycle-DvJIt7ym.cjs.map +0 -1
- package/dist/batch-CLBFgYPC.cjs +0 -2
- package/dist/batch-CLBFgYPC.cjs.map +0 -1
- package/dist/batch-DLG_gtOm.js +0 -12
- package/dist/batch-DLG_gtOm.js.map +0 -1
- package/dist/crashCapture-BYTM4FLC.cjs +0 -2
- package/dist/crashCapture-BYTM4FLC.cjs.map +0 -1
- package/dist/crashCapture-D_rkkBVa.js +0 -31
- package/dist/crashCapture-D_rkkBVa.js.map +0 -1
- package/dist/crashHandler.web-BSxDpFTo.cjs +0 -2
- package/dist/crashHandler.web-BSxDpFTo.cjs.map +0 -1
- package/dist/crashHandler.web-D59bmhg9.js +0 -32
- package/dist/crashHandler.web-D59bmhg9.js.map +0 -1
- package/dist/crashHandlerNative.native-DeAFze4E.cjs +0 -2
- package/dist/crashHandlerNative.native-DeAFze4E.cjs.map +0 -1
- package/dist/crashHandlerNative.native-d7qJkzA6.js +0 -41
- package/dist/crashHandlerNative.native-d7qJkzA6.js.map +0 -1
- package/dist/debug-DsvQ9y3W.js +0 -68
- package/dist/debug-DsvQ9y3W.js.map +0 -1
- package/dist/debug-rnOOxFpN.cjs +0 -2
- package/dist/debug-rnOOxFpN.cjs.map +0 -1
- package/dist/deviceInfo.native-7hbRYixR.cjs +0 -2
- package/dist/deviceInfo.native-7hbRYixR.cjs.map +0 -1
- package/dist/deviceInfo.native-D2k0LDhI.js +0 -1171
- package/dist/deviceInfo.native-D2k0LDhI.js.map +0 -1
- package/dist/deviceInfo.web-ByNAlEJh.cjs +0 -2
- package/dist/deviceInfo.web-ByNAlEJh.cjs.map +0 -1
- package/dist/deviceInfo.web-DzQyEku6.js +0 -40
- package/dist/deviceInfo.web-DzQyEku6.js.map +0 -1
- package/dist/frameAggregate-C_HoVFcK.cjs +0 -2
- package/dist/frameAggregate-C_HoVFcK.cjs.map +0 -1
- package/dist/frameAggregate-Cwh1juw1.js +0 -17
- package/dist/frameAggregate-Cwh1juw1.js.map +0 -1
- package/dist/frameDropsNative.native-CP7zrXDf.js +0 -23
- package/dist/frameDropsNative.native-CP7zrXDf.js.map +0 -1
- package/dist/frameDropsNative.native-DKqEDqip.cjs +0 -2
- package/dist/frameDropsNative.native-DKqEDqip.cjs.map +0 -1
- package/dist/frameDropsWeb.web-C9Lt3Fuj.js +0 -22
- package/dist/frameDropsWeb.web-C9Lt3Fuj.js.map +0 -1
- package/dist/frameDropsWeb.web-azpwQCUz.cjs +0 -2
- package/dist/frameDropsWeb.web-azpwQCUz.cjs.map +0 -1
- package/dist/httpAttributes-BV50UKQU.js +0 -19
- package/dist/httpAttributes-BV50UKQU.js.map +0 -1
- package/dist/httpAttributes-xXOD9trQ.cjs +0 -2
- package/dist/httpAttributes-xXOD9trQ.cjs.map +0 -1
- package/dist/interaction-CH8yoY5-.js +0 -23
- package/dist/interaction-CH8yoY5-.js.map +0 -1
- package/dist/interaction-DcNFBW7a.cjs +0 -2
- package/dist/interaction-DcNFBW7a.cjs.map +0 -1
- package/dist/interceptFetchNative.native-VlhtMG-U.js +0 -49
- package/dist/interceptFetchNative.native-VlhtMG-U.js.map +0 -1
- package/dist/interceptFetchNative.native-jEAldH14.cjs +0 -2
- package/dist/interceptFetchNative.native-jEAldH14.cjs.map +0 -1
- package/dist/interceptFetchWeb.web-DFzZliik.cjs +0 -2
- package/dist/interceptFetchWeb.web-DFzZliik.cjs.map +0 -1
- package/dist/interceptFetchWeb.web-DfsMfoRP.js +0 -77
- package/dist/interceptFetchWeb.web-DfsMfoRP.js.map +0 -1
- package/dist/memoryNative.native-BWLh2S9L.js +0 -48
- package/dist/memoryNative.native-BWLh2S9L.js.map +0 -1
- package/dist/memoryNative.native-DCXSOd4Q.cjs +0 -2
- package/dist/memoryNative.native-DCXSOd4Q.cjs.map +0 -1
- package/dist/memoryWeb.web-B3YuV-cB.js +0 -48
- package/dist/memoryWeb.web-B3YuV-cB.js.map +0 -1
- package/dist/memoryWeb.web-CheXAcJn.cjs +0 -2
- package/dist/memoryWeb.web-CheXAcJn.cjs.map +0 -1
- package/dist/nativeSender-BE_mzw_S.js +0 -70
- package/dist/nativeSender-BE_mzw_S.js.map +0 -1
- package/dist/nativeSender-DyAUGY7c.cjs +0 -2
- package/dist/nativeSender-DyAUGY7c.cjs.map +0 -1
- package/dist/navigationNative.native-3tO5JxSd.cjs +0 -2
- package/dist/navigationNative.native-3tO5JxSd.cjs.map +0 -1
- package/dist/navigationNative.native-BUCGPQX2.js +0 -25
- package/dist/navigationNative.native-BUCGPQX2.js.map +0 -1
- package/dist/navigationTracker-B2GMwyKk.cjs +0 -2
- package/dist/navigationTracker-B2GMwyKk.cjs.map +0 -1
- package/dist/navigationTracker-Cts68dgG.js +0 -19
- package/dist/navigationTracker-Cts68dgG.js.map +0 -1
- package/dist/navigationWeb.web-B0necr5j.cjs +0 -2
- package/dist/navigationWeb.web-B0necr5j.cjs.map +0 -1
- package/dist/navigationWeb.web-CORzE_Id.js +0 -46
- package/dist/navigationWeb.web-CORzE_Id.js.map +0 -1
- package/dist/networkChange-CUO1hRLj.cjs.map +0 -1
- package/dist/networkChange-D39hdSb0.js.map +0 -1
- package/dist/networkInfo.native-BK5fpAOL.js +0 -343
- package/dist/networkInfo.native-BK5fpAOL.js.map +0 -1
- package/dist/networkInfo.native-cxuw93Uy.cjs +0 -2
- package/dist/networkInfo.native-cxuw93Uy.cjs.map +0 -1
- package/dist/networkInfo.web-DJmw1sNK.cjs +0 -2
- package/dist/networkInfo.web-DJmw1sNK.cjs.map +0 -1
- package/dist/networkInfo.web-twcNn_hc.js.map +0 -1
- package/dist/src/adapters/interaction.d.ts +0 -17
- package/dist/src/adapters/native/frameDropsNative.native.d.ts +0 -16
- package/dist/src/adapters/native/interceptFetchNative.native.d.ts +0 -23
- package/dist/src/adapters/native/navigationNative.native.d.ts +0 -12
- package/dist/src/adapters/navigationTracker.d.ts +0 -6
- package/dist/src/adapters/screenTiming.d.ts +0 -9
- package/dist/src/adapters/web/frameDropsWeb.web.d.ts +0 -16
- package/dist/src/adapters/web/memoryWeb.web.d.ts +0 -26
- package/dist/telemetry-Co4MYdwa.cjs +0 -2
- package/dist/telemetry-Co4MYdwa.cjs.map +0 -1
- package/dist/telemetry-KI0x4gzC.js +0 -389
- package/dist/telemetry-KI0x4gzC.js.map +0 -1
- package/dist/v4-BysszJq8.js +0 -31
- package/dist/v4-BysszJq8.js.map +0 -1
- package/dist/v4-CqdK_b8Y.cjs +0 -2
- package/dist/v4-CqdK_b8Y.cjs.map +0 -1
- package/dist/webSender-B27tmT1w.js +0 -42
- package/dist/webSender-B27tmT1w.js.map +0 -1
- package/dist/webSender-BWi4x1df.cjs +0 -2
- package/dist/webSender-BWi4x1df.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -4,47 +4,68 @@
|
|
|
4
4
|
[](https://reactnative.dev/)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
backend — the same backend the web, Android (Ionic) and iOS SDKs feed.
|
|
7
|
+
Real User Monitoring for **React Native** and **React Native Web**. Add it once and it reports
|
|
8
|
+
what your users actually experience — crashes, slow screens, failing requests, dead taps — to
|
|
9
|
+
your EdgeTelemetryProcessor collector.
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
You import from one package name. The bundler picks the native or the web build for you.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createTelemetry } from "@nathanclaire/edge-telemetry-sdk";
|
|
15
|
+
|
|
16
|
+
const telemetry = createTelemetry({
|
|
17
|
+
apiKey: "edge_xxxxxxxx",
|
|
18
|
+
endpoint: "https://collector.example.com/telemetry",
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
That's the whole setup. Crash capture, HTTP interception, screen tracking, frame and memory
|
|
23
|
+
sampling and session management all start on their own — there is nothing else to wire up.
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
| | Minimum |
|
|
28
|
+
|---|---|
|
|
29
|
+
| React Native | 0.64 |
|
|
30
|
+
| React / React DOM | 17 |
|
|
31
|
+
| Platforms | iOS, Android, and any modern browser via React Native Web |
|
|
32
|
+
| TypeScript | Optional — types ship with the package |
|
|
14
33
|
|
|
15
34
|
---
|
|
16
35
|
|
|
17
36
|
## Contents
|
|
18
37
|
|
|
19
|
-
|
|
38
|
+
**Getting started**
|
|
20
39
|
- [Install](#install)
|
|
21
40
|
- [Quick start](#quick-start)
|
|
41
|
+
- [Verify it's working](#verify-its-working)
|
|
22
42
|
- [Configuration](#configuration)
|
|
43
|
+
|
|
44
|
+
**How-to guides**
|
|
45
|
+
- [Send a custom event](#send-a-custom-event)
|
|
46
|
+
- [Time a journey](#time-a-journey)
|
|
47
|
+
- [Identify the signed-in user](#identify-the-signed-in-user)
|
|
48
|
+
- [Track screens](#track-screens)
|
|
49
|
+
- [Track taps](#track-taps)
|
|
50
|
+
- [Report handled errors](#report-handled-errors)
|
|
51
|
+
- [Make crash stacks readable](#make-crash-stacks-readable)
|
|
52
|
+
- [Strip PII before it leaves the device](#strip-pii-before-it-leaves-the-device)
|
|
53
|
+
- [Sample a percentage of sessions](#sample-a-percentage-of-sessions)
|
|
54
|
+
- [Respect a user's opt-out](#respect-a-users-opt-out)
|
|
55
|
+
- [Connect your traces to your backend](#connect-your-traces-to-your-backend)
|
|
56
|
+
|
|
57
|
+
**Reference**
|
|
58
|
+
- [What the SDK captures](#what-the-sdk-captures)
|
|
23
59
|
- [API](#api)
|
|
24
|
-
- [
|
|
60
|
+
- [The Context block](#the-context-block)
|
|
25
61
|
- [Wire format](#wire-format)
|
|
26
|
-
- [Identity
|
|
27
|
-
- [
|
|
28
|
-
- [Debugging](#debugging)
|
|
29
|
-
- [Development](#development)
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Upgrading to v3 (breaking)
|
|
34
|
-
|
|
35
|
-
v3 is a **single clean break** onto the EdgeRum wire contract — no dual-emit, no v2 fallback.
|
|
36
|
-
If you're coming from v2, the headlines:
|
|
62
|
+
- [Identity and IDs](#identity-and-ids)
|
|
63
|
+
- [Delivery and reliability](#delivery-and-reliability)
|
|
37
64
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
events are gone).
|
|
43
|
-
- Several event names changed and only the allowlist ships (`network_request` → `http.request`,
|
|
44
|
-
`screen_view` → `navigation`, …); other `log()` names arrive as `custom_event`.
|
|
45
|
-
- New `debug` option (default `false`) silences all SDK console output.
|
|
46
|
-
|
|
47
|
-
Full breaking-change list and migration checklist: **[CHANGELOG.md](./CHANGELOG.md)**.
|
|
65
|
+
**Help**
|
|
66
|
+
- [Troubleshooting](#troubleshooting)
|
|
67
|
+
- [Upgrading](#upgrading)
|
|
68
|
+
- [Development](#development)
|
|
48
69
|
|
|
49
70
|
---
|
|
50
71
|
|
|
@@ -54,279 +75,1048 @@ Full breaking-change list and migration checklist: **[CHANGELOG.md](./CHANGELOG.
|
|
|
54
75
|
npm install @nathanclaire/edge-telemetry-sdk
|
|
55
76
|
```
|
|
56
77
|
|
|
57
|
-
### React Native
|
|
78
|
+
### React Native — one extra step
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
The native modules the SDK reads device and network state from ship as dependencies, so npm
|
|
81
|
+
installs them for you. On iOS, link them:
|
|
60
82
|
|
|
61
83
|
```bash
|
|
62
|
-
npm install @react-native-async-storage/async-storage react-native-device-info @react-native-community/netinfo
|
|
63
84
|
cd ios && pod install
|
|
64
85
|
```
|
|
65
86
|
|
|
66
|
-
|
|
|
67
|
-
|
|
68
|
-
| `@react-native-async-storage/async-storage` |
|
|
69
|
-
|
|
|
70
|
-
|
|
|
87
|
+
| Module | What it provides | If it's missing |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `@react-native-async-storage/async-storage` | Saves failed batches for replay | Telemetry is lost on a network outage instead of retried |
|
|
90
|
+
| `@react-native-community/netinfo` | `network.*` context, `network_change` events | No connectivity data |
|
|
91
|
+
| `react-native-device-info` | `device.*` detail, the `memory_usage` metric | Degrades gracefully — this one is an **optional** peer |
|
|
92
|
+
|
|
93
|
+
`react` and `react-dom` (>= 17) are required peers and will already be in your app.
|
|
71
94
|
|
|
72
|
-
|
|
95
|
+
### React Native Web
|
|
96
|
+
|
|
97
|
+
The web build uses `fetch`, `localStorage` and `navigator` only. Nothing to link, nothing to
|
|
98
|
+
configure.
|
|
73
99
|
|
|
74
100
|
---
|
|
75
101
|
|
|
76
102
|
## Quick start
|
|
77
103
|
|
|
78
|
-
|
|
79
|
-
**Every public method is `async`** (each awaits a lazily-built core), so `await` your calls.
|
|
80
|
-
|
|
81
|
-
### React Native
|
|
104
|
+
Create the instance once, as early in your app's startup as you can, and export it.
|
|
82
105
|
|
|
83
106
|
```typescript
|
|
107
|
+
// telemetry.ts
|
|
84
108
|
import { createTelemetry } from "@nathanclaire/edge-telemetry-sdk";
|
|
85
109
|
|
|
86
|
-
const telemetry = createTelemetry({
|
|
87
|
-
apiKey: "edge_xxxxxxxx",
|
|
88
|
-
endpoint: "https://collector.example.com/
|
|
89
|
-
|
|
90
|
-
flushIntervalMs: 10000,
|
|
110
|
+
export const telemetry = createTelemetry({
|
|
111
|
+
apiKey: "edge_xxxxxxxx", // required, must start with "edge_"
|
|
112
|
+
endpoint: "https://collector.example.com/telemetry", // your collector's POST URL
|
|
113
|
+
buildId: process.env.GIT_SHA, // optional, makes crashes symbolicatable
|
|
91
114
|
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// App.tsx
|
|
119
|
+
import { telemetry } from "./telemetry";
|
|
92
120
|
|
|
93
121
|
await telemetry.log("checkout_started", { cart_value: 42 });
|
|
94
122
|
```
|
|
95
123
|
|
|
96
|
-
|
|
124
|
+
**Create it early.** Everything before `createTelemetry()` runs is invisible to the SDK — a crash
|
|
125
|
+
during startup, the first screen's load time, the requests your splash screen fires. The first
|
|
126
|
+
line of your entry file is the right place.
|
|
127
|
+
|
|
128
|
+
> **Every public method returns a Promise.** Each one waits on a lazily-built core, so `await`
|
|
129
|
+
> your calls — or at minimum attach a `.catch()`. They never throw at you; the SDK swallows its
|
|
130
|
+
> own failures rather than taking your app down with it.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Verify it's working
|
|
135
|
+
|
|
136
|
+
Turn on debug logging, send one event, and force a flush:
|
|
97
137
|
|
|
98
138
|
```typescript
|
|
99
|
-
|
|
139
|
+
const telemetry = createTelemetry({
|
|
140
|
+
apiKey: "edge_xxxxxxxx",
|
|
141
|
+
endpoint: "https://collector.example.com/telemetry",
|
|
142
|
+
debug: true, // routes the SDK's internal diagnostics to the console
|
|
143
|
+
});
|
|
100
144
|
|
|
145
|
+
await telemetry.log("hello_world");
|
|
146
|
+
await telemetry.flush(); // don't wait for the 30-second timer
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
You should see the batch POST in your console and a `200` from the collector. If you don't, start
|
|
150
|
+
at [Troubleshooting](#troubleshooting).
|
|
151
|
+
|
|
152
|
+
**The SDK is silent by default.** With `debug` off — the default — it writes nothing to your
|
|
153
|
+
console, including when its own sends fail. That is deliberate: a monitoring tool should not be
|
|
154
|
+
the noisiest thing in your log. Turn it on while integrating, then turn it off.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
Everything is passed to `createTelemetry()`. There are no runtime setters for the options marked
|
|
160
|
+
**constructor-only** — see the note below the table.
|
|
161
|
+
|
|
162
|
+
| Option | Type | Default | What it does |
|
|
163
|
+
|---|---|---|---|
|
|
164
|
+
| `apiKey` | `string` | — | **Required.** Must start with `edge_`. Sent as both `X-API-Key` and `Authorization: Bearer`. |
|
|
165
|
+
| `endpoint` | `string` | placeholder | Your collector's full POST URL. **Always set this** — the default resolves nowhere. |
|
|
166
|
+
| `batchSize` | `number` | `50` | Events per flush. |
|
|
167
|
+
| `flushIntervalMs` | `number` | `30000` | How often to flush. `<= 0` disables the timer. |
|
|
168
|
+
| `captureConsole` | `boolean` | `false` | Turns `console.error` into `app.error` and `console.warn` into a breadcrumb. |
|
|
169
|
+
| `debug` | `boolean` | `false` | Prints the SDK's internal diagnostics. Off means completely silent. |
|
|
170
|
+
| `buildId` | `string` | omitted | Your build's identifier, for [symbolicating crashes](#make-crash-stacks-readable). |
|
|
171
|
+
| `beforeSend` | `(event) => event \| null` | none | [Scrubbing hook](#strip-pii-before-it-leaves-the-device). Constructor-only. |
|
|
172
|
+
| `enabled` | `boolean` | `true` | `false` starts the SDK dark until [`enable()`](#respect-a-users-opt-out). |
|
|
173
|
+
| `sessionSampleRate` | `number` | `1` | [Fraction of sessions to keep](#sample-a-percentage-of-sessions), `0`–`1`. Constructor-only. |
|
|
174
|
+
| `traceHostAllowlist` | `string[]` | `[]` (empty) | [Hosts allowed to receive `traceparent`](#connect-your-traces-to-your-backend). Constructor-only. |
|
|
175
|
+
| `autoTrackTaps` | `boolean` | `false` | **Native only.** [Capture every `onPress` / `onLongPress`](#native--or-capture-every-press-automatically). Constructor-only. |
|
|
176
|
+
| `store` | `Store` | platform default | Replaces `localStorage` / `AsyncStorage`. Mostly for tests. |
|
|
177
|
+
| `sender` | `Sender` | platform default | Replaces the HTTP transport. Mostly for tests. |
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
101
180
|
const telemetry = createTelemetry({
|
|
102
181
|
apiKey: "edge_xxxxxxxx",
|
|
103
|
-
endpoint: "https://collector.example.com/
|
|
104
|
-
batchSize:
|
|
105
|
-
flushIntervalMs:
|
|
182
|
+
endpoint: "https://collector.example.com/telemetry",
|
|
183
|
+
batchSize: 50,
|
|
184
|
+
flushIntervalMs: 30_000,
|
|
185
|
+
buildId: process.env.GIT_SHA,
|
|
186
|
+
sessionSampleRate: 1,
|
|
187
|
+
traceHostAllowlist: ["api.example.com"],
|
|
106
188
|
});
|
|
189
|
+
```
|
|
107
190
|
|
|
108
|
-
|
|
191
|
+
**Why some options are constructor-only.** `beforeSend`, `sessionSampleRate` and
|
|
192
|
+
`traceHostAllowlist` cannot be set after init, because the gap between the two is not empty: by
|
|
193
|
+
the time you called a setter, `session.started`, the launch trace root and your first HTTP
|
|
194
|
+
requests are already queued. A scrubber that misses the first events is not a scrubber.
|
|
195
|
+
|
|
196
|
+
### Two things to get right
|
|
197
|
+
|
|
198
|
+
**`apiKey` is validated immediately.** A key that doesn't start with `edge_` throws from
|
|
199
|
+
`createTelemetry()`, so a typo fails at startup instead of silently dropping data for a week. The
|
|
200
|
+
value may be an API key *or* an `edge_`-prefixed JWT; the collector accepts both. You never send a
|
|
201
|
+
tenant ID — the backend resolves your tenant from the key.
|
|
202
|
+
|
|
203
|
+
**`endpoint` is used verbatim.** The collector terminates `POST /telemetry`. If you leave it
|
|
204
|
+
unset, every send fails against a placeholder host.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Send a custom event
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
await telemetry.log("checkout_started", { cart_value: 42, currency: "KES" });
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Your `data` is flattened into dot-notation attributes and must hold **primitive values** — string,
|
|
215
|
+
number, boolean. Objects are flattened; arrays and anything nested deeper than 8 levels are
|
|
216
|
+
JSON-stringified.
|
|
217
|
+
|
|
218
|
+
> **Names outside the allowlist still arrive.** Only [allowlisted event names](#what-the-sdk-captures)
|
|
219
|
+
> travel under their own name. Any other name — `checkout_started` above — is sent as
|
|
220
|
+
> `custom_event` with your name preserved in `attributes["event.name"]`. Nothing is dropped, so
|
|
221
|
+
> query custom events by `event.name`, not by `event_name`.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Time a journey
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
const span = telemetry.startSpan("checkout", { cart_value: 42 });
|
|
229
|
+
// …
|
|
230
|
+
span.end(); // or span.end({ outcome: "failed" })
|
|
231
|
+
|
|
232
|
+
await telemetry.withSpan("sync_contacts", () => api.sync()); // throws → "failed", rethrown
|
|
233
|
+
|
|
234
|
+
telemetry.startSpan("onboarding"); // one screen…
|
|
235
|
+
telemetry.endSpan("onboarding", "completed"); // …closed from another, by name
|
|
109
236
|
```
|
|
110
237
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
238
|
+
Each span sends **one** `task.complete` row when it ends: `task.name`, `task.outcome`
|
|
239
|
+
(`completed` | `failed` | `abandoned`) and `span.duration_ms`. The three span methods are
|
|
240
|
+
synchronous — call them without `await`.
|
|
241
|
+
|
|
242
|
+
- A span started during a tap or navigation joins that action (same `rum.action.id`); otherwise it
|
|
243
|
+
starts its own, `trace.root_type: "custom"`. Spans don't nest: a request inside one belongs to
|
|
244
|
+
the action, not the span.
|
|
245
|
+
- Starting a name that is already open replaces it. Ending an unknown name does nothing. At most
|
|
246
|
+
32 spans can be open; blank names and the 33rd are ignored.
|
|
247
|
+
- Open spans survive an app restart and can still be ended by name. A span still open when its
|
|
248
|
+
session ends is sent as `abandoned`.
|
|
249
|
+
- Your attributes cannot overwrite `task.*`, `span.*`, `trace.*`, `parent.*` or `rum.*` keys.
|
|
114
250
|
|
|
115
251
|
---
|
|
116
252
|
|
|
117
|
-
##
|
|
253
|
+
## Identify the signed-in user
|
|
118
254
|
|
|
119
255
|
```typescript
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
sender?: Sender; // override the transport (mainly for tests)
|
|
128
|
-
};
|
|
256
|
+
await telemetry.identify({
|
|
257
|
+
userId: "u-42",
|
|
258
|
+
name: "Ada Lovelace",
|
|
259
|
+
email: "ada@example.com",
|
|
260
|
+
phone: "+254700000000",
|
|
261
|
+
customAttributes: { plan: "pro", org: "acme" },
|
|
262
|
+
});
|
|
129
263
|
```
|
|
130
264
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
265
|
+
`identify()` does two things: it sets `user.id` on every subsequent event, and it emits one
|
|
266
|
+
`user.profile.update` event carrying the profile.
|
|
267
|
+
|
|
268
|
+
> **Warning — if you are upgrading from v3, read this.** `setUserProfile()`, `setUserDetails()`,
|
|
269
|
+
> `updateUserProfile()`, `setUserName()` and `setUserContact()` now record state **only**. They no
|
|
270
|
+
> longer put anything on the wire. If your app used one of them and never called `identify()`,
|
|
271
|
+
> your profile data stopped arriving at the v4 upgrade. Add one `identify()` call.
|
|
272
|
+
|
|
273
|
+
**Why the change:** `user.name`, `user.email` and `user.phone` used to ride the Context block of
|
|
274
|
+
*every* event, so a 10,000-event session put 10,000 copies of an email address on the wire and at
|
|
275
|
+
rest, to populate a table that needs it once. They now ride `user.profile.update` and no other
|
|
276
|
+
event. Because the profile is held in memory, `identify()` re-fires on every launch and the table
|
|
277
|
+
stays current.
|
|
278
|
+
|
|
279
|
+
**Limits.** `name` and `email` truncate at 255 characters, `phone` at **50** (the column is
|
|
280
|
+
`VARCHAR(50)`, and an over-long value loses the whole profile behind a `200`).
|
|
281
|
+
`customAttributes` is capped at 64 keys, 64-character keys and 255-character values;
|
|
282
|
+
non-primitive values are JSON-stringified then truncated. Anything dropped is counted in
|
|
283
|
+
`user.custom_dropped` and warned about once, in development. A bad payload is never a throw.
|
|
284
|
+
|
|
285
|
+
**`user.id` is yours.** The SDK never mints one. Omit `userId` and your traffic stays anonymous —
|
|
286
|
+
still fully joinable on `device.id`, just not attributed to a person.
|
|
135
287
|
|
|
136
288
|
---
|
|
137
289
|
|
|
138
|
-
##
|
|
290
|
+
## Track screens
|
|
139
291
|
|
|
140
|
-
|
|
292
|
+
The SDK opens a **view** at startup and closes it at each of four boundaries: a route change,
|
|
293
|
+
backgrounding, a session rotation, and process death. Each closed view emits one `view` event
|
|
294
|
+
with its name, dwell time, request count and load time.
|
|
141
295
|
|
|
142
|
-
###
|
|
296
|
+
### React Navigation (recommended, both platforms)
|
|
297
|
+
|
|
298
|
+
```tsx
|
|
299
|
+
import { NavigationContainer, useNavigationContainerRef } from "@react-navigation/native";
|
|
300
|
+
import { useEffect } from "react";
|
|
301
|
+
import { telemetry } from "./telemetry";
|
|
302
|
+
|
|
303
|
+
export default function App() {
|
|
304
|
+
const navRef = useNavigationContainerRef();
|
|
305
|
+
useEffect(() => { telemetry.attachNavigation(navRef); }, [navRef]);
|
|
306
|
+
|
|
307
|
+
return <NavigationContainer ref={navRef}>{/* your screens */}</NavigationContainer>;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
One call covers native **and** web. Attach whenever you like: a ready ref names the current
|
|
312
|
+
screen at once, and a not-yet-ready one names it on its `ready` event — the first screen is never
|
|
313
|
+
`unknown`.
|
|
314
|
+
|
|
315
|
+
`view.name` is the focused route names **joined root to leaf with `/`** (v5) — `HomeTab/Details`
|
|
316
|
+
and `SearchTab/Details` stay distinct. Names are never normalized and route params are never read.
|
|
317
|
+
|
|
318
|
+
### Expo Router
|
|
319
|
+
|
|
320
|
+
No extra dependency and no extra API — Expo Router is React Navigation underneath, and its route
|
|
321
|
+
names are the file paths, so `view.name` comes out as `(tabs)/settings/index`. In the root
|
|
322
|
+
`app/_layout.tsx`:
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
import { Stack, useNavigationContainerRef } from "expo-router";
|
|
326
|
+
import { useEffect } from "react";
|
|
327
|
+
import { telemetry } from "../telemetry";
|
|
328
|
+
|
|
329
|
+
export default function RootLayout() {
|
|
330
|
+
const navRef = useNavigationContainerRef();
|
|
331
|
+
useEffect(() => { telemetry.attachNavigation(navRef); }, [navRef]);
|
|
332
|
+
return <Stack />;
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Naming screens manually
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
await telemetry.screenStart("Checkout"); // native only — names the current view
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
> **Mixing `screenStart()` with `attachNavigation()` is fine (v5).** Screen names have ranks — an
|
|
343
|
+
> explicit name outranks a route name, which outranks a URL — but a route change always opens a
|
|
344
|
+
> new view, so a `screenStart()` name only renames the screen it was called on. Call it from that
|
|
345
|
+
> screen's own effect.
|
|
346
|
+
|
|
347
|
+
### Mark a screen ready
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
import { useScreenReady } from "@nathanclaire/edge-telemetry-sdk";
|
|
351
|
+
|
|
352
|
+
function ProfileScreen() {
|
|
353
|
+
const { data } = useProfile();
|
|
354
|
+
useScreenReady(telemetry, !!data); // or call telemetry.markScreenReady() yourself
|
|
355
|
+
// …
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
The `view` row then carries `view.ready_time` (ms from opening the screen to the mark) and
|
|
360
|
+
`view.ready_outcome: "ready"`. The app's first screen is measured from **process start**, so its
|
|
361
|
+
`view.ready_time` is cold-start-to-usable. If the user leaves a screen you have marked before
|
|
362
|
+
without it becoming ready, the row says `"abandoned"`; screens you never mark carry neither key,
|
|
363
|
+
and leaving by backgrounding is never judged. The first mark per screen wins.
|
|
364
|
+
|
|
365
|
+
### Reading the results
|
|
366
|
+
|
|
367
|
+
`view` events carry `view.loading_time`, measured as **network settle**: the point where the
|
|
368
|
+
screen's in-flight requests go quiet for a second. It is deliberately `null`, never `0`, for a
|
|
369
|
+
screen that fetched nothing — a `0` would make your p75 track the cache-hit rate, so a backend
|
|
370
|
+
caching win would show up as a frontend regression.
|
|
371
|
+
|
|
372
|
+
`view.loading_time_outcome` always ships and tells the nulls apart:
|
|
373
|
+
|
|
374
|
+
| Outcome | Meaning |
|
|
375
|
+
|---|---|
|
|
376
|
+
| `settled` | Requests finished. `view.loading_time` has a number. |
|
|
377
|
+
| `no_activity` | The screen started no requests. Null. |
|
|
378
|
+
| `capped` | Still loading after 30 seconds. Null — **not** the cap, so 30s and 90s stay distinguishable. |
|
|
379
|
+
| `abandoned` | The user left while it was still loading. Null. |
|
|
380
|
+
|
|
381
|
+
Query **p75 where `outcome = 'settled'`**, alongside **% `capped`**. A plain
|
|
382
|
+
`AVG(loading_time)` averages four different populations.
|
|
383
|
+
|
|
384
|
+
> One screen visit can produce several `view` rows — backgrounding and returning splits it. Sum by
|
|
385
|
+
> `view.name`.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
## Track taps
|
|
389
|
+
|
|
390
|
+
### Web — automatic
|
|
391
|
+
|
|
392
|
+
Every click emits a `ui.interaction` event. No wiring: the SDK attaches one capture-phase
|
|
393
|
+
listener to `document`.
|
|
394
|
+
|
|
395
|
+
**Names are read only from elements that are actionable by role** — `<button>`, `<a href>`,
|
|
396
|
+
`<input type="submit|button|reset">`, `<summary>`, `<option>`, or an explicit
|
|
397
|
+
`role="button|link|tab|checkbox|radio|switch|menuitem|option"`. That gate is what stops a
|
|
398
|
+
clickable `<div>` full of customer data from being auto-named. On React Native Web, a `Pressable`
|
|
399
|
+
lands on a role-bearing element automatically.
|
|
400
|
+
|
|
401
|
+
To name anything yourself — including a role-less element — use `data-edge-action-name`:
|
|
402
|
+
|
|
403
|
+
```html
|
|
404
|
+
<div data-edge-action-name="Checkout — Step 2 of 3">…</div>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
It wins over everything else and ships **exactly as written**, uncapped and unnormalized, because
|
|
408
|
+
you should be able to predict the value you just set. Below it the SDK tries `data-testid`,
|
|
409
|
+
`aria-label`, `title`, then `textContent` — each lowercased, with non-alphanumerics folded to `_`
|
|
410
|
+
and capped at 64 characters, so `"Add to cart!"` becomes `add_to_cart`.
|
|
411
|
+
|
|
412
|
+
When nothing matched, `ui.target` tells you why:
|
|
413
|
+
|
|
414
|
+
| The click landed on | `ui.target` | Read it as |
|
|
415
|
+
|---|---|---|
|
|
416
|
+
| A role-bearing element, a name was found | the name | — |
|
|
417
|
+
| A role-bearing element, nothing readable | `unnamed` | An instrumentation gap. Add `data-edge-action-name`. |
|
|
418
|
+
| A role-less element with `cursor: pointer` | `unnamed` | Same gap. |
|
|
419
|
+
| A role-less element, default cursor | `surface` | Someone tapped padding. Nothing to fix. |
|
|
420
|
+
|
|
421
|
+
Two frustration signals ride along automatically: **`ui.rage`** (3+ clicks within a second on the
|
|
422
|
+
same element) and **`ui.dead`** (no DOM change, no request and no navigation within a second of an
|
|
423
|
+
actionable click).
|
|
424
|
+
|
|
425
|
+
> **Warning — the role gate is not a privacy control.** `<button>Delete John Kamau</button>` still
|
|
426
|
+
> ships that text as the event name. Use [`beforeSend`](#strip-pii-before-it-leaves-the-device)
|
|
427
|
+
> to scrub it. There is deliberately no per-element masking attribute.
|
|
428
|
+
|
|
429
|
+
### Native — name the taps you care about
|
|
430
|
+
|
|
431
|
+
```tsx
|
|
432
|
+
<Pressable
|
|
433
|
+
onPress={() => {
|
|
434
|
+
telemetry.trackTap("checkout");
|
|
435
|
+
navigation.navigate("Cart");
|
|
436
|
+
}}
|
|
437
|
+
/>
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Native taps are explicit-only. React Native gives a press handler a numeric node tag with no
|
|
441
|
+
public API to resolve it, so a root-level listener genuinely cannot tell a button from padding —
|
|
442
|
+
anything auto-derived would be wrong, or a PII leak. Name the controls that matter.
|
|
443
|
+
|
|
444
|
+
The name ships uncapped and unnormalized, exactly as you wrote it.
|
|
445
|
+
|
|
446
|
+
> **Your interaction coverage equals your instrumentation coverage.** An uninstrumented screen
|
|
447
|
+
> looks identical to an unused one. `ui.rage` on native is gated to named taps too, so a low rage
|
|
448
|
+
> count means *few named taps*, not happy users. And `ui.dead` never appears on native at all —
|
|
449
|
+
> there is no DOM, so there is no mutation signal — so any dead-click rate must filter to web.
|
|
450
|
+
|
|
451
|
+
**The tap's identity is captured at the tap, not at send.** A tap that navigates is still
|
|
452
|
+
attributed to the screen it happened on, not the one it opened.
|
|
453
|
+
|
|
454
|
+
### Native — or capture every press automatically
|
|
143
455
|
|
|
144
456
|
```typescript
|
|
145
|
-
|
|
146
|
-
flush(): Promise<void> // force-send the queue now
|
|
147
|
-
shutdown(): Promise<void> // clear the flush timer + final flush
|
|
457
|
+
const telemetry = createTelemetry({ apiKey, endpoint, autoTrackTaps: true }); // native only
|
|
148
458
|
```
|
|
149
459
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
460
|
+
Opt in and every `onPress` sends a `ui.interaction` (`ui.type: "tap"`), and every `onLongPress` a
|
|
461
|
+
`"long_press"` — no annotation needed. It fires when a press activates, never on a scroll.
|
|
462
|
+
|
|
463
|
+
Names come from **`testID` only** (normalized: `"Checkout Button!"` → `checkout_button`), never
|
|
464
|
+
from the button's text or accessibility label, which is where names and amounts live. A press with
|
|
465
|
+
no `testID` arrives as `unnamed` — add one to name it. A `trackTap()` call inside the handler
|
|
466
|
+
wins, and nested pressables produce one row.
|
|
153
467
|
|
|
154
|
-
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## Report handled errors
|
|
471
|
+
|
|
472
|
+
Unhandled errors are captured for you. For the ones you catch, call `captureError()`:
|
|
155
473
|
|
|
156
474
|
```typescript
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
475
|
+
try {
|
|
476
|
+
await pay();
|
|
477
|
+
} catch (err) {
|
|
478
|
+
await telemetry.captureError(err, { "checkout.step": "pay" });
|
|
479
|
+
}
|
|
480
|
+
```
|
|
162
481
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
482
|
+
It takes `unknown` on purpose — real `catch` blocks receive strings and axios rejection objects,
|
|
483
|
+
and you shouldn't have to prove to TypeScript that it's an `Error` first.
|
|
484
|
+
|
|
485
|
+
### Render errors — `<EdgeErrorBoundary>`
|
|
486
|
+
|
|
487
|
+
```tsx
|
|
488
|
+
import { EdgeErrorBoundary } from "@nathanclaire/edge-telemetry-sdk";
|
|
489
|
+
|
|
490
|
+
<EdgeErrorBoundary
|
|
491
|
+
telemetry={telemetry}
|
|
492
|
+
fallback={({ error, resetError }) => <ErrorScreen onRetry={resetError} />} // or a plain element
|
|
493
|
+
onError={(error, info) => { /* runs after the SDK reports; a throw here is ignored */ }}
|
|
494
|
+
>
|
|
495
|
+
<App />
|
|
496
|
+
</EdgeErrorBoundary>
|
|
172
497
|
```
|
|
173
498
|
|
|
499
|
+
A caught render error is sent once, as `app.error` with `error.source: "boundary"` and
|
|
500
|
+
`error.component_stack`. React's own console report and the global error handlers skip it, so
|
|
501
|
+
turning on `captureConsole` does not double-count it.
|
|
502
|
+
|
|
503
|
+
### Two event names, and why it matters
|
|
504
|
+
|
|
505
|
+
| | `app.crash` | `app.error` |
|
|
506
|
+
|---|---|---|
|
|
507
|
+
| Means | Unhandled | Handled |
|
|
508
|
+
| Comes from | `ErrorUtils`, `window.onerror`, unhandled rejections | `captureError()`, opted-in `console.error` |
|
|
509
|
+
| Carries breadcrumbs | Yes — the last 20 actions | No |
|
|
510
|
+
|
|
511
|
+
The split exists for one query: crash-free rate is
|
|
512
|
+
`COUNT(event_name = 'app.crash') / sessions`, with no `WHERE` clause anyone can forget.
|
|
513
|
+
|
|
514
|
+
> **`app.crash` is SDK-owned.** `log("app.crash", …)` is routed to `app.error` rather than
|
|
515
|
+
> manufacturing a crash row. A reported error is data — it just isn't a crash.
|
|
516
|
+
|
|
517
|
+
> **Warning — `error.fatal` is a trap on web.** Nothing is fatal in a browser: `window.onerror`
|
|
518
|
+
> fires and the page keeps running, so `error.fatal` is native-only. A cross-platform
|
|
519
|
+
> `1 − COUNT(fatal = true) / sessions` scores web at 100% forever. Use the unfiltered
|
|
520
|
+
> `COUNT(app.crash)`, or exclude web.
|
|
521
|
+
|
|
522
|
+
### Capturing console output
|
|
523
|
+
|
|
524
|
+
```typescript
|
|
525
|
+
createTelemetry({ apiKey: "edge_xxxxxxxx", endpoint: "…", captureConsole: true });
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Off by default. With it on, `console.error` becomes an `app.error` and `console.warn` becomes a
|
|
529
|
+
breadcrumb. It defaults off because React's own development-mode warnings were the single largest
|
|
530
|
+
contributor to v3 crash counts, which made "is this release crashing more?" unanswerable.
|
|
531
|
+
|
|
532
|
+
---
|
|
533
|
+
|
|
534
|
+
## Make crash stacks readable
|
|
535
|
+
|
|
536
|
+
React Native ships every crash stack minified, so each frame reads as a single letter. Two lines
|
|
537
|
+
fix that, and the SDK writes neither on your behalf.
|
|
538
|
+
|
|
539
|
+
```typescript
|
|
540
|
+
// 1. In your entry file, before anything else runs:
|
|
541
|
+
Error.stackTraceLimit = 50;
|
|
542
|
+
|
|
543
|
+
// 2. In your telemetry config:
|
|
544
|
+
const telemetry = createTelemetry({
|
|
545
|
+
apiKey: "edge_xxxxxxxx",
|
|
546
|
+
endpoint: "https://collector.example.com/telemetry",
|
|
547
|
+
buildId: process.env.GIT_SHA, // ships as app.build_id
|
|
548
|
+
});
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
**`Error.stackTraceLimit`** defaults to **10 frames** — well short of what the SDK can carry, and
|
|
552
|
+
ten frames of a rejected promise can be entirely library internals. The SDK never assigns it,
|
|
553
|
+
because raising it globally would make every `new Error()` in *your* app more expensive,
|
|
554
|
+
invisibly. It warns once in development and leaves the line to you.
|
|
555
|
+
|
|
556
|
+
**`buildId`** is the symbolication join key. Use a git SHA or a CI run number. Crashes resolve
|
|
557
|
+
against `(app, device.platform, app.build_id)` — three parts, because one commit produces
|
|
558
|
+
different Metro output for iOS and Android, and a one-part key would resolve an Android crash
|
|
559
|
+
against the iOS source map and give you frames that are plausible and wrong.
|
|
560
|
+
|
|
561
|
+
> **Warning — never derive `buildId` from your app version.** `${version}-${buildNumber}` is
|
|
562
|
+
> correct for most apps, which is exactly what makes it dangerous: under Expo Updates or CodePush
|
|
563
|
+
> the native binary is unchanged, so the derived key fetches the **wrong** source map and resolves
|
|
564
|
+
> to plausible-wrong line numbers, with nothing on the row marking them untrustworthy. The SDK has
|
|
565
|
+
> no OTA awareness and will not guess. Leave `buildId` unset and crashes stay unsymbolicated —
|
|
566
|
+
> which is at least honest.
|
|
567
|
+
|
|
568
|
+
Stack traces travel raw and byte-for-byte so `metro-symbolicate` can consume them. Over the
|
|
569
|
+
2000-character cap the tail is dropped on a frame boundary and marked `… [truncated]`.
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
## Strip PII before it leaves the device
|
|
573
|
+
|
|
574
|
+
`beforeSend` runs on every event and metric, synchronously, **at enqueue** — before anything can
|
|
575
|
+
reach the network *or* the offline store. Return the event to keep it, or `null` to drop it.
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
import { createTelemetry, type BeforeSend } from "@nathanclaire/edge-telemetry-sdk";
|
|
579
|
+
|
|
580
|
+
const scrub: BeforeSend = (event) => {
|
|
581
|
+
const attrs = event.attributes;
|
|
582
|
+
if (!attrs) return event;
|
|
583
|
+
|
|
584
|
+
// Drop a key outright
|
|
585
|
+
delete attrs["ui.target"];
|
|
586
|
+
|
|
587
|
+
// Or rewrite one
|
|
588
|
+
if (typeof attrs["user.email"] === "string") {
|
|
589
|
+
attrs["user.email"] = hash(attrs["user.email"]);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// Or drop the whole event
|
|
593
|
+
if (event.eventName === "custom_event" && attrs["event.name"] === "internal_debug") {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return event;
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const telemetry = createTelemetry({ apiKey: "edge_xxxxxxxx", endpoint: "…", beforeSend: scrub });
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
**It runs at enqueue, not at flush,** because a failed send persists the batch to disk — and on
|
|
604
|
+
native that disk outlives the process. A flush-time hook would let unscrubbed PII land there
|
|
605
|
+
first. **It is synchronous** because crashes flush during teardown, and a Promise-returning hook
|
|
606
|
+
would put your `await` in a dying app's path.
|
|
607
|
+
|
|
608
|
+
**It covers metrics too.** `vital.target` is a raw CSS selector and the least sanitized value the
|
|
609
|
+
SDK sends.
|
|
610
|
+
|
|
611
|
+
### What you can and cannot change
|
|
612
|
+
|
|
613
|
+
Your hook gets a **copy**. Three tiers are re-stamped from the original after it returns:
|
|
614
|
+
|
|
615
|
+
| Tier | Keys | What happens |
|
|
616
|
+
|---|---|---|
|
|
617
|
+
| **A — immutable** | `type`, `eventName`/`metricName`, `timestamp`, `session.*`, `event.sequence`, everything under `sdk.` and `app.`, `device.platform`, `trace.id`, `span.id`, `parent.span.id`, `rum.action.id`, `view.id` | Restored — covers deletion *and* forgery |
|
|
618
|
+
| **B — rewritable, not deletable** | `device.id` | Hash it if you like; delete it and the collector rejects the batch |
|
|
619
|
+
| **C — yours** | Everything else: `user.*`, `http.*`, `error.*`, `ui.target`, `vital.target`, your own `log()` data | Untouched. This is where the PII lives. |
|
|
620
|
+
|
|
621
|
+
The tiers are enforced by re-stamping, **never by throwing**. The realistic hook is a `delete`
|
|
622
|
+
loop and the realistic bug is over-deletion — an over-broad hook must not be able to get your
|
|
623
|
+
whole feed silently discarded behind a `200`.
|
|
624
|
+
|
|
625
|
+
**A hook that throws fails closed:** the event is dropped, never sent in its original form,
|
|
626
|
+
because a bug in a scrubber must not ship the exact field the scrubber existed to remove. Only an
|
|
627
|
+
explicit `null` counts as a deliberate drop. The two outcomes are counted separately on the wire
|
|
628
|
+
— `sdk.hook_dropped` and `sdk.hook_failed` — because "my volume is down 40%" needs to distinguish
|
|
629
|
+
a working scrubber from a broken one.
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
## Respect a user's opt-out
|
|
634
|
+
|
|
635
|
+
```typescript
|
|
636
|
+
telemetry.disable(); // takes effect immediately
|
|
637
|
+
telemetry.enable(); // resume
|
|
638
|
+
|
|
639
|
+
// No consent yet at launch? Start dark — nothing is collected until enable():
|
|
640
|
+
const telemetry = createTelemetry({ apiKey, endpoint, enabled: hasConsent() });
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
`disable()` drops everything queued and stored on the device, stops every timer, and leaves your
|
|
644
|
+
network requests untouched — no `traceparent` header is added while disabled. Nothing is sent or
|
|
645
|
+
written until `enable()`. The SDK does not remember the choice across launches: store it yourself
|
|
646
|
+
and pass `enabled` at startup. A launch that starts dark never sends `app.start`.
|
|
647
|
+
|
|
648
|
+
---
|
|
649
|
+
|
|
650
|
+
## Sample a percentage of sessions
|
|
651
|
+
|
|
652
|
+
```typescript
|
|
653
|
+
createTelemetry({ apiKey: "edge_xxxxxxxx", endpoint: "…", sessionSampleRate: 0.1 });
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
The dice are rolled **once per session**, persisted with the session record and re-rolled when
|
|
657
|
+
the session rotates — never per event, which would desynchronise the per-view counters. A
|
|
658
|
+
sampled-out session sends **nothing at all**.
|
|
659
|
+
|
|
660
|
+
> **Warning — crashes are not exempt.** Sampling out a session drops its crashes too. It has to:
|
|
661
|
+
> keeping 100% of crashes over 10% of sessions makes the unfiltered crash-free query read ten
|
|
662
|
+
> times too healthy, with no `WHERE` clause available to repair it.
|
|
663
|
+
|
|
664
|
+
Every row carries `session.sample_rate`, so extrapolating back up is arithmetic. A rate outside
|
|
665
|
+
`0`–`1`, or a `NaN`, warns and falls back to `1` — `Math.random() < NaN` is always false and
|
|
666
|
+
would silently mute your entire deployment.
|
|
667
|
+
|
|
668
|
+
---
|
|
669
|
+
|
|
670
|
+
## Connect your traces to your backend
|
|
671
|
+
|
|
672
|
+
The SDK can attach a W3C `traceparent` header to your API calls, so a slow screen in your RUM
|
|
673
|
+
data links to the exact backend trace that caused it.
|
|
674
|
+
|
|
675
|
+
**This is off by default.** The allowlist starts empty, so upgrading can never break your network
|
|
676
|
+
calls on day one. Opt hosts in explicitly:
|
|
677
|
+
|
|
174
678
|
```typescript
|
|
175
|
-
|
|
679
|
+
createTelemetry({
|
|
680
|
+
apiKey: "edge_xxxxxxxx",
|
|
681
|
+
endpoint: "https://collector.example.com/telemetry",
|
|
682
|
+
traceHostAllowlist: ["api.example.com", "checkout.example.com"],
|
|
683
|
+
});
|
|
176
684
|
```
|
|
177
685
|
|
|
178
|
-
|
|
686
|
+
> **Warning — do this first.** Add `traceparent` to `Access-Control-Allow-Headers` on every host
|
|
687
|
+
> you list, *before* you list it. Missing that header is what *"our app broke when we turned on
|
|
688
|
+
> tracing"* actually means. Adding a header also turns previously-simple cross-origin GETs into
|
|
689
|
+
> preflighted ones, so set `Access-Control-Max-Age` while you're there.
|
|
690
|
+
|
|
691
|
+
### The rules, in full
|
|
692
|
+
|
|
693
|
+
- **Bare hosts, exact match.** `api.example.com`, not `https://api.example.com/v2` and not
|
|
694
|
+
`*.example.com`. Listing a host is your assertion that *that host's* CORS allows the header,
|
|
695
|
+
and nobody can make that assertion over a wildcard.
|
|
696
|
+
- **Ports are ignored** when matching. Note that `http.host` on the wire *keeps* the port — the
|
|
697
|
+
two are deliberately different, so don't join on them.
|
|
698
|
+
- **`traceparent` is the only header the SDK writes, and the only one it reads.** No `b3`, no
|
|
699
|
+
`tracestate`, ever. That is a sentence you should be able to state in a security review.
|
|
700
|
+
- **The SDK never strips or rewrites a header it didn't add.** Set your own `traceparent` and it
|
|
701
|
+
adopts yours and steps aside.
|
|
702
|
+
- **No retry without the header.** A rejected preflight and a dead server are the same
|
|
703
|
+
`TypeError`, so retrying would double-send a non-idempotent POST. A tracing feature must not be
|
|
704
|
+
able to double-charge a card.
|
|
705
|
+
- **A malformed allowlist entry throws in development and is dropped in production.** A RUM SDK
|
|
706
|
+
crashing a shipped banking app over a config typo is the one failure worse than no tracing.
|
|
707
|
+
|
|
708
|
+
### Debugging a missing join
|
|
709
|
+
|
|
710
|
+
Every request stamps `traceparent.outcome`, so "the trace isn't joining" is a query rather than a
|
|
711
|
+
mystery:
|
|
712
|
+
|
|
713
|
+
| Value | What happened |
|
|
714
|
+
|---|---|
|
|
715
|
+
| *(absent)* | Not traced — you have no allowlist |
|
|
716
|
+
| `skipped_off_allowlist` | You have an allowlist and this host isn't on it |
|
|
717
|
+
| `skipped_no_cors` | The request's `mode` ruled it out (fetch only) |
|
|
718
|
+
| `skipped_consumer_set` | You set a `traceparent` and it couldn't be parsed |
|
|
719
|
+
| `adopted` | You set a valid one; the SDK used yours |
|
|
720
|
+
| `injected_attributed` | Injected and joined to a live user action — the healthy case |
|
|
721
|
+
| `injected_expired` | Injected, but the action it belonged to had aged out |
|
|
722
|
+
| `injected_unattributed` | Injected with no user action in flight at all |
|
|
723
|
+
|
|
724
|
+
Every skip still stamps local IDs even though no header goes out. That is what makes *"the row is
|
|
725
|
+
here but the backend join is missing"* mean **the header was stripped in transit** rather than
|
|
726
|
+
something ambiguous.
|
|
727
|
+
|
|
728
|
+
> An unsampled session injects no header at all — not a `flags=00` one.
|
|
729
|
+
|
|
730
|
+
---
|
|
731
|
+
## What the SDK captures
|
|
732
|
+
|
|
733
|
+
All of this starts in the constructor. You don't call anything to enable it.
|
|
734
|
+
|
|
735
|
+
### Events
|
|
736
|
+
|
|
737
|
+
| Event | Fires when | Platform |
|
|
738
|
+
|---|---|---|
|
|
739
|
+
| `app.start` | Once per process, at init | Both |
|
|
740
|
+
| `session.started` / `session.finalized` | Session begins / rotates | Both |
|
|
741
|
+
| `app_lifecycle` | Foreground ⇄ background | Both |
|
|
742
|
+
| `view` | A screen visit ends (route change, background, session rotation) | Both |
|
|
743
|
+
| `http.request` | Every `fetch` / `XHR` completes | Both |
|
|
744
|
+
| `app.crash` | Unhandled error or promise rejection | Both |
|
|
745
|
+
| `app.error` | `captureError()`, or an opted-in `console.error` | Both |
|
|
746
|
+
| `ui.interaction` | Every click (web) / every `trackTap()` (native) | Both |
|
|
747
|
+
| `network_change` | Connectivity type changes | Both |
|
|
748
|
+
| `user.profile.update` | `identify()` | Both |
|
|
749
|
+
| `task.complete` | A [span](#time-a-journey) ends, or its session ends first | Both |
|
|
750
|
+
| `app.hang` | The JS thread froze for 2–60 s in the foreground (not in dev builds) | Both |
|
|
751
|
+
| `custom_event` | Any `log()` name not in this table | Both |
|
|
752
|
+
|
|
753
|
+
### Metrics
|
|
754
|
+
|
|
755
|
+
| Metric | What it measures | Platform |
|
|
756
|
+
|---|---|---|
|
|
757
|
+
| `frame_render_time` | p95 frame time per window; closes every 10s **or** at a screen change | Both |
|
|
758
|
+
| `memory_usage` | Resident memory (RSS) in MB, sampled every 30s | **Native only** |
|
|
759
|
+
| `LCP` `FCP` `TTFB` | Core Web Vitals, once per page load | **Web only** |
|
|
760
|
+
| `CLS` `INP` | Running values, sent when the tab is hidden | **Web only** |
|
|
761
|
+
|
|
762
|
+
Metrics carry `metric.unit` — `ms`, `MB`, or `score` for CLS.
|
|
763
|
+
|
|
764
|
+
> **Web-only metrics are web-only on purpose.** Native emits no Core Web Vitals, and web emits no
|
|
765
|
+
> `memory_usage` — `performance.memory` is Chromium-only, so the metric's mere presence was a
|
|
766
|
+
> browser-detection signal wearing a memory label.
|
|
767
|
+
|
|
768
|
+
> **Warning — Core Web Vitals are page-load-scoped, not screen-scoped.** `LCP`, `FCP` and `TTFB`
|
|
769
|
+
> physically cannot recur on a soft navigation, so `view.id` on a vital row is always the
|
|
770
|
+
> **initial** view's. `GROUP BY view.name` over vitals reads as *"by entry point"* — a useful
|
|
771
|
+
> dashboard, as long as you label it that way.
|
|
772
|
+
|
|
773
|
+
### Retired names
|
|
774
|
+
|
|
775
|
+
`page_load`, `resource_timing`, `long_task` and `user.interaction` were removed in v4. They are
|
|
776
|
+
unreachable — `log("page_load")` now arrives as `custom_event`. Their jobs are covered by `view`,
|
|
777
|
+
`view.loading_time`, the Core Web Vitals and `frame_render_time`.
|
|
778
|
+
|
|
779
|
+
---
|
|
780
|
+
|
|
781
|
+
## API
|
|
782
|
+
|
|
783
|
+
Every method returns a Promise, except the span methods, `markScreenReady()`, `disable()` and `enable()`, which are synchronous.
|
|
784
|
+
|
|
785
|
+
### Core — both platforms
|
|
179
786
|
|
|
180
787
|
```typescript
|
|
788
|
+
log(event: string, data?: Record<string, any>): Promise<void>
|
|
789
|
+
captureError(error: unknown, context?: Record<string, any>): Promise<void>
|
|
790
|
+
flush(): Promise<void> // send the queue now
|
|
791
|
+
shutdown(): Promise<void> // stop timers and do a final flush
|
|
792
|
+
attachNavigation(navigationRef: any): Promise<void>
|
|
793
|
+
trackErrors(options?: { captureConsole?: boolean }): Promise<void>
|
|
181
794
|
getDeviceInfo(): Promise<DeviceInfo>
|
|
182
795
|
getNetworkInfo(): Promise<NetworkInfo>
|
|
796
|
+
|
|
797
|
+
startSpan(name: string, attributes?: Record<string, unknown>): SpanHandle
|
|
798
|
+
// SpanHandle.end(opts?: { outcome?: "completed" | "failed" | "abandoned"; attributes? })
|
|
799
|
+
withSpan<T>(name: string, fn: () => T, attributes?: Record<string, unknown>): T
|
|
800
|
+
endSpan(name: string, outcome?: "completed" | "failed" | "abandoned", attributes?: Record<string, unknown>): void
|
|
801
|
+
markScreenReady(): void
|
|
802
|
+
|
|
803
|
+
recordMetric(name: string, value: number, attributes?: Record<string, any>, opts?: { unit?: string }): Promise<void>
|
|
804
|
+
// the SDK's own metric names are reserved; NaN / Infinity are dropped
|
|
805
|
+
addBreadcrumb(name: string, data?: Record<string, unknown>): Promise<void>
|
|
806
|
+
// into the trail of 20 on app.crash / app.hang — name ≤64 chars, ≤8 keys, values ≤255
|
|
807
|
+
startNewSession(): Promise<void> // session.reason: "manual"
|
|
808
|
+
disable(): void / enable(): void // consent; synchronous
|
|
183
809
|
```
|
|
184
810
|
|
|
185
|
-
###
|
|
811
|
+
### Identity — both platforms
|
|
186
812
|
|
|
187
813
|
```typescript
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
814
|
+
identify(profile: {
|
|
815
|
+
userId?: string;
|
|
816
|
+
name?: string;
|
|
817
|
+
email?: string;
|
|
818
|
+
phone?: string;
|
|
819
|
+
avatar?: string;
|
|
820
|
+
customAttributes?: Record<string, any>;
|
|
821
|
+
}): Promise<void> // the only method that puts a profile on the wire
|
|
822
|
+
|
|
823
|
+
setUserId(id: string): Promise<void> // "" clears it — no empty string is ever sent
|
|
824
|
+
getUserProfile(): Promise<UserProfile | undefined>
|
|
825
|
+
clearUserProfile(): Promise<void> // clears user.id; leaves device.id alone
|
|
826
|
+
|
|
827
|
+
// State-only. These record a profile but emit nothing — call identify() to send it.
|
|
828
|
+
setUserProfile(profile): Promise<void>
|
|
829
|
+
setUserDetails(details): Promise<void>
|
|
830
|
+
updateUserProfile(updates): Promise<void>
|
|
831
|
+
setUserName(fullName: string, firstName?: string, lastName?: string): Promise<void>
|
|
832
|
+
setUserContact(email?: string, phone?: string): Promise<void>
|
|
192
833
|
```
|
|
193
834
|
|
|
194
|
-
|
|
195
|
-
|
|
835
|
+
> `fullName`, `firstName`, `lastName`, `avatar`, `createdAt` and `updatedAt` are `@deprecated` and
|
|
836
|
+
> go away in v6. `fullName` still works — it's what `user.name` is built from. The other five
|
|
837
|
+
> reach no wire key at all.
|
|
196
838
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
839
|
+
### Native only
|
|
840
|
+
|
|
841
|
+
```typescript
|
|
842
|
+
trackTap(name: string): Promise<void> // → ui.interaction. Never rejects.
|
|
843
|
+
trackMemoryUsage(): Promise<void> // auto-started
|
|
844
|
+
screenStart(name: string): Promise<void> // names the current view (explicit rung)
|
|
845
|
+
screenEnd(name: string): Promise<void> // @deprecated no-op since v5 — deleted in v6
|
|
846
|
+
trackRoute(from: string, to: string): Promise<void> // @deprecated no-op since v5 — deleted in v6
|
|
200
847
|
```
|
|
201
848
|
|
|
202
|
-
|
|
849
|
+
`navigation` and `screen.duration` are removed in v5 — the `view` event replaces both.
|
|
203
850
|
|
|
204
|
-
###
|
|
851
|
+
### Web only
|
|
205
852
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
853
|
+
```typescript
|
|
854
|
+
trackInteractions(): Promise<void> // auto-started
|
|
855
|
+
autoTrackNavigation(): Promise<void> // auto-started
|
|
856
|
+
```
|
|
209
857
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
858
|
+
`trackFrameDrops()`, `trackNetworkRequests()` and `attachAppLifecycle()` exist on both classes and
|
|
859
|
+
are auto-started too. Core Web Vitals capture is intentionally private — there is nothing to
|
|
860
|
+
configure, and a vital that only fires when someone remembers to call a method is a vital nobody
|
|
861
|
+
has.
|
|
862
|
+
|
|
863
|
+
### Exports
|
|
864
|
+
|
|
865
|
+
```typescript
|
|
866
|
+
import {
|
|
867
|
+
createTelemetry, // the factory — start here
|
|
868
|
+
memoryStore, // an in-memory Store, for tests
|
|
869
|
+
type TelemetryOpts,
|
|
870
|
+
type BeforeSend,
|
|
871
|
+
type SpanHandle, type TaskOutcome,
|
|
872
|
+
EdgeErrorBoundary, // the render-error boundary
|
|
873
|
+
useScreenReady, // marks the current screen ready
|
|
874
|
+
type EdgeErrorBoundaryProps,
|
|
875
|
+
type Store, type SyncStore, type AsyncStore, type StoreRead, type StoreWrite,
|
|
876
|
+
type MemoryStoreOpts,
|
|
877
|
+
} from "@nathanclaire/edge-telemetry-sdk";
|
|
216
878
|
```
|
|
217
879
|
|
|
880
|
+
`TelemetryWeb` and `TelemetryNative` are exported **as types only** (v5): `createTelemetry()` is
|
|
881
|
+
the only way to construct one, so your `apiKey` and trace allowlist are always validated.
|
|
882
|
+
|
|
883
|
+
> `TelemetryEvent`, `DeviceInfo`, `NetworkInfo` and `UserProfile` are documented in this README as
|
|
884
|
+
> wire and return shapes, but are **not currently exported as types**. For a `beforeSend` hook,
|
|
885
|
+
> annotate with the exported `BeforeSend` and let the event type infer.
|
|
886
|
+
|
|
218
887
|
---
|
|
219
888
|
|
|
220
|
-
##
|
|
889
|
+
## The Context block
|
|
890
|
+
|
|
891
|
+
Every event and metric carries a flat, dot-namespaced set of attributes describing *who, where and
|
|
892
|
+
when*. It means each row is self-describing — you never join against a separate device or session
|
|
893
|
+
event.
|
|
894
|
+
|
|
895
|
+
```
|
|
896
|
+
session.id session.start_time session.sequence session.sample_rate event.sequence
|
|
897
|
+
user.id device.id device.id_ephemeral
|
|
898
|
+
view.id view.name
|
|
899
|
+
sdk.platform sdk.version sdk.events_dropped sdk.drop_reason sdk.hook_dropped sdk.hook_failed
|
|
900
|
+
app.name app.version app.build_number app.package_name app.build_id
|
|
901
|
+
device.platform device.platform_version device.model device.manufacturer device.brand
|
|
902
|
+
device.screen_density device.screen_width_px device.screen_height_px device.orientation
|
|
903
|
+
device.cpu_abi device.low_ram ← native only
|
|
904
|
+
network.type network.is_connected
|
|
905
|
+
```
|
|
221
906
|
|
|
222
|
-
|
|
907
|
+
It is **frozen at 39 keys**. A key the SDK has nothing for is **omitted entirely** — never sent as
|
|
908
|
+
`null` or `undefined`. Absence means "we had nothing", consistently, everywhere.
|
|
223
909
|
|
|
224
|
-
|
|
910
|
+
Your `log()` data is flattened on top, so it can override any `app.*`, `device.*` or `network.*`
|
|
911
|
+
key — but **not** the identity keys, which are stamped afterwards.
|
|
912
|
+
|
|
913
|
+
**Network and device state are read at log time**, not at init: a request that failed when the
|
|
914
|
+
Wi-Fi dropped is better described by the network at the moment it completed.
|
|
915
|
+
|
|
916
|
+
**Two small sets of device state ride outside the block**, on the rows that need them:
|
|
917
|
+
|
|
918
|
+
| Keys | On | Platform |
|
|
225
919
|
|---|---|---|
|
|
226
|
-
|
|
|
227
|
-
|
|
|
228
|
-
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
| JS error / crash / (opt-out) console errors | `app.crash` | event |
|
|
233
|
-
| Identity update via `identify()` | `user.profile.update` | event |
|
|
234
|
-
| Tap (native, best-effort) | `user.interaction` | event |
|
|
235
|
-
| Custom `log()` name (non-allowlisted) | `custom_event` | event |
|
|
236
|
-
| Memory sample | `memory_usage` | metric |
|
|
237
|
-
| Frame render window | `frame_render_time` | metric |
|
|
238
|
-
|
|
239
|
-
`app.crash` carries a `cause` discriminator and `crash.breadcrumbs` (last 20 actions,
|
|
240
|
-
JSON-stringified). Sessions rotate after 30 minutes of inactivity; `session.finalized` flushes
|
|
241
|
-
immediately and includes a journey summary + `sdk.error_count`.
|
|
242
|
-
|
|
243
|
-
**Web-only signals** (`page_load`, `resource_timing`, `long_task`, and Web Vitals
|
|
244
|
-
LCP/FCP/CLS/INP/TTFB) are emitted only by the web build — native never reports metrics it can't
|
|
245
|
-
honestly measure.
|
|
920
|
+
| `device.battery_level` (0–100), `device.battery_charging`, `device.power_save` | `app.crash`, `app.error`, `app.hang` | Native only (needs `react-native-device-info`) |
|
|
921
|
+
| `device.reduce_motion` | `session.started` | Both |
|
|
922
|
+
| `device.screen_reader`, `device.font_scale` | `session.started` | Native only |
|
|
923
|
+
|
|
924
|
+
Battery is a cached reading (refreshed every 60 s and on foreground), so reporting a crash never
|
|
925
|
+
waits on it. A reading the device can't give — a simulator's `-1`, say — is left out, not faked.
|
|
246
926
|
|
|
247
927
|
---
|
|
248
928
|
|
|
249
929
|
## Wire format
|
|
250
930
|
|
|
251
|
-
```
|
|
252
|
-
POST
|
|
931
|
+
```http
|
|
932
|
+
POST /telemetry HTTP/1.1
|
|
253
933
|
Content-Type: application/json
|
|
254
934
|
X-API-Key: edge_xxxxxxxx
|
|
935
|
+
Authorization: Bearer edge_xxxxxxxx
|
|
936
|
+
```
|
|
255
937
|
|
|
938
|
+
```json
|
|
256
939
|
{
|
|
257
940
|
"type": "telemetry_batch",
|
|
258
|
-
"timestamp": "2026-07-02T06:00:00.000Z",
|
|
941
|
+
"timestamp": "2026-07-02T06:00:00.000Z",
|
|
259
942
|
"batch_size": 3,
|
|
260
|
-
"events": [ /*
|
|
943
|
+
"events": [ /* … */ ]
|
|
261
944
|
}
|
|
262
945
|
```
|
|
263
946
|
|
|
264
|
-
Each
|
|
947
|
+
Each entry:
|
|
265
948
|
|
|
266
949
|
```typescript
|
|
267
950
|
type TelemetryEvent = {
|
|
268
951
|
type: "event" | "metric";
|
|
269
|
-
eventName?: string;
|
|
270
|
-
metricName?: string;
|
|
271
|
-
value?: number;
|
|
272
|
-
timestamp: string;
|
|
273
|
-
attributes?: Record<string, any>;
|
|
952
|
+
eventName?: string; // events
|
|
953
|
+
metricName?: string; // metrics
|
|
954
|
+
value?: number; // metrics
|
|
955
|
+
timestamp: string; // ISO 8601, never a millisecond epoch
|
|
956
|
+
attributes?: Record<string, any>; // flat, dot-namespaced, includes the Context block
|
|
274
957
|
};
|
|
275
958
|
```
|
|
276
959
|
|
|
277
|
-
|
|
278
|
-
`
|
|
279
|
-
|
|
280
|
-
separate context events.
|
|
960
|
+
**Both credential headers are always sent, with the same value.** A shared collector reads
|
|
961
|
+
`X-API-Key`; a segmented one running `AUTH_MODE=jwt` reads `Authorization`. One build serves
|
|
962
|
+
both, so nothing has to sniff the credential's shape.
|
|
281
963
|
|
|
282
964
|
---
|
|
283
965
|
|
|
284
|
-
## Identity
|
|
285
|
-
|
|
286
|
-
IDs use 16 hex chars of entropy; device/session are suffixed with the device OS, user is not:
|
|
966
|
+
## Identity and IDs
|
|
287
967
|
|
|
288
968
|
```
|
|
289
|
-
device_{ms}_{
|
|
290
|
-
session_{ms}_{
|
|
291
|
-
user_{ms}_{16hex}
|
|
969
|
+
device_{ms}_{16 hex}_{ios|android|web}
|
|
970
|
+
session_{ms}_{16 hex}_{ios|android|web}
|
|
292
971
|
```
|
|
293
972
|
|
|
294
|
-
|
|
295
|
-
|
|
973
|
+
Entropy comes from `crypto.getRandomValues`. There is no `Math.random()` fallback — a weak ID
|
|
974
|
+
that persists forever is worse than refusing to mint one.
|
|
975
|
+
|
|
976
|
+
**`device.id` is the SDK's. `user.id` is yours.**
|
|
977
|
+
|
|
978
|
+
| | `device.id` | `user.id` |
|
|
979
|
+
|---|---|---|
|
|
980
|
+
| Minted by | The SDK, once | You, via `setUserId()` / `identify({ userId })` |
|
|
981
|
+
| Rotates | **Never** — not on `identify()`, not on logout | Whenever you set it |
|
|
982
|
+
| Present | Always | Only after you set one |
|
|
983
|
+
| Answers | Anonymous reach | Known-user reach |
|
|
984
|
+
|
|
985
|
+
Because `device.id` survives the login transition, `GROUP BY device.id` stitches a user's
|
|
986
|
+
anonymous and signed-in sessions together.
|
|
987
|
+
|
|
988
|
+
**When storage is unavailable** — incognito, a partitioned iframe, Safari ITP eviction, a full
|
|
989
|
+
disk — `device.id` lives for one process only and the row carries `device.id_ephemeral: true`.
|
|
990
|
+
Exclude that population from device counts; without the flag, a set of users who never return
|
|
991
|
+
inflates `COUNT(DISTINCT device.id)` and reads as growth.
|
|
992
|
+
|
|
993
|
+
### Sessions
|
|
994
|
+
|
|
995
|
+
A session ends after **30 minutes of inactivity** or **4 hours** total, whichever comes first.
|
|
296
996
|
|
|
297
|
-
|
|
298
|
-
|
|
997
|
+
The session record is persisted, so **process death, a tab close, a hard reload and a bfcache
|
|
998
|
+
restore all resume the same session** if the gap is inside the idle window. A resumed session
|
|
999
|
+
deliberately does *not* re-emit `session.started` — otherwise `COUNT(session.started)` would stop
|
|
1000
|
+
equalling your session count.
|
|
1001
|
+
|
|
1002
|
+
Call `startNewSession()` to end one yourself — on logout, say. Both session events then carry
|
|
1003
|
+
`session.reason: "manual"`.
|
|
299
1004
|
|
|
300
1005
|
---
|
|
301
1006
|
|
|
302
|
-
##
|
|
1007
|
+
## Delivery and reliability
|
|
1008
|
+
|
|
1009
|
+
| | Behaviour |
|
|
1010
|
+
|---|---|
|
|
1011
|
+
| **Batching** | Flushes at `batchSize` events or every `flushIntervalMs`, whichever comes first |
|
|
1012
|
+
| **Retry** | 3 attempts — exponential backoff with jitter on native, linear on web |
|
|
1013
|
+
| **Offline queue** | After the last retry, the batch is written to `telemetry_failed_events` and replayed on the next init |
|
|
1014
|
+
| **Caps** | 500 events in memory, 500 events / 1 MB on disk. Both drop oldest first, and **`app.crash` is evicted last** |
|
|
1015
|
+
| **Crashes** | Don't wait for the batch — the queue is persisted and one batch sent immediately, crash first |
|
|
1016
|
+
| **Page unload** | The web sender uses `fetch({ keepalive: true })`, so in-flight batches outlive the document |
|
|
1017
|
+
|
|
1018
|
+
Anything dropped is reported on the wire as `sdk.events_dropped` and `sdk.drop_reason`, so loss is
|
|
1019
|
+
visible rather than silent.
|
|
1020
|
+
|
|
1021
|
+
**Crashes are evicted last on purpose.** Evicting them first would make your crash-free rate look
|
|
1022
|
+
*better* the worse the user's network was.
|
|
303
1023
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- **Persisted replay:** after final failure, batches are persisted (AsyncStorage on native,
|
|
307
|
-
`localStorage` on web, key `telemetry_failed_events`) and replayed on next init — telemetry
|
|
308
|
-
survives transient network loss.
|
|
309
|
-
- **Web unload:** the web sender uses `fetch({ keepalive: true })` (not `sendBeacon`, which can't
|
|
310
|
-
set the required `X-API-Key` header) so in-flight batches survive page unload.
|
|
1024
|
+
> **Note — `flush()` sends one batch per call.** It does not loop. A large backlog still drains
|
|
1025
|
+
> one batch per interval.
|
|
311
1026
|
|
|
312
1027
|
---
|
|
1028
|
+
## Troubleshooting
|
|
313
1029
|
|
|
314
|
-
|
|
1030
|
+
Start by setting `debug: true` and calling `await telemetry.flush()`. Almost everything below
|
|
1031
|
+
shows up in that output.
|
|
315
1032
|
|
|
316
|
-
|
|
1033
|
+
### Nothing arrives at all
|
|
317
1034
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
1035
|
+
| Check | How |
|
|
1036
|
+
|---|---|
|
|
1037
|
+
| Is the endpoint right? | The collector terminates **`POST /telemetry`**. Leave `endpoint` unset and every send goes to a placeholder host that resolves nowhere. |
|
|
1038
|
+
| Did `createTelemetry()` throw? | An `apiKey` not starting with `edge_` throws synchronously, at startup. |
|
|
1039
|
+
| Is the session sampled out? | With `sessionSampleRate < 1`, a sampled-out session sends **nothing**, crashes included. |
|
|
1040
|
+
| Is `beforeSend` eating events? | A hook that throws drops the event. Check `sdk.hook_failed` on the rows that do arrive. |
|
|
1041
|
+
| Did you flush? | Without `flush()` the first batch waits for 50 events or 30 seconds. |
|
|
1042
|
+
|
|
1043
|
+
### Events arrive but a dashboard is empty
|
|
321
1044
|
|
|
322
|
-
|
|
323
|
-
|
|
1045
|
+
Your event name is probably being rewritten. Only [allowlisted names](#what-the-sdk-captures)
|
|
1046
|
+
travel as themselves; everything else arrives as `custom_event` with your name in
|
|
1047
|
+
`attributes["event.name"]`. Query on `event.name` for custom events.
|
|
1048
|
+
|
|
1049
|
+
If the name *is* allowlisted and the column is still empty, the backend may not have the name
|
|
1050
|
+
enabled on its own ingest allowlist yet — unlisted names are dropped on arrival. That is a
|
|
1051
|
+
backend configuration question, not an SDK one.
|
|
1052
|
+
|
|
1053
|
+
### Common surprises
|
|
1054
|
+
|
|
1055
|
+
| Symptom | Cause |
|
|
1056
|
+
|---|---|
|
|
1057
|
+
| Profile data stopped arriving after upgrading to v4 | `setUserProfile()` and friends are state-only now. Call `identify()`. |
|
|
1058
|
+
| "Our app broke when we enabled tracing" | The host is missing `Access-Control-Allow-Headers: traceparent`. |
|
|
1059
|
+
| Crash stacks are single letters | Set `buildId` and `Error.stackTraceLimit = 50`. See [Make crash stacks readable](#make-crash-stacks-readable). |
|
|
1060
|
+
| `device.id` changes every launch | Storage is unavailable. Look for `device.id_ephemeral: true` on the rows. |
|
|
1061
|
+
| No `http.request` events from axios | Should work — axios rides XHR, and XHR is the SDK's interception point on both builds. If it doesn't, check that the request isn't going to your collector's own endpoint, which is excluded by design. |
|
|
1062
|
+
| No Core Web Vitals on native | Correct — they're web-only, by design. |
|
|
1063
|
+
| No `memory_usage` on web | Correct — it's native-only, by design. |
|
|
1064
|
+
| No dead-click data on native | Correct — no DOM, so no mutation signal. Filter dead-click rates to web. |
|
|
1065
|
+
| `navigation` / `screen.duration` stopped arriving | Removed in v5. Use the `view` event — `view.time_spent` is the dwell. |
|
|
1066
|
+
| The *previous* screen got my `screenStart()` name | It ran before the route event. Call it from the new screen's own `useEffect`. |
|
|
1067
|
+
| `view.loading_time` is null | Read `view.loading_time_outcome` — it tells you which of the three reasons applies. |
|
|
1068
|
+
|
|
1069
|
+
### Requests the SDK can't see
|
|
1070
|
+
|
|
1071
|
+
Interception covers JavaScript `fetch` and `XHR`. It does **not** see `rn-fetch-blob`, React
|
|
1072
|
+
Native Firebase, native Apollo links, `expo-file-system`, `Image` loading or WebSockets. A screen
|
|
1073
|
+
whose real wait is one of those reports `no_activity`.
|
|
1074
|
+
|
|
1075
|
+
---
|
|
1076
|
+
|
|
1077
|
+
## Upgrading
|
|
1078
|
+
|
|
1079
|
+
### To v5
|
|
1080
|
+
|
|
1081
|
+
**Read [`docs/migration-v5.md`](docs/migration-v5.md) before you deploy.** It ships inside the npm
|
|
1082
|
+
package.
|
|
1083
|
+
|
|
1084
|
+
Of v5's six breaking changes, **exactly one breaks a build**: `TelemetryWeb` / `TelemetryNative`
|
|
1085
|
+
are types only, so construct through `createTelemetry()`. The rest move a chart — `navigation` and
|
|
1086
|
+
`screen.duration` are gone (read `view`), nested `view.name`s are joined paths (`HomeTab/Details`),
|
|
1087
|
+
a route change always bounds a view, the native-module packages run from your install, and a 4xx
|
|
1088
|
+
drops its batch instead of persisting it.
|
|
1089
|
+
|
|
1090
|
+
### To v4
|
|
1091
|
+
|
|
1092
|
+
**Read [`docs/migration-v4.md`](docs/migration-v4.md) before you deploy.** It ships inside the npm
|
|
1093
|
+
package, not just in the repo.
|
|
1094
|
+
|
|
1095
|
+
Of the twenty behavioural changes between 3.1.0 and v4, **exactly one breaks a build** — the
|
|
1096
|
+
`getDeviceInfo()` / `getNetworkInfo()` return shapes. The other nineteen are silent: no compile
|
|
1097
|
+
error, no runtime error, no log line. They surface as a saved filter returning zero rows, or a
|
|
1098
|
+
chart stepping at the release boundary. That is precisely why the note exists.
|
|
1099
|
+
|
|
1100
|
+
**The one action item most apps have:** if you call `setUserProfile()`, `setUserDetails()`,
|
|
1101
|
+
`updateUserProfile()`, `setUserName()` or `setUserContact()` and never call `identify()`, your
|
|
1102
|
+
profile data no longer reaches the wire. Add one `identify()` call.
|
|
1103
|
+
|
|
1104
|
+
The migration note also lists **the columns React Native will never write** — ANR, hangs,
|
|
1105
|
+
battery, `app.exit`, native crashes — so nobody builds a panel that stays empty forever.
|
|
1106
|
+
|
|
1107
|
+
### To v3
|
|
1108
|
+
|
|
1109
|
+
v3 was a single clean break onto the EdgeRum wire contract: `apiKey` became required, the POST
|
|
1110
|
+
body became the `telemetry_batch` envelope, timestamps became ISO-8601, device and network data
|
|
1111
|
+
moved onto every event as the Context block, and several event names changed. Full list in
|
|
1112
|
+
[CHANGELOG.md](./CHANGELOG.md).
|
|
324
1113
|
|
|
325
1114
|
---
|
|
326
1115
|
|
|
327
1116
|
## Development
|
|
328
1117
|
|
|
329
1118
|
```bash
|
|
1119
|
+
npm install
|
|
330
1120
|
npm run build # vite build → dist/ (web + native entries, ESM + CJS)
|
|
331
1121
|
npm run dev # vite in watch mode
|
|
332
1122
|
npm test # vitest run
|
|
@@ -334,15 +1124,25 @@ npm run typecheck # tsc --noEmit
|
|
|
334
1124
|
npm run clean # remove dist/
|
|
335
1125
|
```
|
|
336
1126
|
|
|
337
|
-
`
|
|
338
|
-
|
|
339
|
-
|
|
1127
|
+
`prepare` runs the build, so installing this as a git dependency builds it automatically. `dist/`
|
|
1128
|
+
and `*.tgz` are git-ignored.
|
|
1129
|
+
|
|
1130
|
+
**Platform code is split by filename**, not by runtime branching: `*.native.ts` and `*.web.ts`,
|
|
1131
|
+
with the bundler choosing. Shared logic lives in a plain `.ts` and is tested once, which is how
|
|
1132
|
+
the two builds stay in lockstep. When you add a capability, add both halves.
|
|
1133
|
+
|
|
1134
|
+
> One test (`src/vitals.native.test.ts`) reads `dist/` to prove the web-vitals dependency
|
|
1135
|
+
> contributes zero bytes to the native bundle. It is red after `npm run clean` until the next
|
|
1136
|
+
> build. That's deliberate — a source-graph proxy would pass a bundler change that a real chunk
|
|
1137
|
+
> graph catches.
|
|
340
1138
|
|
|
341
|
-
|
|
342
|
-
|
|
1139
|
+
Architecture, conventions and the reasoning behind the design decisions live in
|
|
1140
|
+
[`CLAUDE.md`](./CLAUDE.md). The wire contract — every key, its type and its null discipline — is
|
|
1141
|
+
[`docs/backend-wire-contract.md`](./docs/backend-wire-contract.md), and it outranks everything
|
|
1142
|
+
else where they disagree.
|
|
343
1143
|
|
|
344
1144
|
---
|
|
345
1145
|
|
|
346
1146
|
## License
|
|
347
1147
|
|
|
348
|
-
|
|
1148
|
+
MIT
|