@nathanclaire/edge-telemetry-sdk 4.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 +185 -30
- package/dist/appLifecycle-DS_fEclk.cjs +2 -0
- package/dist/appLifecycle-DS_fEclk.cjs.map +1 -0
- package/dist/{appLifecycle-DQErzJIR.js → appLifecycle-PffQ4vC1.js} +5 -3
- 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-FupMnr1U.js → crashHandlerNative.native-DsCRd-oN.js} +13 -13
- package/dist/crashHandlerNative.native-DsCRd-oN.js.map +1 -0
- package/dist/deviceInfo.native-D5gNBG7m.cjs +2 -0
- package/dist/{deviceInfo.native-BoeTZcD6.cjs.map → deviceInfo.native-D5gNBG7m.cjs.map} +1 -1
- package/dist/deviceInfo.native-DiiHrnI3.js +53 -0
- package/dist/{deviceInfo.native-BJ-3Jj1T.js.map → deviceInfo.native-DiiHrnI3.js.map} +1 -1
- package/dist/{deviceInfo.web-BFB1-pcA.js → deviceInfo.web-BHsjVveq.js} +3 -3
- package/dist/{deviceInfo.web-BFB1-pcA.js.map → deviceInfo.web-BHsjVveq.js.map} +1 -1
- package/dist/{deviceInfo.web-3L3IDQQA.cjs → deviceInfo.web-DGCUHAnv.cjs} +2 -2
- package/dist/{deviceInfo.web-3L3IDQQA.cjs.map → deviceInfo.web-DGCUHAnv.cjs.map} +1 -1
- 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-DdB8W_kC.js → frameTracker-BzXnxSkb.js} +18 -19
- package/dist/frameTracker-BzXnxSkb.js.map +1 -0
- package/dist/{httpAttributes-BrrtM8zh.js → httpAttributes-BWXOr4eP.js} +1 -1
- package/dist/{httpAttributes-BrrtM8zh.js.map → httpAttributes-BWXOr4eP.js.map} +1 -1
- package/dist/{httpAttributes-D0m6UID7.cjs → httpAttributes-COY0_kiF.cjs} +1 -1
- package/dist/{httpAttributes-D0m6UID7.cjs.map → httpAttributes-COY0_kiF.cjs.map} +1 -1
- 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 +128 -71
- 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 +51 -38
- package/dist/index.web.js.map +1 -1
- package/dist/{interactionWeb.web-CJAviVQ7.js → interactionWeb.web-BWBjmovb.js} +8 -8
- package/dist/{interactionWeb.web-CJAviVQ7.js.map → interactionWeb.web-BWBjmovb.js.map} +1 -1
- package/dist/interactionWeb.web-CKDJLD9r.cjs +2 -0
- package/dist/{interactionWeb.web-Bl_cZlgh.cjs.map → interactionWeb.web-CKDJLD9r.cjs.map} +1 -1
- package/dist/{interceptFetchWeb.web-UXC2Lb6X.js → interceptFetchWeb.web-DjSR_Rft.js} +18 -17
- package/dist/interceptFetchWeb.web-DjSR_Rft.js.map +1 -0
- package/dist/interceptFetchWeb.web-ZHw6IQkU.cjs +2 -0
- package/dist/{interceptFetchWeb.web-UXC2Lb6X.js.map → interceptFetchWeb.web-ZHw6IQkU.cjs.map} +1 -1
- package/dist/{interceptHttpNative.native-BVpFuoNB.cjs → interceptHttpNative.native-C5scIcgY.cjs} +2 -2
- package/dist/{interceptHttpNative.native-BVpFuoNB.cjs.map → interceptHttpNative.native-C5scIcgY.cjs.map} +1 -1
- package/dist/{interceptHttpNative.native-rX-lPNST.js → interceptHttpNative.native-vF_Fksjk.js} +2 -2
- package/dist/{interceptHttpNative.native-rX-lPNST.js.map → interceptHttpNative.native-vF_Fksjk.js.map} +1 -1
- package/dist/{loadingTime-Bhomd9qq.cjs → loadingTime-Cj5Oh8lT.cjs} +1 -1
- package/dist/{loadingTime-Bhomd9qq.cjs.map → loadingTime-Cj5Oh8lT.cjs.map} +1 -1
- package/dist/{loadingTime-ZkYvFijA.js → loadingTime-DMc0zTY8.js} +1 -1
- package/dist/{loadingTime-ZkYvFijA.js.map → loadingTime-DMc0zTY8.js.map} +1 -1
- package/dist/memoryNative.native-CK3QFVjY.cjs +2 -0
- package/dist/memoryNative.native-CK3QFVjY.cjs.map +1 -0
- package/dist/{memoryNative.native-C42h9SjK.js → memoryNative.native-DkA6f7id.js} +12 -12
- 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-B2YlLNsI.js → networkInfo.web-CcUpXMUK.js} +2 -2
- package/dist/networkInfo.web-CcUpXMUK.js.map +1 -0
- package/dist/{networkInfo.web-PltJTHsy.cjs → networkInfo.web-DfO-BUFx.cjs} +2 -2
- 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-C8fdIbVR.js → runtimeReady.web-JuE239Tg.js} +2 -2
- package/dist/{runtimeReady.web-C8fdIbVR.js.map → runtimeReady.web-JuE239Tg.js.map} +1 -1
- package/dist/{runtimeReady.web-DHW682RN.cjs → runtimeReady.web-vhAJFU61.cjs} +2 -2
- package/dist/{runtimeReady.web-DHW682RN.cjs.map → runtimeReady.web-vhAJFU61.cjs.map} +1 -1
- package/dist/{seedRuntimeReady-Cz8nOKoo.js → seedRuntimeReady-BlRdf3pR.js} +2 -2
- package/dist/{seedRuntimeReady-Cz8nOKoo.js.map → seedRuntimeReady-BlRdf3pR.js.map} +1 -1
- package/dist/seedRuntimeReady-CbjqbWCd.cjs +2 -0
- package/dist/{seedRuntimeReady-BKwkBEAF.cjs.map → seedRuntimeReady-CbjqbWCd.cjs.map} +1 -1
- package/dist/src/adapters/appLifecycle.d.ts +3 -3
- package/dist/src/adapters/batch.d.ts +44 -0
- package/dist/src/adapters/crashCapture.d.ts +5 -1
- package/dist/src/adapters/deviceState.d.ts +9 -0
- package/dist/src/adapters/frameAggregate.d.ts +15 -13
- package/dist/src/adapters/frameTracker.d.ts +1 -1
- package/dist/src/adapters/hangDetector.d.ts +41 -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/memoryNative.native.d.ts +3 -3
- package/dist/src/adapters/native/networkInfo.native.d.ts +1 -1
- package/dist/src/adapters/native/runtimeReady.native.d.ts +16 -0
- package/dist/src/adapters/navigationRef.d.ts +17 -9
- package/dist/src/adapters/networkChange.d.ts +2 -2
- package/dist/src/adapters/traceManager.d.ts +18 -5
- package/dist/src/adapters/uiInteraction.d.ts +1 -1
- package/dist/src/adapters/viewManager.d.ts +24 -8
- package/dist/src/adapters/web/deviceState.web.d.ts +10 -0
- package/dist/src/adapters/web/navigationWeb.web.d.ts +6 -10
- package/dist/src/adapters/web/webVitals.web.d.ts +7 -0
- package/dist/src/adapters/xhrIntercept.d.ts +2 -0
- package/dist/src/core/breadcrumbs.d.ts +10 -0
- package/dist/src/core/telemetry.d.ts +139 -29
- package/dist/src/core/userProfile.d.ts +7 -0
- package/dist/src/createTelemetry.native.d.ts +3 -1
- package/dist/src/createTelemetry.web.d.ts +2 -1
- package/dist/src/golden.helper.d.ts +4 -0
- package/dist/src/index.base.d.ts +80 -6
- package/dist/src/index.native.d.ts +4 -61
- package/dist/src/index.web.d.ts +4 -51
- 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-TPqXngmF.cjs → store.native-BbS76uWV.cjs} +1 -1
- package/dist/{store.native-TPqXngmF.cjs.map → store.native-BbS76uWV.cjs.map} +1 -1
- package/dist/{store.native-BYBJcy6o.js → store.native-MlWyGgBp.js} +1 -1
- package/dist/{store.native-BYBJcy6o.js.map → store.native-MlWyGgBp.js.map} +1 -1
- package/dist/{store.web-CvqqN-_Z.cjs → store.web-BzKaP57Z.cjs} +1 -1
- package/dist/{store.web-CvqqN-_Z.cjs.map → store.web-BzKaP57Z.cjs.map} +1 -1
- package/dist/{store.web-DJAlN0nc.js → store.web-rhh0NOfs.js} +1 -1
- package/dist/{store.web-DJAlN0nc.js.map → store.web-rhh0NOfs.js.map} +1 -1
- 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-DAqxxz0q.js → uiInteraction-BIDOMcrL.js} +39 -34
- package/dist/{uiInteraction-DAqxxz0q.js.map → uiInteraction-BIDOMcrL.js.map} +1 -1
- package/dist/uiInteraction-DxlwCVSn.cjs +2 -0
- package/dist/{uiInteraction-CdzvEI1p.cjs.map → uiInteraction-DxlwCVSn.cjs.map} +1 -1
- package/dist/{viewport-Dd85GUNO.cjs → viewport-9JcVIXYF.cjs} +1 -1
- package/dist/{viewport-Dd85GUNO.cjs.map → viewport-9JcVIXYF.cjs.map} +1 -1
- package/dist/{viewport-Dzmt5QwK.js → viewport-GWTEBt2K.js} +1 -1
- package/dist/{viewport-Dzmt5QwK.js.map → viewport-GWTEBt2K.js.map} +1 -1
- package/dist/{web-vitals.attribution-CVCPiX-h.cjs → web-vitals.attribution-DAvBvdng.cjs} +1 -1
- package/dist/{web-vitals.attribution-CVCPiX-h.cjs.map → web-vitals.attribution-DAvBvdng.cjs.map} +1 -1
- package/dist/{web-vitals.attribution-xw9N5MKQ.js → web-vitals.attribution-DcoMtvlY.js} +1 -1
- package/dist/{web-vitals.attribution-xw9N5MKQ.js.map → web-vitals.attribution-DcoMtvlY.js.map} +1 -1
- 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-CNIpsKlA.js → webVitals.web-DRTDK6s5.js} +39 -24
- 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-BNiA41Mj.js → xhrIntercept-9uAkQh3N.js} +16 -14
- 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 +1 -1
- package/docs/migration-v5.md +178 -0
- package/package.json +12 -4
- package/dist/appLifecycle-CECgRVu_.cjs +0 -2
- package/dist/appLifecycle-CECgRVu_.cjs.map +0 -1
- package/dist/appLifecycle-DQErzJIR.js.map +0 -1
- package/dist/batch-CwoO7noL.js +0 -56
- package/dist/batch-CwoO7noL.js.map +0 -1
- package/dist/batch-DNu8Xr9T.cjs +0 -2
- package/dist/batch-DNu8Xr9T.cjs.map +0 -1
- package/dist/crashCapture-BOJ8nSAZ.cjs +0 -4
- package/dist/crashCapture-BOJ8nSAZ.cjs.map +0 -1
- package/dist/crashCapture-BW8WuyaU.js +0 -70
- package/dist/crashCapture-BW8WuyaU.js.map +0 -1
- package/dist/crashHandler.web-8F_k2veo.js +0 -29
- package/dist/crashHandler.web-8F_k2veo.js.map +0 -1
- package/dist/crashHandler.web-CWmF56mJ.cjs +0 -2
- package/dist/crashHandler.web-CWmF56mJ.cjs.map +0 -1
- package/dist/crashHandlerNative.native-C2kSikDt.cjs +0 -2
- package/dist/crashHandlerNative.native-C2kSikDt.cjs.map +0 -1
- package/dist/crashHandlerNative.native-FupMnr1U.js.map +0 -1
- package/dist/deviceInfo.native-BJ-3Jj1T.js +0 -53
- package/dist/deviceInfo.native-BoeTZcD6.cjs +0 -2
- package/dist/frameTracker-CHG6sIx9.cjs +0 -2
- package/dist/frameTracker-CHG6sIx9.cjs.map +0 -1
- package/dist/frameTracker-DdB8W_kC.js.map +0 -1
- package/dist/index-BtLlV1HA.js +0 -57
- package/dist/index-BtLlV1HA.js.map +0 -1
- package/dist/index-C2XQ-EYw.js +0 -1122
- package/dist/index-C2XQ-EYw.js.map +0 -1
- package/dist/index-CXsVZY35.cjs +0 -2
- package/dist/index-CXsVZY35.cjs.map +0 -1
- package/dist/index-DLquF88M.cjs +0 -2
- package/dist/index-DLquF88M.cjs.map +0 -1
- package/dist/interactionWeb.web-Bl_cZlgh.cjs +0 -2
- package/dist/interceptFetchWeb.web-T88kO-bE.cjs +0 -2
- package/dist/interceptFetchWeb.web-T88kO-bE.cjs.map +0 -1
- package/dist/memoryNative.native-C42h9SjK.js.map +0 -1
- package/dist/memoryNative.native-CA-7w9w1.cjs +0 -2
- package/dist/memoryNative.native-CA-7w9w1.cjs.map +0 -1
- package/dist/memoryStore-BIGZmmfD.cjs +0 -2
- package/dist/memoryStore-BIGZmmfD.cjs.map +0 -1
- package/dist/memoryStore-F5I-GQKM.js +0 -193
- package/dist/memoryStore-F5I-GQKM.js.map +0 -1
- package/dist/nativeSender-CfQaRuDK.cjs +0 -2
- package/dist/nativeSender-CfQaRuDK.cjs.map +0 -1
- package/dist/nativeSender-pgVSIv-X.js +0 -59
- package/dist/nativeSender-pgVSIv-X.js.map +0 -1
- package/dist/navigationRef-BzYbs8cm.js +0 -28
- package/dist/navigationRef-BzYbs8cm.js.map +0 -1
- package/dist/navigationRef-C-_qhb43.cjs +0 -2
- package/dist/navigationRef-C-_qhb43.cjs.map +0 -1
- package/dist/navigationTracker-BmywA_Bg.js +0 -19
- package/dist/navigationTracker-BmywA_Bg.js.map +0 -1
- package/dist/navigationTracker-HkwVyywz.cjs +0 -2
- package/dist/navigationTracker-HkwVyywz.cjs.map +0 -1
- package/dist/navigationWeb.web-CW_z7Ca4.cjs +0 -2
- package/dist/navigationWeb.web-CW_z7Ca4.cjs.map +0 -1
- package/dist/navigationWeb.web-CcwgKuIZ.js +0 -55
- package/dist/navigationWeb.web-CcwgKuIZ.js.map +0 -1
- package/dist/networkChange-CUO1hRLj.cjs.map +0 -1
- package/dist/networkChange-D39hdSb0.js.map +0 -1
- package/dist/networkInfo.native-CGrx9cnH.js +0 -343
- package/dist/networkInfo.native-CGrx9cnH.js.map +0 -1
- package/dist/networkInfo.native-YVySdv3S.cjs +0 -2
- package/dist/networkInfo.native-YVySdv3S.cjs.map +0 -1
- package/dist/networkInfo.web-B2YlLNsI.js.map +0 -1
- package/dist/networkInfo.web-PltJTHsy.cjs.map +0 -1
- package/dist/runtimeReady.native-Bh7EcYmK.js +0 -14
- package/dist/runtimeReady.native-Bh7EcYmK.js.map +0 -1
- package/dist/runtimeReady.native-jUmuE1lV.cjs +0 -2
- package/dist/runtimeReady.native-jUmuE1lV.cjs.map +0 -1
- package/dist/seedRuntimeReady-BKwkBEAF.cjs +0 -2
- package/dist/src/adapters/navigationTracker.d.ts +0 -6
- package/dist/src/adapters/screenTiming.d.ts +0 -15
- package/dist/telemetry-ByDJIz_9.js +0 -1280
- package/dist/telemetry-ByDJIz_9.js.map +0 -1
- package/dist/telemetry-CrU7i1Jc.cjs +0 -2
- package/dist/telemetry-CrU7i1Jc.cjs.map +0 -1
- package/dist/uiInteraction-CdzvEI1p.cjs +0 -2
- package/dist/webSender-BIwslfpT.js +0 -63
- package/dist/webSender-BIwslfpT.js.map +0 -1
- package/dist/webSender-CVtE4sOF.cjs +0 -2
- package/dist/webSender-CVtE4sOF.cjs.map +0 -1
- package/dist/webVitals.web-CNIpsKlA.js.map +0 -1
- package/dist/webVitals.web-DpWJ-iYp.cjs +0 -2
- package/dist/webVitals.web-DpWJ-iYp.cjs.map +0 -1
- package/dist/xhrIntercept-BADex6Cq.cjs +0 -2
- package/dist/xhrIntercept-BADex6Cq.cjs.map +0 -1
- package/dist/xhrIntercept-BNiA41Mj.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const o=require("./react-bqe7KPOf.cjs"),N=require("./loadingTime-Cj5Oh8lT.cjs"),W="4.3.0",z=["device.id","app.name","app.package_name","app.version","app.build_number","sdk.version","sdk.platform"],X=i=>JSON.stringify(z.map(e=>i.attributes?.[e]));function Y(i){const e=i[0]?.attributes??{};return JSON.stringify({type:"telemetry_batch",contract_version:W,timestamp:new Date().toISOString(),batch_size:i.length,device_id:e["device.id"],sdk:{name:"react_native",version:e["sdk.version"]},app:{name:e["app.name"],package_name:e["app.package_name"],platform:e["device.platform"],version:e["app.version"],build_number:e["app.build_number"]},events:i.map(t=>{const s={...t.attributes};for(const r of z)delete s[r];return{...t,attributes:s}})})}function G(i){const e=new Map;for(const t of i){const s=X(t);e.set(s,[...e.get(s)??[],t])}return[...e.values()]}async function Q(i,e,t){const s=G(i);for(let r=0;r<s.length;r++)try{await e(s[r])}catch(n){const a=s.slice(b(n)?r+1:r).flat();throw a.length>0&&await t(a),n}}function Z(i){return{"Content-Type":"application/json",...i?{"X-API-Key":i}:{}}}class ee extends Error{constructor(e,t){super(`Telemetry send failed: ${e}`),this.status=e,this.resetAt=t}}function u(i){const e=i?.status;return typeof e=="number"?e:void 0}const b=i=>{const e=u(i);return e!==void 0&&e>=400&&e<500&&e!==429};function te(i,e=Date.now()){const t=Number(i?.get?.("x-ratelimit-reset"));if(!(!Number.isFinite(t)||t<0))return t>1e9?t*1e3:e+t*1e3}async function se(i,e,t){let s;for(let r=1;r<=e;r++){try{const n=await i();if(n.ok)return;const a=new ee(n.status,n.status===429?te(n.headers):void 0);if(n.status>=400&&n.status<500)throw a;s=a}catch(n){if(u(n)!==void 0&&u(n)<500)throw n;s=n}r<e&&await new Promise(n=>setTimeout(n,t(r)))}throw s}const ie="https://your.telemetry.endpoint/telemetry";function p(i=16){if(typeof globalThis.crypto?.getRandomValues!="function")throw new Error("edge-telemetry: crypto.getRandomValues is unavailable, so no id can be minted. On React Native this means react-native-get-random-values failed to load — reinstall it and rebuild.");const e=new Uint8Array(Math.ceil(i/2));crypto.getRandomValues(e);let t="";for(const s of e)t+=s.toString(16).padStart(2,"0");return t.slice(0,i)}const D={none:0,url:1,route:2,explicit:3},R="unknown",re=16;function M(){return`view_${Date.now()}_${p(16)}`}class ne{constructor(e){this.telemetry=e,this.activityListeners=new Set,this.boundaryListeners=new Set,this.retiredNames=new Map,this.markedNames=new Set,this.host=typeof location<"u"&&location?.origin?location.origin:void 0;const t=Date.now();this.view={id:M(),name:R,source:"none",referrer:"",loadType:"initial_load",elapsed:0,resumedAt:t,errors:0,actions:0,settle:new N.NetworkSettle(t,{awaitRuntimeReady:!0}),span:e.trace?.viewSpan(t)??{},routes:{},token:!0}}anchorInitial(e){this.view.loadType==="initial_load"&&(this.view.anchor=e)}markReady(e){const t=this.view;t.token&&t.readyAt===void 0&&(t.readyAt=e)}get id(){return this.view.id}get name(){return this.view.name}nameOf(e){return e===this.view.id?this.view.name:this.retiredNames.get(e)??R}async navigate(e,t){if(t==="route"||t==="url"){const n=this.view.routes[t];if(n!==void 0&&n!==e){await this.exit("route_change",e,t);return}this.view.routes[t]=e}const s=D[t],r=D[this.view.source];if(!(s<r)){if(s>r){this.view.name=e,this.view.source=t;return}e!==this.view.name&&await this.exit("route_change",e,t)}}countError(){this.view.errors++}countAction(){this.view.actions++}requestStarted(e){return this.notifyActivity(),this.view.settle.requestStarted(e)}onActivity(e){return this.activityListeners.add(e),()=>{this.activityListeners.delete(e)}}notifyActivity(){for(const e of this.activityListeners)e()}onBoundary(e){return this.boundaryListeners.add(e),()=>{this.boundaryListeners.delete(e)}}seedRuntimeReady(e){this.view.settle.seedRuntimeReady(e)}async endView(e="session_rotation"){const t=this.view,{loadingTime:s,outcome:r}=t.settle.resolve();let n={};if(t.token&&t.anchor!==void 0&&(t.readyAt!==void 0?(this.markedNames.add(t.name),n={"view.ready_time":Math.max(0,t.readyAt-t.anchor),"view.ready_outcome":"ready"}):e!=="resume"&&this.markedNames.has(t.name)&&(n={"view.ready_outcome":"abandoned"})),await this.telemetry.log("view",{...t.span,...this.host?{"view.host":this.host}:{},"view.referrer":t.referrer,"view.load_type":t.loadType,"view.name_source":t.source,"view.time_spent":this.timeSpent(),...s===null?{}:{"view.loading_time":s},"view.loading_time_outcome":r,"view.error_count":t.errors,"view.action_count":t.actions,"view.request_count":t.settle.requestCount,...n}),t.loadType!=="initial_load"&&t.loadType!=="route_change")return;const a=typeof n["view.ready_time"]=="number",d=a?n["view.ready_time"]:s;await this.telemetry.log("screen.load",{"screen.name":t.name,"screen.load.source":a?"reported":"inferred","screen.load.outcome":a?"settled":r,...d===null?{}:{"screen.load.settled_ms":d}})}async beginView(e,t,s){if(this.notifyActivity(),e!=="session_rotation")for(const a of this.boundaryListeners)try{await a(e)}catch{}const r=this.view,n=Date.now();if(this.retiredNames.set(r.id,r.name),this.retiredNames.size>re){const a=this.retiredNames.keys().next();a.done||this.retiredNames.delete(a.value)}this.view={id:M(),name:t??r.name,source:s??r.source,referrer:r.name,loadType:e,elapsed:0,resumedAt:n,errors:0,actions:0,settle:new N.NetworkSettle(n),span:this.telemetry.trace?.viewSpan(n)??{},routes:e==="route_change"?s==="route"||s==="url"?{[s]:t}:{}:{...r.routes},token:e==="route_change",anchor:n}}async exit(e,t,s){await this.endView(e),await this.beginView(e,t,s)}async background(){await this.exit("resume");const e=this.view;e.elapsed+=this.sinceResume(),e.resumedAt=void 0}foreground(){this.view.resumedAt??=Date.now()}sinceResume(){return this.view.resumedAt===void 0?0:Date.now()-this.view.resumedAt}timeSpent(){return Math.max(0,this.view.elapsed+this.sinceResume())}}const ae=2e3,oe=1e4,de=()=>p(32),$=()=>p(16);class he{constructor(e,t){this.allowlist=o.normalizeAllowlist(t);const s=Date.now();this.launch=this.mint("launch",s,e??s)}allowlistSize(){return this.allowlist.size}launchRootAttributes(){return f(this.launch,!0,this.launch.spanStartMs).keys}viewSpan(e){const{root:t,isRoot:s}=this.attach("navigation",e);return f(t,s,e).keys}interactionSpan(e){const t=this.mint("interaction",e,e);return f(t,!0,e).keys}manualSpan(e){const{root:t,isRoot:s}=this.attach("custom",e);return f(t,s,e).keys}requestTrace(e,t){const s=this.decide(t);if(s==="adopted"){const l=o.parseTraceparent(t.consumerTraceparent),J={"trace.id":l.traceId,"span.id":l.spanId,"rum.action.id":l.spanId,"span.start_time":new Date(e).toISOString(),"traceparent.outcome":"adopted"};return{finish:()=>J,discard:()=>{}}}const{root:r,isRoot:n,attribution:a}=this.attach("request",e),d=s==="inject"?a:s,h=f(r,n,e),c={...h.keys,...d?{"traceparent.outcome":d}:{}},E=n?()=>c:l=>({...c,"span.duration_ms":Math.max(0,l-e)}),T=()=>{n&&this.root===r&&(this.root=void 0)};return s==="inject"?{finish:E,discard:T,header:o.formatTraceparent(r.traceId,h.spanId)}:{finish:E,discard:T}}decide(e){if(!(this.allowlist.size===0||!e.sampled))return o.allowsHost(this.allowlist,e.url)?e.noCors?"skipped_no_cors":e.consumerTraceparent!=null?o.parseTraceparent(e.consumerTraceparent)?"adopted":"skipped_consumer_set":"inject":"skipped_off_allowlist"}annotate(e=Date.now()){const t=this.liveRoot(e);return t?{"trace.id":t.traceId,"rum.action.id":t.spanId,"trace.root_type":t.rootType}:{}}clear(){this.root=void 0}restartLaunchRoot(){this.launch=this.mint("launch",Date.now(),this.launch.spanStartMs)}attach(e,t){const s=this.root!==void 0,r=this.liveRoot(t);return r?(r.lastTouch=t,{root:r,isRoot:!1,attribution:"injected_attributed"}):{root:this.mint(e,t,t),isRoot:!0,attribution:s?"injected_expired":"injected_unattributed"}}mint(e,t,s){const r={traceId:de(),spanId:$(),rootType:e,startedAt:t,spanStartMs:s,lastTouch:t};return this.root=r,r}liveRoot(e){const t=this.root;if(!t)return;const s=e-t.lastTouch,r=e-t.startedAt;if(s<0||r<0||s>ae||r>oe){this.root=void 0;return}return t}}function f(i,e,t){const s=e?i.spanId:$();return{spanId:s,keys:{"trace.id":i.traceId,"span.id":s,...e?{}:{"parent.span.id":i.spanId},"rum.action.id":i.spanId,"trace.root_type":i.rootType,"span.start_time":new Date(t).toISOString()}}}const L=1e3,ce=2e3,ue=6e4;function le(i,e){const t=e-i-L;return t>=ce&&t<=ue?Math.round(t):void 0}class fe{constructor(e,t=()=>performance.now()){this.core=e,this.now=t,this.active=!1,this.suspended=!1,this.tick=()=>{const s=this.now(),r=this.last,n=r&&le(r.mono,s);r&&n!==void 0&&this.core.log("app.hang",{...r.trace,"hang.duration_ms":n},r.snap).catch(d=>o.debug.warn("app.hang failed:",d));const a=Date.now();this.last={mono:s,snap:this.core.snapshot(a),trace:this.core.trace.annotate(a)},this.timer=setTimeout(this.tick,L)}}setActive(e){this.active=e,this.sync()}suspend(e){this.suspended=e,this.sync()}sync(){this.active&&!this.suspended?this.start():this.stop()}start(){this.timer===void 0&&this.tick()}stop(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.last=void 0}}const K="telemetry_failed_events";function pe(i){if(i.status!=="hit")return[];try{const e=JSON.parse(i.value);return Array.isArray(e)?e:[]}catch{return[]}}const me=500,ve=1e6,we=i=>typeof TextEncoder<"u"?new TextEncoder().encode(i).length:i.length;function ye(i,e){const t=[...i,...e];let s=0;for(;t.length>me;)t.splice(w(t),1),s++;const r=t.map(a=>we(JSON.stringify(a)));let n=r.reduce((a,d)=>a+d,0)+Math.max(t.length-1,0)+2;for(;n>ve&&t.length>0;){const a=w(t);n-=r[a]+(t.length>1?1:0),r.splice(a,1),t.splice(a,1),s++}return{json:JSON.stringify(t),dropped:s}}function Se(i){let e;return()=>e??=i().finally(()=>{e=void 0})}function A(i){try{return JSON.stringify(i)??void 0}catch{return}}const P=32,ge=255,be=/^(task|span|trace|parent|rum)(\.|$)/;function O(i){if(!i||typeof i!="object")return;const e={};for(const[t,s]of Object.entries(i))be.test(t)||(e[t]=s);return e}function y(i){return typeof i=="string"&&i.trim()!==""?i.slice(0,ge):void 0}class _e{constructor(){this.open=new Map}start(e,t,s){if(!this.open.has(e)&&this.open.size>=P)return;const r={name:e,start:t,attrs:s};return this.open.delete(e),this.open.set(e,r),r}take(e,t){const s=this.open.get(e);if(!(!s||t&&s!==t))return this.open.delete(e),s}clear(){this.open.clear()}has(e){return this.open.get(e.name)===e}takeSession(e){const t=[...this.open.values()].filter(s=>s.sessionId===e);for(const s of t)this.open.delete(s.name);return t}toJSON(){return[...this.open.values()].filter(e=>e.sessionId!==void 0).map(({ready:e,attrs:t,...s})=>({...s,attrs:t&&A(t)}))}restore(e){if(this.open.clear(),!!Array.isArray(e))for(const t of e.slice(0,P)){if(typeof t?.name!="string"||typeof t.start!="number"||typeof t.sessionId!="string")continue;let s;try{s=t.attrs?JSON.parse(t.attrs):void 0}catch{s=void 0}this.open.set(t.name,{...t,attrs:s})}}}const Ie=255,ke=255,Ae=50,q=64,C=64,_=255;let x=!1;function S(i,e){if(typeof i!="string")return;const t=i.slice(0,e);return t.length?t:void 0}function B(i){if(i==null)return;if(typeof i=="number"||typeof i=="boolean")return i;if(typeof i=="string")return i.slice(0,_)||void 0;const e=A(i);return e===void 0?void 0:e.slice(0,_)||void 0}function Ee(i){const e={};if(!i)return e;const t=S(i.fullName,Ie),s=S(i.email,ke),r=S(i.phone,Ae);t!==void 0&&(e["user.name"]=t),s!==void 0&&(e["user.email"]=s),r!==void 0&&(e["user.phone"]=r);let n=0,a=0;for(const d of Object.keys(i.customAttributes||{})){if(d.length>C||a>=q){n++;continue}const h=B(i.customAttributes[d]);if(h===void 0){n++;continue}e[`user.custom.${d}`]=h,a++}return n>0&&(e["user.custom_dropped"]=n,o.isDev()&&!x&&(x=!0,console.warn(`[edge-telemetry] identify(): ${n} custom attribute(s) dropped. user.custom.* is bounded at ${q} keys, ${C}-char keys and ${_}-char values; unserializable values are dropped.`))),e}const Te=64,Ne=8;function De(i,e,t=new Date){const s={};if(e&&typeof e=="object")for(const[r,n]of Object.entries(e).slice(0,Ne)){const a=B(n);a!==void 0&&(s[r]=a)}return s.name=String(i).slice(0,Te),s.timestamp=t.toISOString(),s}class Re{constructor(e=20){this.max=e,this.items=[]}add(e){this.items.push(e),this.items.length>this.max&&this.items.shift()}list(){return[...this.items]}toJSON(){return JSON.stringify(this.items)}}const Me=new Set(["session.id","session.start_time","session.sequence","event.sequence","device.platform","trace.id","span.id","parent.span.id","rum.action.id","view.id"]),U=i=>Me.has(i)||i.startsWith("sdk.")||i.startsWith("app."),m="device.id";function Pe(i,e){let t;try{t=e({...i,attributes:{...i.attributes}})}catch(s){return o.debug.warn("Telemetry: beforeSend threw — event dropped",s),{kind:"failed"}}return t===null?{kind:"dropped"}:typeof t!="object"?(o.debug.warn("Telemetry: beforeSend returned a non-event — event dropped",t),{kind:"failed"}):{kind:"kept",event:Oe(i,t)}}function Oe(i,e){const t={};for(const[n,a]of Object.entries(e.attributes??{}))U(n)||(t[n]=a);for(const[n,a]of Object.entries(i.attributes??{}))U(n)&&(t[n]=a);const s=t[m];if(typeof s!="string"||s===""){const n=i.attributes?.[m];n===void 0?delete t[m]:t[m]=n}const r={type:i.type,timestamp:i.timestamp,attributes:t};return i.eventName!==void 0&&(r.eventName=i.eventName),i.metricName!==void 0&&(r.metricName=i.metricName),i.type==="metric"&&(r.value=e.value??i.value),r}const qe="5.0.1",Ce=i=>i?`react-native-${i}`:"react-native",xe=qe,Ue=1800*1e3,He=14400*1e3,je=8,Fe=500,Ve=50,ze=100,$e=1e3;let H=!1;const g=i=>i.attributes?.["event.sequence"]??-1,I=i=>i==="app.crash"||i==="app.error";function w(i){const e=i.findIndex(t=>t.eventName!=="app.crash");return e===-1?0:e}const k="telemetry_device_id",v="telemetry_session",Le=255,Ke=new Set(["session.started","session.finalized","app.lifecycle","http.request","network.change","user.profile.update","app.crash","view","screen.load","app.error","ui.interaction","app.start","task.complete","app.hang","frame.summary","memory.usage","custom.metric","perf.lcp","perf.fcp","perf.cls","perf.inp","perf.ttfb"]),j={"perf.lcp":"ms","perf.fcp":"ms","perf.inp":"ms","perf.ttfb":"ms","perf.cls":"score"},Be=new Set(["frame.summary","memory.usage"]),Je=new Set(["app.crash","app.error","custom.event"]),F=i=>typeof i=="number"&&Number.isFinite(i)&&i>=0&&i<=1;function V(i){if(typeof i!="string")return;let e;try{e=JSON.parse(i)}catch{return}if(!(typeof e?.id!="string"||typeof e.start!="number"||typeof e.lastActivity!="number"))return e}function We(i){return i===void 0?1:!Number.isFinite(i)||i<0||i>1?(o.debug.warn(`Telemetry: sessionSampleRate must be a number in [0,1] — got ${i}; using 1`),1):i}class Xe{constructor(e){this.queue=[],this.intervalId=null,this.networkStarted=!1,this.userId=void 0,this.deviceIdEphemeral=!1,this.userProfile=void 0,this.eventCount=0,this.breadcrumbs=new Re(20),this.sessionSequence=0,this.eventSequence=0,this.sessionEventCount=0,this.errorCount=0,this.hookDropped=0,this.hookFailed=0,this.eventsDropped=0,this.crashPersistedThrough=-1,this.appStartEmitted=!1,this.spans=new _e,this.finalizing=!1,this.pendingStart=!1,this.holdUntil=0,this.sender=e?.sender,this.batchSize=e?.batchSize??50,this.flushIntervalMs=e?.flushIntervalMs??3e4,this.endpoint=e?.endpoint,this.platform=e?.platform,this.store=e?.store??o.memoryStore({unavailable:!0}),this.beforeSend=e?.beforeSend,this.buildId=typeof e?.buildId=="string"&&e.buildId!==""?e.buildId:void 0,this.enabled=e?.enabled!==!1,this.enabled||(this.appStartEmitted=!0),this.configuredSampleRate=We(e?.sessionSampleRate),this.sampleRate=this.configuredSampleRate,this.sampled=this.rollSample(),this.sessionId=e?.sessionId??this.generateSessionId(),e?.userId&&this.setUserId(e.userId),this.sessionStart=Date.now(),this.sdkVersion=e?.sdkVersion??xe,this.enabled&&this.startDelivery(),this.trace=new he(e?.traceLaunchStart,e?.traceHostAllowlist),this.deviceState=e?.deviceStateHandler,this.enabled&&this.deviceState?.start?.(),o.isDev()||(this.hangs=new fe(this),this.hangs.suspend(!this.enabled)),this.views=new ne(this),this.deviceInfoHandler=e?.deviceInfoHandler??{start:async()=>Promise.resolve(),collect:async()=>Promise.resolve({app:{name:"",version:""},device:{platform:""}})},this.networkInfoHandler=e?.networkInfoHandler??{start:async()=>Promise.resolve({}),collect:async()=>Promise.resolve({})},e?.networkInfoHandler&&this.getNetworkInfo(e.networkInfoHandler)}captureError(e,t,s="reported"){const r=this.isNativePlatform()?{fatal:!1}:{};return this.log("app.error",{...t,...o.buildErrorAttributes(s,e,r)})}addBreadcrumb(e,t){this.breadcrumbs.add(De(e,t))}async startNewSession(){await this.rotateSession("manual")}trackErrors(e,t){this.crashHandler=e,e.attach(t).catch(s=>{o.debug.warn("Telemetry crashHandler attach failed:",s)})}getDeviceInfo(e){this.deviceInfoHandler=e,e.start(this).catch(t=>{o.debug.warn("Telemetry deviceInfo tracking start failed:",t)})}getNetworkInfo(e){this.networkStarted||(this.networkStarted=!0,this.networkInfoHandler=e,e.start(this).catch(t=>{o.debug.warn("Telemetry networkInfoHandler start failed:",t)}))}trackFrameDrops(e){this.frameDropsHandler=e,e.start().catch(t=>{o.debug.warn("Telemetry frameDropsHandler start failed:",t)})}trackNetworkRequests(e){this.networkHandler=e,e.start().catch(t=>{o.debug.warn("Telemetry networkHandler start failed:",t)})}startDelivery(){this.sender?.replayFailed&&this.sender.replayFailed().catch(e=>{o.debug.warn("Telemetry replay failed Telemetry class:",e)}),this.flushIntervalMs>0&&!this.intervalId&&(this.intervalId=setInterval(()=>this.flush().catch(()=>{}),this.flushIntervalMs))}isEnabled(){return this.enabled}disable(){if(this.enabled){this.enabled=!1,this.queue=[],this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.memoryHandler?.stop?.(),this.deviceState?.stop?.(),this.hangs?.suspend(!0),this.spans.clear();for(const e of[K,v])Promise.resolve(this.store.remove(e)).catch(t=>o.debug.warn("disable: store remove failed:",t))}}async enable(){if(this.enabled)return;if(this.enabled=!0,this.startDelivery(),this.memoryHandler&&this.memoryHandler.start().catch(t=>o.debug.warn("Telemetry memoryHandler start failed:",t)),this.hangs?.suspend(!1),this.deviceState?.start?.(),this.pendingStart){this.pendingStart=!1,await this.hydrateAndAnnounce();return}const e=this.expiryReason(Date.now());e&&await this.rotateSession(e)}trackMemoryUsage(e){this.memoryHandler?.stop?.(),this.memoryHandler=e,this.enabled&&e.start().catch(t=>{o.debug.warn("Telemetry memoryHandler start failed:",t)})}autoTrackNavigation(e){this.navigationHandler=e,e?.start().catch(t=>{o.debug.warn("Telemetry navigationHandler start failed:",t)})}rollSample(){return Math.random()<this.sampleRate}isNativePlatform(){return this.platform==="ios"||this.platform==="android"}generateSessionId(){const e=`session_${Date.now()}_${p(16)}`;return this.platform?`${e}_${this.platform}`:e}setSessionId(e){this.sessionId=e,this.sessionStart=Date.now()}getSessionId(){return this.sessionId}snapshot(e){return{at:e,viewId:this.views.id,sessionId:this.sessionId,sessionStart:this.sessionStart}}getEndpoint(){return this.endpoint}isSampled(){return this.sampled}async resumeOrStartSession(){if(!this.enabled){this.pendingStart=!0;return}await this.hydrateAndAnnounce(),await this.emitAppStart()}async hydrateAndAnnounce(){const e=await this.hydrateSession();if(e.kind==="resumed")return;if(e.kind==="expired"){await this.rotateSession(e.reason);return}if(this.lastActivity===void 0){await this.startSession("launch");return}const t=this.expiryReason(Date.now());t&&await this.rotateSession(t)}async emitAppStart(){if(this.appStartEmitted)return;this.appStartEmitted=!0;const e=s=>{const r=this.jsReadyMs?.();return this.log("app.start",{...this.trace.launchRootAttributes(),"app.start.type":"cold",...s===void 0?{}:{"app.start.duration_ms":Math.round(s)},...r===void 0?{}:{"app.start.js_ready_ms":r}})},t=this.appStartMs?.();if(!t)return e();t.then(e,()=>e()).catch(s=>o.debug.warn("app.start failed:",s))}async hydrateSession(){const e=await this.store.get(v);if(e.status==="unavailable")return o.debug.warn("Telemetry: session storage unavailable — this session cannot be resumed"),{kind:"nothing"};if(e.status==="miss")return{kind:"nothing"};const t=V(e.value);if(!t)return{kind:"nothing"};this.sessionId=t.id,this.sessionStart=t.start,this.lastActivity=t.lastActivity,this.sessionSequence=t.sequence??0,this.eventSequence=t.eventSequence??0,this.sessionEventCount=t.eventCount??0,this.errorCount=t.errorCount??0,this.spans.restore(t.spans),typeof t.sampled=="boolean"&&F(t.sampleRate)&&(this.sampled=t.sampled,this.sampleRate=t.sampleRate);const s=this.expiryReason(Date.now());return s?{kind:"expired",reason:s}:{kind:"resumed"}}async adoptSessionRecord(e){const t=V(e);if(t){if(t.id===this.sessionId){this.lastActivity=Math.max(this.lastActivity??t.lastActivity,t.lastActivity),this.sessionSequence=Math.max(this.sessionSequence,t.sequence??0),this.eventSequence=Math.max(this.eventSequence,t.eventSequence??0),this.sessionEventCount=Math.max(this.sessionEventCount,t.eventCount??0),this.errorCount=Math.max(this.errorCount,t.errorCount??0);return}t.start<this.sessionStart||(await this.views.endView(),await this.abandonSpans(),this.sessionId=t.id,this.sessionStart=t.start,this.lastActivity=t.lastActivity,this.sessionSequence=t.sequence??0,this.eventSequence=t.eventSequence??0,this.sessionEventCount=t.eventCount??0,this.errorCount=t.errorCount??0,this.crashPersistedThrough=-1,typeof t.sampled=="boolean"&&F(t.sampleRate)&&(this.sampled=t.sampled,this.sampleRate=t.sampleRate),this.trace.clear(),await this.views.beginView("session_rotation"))}}expiryReason(e){if(this.lastActivity!==void 0){if(e-this.lastActivity>Ue)return"timeout";if(e-this.sessionStart>He)return"max_duration"}}async persistSession(){if(!this.enabled)return;const e={id:this.sessionId,start:this.sessionStart,lastActivity:this.lastActivity??this.sessionStart,sequence:this.sessionSequence,eventSequence:this.eventSequence,eventCount:this.sessionEventCount,errorCount:this.errorCount,sampled:this.sampled,sampleRate:this.sampleRate,spans:this.spans.toJSON()};(await this.store.set(v,JSON.stringify(e))).status==="unavailable"&&o.debug.log("Telemetry: session not persisted (store unavailable)")}async startSession(e){this.lastActivity=Date.now(),await this.persistSession();const t=await this.deviceState?.accessibility().catch(()=>({}))??{};await this.log("session.started",{...t,...e==="launch"?{}:{"session.reason":e},"sdk.trace_allowlist_size":this.trace.allowlistSize()})}async finalizeSession(e){await this.abandonSpans(),await this.log("session.finalized",{"session.duration_ms":Math.max(0,(this.lastActivity??this.sessionStart)-this.sessionStart),"session.event_count":this.sessionEventCount,"sdk.error_count":this.errorCount,"session.reason":e}),await this.flush()}async abandonSpans(){this.finalizing=!0;try{for(const e of this.spans.takeSession(this.sessionId))await this.emitTask(e,"abandoned",void 0,Math.max(e.start,this.lastActivity??e.start))}finally{this.finalizing=!1}}async newSession(e){this.sessionId=this.generateSessionId(),this.sessionStart=Date.now(),this.sessionSequence=0,this.eventSequence=0,this.crashPersistedThrough=-1,this.sessionEventCount=0,this.errorCount=0,this.sampleRate=this.configuredSampleRate,this.sampled=this.rollSample(),this.appStartEmitted?this.trace.clear():this.trace.restartLaunchRoot(),await this.views.beginView("session_rotation"),await this.startSession(e)}startSpan(e,t,s=Date.now()){if(!this.enabled)return;const r=y(e);if(!r){o.debug.warn("startSpan: blank name — span is inert");return}const n=this.spans.start(r,s,O(t));if(!n){o.debug.warn(`startSpan: ${r} — more than 32 open spans, span is inert`);return}const a=()=>{n.keys=this.trace.manualSpan(s),n.viewId=this.views.id,n.sessionId=this.sessionId,n.sessionStart=this.sessionStart,this.lastActivity=Math.max(this.lastActivity??s,s),this.persistSession().catch(h=>o.debug.warn("startSpan: persist failed:",h))},d=this.expiryReason(s);return d?n.ready=this.rotateSession(d).catch(h=>o.debug.warn("startSpan: rotation failed:",h)).then(()=>{this.spans.has(n)&&a()}):a(),n}async endSpan(e,t="completed",s,r=Date.now(),n,a){const d=y(e),h=d===void 0?void 0:this.spans.take(d,n);if(!h){o.debug.log(`endSpan: no open span named ${String(e)}`);return}await h.ready,await this.emitTask(h,t,O(s),r,t==="failed"?y(a):void 0)}async emitTask(e,t,s,r,n){!e.keys||!e.viewId||!e.sessionId||e.sessionStart===void 0||await this.log("task.complete",{...e.attrs,...s,...e.keys,"task.name":e.name,"task.outcome":t,...n===void 0?{}:{"task.failure_reason":n},"span.duration_ms":Math.max(0,r-e.start)},{at:r,viewId:e.viewId,sessionId:e.sessionId,sessionStart:e.sessionStart})}async rotateSession(e){await this.views.endView(),await this.finalizeSession(e),await this.newSession(e)}setUserId(e){this.userId=e?e.slice(0,Le):void 0}getUserId(){return this.userId}async getDeviceId(){return this.deviceIdPromise??=(async()=>{const e=await this.store.get(k);if(e.status==="hit")return e.value;const t=this.platform?`_${this.platform}`:"",s=`device_${Date.now()}_${p(16)}${t}`,r=await this.store.set(k,s);return this.deviceIdEphemeral=e.status==="unavailable"||r.status==="unavailable",s})(),this.deviceIdPromise}setUserProfile(e){const t=Date.now(),s=!this.userProfile||e.userId&&e.userId!==this.userProfile.userId;this.userProfile={...this.userProfile,...e,updatedAt:t,...s&&{createdAt:t}},e.userId?(this.setUserId(e.userId),this.userProfile.userId=this.userId):this.userProfile&&!this.userProfile.userId&&(this.userProfile.userId=this.userId),o.debug.log("Telemetry: User profile updated",this.userProfile)}async identify(e){e.userId!==void 0&&this.setUserId(e.userId),this.setUserProfile({...e.name!==void 0?{fullName:e.name}:{},...e.email!==void 0?{email:e.email}:{},...e.phone!==void 0?{phone:e.phone}:{},...e.avatar!==void 0?{avatar:e.avatar}:{},...e.customAttributes!==void 0?{customAttributes:e.customAttributes}:{}}),await this.log("user.profile.update",Ee(this.userProfile))}setUserDetails(e){this.setUserProfile(e)}updateUserProfile(e){if(!this.userProfile){this.setUserProfile(e);return}this.userProfile={...this.userProfile,...e,updatedAt:Date.now()},o.debug.log("Telemetry: User profile updated",this.userProfile)}getUserProfile(){return this.userProfile}clearUserProfile(){this.userProfile=void 0,this.userId=void 0,o.debug.log("Telemetry: User profile cleared")}setUserName(e,t,s){this.setUserProfile({fullName:e,firstName:t,lastName:s})}setUserContact(e,t){this.setUserProfile({email:e,phone:t})}async log(e,t,s){if(!this.enabled)return;this.eventCount++;let r=!1,n=!1;const a=Be.has(e);if(a){const d=this.expiryReason(Date.now());d&&await this.rotateSession(d)}else if(!e.startsWith("session.")&&e!=="view"&&e!=="screen.load"&&!this.finalizing){const d=Date.now(),h=this.expiryReason(d);h&&await this.rotateSession(h),this.lastActivity=d,this.sessionEventCount++,I(e)&&this.errorCount++,r=!0}if(this.sampled){const d=Ke.has(e),h=d?e:"custom.event",c=await this.collectContext(t);d||(c["event.name"]=e),Je.has(h)&&Object.assign(c,this.trace.annotate()),(h==="app.crash"||h==="app.hang")&&(c["error.breadcrumbs"]=this.breadcrumbs.toJSON()),(h==="app.crash"||h==="app.error"||h==="app.hang")&&Object.assign(c,this.deviceState?.battery?.()),h==="app.crash"?n=!0:a||this.breadcrumbs.add({name:h,timestamp:new Date().toISOString()}),I(h)?this.views.countError():h==="ui.interaction"&&this.views.countAction(),s&&(c["view.id"]=s.viewId,c["view.name"]=this.views.nameOf(s.viewId),c["session.id"]=s.sessionId,c["session.start_time"]=new Date(s.sessionStart).toISOString()),this.enqueue({type:"event",eventName:h,timestamp:new Date(s?.at??Date.now()).toISOString(),attributes:c}),o.debug.log("Telemetry queued event:",e,"Queue size:",this.queue.length),o.debug.log("Event attributes:",c)}r&&await this.persistSession(),n?await this.flushCrash():this.queue.length>=this.batchSize&&this.flush()}reject(e,t){this.recordDrop("rejected",t),o.isDev()&&!H&&(H=!0,console.warn(`edge-telemetry: the collector rejected a batch with HTTP ${u(e)} — dropped, not retried. Check the apiKey and endpoint. (Shown once, in dev only.)`))}holdFor(e){const t=e?.resetAt;this.holdUntil=typeof t=="number"?t:Date.now()+$e}async flushCrash(){if(!this.enabled||!this.sender||this.queue.length===0)return;const e=r=>r.eventName==="app.crash";this.queue=[...this.queue.filter(e),...this.queue.filter(r=>!e(r))];const t=this.queue.filter(r=>g(r)>this.crashPersistedThrough);if(t.length>0&&this.sender.onFailure)try{this.recordDrop("store_full",await this.sender.onFailure(t)),this.crashPersistedThrough=Math.max(this.crashPersistedThrough,...t.map(g))}catch(r){o.debug.warn("Telemetry: crash-path persist failed:",r)}const s=this.queue.splice(0,this.batchSize);try{await this.sender.send(s),await this.ackBatch()}catch(r){if(o.debug.warn("Telemetry: crash-path send failed:",r),b(r)){this.reject(r,s.length);return}u(r)===429&&this.holdFor(r);const n=s.filter(a=>g(a)>this.crashPersistedThrough);n.length>0&&this.queue.unshift(...n)}}async collectContext(e){let t={},s={};try{t=await this.deviceInfoHandler?.collect()||{}}catch(a){o.debug.warn("Telemetry: failed to fetch device info",a)}try{s=await this.networkInfoHandler?.collect()||{}}catch(a){o.debug.warn("Telemetry: failed to fetch network info",a)}const r=await this.getDeviceId();return{...this.flattenWithPrefix("",t),...this.flattenWithPrefix("network",s),...this.flattenWithPrefix("",e||{}),...this.buildId?{"app.build_id":this.buildId}:{},"device.id":r,...this.deviceIdEphemeral?{"device.id_ephemeral":!0}:{},...this.userId?{"user.id":this.userId}:{},"view.id":this.views.id,"view.name":this.views.name,"session.id":this.sessionId,"session.start_time":new Date(this.sessionStart).toISOString(),"session.sequence":this.sessionSequence,"session.sample_rate":this.sampleRate,"sdk.events_dropped":this.eventsDropped,...this.dropReason?{"sdk.drop_reason":this.dropReason}:{},"sdk.hook_dropped":this.hookDropped,"sdk.hook_failed":this.hookFailed,"sdk.platform":Ce(this.platform),"sdk.version":this.sdkVersion}}async logMetric(e,t,s,r,n){if(!this.enabled)return;this.eventCount++;const a=this.expiryReason(Date.now());if(a&&await this.rotateSession(a),!this.sampled)return;const d=await this.collectContext(s),h=j[e]??r;h&&(d["metric.unit"]=h),n!==void 0&&(d["metric.name"]=n),this.enqueue({type:"metric",metricName:e,value:t,timestamp:new Date().toISOString(),attributes:d}),this.queue.length>=this.batchSize&&this.flush()}enqueue(e){if(!this.sampled||!this.enabled)return;let t=e;if(this.beforeSend){const s=Pe(e,this.beforeSend);if(s.kind==="failed"){this.hookFailed++;return}if(s.kind==="dropped"){this.hookDropped++;return}t=s.event}(t.attributes??={})["event.sequence"]=this.eventSequence++,this.queue.push(t),this.capQueue()}capQueue(){for(;this.queue.length>Fe;)this.queue.splice(w(this.queue),1),this.recordDrop("queue_full")}recordDrop(e,t=1){!t||t<=0||(this.eventsDropped+=t,this.dropReason=e)}flattenWithPrefix(e,t,s=0){const r={};for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const a=t[n],d=e?`${e}.${n}`:n;if(a!==void 0)if(typeof a=="object"&&a!==null&&!Array.isArray(a)&&s<je)Object.assign(r,this.flattenWithPrefix(d,a,s+1));else if(typeof a=="object"&&a!==null){const h=A(a);h!==void 0&&(r[d]=h)}else r[d]=a}return r}recordMetric(e,t,s,r){if(typeof e!="string"||e.trim()===""){o.debug.warn("recordMetric: blank name — dropped");return}if(Object.prototype.hasOwnProperty.call(j,e)){o.debug.warn(`recordMetric: ${e} is reserved by the SDK — dropped`);return}if(typeof t!="number"||!Number.isFinite(t)){o.debug.warn(`recordMetric: ${e} value is not finite — dropped`);return}const n=typeof r?.unit=="string"&&r.unit!==""?r.unit:void 0;return this.logMetric("custom.metric",t,s,n,e)}flush(){return this.draining??=this.drain().finally(()=>{this.draining=void 0})}async drain(){for(let e=0;e<Ve;e++){if(e>0&&this.queue.length>0&&await new Promise(s=>setTimeout(s,ze)),!this.sender||this.queue.length===0||Date.now()<this.holdUntil)return;const t=this.queue.splice(0,this.batchSize);try{await this.sender.send(t),await this.ackBatch()}catch(s){throw await this.onSendFailure(t,s),o.debug.error("Telemetry flush failed:",s),s}}}async onSendFailure(e,t){if(this.enabled){if(b(t)){this.reject(t,e.length);return}if(u(t)===429){this.queue.unshift(...e),this.holdFor(t);return}if(this.sender?.onFailure)try{this.recordDrop("store_full",await this.sender.onFailure(e))}catch(s){this.queue.unshift(...e),o.debug.warn("Sender.onFailure failed, requeued events:",s)}else this.queue.unshift(...e)}}async ackBatch(){this.sessionSequence++,await this.persistSession()}getQueue(){return[...this.queue]}async shutdown(){this.intervalId&&clearInterval(this.intervalId),this.memoryHandler?.stop?.(),this.webVitals?.stop(),this.hangs?.stop(),this.deviceState?.stop?.(),await this.flush()}getEventCount(){return this.eventCount}async recordRouteChange(e){await this.enterView(e,"route")}async enterView(e,t){await this.views.navigate(e,t)}}const Ye=Object.freeze(Object.defineProperty({__proto__:null,DEVICE_ID_KEY:k,SESSION_KEY:v,Telemetry:Xe,evictIndex:w,isErrorName:I},Symbol.toStringTag,{value:"Module"}));exports.DEFAULT_ENDPOINT=ie;exports.FAILED_EVENTS_KEY=K;exports.buildBatch=Y;exports.buildHeaders=Z;exports.decodeFailed=pe;exports.encodeFailed=ye;exports.guardedDrain=Se;exports.replayGroups=Q;exports.sendWithRetry=se;exports.telemetry=Ye;
|
|
2
|
+
//# sourceMappingURL=telemetry-CW63glwb.cjs.map
|