@safaricom-mxl/web-sdk 0.1.3 → 0.1.5
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/README.md +18 -14
- package/UPGRADING.md +23 -1
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.cjs +12 -1
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.cjs.map +1 -1
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.d.cts +2 -0
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.d.cts.map +1 -1
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.d.ts +2 -0
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.d.ts.map +1 -1
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.js +12 -1
- package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.js.map +1 -1
- package/dist/api-page/manager/types.d.cts +2 -1
- package/dist/api-page/manager/types.d.cts.map +1 -1
- package/dist/api-page/manager/types.d.ts +2 -1
- package/dist/api-page/manager/types.d.ts.map +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.cjs +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.cjs.map +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.d.cts +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.d.cts.map +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.d.ts +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.d.ts.map +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.js +1 -1
- package/dist/api-sessions/manager/NoOpUserSessionManager/NoOpUserSessionManager.js.map +1 -1
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.cjs +2 -2
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.cjs.map +1 -1
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.d.cts +1 -1
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.d.cts.map +1 -1
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.d.ts +1 -1
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.d.ts.map +1 -1
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.js +2 -2
- package/dist/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.js.map +1 -1
- package/dist/constants/attributes.cjs +12 -0
- package/dist/constants/attributes.cjs.map +1 -1
- package/dist/constants/attributes.d.cts +7 -1
- package/dist/constants/attributes.d.cts.map +1 -1
- package/dist/constants/attributes.d.ts +7 -1
- package/dist/constants/attributes.d.ts.map +1 -1
- package/dist/constants/attributes.js +7 -1
- package/dist/constants/attributes.js.map +1 -1
- package/dist/exporters/BaseFetchExporter/BaseFetchExporter.d.ts +1 -1
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.cjs +1 -2
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.cjs.map +1 -1
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.d.cts +3 -4
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.d.cts.map +1 -1
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.d.ts +1 -2
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.d.ts.map +1 -1
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.js +1 -2
- package/dist/instrumentations/InstrumentationAbstract/InstrumentationAbstract.js.map +1 -1
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.cjs +12 -2
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.cjs.map +1 -1
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.d.cts +5 -2
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.d.cts.map +1 -1
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.d.ts +5 -2
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.d.ts.map +1 -1
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.js +12 -2
- package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.js.map +1 -1
- package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.cjs +1 -2
- package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.js +1 -2
- package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.js.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.cjs +29 -33
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.d.cts +4 -2
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.d.ts +4 -2
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.js +29 -33
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.js.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.cjs +14 -12
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.cjs.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.d.cts +3 -2
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.d.cts.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.d.ts +3 -2
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.d.ts.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.js +14 -12
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/networkEvents.js.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/types.d.cts +1 -2
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/types.d.cts.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/types.d.ts +1 -2
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/types.d.ts.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/utils.cjs +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/utils.cjs.map +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/utils.js +1 -1
- package/dist/instrumentations/document-load/DocumentLoadInstrumentation/utils.js.map +1 -1
- package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.cjs +3 -5
- package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.js +3 -5
- package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.js.map +1 -1
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.cjs +7 -3
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.d.cts +1 -0
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.d.ts +1 -0
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.js +7 -3
- package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.js.map +1 -1
- package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.cjs +2 -3
- package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.js +2 -3
- package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.js.map +1 -1
- package/dist/instrumentations/first-interaction/FirstInteractionInstrumentation/FirstInteractionInstrumentation.cjs +4 -5
- package/dist/instrumentations/first-interaction/FirstInteractionInstrumentation/FirstInteractionInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/first-interaction/FirstInteractionInstrumentation/FirstInteractionInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/first-interaction/FirstInteractionInstrumentation/FirstInteractionInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/first-interaction/FirstInteractionInstrumentation/FirstInteractionInstrumentation.js +3 -4
- package/dist/instrumentations/first-interaction/FirstInteractionInstrumentation/FirstInteractionInstrumentation.js.map +1 -1
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.cjs +172 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.cjs.map +1 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.d.cts +38 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.d.cts.map +1 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.d.ts +38 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.d.ts.map +1 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.js +170 -0
- package/dist/instrumentations/js-profiler/JsProfilerInstrumentation.js.map +1 -0
- package/dist/instrumentations/js-profiler/constants.cjs +21 -0
- package/dist/instrumentations/js-profiler/constants.cjs.map +1 -0
- package/dist/instrumentations/js-profiler/constants.d.cts +13 -0
- package/dist/instrumentations/js-profiler/constants.d.cts.map +1 -0
- package/dist/instrumentations/js-profiler/constants.d.ts +13 -0
- package/dist/instrumentations/js-profiler/constants.d.ts.map +1 -0
- package/dist/instrumentations/js-profiler/constants.js +13 -0
- package/dist/instrumentations/js-profiler/constants.js.map +1 -0
- package/dist/instrumentations/js-profiler/fixture.cjs +54 -0
- package/dist/instrumentations/js-profiler/fixture.cjs.map +1 -0
- package/dist/instrumentations/js-profiler/fixture.d.cts +7 -0
- package/dist/instrumentations/js-profiler/fixture.d.cts.map +1 -0
- package/dist/instrumentations/js-profiler/fixture.d.ts +7 -0
- package/dist/instrumentations/js-profiler/fixture.d.ts.map +1 -0
- package/dist/instrumentations/js-profiler/fixture.js +53 -0
- package/dist/instrumentations/js-profiler/fixture.js.map +1 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.cjs +63 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.cjs.map +1 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.d.cts +7 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.d.cts.map +1 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.d.ts +7 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.d.ts.map +1 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.js +62 -0
- package/dist/instrumentations/js-profiler/reduceProfilerTrace.js.map +1 -0
- package/dist/instrumentations/js-profiler/types.cjs +0 -0
- package/dist/instrumentations/js-profiler/types.d.cts +51 -0
- package/dist/instrumentations/js-profiler/types.d.cts.map +1 -0
- package/dist/instrumentations/js-profiler/types.d.ts +51 -0
- package/dist/instrumentations/js-profiler/types.d.ts.map +1 -0
- package/dist/instrumentations/js-profiler/types.js +0 -0
- package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.cjs +3 -5
- package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.js +1 -3
- package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.js.map +1 -1
- package/dist/instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/MaxScrollDepthInstrumentation.cjs +2 -3
- package/dist/instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/MaxScrollDepthInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/MaxScrollDepthInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/MaxScrollDepthInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/MaxScrollDepthInstrumentation.js +1 -2
- package/dist/instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/MaxScrollDepthInstrumentation.js.map +1 -1
- package/dist/instrumentations/memory/MemoryInstrumentation.cjs +216 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.cjs.map +1 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.d.cts +55 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.d.cts.map +1 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.d.ts +55 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.d.ts.map +1 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.js +215 -0
- package/dist/instrumentations/memory/MemoryInstrumentation.js.map +1 -0
- package/dist/instrumentations/memory/browserFamily.cjs +13 -0
- package/dist/instrumentations/memory/browserFamily.cjs.map +1 -0
- package/dist/instrumentations/memory/browserFamily.d.cts +5 -0
- package/dist/instrumentations/memory/browserFamily.d.cts.map +1 -0
- package/dist/instrumentations/memory/browserFamily.d.ts +5 -0
- package/dist/instrumentations/memory/browserFamily.d.ts.map +1 -0
- package/dist/instrumentations/memory/browserFamily.js +12 -0
- package/dist/instrumentations/memory/browserFamily.js.map +1 -0
- package/dist/instrumentations/memory/constants.cjs +25 -0
- package/dist/instrumentations/memory/constants.cjs.map +1 -0
- package/dist/instrumentations/memory/constants.d.cts +13 -0
- package/dist/instrumentations/memory/constants.d.cts.map +1 -0
- package/dist/instrumentations/memory/constants.d.ts +13 -0
- package/dist/instrumentations/memory/constants.d.ts.map +1 -0
- package/dist/instrumentations/memory/constants.js +22 -0
- package/dist/instrumentations/memory/constants.js.map +1 -0
- package/dist/instrumentations/memory/resource.cjs +30 -0
- package/dist/instrumentations/memory/resource.cjs.map +1 -0
- package/dist/instrumentations/memory/resource.d.cts +16 -0
- package/dist/instrumentations/memory/resource.d.cts.map +1 -0
- package/dist/instrumentations/memory/resource.d.ts +16 -0
- package/dist/instrumentations/memory/resource.d.ts.map +1 -0
- package/dist/instrumentations/memory/resource.js +27 -0
- package/dist/instrumentations/memory/resource.js.map +1 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.cjs +27 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.cjs.map +1 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.d.cts +7 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.d.cts.map +1 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.d.ts +7 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.d.ts.map +1 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.js +25 -0
- package/dist/instrumentations/memory/startMemoryMeterProvider.js.map +1 -0
- package/dist/instrumentations/memory/types.cjs +0 -0
- package/dist/instrumentations/memory/types.d.cts +47 -0
- package/dist/instrumentations/memory/types.d.cts.map +1 -0
- package/dist/instrumentations/memory/types.d.ts +47 -0
- package/dist/instrumentations/memory/types.d.ts.map +1 -0
- package/dist/instrumentations/memory/types.js +0 -0
- package/dist/instrumentations/memory/visibility.cjs +25 -0
- package/dist/instrumentations/memory/visibility.cjs.map +1 -0
- package/dist/instrumentations/memory/visibility.d.cts +14 -0
- package/dist/instrumentations/memory/visibility.d.cts.map +1 -0
- package/dist/instrumentations/memory/visibility.d.ts +14 -0
- package/dist/instrumentations/memory/visibility.d.ts.map +1 -0
- package/dist/instrumentations/memory/visibility.js +24 -0
- package/dist/instrumentations/memory/visibility.js.map +1 -0
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.cjs +62 -55
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.d.cts +16 -5
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.d.ts +16 -5
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.js +62 -55
- package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.js.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.cjs +3 -3
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.cjs.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.d.cts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.d.ts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.js +3 -3
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.js.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.cjs +10 -13
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.cjs.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.d.cts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.d.ts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.js +10 -13
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.js.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.cjs +8 -4
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.cjs.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.d.cts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.d.ts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.js +8 -4
- package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.js.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/types.d.cts +2 -0
- package/dist/instrumentations/navigation/NavigationInstrumentation/types.d.cts.map +1 -1
- package/dist/instrumentations/navigation/NavigationInstrumentation/types.d.ts +2 -0
- package/dist/instrumentations/navigation/NavigationInstrumentation/types.d.ts.map +1 -1
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.cjs +14 -13
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.d.cts +1 -0
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.d.ts +1 -0
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.js +13 -12
- package/dist/instrumentations/rage-click/RageClickInstrumentation/RageClickInstrumentation.js.map +1 -1
- package/dist/instrumentations/replay/ReplayInstrumentation/ReplayInstrumentation.cjs +0 -2
- package/dist/instrumentations/replay/ReplayInstrumentation/ReplayInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/replay/ReplayInstrumentation/ReplayInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/replay/ReplayInstrumentation/ReplayInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/replay/ReplayInstrumentation/ReplayInstrumentation.js +0 -2
- package/dist/instrumentations/replay/ReplayInstrumentation/ReplayInstrumentation.js.map +1 -1
- package/dist/instrumentations/replay/ReplayInstrumentation/types.d.cts +1 -1
- package/dist/instrumentations/replay/ReplayInstrumentation/types.d.ts +1 -1
- package/dist/instrumentations/replay/events/capture/network.cjs +31 -22
- package/dist/instrumentations/replay/events/capture/network.cjs.map +1 -1
- package/dist/instrumentations/replay/events/capture/network.js +31 -22
- package/dist/instrumentations/replay/events/capture/network.js.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.esm.cjs +2 -2
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.esm.cjs.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.esm.d.cts.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.esm.d.ts.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.esm.js +2 -2
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.esm.js.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.iife.cjs +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.iife.cjs.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.iife.js +1 -1
- package/dist/instrumentations/replay/rrwebLoader/loadRrwebModule.iife.js.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/types.d.cts +4 -2
- package/dist/instrumentations/replay/rrwebLoader/types.d.cts.map +1 -1
- package/dist/instrumentations/replay/rrwebLoader/types.d.ts +4 -2
- package/dist/instrumentations/replay/rrwebLoader/types.d.ts.map +1 -1
- package/dist/instrumentations/replay/transport/idleFlushTimer.cjs.map +1 -1
- package/dist/instrumentations/replay/transport/idleFlushTimer.d.cts.map +1 -1
- package/dist/instrumentations/replay/transport/idleFlushTimer.d.ts.map +1 -1
- package/dist/instrumentations/replay/transport/idleFlushTimer.js.map +1 -1
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.cjs +4 -18
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.d.cts +0 -2
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.d.ts +0 -2
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.js +3 -17
- package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.js.map +1 -1
- package/dist/instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/SoftNavigationPerformanceInstrumentation.cjs +8 -11
- package/dist/instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/SoftNavigationPerformanceInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/SoftNavigationPerformanceInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/SoftNavigationPerformanceInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/SoftNavigationPerformanceInstrumentation.js +8 -11
- package/dist/instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/SoftNavigationPerformanceInstrumentation.js.map +1 -1
- package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.cjs +7 -10
- package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.js +6 -9
- package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.js.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.cjs +24 -16
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.cjs.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.cts +3 -2
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.cts.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts +3 -2
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.js +24 -16
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.js.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.cjs +11 -63
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.cjs.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.d.cts +4 -56
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.d.cts.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.d.ts +4 -56
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.d.ts.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.js +11 -62
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/constants.js.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/types.d.cts +1 -2
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/types.d.cts.map +1 -1
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/types.d.ts +1 -2
- package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/types.d.ts.map +1 -1
- package/dist/managers/MXLAnalyticsManager/MXLAnalyticsManager.cjs +5 -5
- package/dist/managers/MXLAnalyticsManager/MXLAnalyticsManager.cjs.map +1 -1
- package/dist/managers/MXLAnalyticsManager/MXLAnalyticsManager.d.cts.map +1 -1
- package/dist/managers/MXLAnalyticsManager/MXLAnalyticsManager.d.ts.map +1 -1
- package/dist/managers/MXLAnalyticsManager/MXLAnalyticsManager.js +4 -4
- package/dist/managers/MXLAnalyticsManager/MXLAnalyticsManager.js.map +1 -1
- package/dist/managers/MXLAnalyticsManager/types.d.cts +1 -2
- package/dist/managers/MXLAnalyticsManager/types.d.cts.map +1 -1
- package/dist/managers/MXLAnalyticsManager/types.d.ts +1 -2
- package/dist/managers/MXLAnalyticsManager/types.d.ts.map +1 -1
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.cjs +14 -0
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.cjs.map +1 -1
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.d.cts +4 -1
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.d.cts.map +1 -1
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.d.ts +4 -1
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.d.ts.map +1 -1
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.js +14 -0
- package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.js.map +1 -1
- package/dist/managers/MXLConfigManager/performanceDefaults.cjs +21 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.cjs.map +1 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.d.cts +12 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.d.cts.map +1 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.d.ts +12 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.d.ts.map +1 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.js +13 -0
- package/dist/managers/MXLConfigManager/performanceDefaults.js.map +1 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.cjs +29 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.cjs.map +1 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.d.cts +40 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.d.cts.map +1 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.d.ts +40 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.d.ts.map +1 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.js +27 -0
- package/dist/managers/MXLConfigManager/resolveEffectivePerformance.js.map +1 -0
- package/dist/managers/MXLConfigManager/types.d.cts +18 -1
- package/dist/managers/MXLConfigManager/types.d.cts.map +1 -1
- package/dist/managers/MXLConfigManager/types.d.ts +18 -1
- package/dist/managers/MXLConfigManager/types.d.ts.map +1 -1
- package/dist/managers/MXLConfigManager/utils.cjs +37 -0
- package/dist/managers/MXLConfigManager/utils.cjs.map +1 -1
- package/dist/managers/MXLConfigManager/utils.d.cts.map +1 -1
- package/dist/managers/MXLConfigManager/utils.d.ts.map +1 -1
- package/dist/managers/MXLConfigManager/utils.js +37 -0
- package/dist/managers/MXLConfigManager/utils.js.map +1 -1
- package/dist/managers/MXLLogManager/MXLLogManager.cjs +7 -8
- package/dist/managers/MXLLogManager/MXLLogManager.cjs.map +1 -1
- package/dist/managers/MXLLogManager/MXLLogManager.js +3 -4
- package/dist/managers/MXLLogManager/MXLLogManager.js.map +1 -1
- package/dist/managers/MXLLogManager/MXLLoggerProvider.cjs +46 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.cjs.map +1 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.d.cts +22 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.d.cts.map +1 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.d.ts +22 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.d.ts.map +1 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.js +44 -0
- package/dist/managers/MXLLogManager/MXLLoggerProvider.js.map +1 -0
- package/dist/managers/MXLLogManager/types.d.cts +9 -3
- package/dist/managers/MXLLogManager/types.d.cts.map +1 -1
- package/dist/managers/MXLLogManager/types.d.ts +9 -3
- package/dist/managers/MXLLogManager/types.d.ts.map +1 -1
- package/dist/managers/MXLPageManager/MXLPageManager.cjs +6 -5
- package/dist/managers/MXLPageManager/MXLPageManager.cjs.map +1 -1
- package/dist/managers/MXLPageManager/MXLPageManager.d.cts.map +1 -1
- package/dist/managers/MXLPageManager/MXLPageManager.d.ts.map +1 -1
- package/dist/managers/MXLPageManager/MXLPageManager.js +7 -6
- package/dist/managers/MXLPageManager/MXLPageManager.js.map +1 -1
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.cjs +56 -9
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.cjs.map +1 -1
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.d.cts +21 -5
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.d.cts.map +1 -1
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.d.ts +21 -5
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.d.ts.map +1 -1
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.js +56 -10
- package/dist/managers/MXLTraceManager/MXLExtendedSpan.js.map +1 -1
- package/dist/managers/MXLTraceManager/MXLTraceManager.cjs +2 -2
- package/dist/managers/MXLTraceManager/MXLTraceManager.cjs.map +1 -1
- package/dist/managers/MXLTraceManager/MXLTraceManager.js +2 -2
- package/dist/managers/MXLTraceManager/MXLTraceManager.js.map +1 -1
- package/dist/managers/MXLTraceManager/MXLTracerProvider.cjs +42 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.cjs.map +1 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.d.cts +22 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.d.cts.map +1 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.d.ts +22 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.d.ts.map +1 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.js +40 -0
- package/dist/managers/MXLTraceManager/MXLTracerProvider.js.map +1 -0
- package/dist/managers/MXLTraceManager/types.cjs +0 -0
- package/dist/managers/MXLTraceManager/types.d.cts +10 -0
- package/dist/managers/MXLTraceManager/types.d.cts.map +1 -0
- package/dist/managers/MXLTraceManager/types.d.ts +10 -0
- package/dist/managers/MXLTraceManager/types.d.ts.map +1 -0
- package/dist/managers/MXLTraceManager/types.js +0 -0
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.cjs +30 -20
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.cjs.map +1 -1
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.d.cts +3 -3
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.d.cts.map +1 -1
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.d.ts +3 -3
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.d.ts.map +1 -1
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.js +31 -21
- package/dist/managers/MXLUserSessionManager/MXLUserSessionManager.js.map +1 -1
- package/dist/managers/MXLUserSessionManager/types.d.cts +10 -2
- package/dist/managers/MXLUserSessionManager/types.d.cts.map +1 -1
- package/dist/managers/MXLUserSessionManager/types.d.ts +10 -2
- package/dist/managers/MXLUserSessionManager/types.d.ts.map +1 -1
- package/dist/mxl-web-sdk.js +12 -2
- package/dist/mxl-web-sdk.js.map +1 -1
- package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.cjs.map +1 -1
- package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.d.cts +2 -2
- package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.d.cts.map +1 -1
- package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.d.ts +2 -2
- package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.d.ts.map +1 -1
- package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.js.map +1 -1
- package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.cjs.map +1 -1
- package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.d.cts +2 -2
- package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.d.cts.map +1 -1
- package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.d.ts +2 -2
- package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.d.ts.map +1 -1
- package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.js.map +1 -1
- package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.cjs.map +1 -1
- package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.d.cts +2 -2
- package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.d.cts.map +1 -1
- package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.d.ts +2 -2
- package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.d.ts.map +1 -1
- package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.js.map +1 -1
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.cjs +1 -1
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.cjs.map +1 -1
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.d.cts +2 -2
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.d.cts.map +1 -1
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.d.ts +2 -2
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.d.ts.map +1 -1
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.js +1 -1
- package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.js.map +1 -1
- package/dist/processors/PageSpanProcessor/PageSpanProcessor.cjs +1 -1
- package/dist/processors/PageSpanProcessor/PageSpanProcessor.cjs.map +1 -1
- package/dist/processors/PageSpanProcessor/PageSpanProcessor.d.cts.map +1 -1
- package/dist/processors/PageSpanProcessor/PageSpanProcessor.d.ts.map +1 -1
- package/dist/processors/PageSpanProcessor/PageSpanProcessor.js +1 -1
- package/dist/processors/PageSpanProcessor/PageSpanProcessor.js.map +1 -1
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.cjs +26 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.cjs.map +1 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.d.cts +20 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.d.cts.map +1 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.d.ts +20 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.d.ts.map +1 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.js +25 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/PerfClockLagLogRecordProcessor.js.map +1 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/types.cjs +0 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/types.d.cts +9 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/types.d.cts.map +1 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/types.d.ts +9 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/types.d.ts.map +1 -0
- package/dist/processors/PerfClockLagLogRecordProcessor/types.js +0 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.cjs +27 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.cjs.map +1 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.d.cts +21 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.d.cts.map +1 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.d.ts +21 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.d.ts.map +1 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.js +26 -0
- package/dist/processors/PerfClockLagSpanProcessor/PerfClockLagSpanProcessor.js.map +1 -0
- package/dist/processors/PerfClockLagSpanProcessor/types.cjs +0 -0
- package/dist/processors/PerfClockLagSpanProcessor/types.d.cts +9 -0
- package/dist/processors/PerfClockLagSpanProcessor/types.d.cts.map +1 -0
- package/dist/processors/PerfClockLagSpanProcessor/types.d.ts +9 -0
- package/dist/processors/PerfClockLagSpanProcessor/types.d.ts.map +1 -0
- package/dist/processors/PerfClockLagSpanProcessor/types.js +0 -0
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.cjs +1 -1
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.cjs.map +1 -1
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.d.cts +2 -2
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.d.cts.map +1 -1
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.d.ts +2 -2
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.d.ts.map +1 -1
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.js +1 -1
- package/dist/processors/SignalCorrelationLogRecordProcessor/SignalCorrelationLogRecordProcessor.js.map +1 -1
- package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.cjs.map +1 -1
- package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.d.cts +2 -2
- package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.d.cts.map +1 -1
- package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.d.ts +2 -2
- package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.d.ts.map +1 -1
- package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.js.map +1 -1
- package/dist/processors/UserSessionLogRecordProcessor/UserSessionLogRecordProcessor.cjs.map +1 -1
- package/dist/processors/UserSessionLogRecordProcessor/UserSessionLogRecordProcessor.d.cts +2 -2
- package/dist/processors/UserSessionLogRecordProcessor/UserSessionLogRecordProcessor.d.cts.map +1 -1
- package/dist/processors/UserSessionLogRecordProcessor/UserSessionLogRecordProcessor.d.ts +2 -2
- package/dist/processors/UserSessionLogRecordProcessor/UserSessionLogRecordProcessor.d.ts.map +1 -1
- package/dist/processors/UserSessionLogRecordProcessor/UserSessionLogRecordProcessor.js.map +1 -1
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.cjs +30 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.cjs.map +1 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.d.cts +22 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.d.cts.map +1 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.d.ts +22 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.d.ts.map +1 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.js +29 -0
- package/dist/processors/UserSessionSpanProcessor/UserSessionSpanProcessor.js.map +1 -0
- package/dist/processors/UserSessionSpanProcessor/types.cjs +0 -0
- package/dist/processors/UserSessionSpanProcessor/types.d.cts +9 -0
- package/dist/processors/UserSessionSpanProcessor/types.d.cts.map +1 -0
- package/dist/processors/UserSessionSpanProcessor/types.d.ts +9 -0
- package/dist/processors/UserSessionSpanProcessor/types.d.ts.map +1 -0
- package/dist/processors/UserSessionSpanProcessor/types.js +0 -0
- package/dist/resources/sdkConstants.cjs +1 -1
- package/dist/resources/sdkConstants.cjs.map +1 -1
- package/dist/resources/sdkConstants.d.cts +1 -1
- package/dist/resources/sdkConstants.d.ts +1 -1
- package/dist/resources/sdkConstants.js +1 -1
- package/dist/resources/sdkConstants.js.map +1 -1
- package/dist/sdk/endpoints.cjs +2 -2
- package/dist/sdk/endpoints.cjs.map +1 -1
- package/dist/sdk/endpoints.d.cts +1 -1
- package/dist/sdk/endpoints.d.ts +1 -1
- package/dist/sdk/endpoints.js +2 -2
- package/dist/sdk/endpoints.js.map +1 -1
- package/dist/sdk/initSDK.cjs +43 -12
- package/dist/sdk/initSDK.cjs.map +1 -1
- package/dist/sdk/initSDK.js +46 -15
- package/dist/sdk/initSDK.js.map +1 -1
- package/dist/sdk/networkInstrumentations.cjs +1 -1
- package/dist/sdk/networkInstrumentations.cjs.map +1 -1
- package/dist/sdk/networkInstrumentations.d.cts.map +1 -1
- package/dist/sdk/networkInstrumentations.d.ts.map +1 -1
- package/dist/sdk/networkInstrumentations.js +1 -1
- package/dist/sdk/networkInstrumentations.js.map +1 -1
- package/dist/sdk/resolveInitConfig.cjs +2 -1
- package/dist/sdk/resolveInitConfig.cjs.map +1 -1
- package/dist/sdk/resolveInitConfig.d.cts +4 -0
- package/dist/sdk/resolveInitConfig.d.cts.map +1 -1
- package/dist/sdk/resolveInitConfig.d.ts +4 -0
- package/dist/sdk/resolveInitConfig.d.ts.map +1 -1
- package/dist/sdk/resolveInitConfig.js +2 -1
- package/dist/sdk/resolveInitConfig.js.map +1 -1
- package/dist/sdk/setupDefaultInstrumentations.cjs +17 -1
- package/dist/sdk/setupDefaultInstrumentations.cjs.map +1 -1
- package/dist/sdk/setupDefaultInstrumentations.d.cts +2 -1
- package/dist/sdk/setupDefaultInstrumentations.d.cts.map +1 -1
- package/dist/sdk/setupDefaultInstrumentations.d.ts +2 -1
- package/dist/sdk/setupDefaultInstrumentations.d.ts.map +1 -1
- package/dist/sdk/setupDefaultInstrumentations.js +17 -1
- package/dist/sdk/setupDefaultInstrumentations.js.map +1 -1
- package/dist/sdk/types.d.cts +43 -2
- package/dist/sdk/types.d.cts.map +1 -1
- package/dist/sdk/types.d.ts +43 -2
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/transport/RetryingTransport/RetryingTransport.cjs +2 -2
- package/dist/transport/RetryingTransport/RetryingTransport.cjs.map +1 -1
- package/dist/transport/RetryingTransport/RetryingTransport.js +2 -2
- package/dist/transport/RetryingTransport/RetryingTransport.js.map +1 -1
- package/dist/utils/InMemoryStorage/InMemoryStorage.cjs +27 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.cjs.map +1 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.d.cts +13 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.d.cts.map +1 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.d.ts +13 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.d.ts.map +1 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.js +26 -0
- package/dist/utils/InMemoryStorage/InMemoryStorage.js.map +1 -0
- package/dist/utils/PerformanceManager/OTelPerformanceManager.cjs +71 -24
- package/dist/utils/PerformanceManager/OTelPerformanceManager.cjs.map +1 -1
- package/dist/utils/PerformanceManager/OTelPerformanceManager.d.cts +18 -19
- package/dist/utils/PerformanceManager/OTelPerformanceManager.d.cts.map +1 -1
- package/dist/utils/PerformanceManager/OTelPerformanceManager.d.ts +18 -19
- package/dist/utils/PerformanceManager/OTelPerformanceManager.d.ts.map +1 -1
- package/dist/utils/PerformanceManager/OTelPerformanceManager.js +70 -22
- package/dist/utils/PerformanceManager/OTelPerformanceManager.js.map +1 -1
- package/dist/utils/PerformanceManager/types.d.cts +28 -12
- package/dist/utils/PerformanceManager/types.d.cts.map +1 -1
- package/dist/utils/PerformanceManager/types.d.ts +28 -12
- package/dist/utils/PerformanceManager/types.d.ts.map +1 -1
- package/dist/utils/getWindowStorageOrInMemory.cjs +24 -0
- package/dist/utils/getWindowStorageOrInMemory.cjs.map +1 -0
- package/dist/utils/getWindowStorageOrInMemory.d.cts +13 -0
- package/dist/utils/getWindowStorageOrInMemory.d.cts.map +1 -0
- package/dist/utils/getWindowStorageOrInMemory.d.ts +13 -0
- package/dist/utils/getWindowStorageOrInMemory.d.ts.map +1 -0
- package/dist/utils/getWindowStorageOrInMemory.js +23 -0
- package/dist/utils/getWindowStorageOrInMemory.js.map +1 -0
- package/dist/utils/sdkLoadOriginOffset.cjs +12 -0
- package/dist/utils/sdkLoadOriginOffset.cjs.map +1 -0
- package/dist/utils/sdkLoadOriginOffset.d.cts +10 -0
- package/dist/utils/sdkLoadOriginOffset.d.cts.map +1 -0
- package/dist/utils/sdkLoadOriginOffset.d.ts +10 -0
- package/dist/utils/sdkLoadOriginOffset.d.ts.map +1 -0
- package/dist/utils/sdkLoadOriginOffset.js +11 -0
- package/dist/utils/sdkLoadOriginOffset.js.map +1 -0
- package/package.json +20 -22
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.cjs
CHANGED
|
@@ -8,9 +8,9 @@ const require_utils_getBfcacheNotRestoredReasons = require("../../../utils/getBf
|
|
|
8
8
|
const require_utils_getSelector = require("../../../utils/getSelector.cjs");
|
|
9
9
|
const require_instrumentations_web_vitals_WebVitalsInstrumentation_attributes = require("./attributes.cjs");
|
|
10
10
|
const require_instrumentations_web_vitals_WebVitalsInstrumentation_constants = require("./constants.cjs");
|
|
11
|
-
let
|
|
12
|
-
let _opentelemetry_api_logs = require("@opentelemetry/api-logs");
|
|
11
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
13
12
|
let _opentelemetry_instrumentation = require("@opentelemetry/instrumentation");
|
|
13
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
14
14
|
//#region src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts
|
|
15
15
|
const roundClamp = (value) => Math.round(Math.max(0, value));
|
|
16
16
|
const roundRect = (rect) => ({
|
|
@@ -143,7 +143,7 @@ var WebVitalsInstrumentation = class extends require_instrumentations_MXLInstrum
|
|
|
143
143
|
_clsMetricId = void 0;
|
|
144
144
|
_applyCustomLogRecordData;
|
|
145
145
|
_listenersRegistered = false;
|
|
146
|
-
constructor({ diag, perf, listeners
|
|
146
|
+
constructor({ diag, perf, listeners, urlDocument, urlAttribution = true, includeRawAttribution = true, reportSoftNavs = true, pageManager, applyCustomLogRecordData, ...config } = {}) {
|
|
147
147
|
super({
|
|
148
148
|
config,
|
|
149
149
|
diag,
|
|
@@ -151,19 +151,16 @@ var WebVitalsInstrumentation = class extends require_instrumentations_MXLInstrum
|
|
|
151
151
|
instrumentationVersion: "1.0.0",
|
|
152
152
|
perf
|
|
153
153
|
});
|
|
154
|
-
this._listeners = listeners;
|
|
154
|
+
this._listeners = listeners ?? {};
|
|
155
155
|
this._urlDocument = urlDocument ?? window.document;
|
|
156
156
|
this._urlAttribution = urlAttribution;
|
|
157
157
|
this._includeRawAttribution = includeRawAttribution;
|
|
158
158
|
this._softNavsActive = reportSoftNavs && require_utils_performanceObserver_performanceObserver.isEntryTypeSupported("soft-navigation");
|
|
159
159
|
this._pageManager = pageManager ?? require_api_page_pageAPI.page.getPageManager();
|
|
160
160
|
this._applyCustomLogRecordData = applyCustomLogRecordData;
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
enable() {
|
|
164
|
-
if (typeof PerformanceObserver !== "undefined") super.enable();
|
|
165
|
-
else this._diag.debug("PerformanceObserver not supported, web vitals will not be collected");
|
|
161
|
+
this._listenersProvided = listeners !== void 0;
|
|
166
162
|
}
|
|
163
|
+
_listenersProvided;
|
|
167
164
|
onDisable() {
|
|
168
165
|
this._diag.debug("WebVitalsInstrumentation disabled, pausing emission");
|
|
169
166
|
}
|
|
@@ -173,6 +170,17 @@ var WebVitalsInstrumentation = class extends require_instrumentations_MXLInstrum
|
|
|
173
170
|
return;
|
|
174
171
|
}
|
|
175
172
|
this._listenersRegistered = true;
|
|
173
|
+
if (this._listenersProvided) {
|
|
174
|
+
this._registerListeners();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
require_instrumentations_web_vitals_WebVitalsInstrumentation_constants.loadWebVitalListeners().then((listeners) => {
|
|
178
|
+
if (!this._isEnabled) return;
|
|
179
|
+
this._listeners = listeners;
|
|
180
|
+
this._registerListeners();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
_registerListeners() {
|
|
176
184
|
require_instrumentations_web_vitals_WebVitalsInstrumentation_constants.ALL_WEB_VITALS.forEach((name) => {
|
|
177
185
|
const reportSoftNavs = name !== "TTFB" && this._softNavsActive;
|
|
178
186
|
if (this._urlAttribution) this._listeners[name]?.((metric) => {
|
|
@@ -208,15 +216,15 @@ var WebVitalsInstrumentation = class extends require_instrumentations_MXLInstrum
|
|
|
208
216
|
};
|
|
209
217
|
}
|
|
210
218
|
_getTimeForMetric(metric) {
|
|
211
|
-
if (metric.name === "INP" && metric.attribution.interactionTime !== void 0) return this.perf.
|
|
219
|
+
if (metric.name === "INP" && metric.attribution.interactionTime !== void 0) return this.perf.offsetToAbsoluteTime(metric.attribution.interactionTime);
|
|
212
220
|
if (metric.name === "CLS") {
|
|
213
221
|
const windowStart = metric.entries.length > 0 ? Math.min(...metric.entries.map((entry) => entry.startTime)) : metric.attribution.largestShiftTime;
|
|
214
|
-
if (windowStart !== void 0) return this.perf.
|
|
222
|
+
if (windowStart !== void 0) return this.perf.offsetToAbsoluteTime(windowStart);
|
|
215
223
|
}
|
|
216
224
|
if (metric.name === "TTFB") return this.perf.getZeroTime();
|
|
217
225
|
const metricStartTime = metric.entries[metric.entries.length - 1]?.startTime;
|
|
218
|
-
if (metricStartTime !== void 0) return this.perf.
|
|
219
|
-
return this.perf.
|
|
226
|
+
if (metricStartTime !== void 0) return this.perf.offsetToAbsoluteTime(metricStartTime);
|
|
227
|
+
return this.perf.getNow();
|
|
220
228
|
}
|
|
221
229
|
_emitWebVital(metric) {
|
|
222
230
|
const attributedPage = this._attributedPage[metric.name];
|
|
@@ -232,7 +240,7 @@ var WebVitalsInstrumentation = class extends require_instrumentations_MXLInstrum
|
|
|
232
240
|
[require_instrumentations_web_vitals_WebVitalsInstrumentation_attributes.KEY_BROWSER_WEB_VITAL_RATING]: metric.rating,
|
|
233
241
|
[require_instrumentations_web_vitals_WebVitalsInstrumentation_attributes.KEY_BROWSER_WEB_VITAL_ID]: metric.id,
|
|
234
242
|
[require_instrumentations_web_vitals_WebVitalsInstrumentation_attributes.KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE]: metric.navigationType,
|
|
235
|
-
|
|
243
|
+
[require_instrumentations_web_vitals_WebVitalsInstrumentation_attributes.KEY_BROWSER_WEB_VITAL_NAVIGATION_ID]: metric.navigationId,
|
|
236
244
|
...metric.navigationInteractionId !== void 0 ? { [require_instrumentations_web_vitals_WebVitalsInstrumentation_attributes.KEY_BROWSER_WEB_VITAL_INTERACTION_ID]: metric.navigationInteractionId } : {},
|
|
237
245
|
...sessionPartId !== null ? { [require_constants_attributes.KEY_MXL_SESSION_PART_ID]: sessionPartId } : {},
|
|
238
246
|
...notRestoredReasons?.length ? { [require_constants_attributes.KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS]: notRestoredReasons } : {},
|
|
@@ -248,9 +256,9 @@ var WebVitalsInstrumentation = class extends require_instrumentations_MXLInstrum
|
|
|
248
256
|
...metric.name === "CLS" ? clsLayoutShiftsAttribution(metric, this._diag) : {},
|
|
249
257
|
...metric.name === "LCP" ? lcpElementAttribution(metric, this._diag) : {}
|
|
250
258
|
},
|
|
251
|
-
body: this._includeRawAttribution
|
|
259
|
+
body: this._includeRawAttribution ? JSON.stringify(Object.fromEntries(Object.entries(metric.attribution).filter(([, v]) => isPrimitiveValue(v)))) : void 0,
|
|
252
260
|
eventName: require_instrumentations_web_vitals_WebVitalsInstrumentation_constants.WEB_VITAL_EVENT_NAME,
|
|
253
|
-
severityNumber:
|
|
261
|
+
severityNumber: _opentelemetry_api.SeverityNumber.INFO,
|
|
254
262
|
timestamp: (0, _opentelemetry_core.millisToHrTime)(metricTimeMillis)
|
|
255
263
|
};
|
|
256
264
|
if (this._applyCustomLogRecordData) (0, _opentelemetry_instrumentation.safeExecuteInTheMiddle)(() => this._applyCustomLogRecordData?.(logRecord), (error) => {
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebVitalsInstrumentation.cjs","names":["MAX_LOAF_SCRIPT_URL_LENGTH","KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX","getSelector","MXLInstrumentationBase","WEB_VITALS_ID_TO_LISTENER","isEntryTypeSupported","page","getBfcacheNotRestoredReasons","KEY_MXL_TYPE","KEY_BROWSER_WEB_VITAL_NAME","KEY_BROWSER_WEB_VITAL_VALUE","KEY_BROWSER_WEB_VITAL_DELTA","KEY_BROWSER_WEB_VITAL_RATING","KEY_BROWSER_WEB_VITAL_ID","KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE","KEY_BROWSER_WEB_VITAL_NAVIGATION_ID","KEY_BROWSER_WEB_VITAL_INTERACTION_ID","KEY_MXL_SESSION_PART_ID","KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS","KEY_BROWSER_URL_FULL","KEY_MXL_PAGE_PATH","KEY_MXL_PAGE_ID","KEY_APP_SURFACE_LABEL","WEB_VITAL_EVENT_NAME","SeverityNumber"],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"sourcesContent":["import type { Attributes, DiagLogger } from '@opentelemetry/api';\nimport type { LogRecord } from '@opentelemetry/api-logs';\nimport { SeverityNumber } from '@opentelemetry/api-logs';\nimport { millisToHrTime } from '@opentelemetry/core';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type {\n CLSMetricWithAttribution,\n INPAttribution,\n LCPAttribution,\n Metric,\n MetricWithAttribution,\n TTFBAttribution,\n} from 'web-vitals/attribution';\nimport type { PageManager } from '../../../api-page/manager/types';\nimport { page } from '../../../api-page/pageAPI';\nimport type { URLDocument } from '../../../common/types';\nimport {\n KEY_APP_SURFACE_LABEL,\n KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS,\n KEY_BROWSER_URL_FULL,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_SESSION_PART_ID,\n KEY_MXL_TYPE,\n MXL_TYPES,\n} from '../../../constants/attributes';\nimport { getBfcacheNotRestoredReasons } from '../../../utils/getBfcacheNotRestoredReasons';\nimport { getSelector } from '../../../utils/getSelector';\nimport { isEntryTypeSupported } from '../../../utils/performanceObserver/performanceObserver';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/MXLInstrumentationBase';\nimport {\n KEY_BROWSER_WEB_VITAL_DELTA,\n KEY_BROWSER_WEB_VITAL_ID,\n KEY_BROWSER_WEB_VITAL_INTERACTION_ID,\n KEY_BROWSER_WEB_VITAL_NAME,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_ID,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE,\n KEY_BROWSER_WEB_VITAL_RATING,\n KEY_BROWSER_WEB_VITAL_VALUE,\n KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX,\n} from './attributes';\nimport {\n ALL_WEB_VITALS,\n MAX_CLS_LAYOUT_SHIFTS,\n MAX_LOAF_SCRIPT_ENTRIES,\n MAX_LOAF_SCRIPT_URL_LENGTH,\n WEB_VITAL_EVENT_NAME,\n WEB_VITALS_ID_TO_LISTENER,\n} from './constants';\nimport type { WebVitalListeners, WebVitalsInstrumentationArgs } from './types';\n\ntype AttributedPage = {\n fullURL: string;\n path?: string;\n pageID?: string;\n label?: string;\n};\n\nconst roundClamp = (value: number): number => Math.round(Math.max(0, value));\n\nconst roundRect = (rect?: DOMRectReadOnly) => ({\n x: Math.round(rect?.x ?? 0),\n y: Math.round(rect?.y ?? 0),\n width: Math.round(rect?.width ?? 0),\n height: Math.round(rect?.height ?? 0),\n});\n\nconst isPrimitiveValue = (\n value: unknown,\n): value is string | number | boolean => {\n const type = typeof value;\n return type === 'number' || type === 'string' || type === 'boolean';\n};\n\nconst loafScriptsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as INPAttribution;\n\n try {\n // Suppress LoAF baseline errors\n /* eslint-disable baseline-js/use-baseline */\n if (attribution.longAnimationFrameEntries.length > 0) {\n const scripts = new Map<\n string,\n {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n }\n >();\n for (const entry of attribution.longAnimationFrameEntries) {\n for (const script of entry.scripts) {\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_LOAF_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_LOAF_SCRIPT_URL_LENGTH)}...`;\n }\n const existing = scripts.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n scripts.set(url, {\n count: 1,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n totalDuration: script.duration,\n });\n }\n }\n }\n if (scripts.size > 0) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}loaf_scripts`] =\n JSON.stringify(\n Object.fromEntries(\n [...scripts]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_LOAF_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n count: script.count,\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n total_duration: Math.round(script.totalDuration),\n },\n ]),\n ),\n );\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building loaf scripts for INP', error);\n }\n\n return attributes;\n};\n\nconst clsLayoutShiftsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const entries = metric.entries as LayoutShift[];\n\n if (entries.length > 0) {\n const shifts = entries.slice(0, MAX_CLS_LAYOUT_SHIFTS).map((entry) => {\n // web-vitals exposes sources sorted by impact area descending, so the\n // first source is the element that contributed most to the shift.\n const source = entry.sources[0];\n return {\n selector: getSelector(source?.node ?? null),\n startRect: roundRect(source?.previousRect),\n endRect: roundRect(source?.currentRect),\n };\n });\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}clsLayoutShifts`] = JSON.stringify(shifts);\n\n if (entries.length > MAX_CLS_LAYOUT_SHIFTS) {\n attributes[`${prefix}clsLayoutShiftsDroppedCount`] =\n entries.length - MAX_CLS_LAYOUT_SHIFTS;\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building CLS layout shifts', error);\n }\n\n return attributes;\n};\n\nconst inpAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const target = (metric.entries as PerformanceEventTiming[]).find(\n (entry) => entry.target,\n )?.target as Element | null | undefined;\n\n const tagName = target?.tagName?.toLowerCase();\n\n if (tagName) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}element_type`] =\n tagName;\n }\n\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building INP element type attribution', error);\n }\n\n return attributes;\n};\n\nconst ttfbSubPartsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as TTFBAttribution;\n const entry = attribution.navigationEntry as\n | PerformanceNavigationTiming\n | undefined;\n\n if (entry) {\n try {\n const redirect = roundClamp(entry.redirectEnd - entry.redirectStart);\n const domainLookup = roundClamp(\n entry.domainLookupEnd - entry.domainLookupStart,\n );\n const tcpConnection = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.secureConnectionStart - entry.connectStart\n : entry.connectEnd - entry.connectStart,\n );\n const tlsNegotiation = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.connectEnd - entry.secureConnectionStart\n : 0,\n );\n const effectiveResponseStart = Math.max(\n // @ts-expect-error 103 Early hints are not supported in all browsers\n // https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/finalResponseHeadersStart\n entry.finalResponseHeadersStart ?? 0,\n entry.responseStart,\n );\n const serverResponse = roundClamp(\n effectiveResponseStart - entry.requestStart,\n );\n const total = Math.round(entry.responseEnd - entry.startTime);\n const unattributed = roundClamp(\n total -\n redirect -\n domainLookup -\n tcpConnection -\n tlsNegotiation -\n serverResponse,\n );\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}redirect`] = redirect;\n attributes[`${prefix}domainLookup`] = domainLookup;\n attributes[`${prefix}tcpConnection`] = tcpConnection;\n attributes[`${prefix}tlsNegotiation`] = tlsNegotiation;\n attributes[`${prefix}serverResponse`] = serverResponse;\n attributes[`${prefix}unattributed`] = unattributed;\n } catch (error) {\n diag.error('error computing TTFB timing breakdown', error);\n }\n } else {\n diag.debug('TTFB navigationEntry unavailable, skipping timing breakdown');\n }\n\n return attributes;\n};\n\nconst lcpElementAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n const attribution = metric.attribution as LCPAttribution;\n const element = attribution.lcpEntry?.element;\n\n if (element) {\n const elementType = element.tagName.toLowerCase();\n const elementBoundingRect = JSON.stringify(\n roundRect(element.getBoundingClientRect()),\n );\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}elementType`] = elementType;\n attributes[`${prefix}elementBoundingRect`] = elementBoundingRect;\n }\n } catch (error) {\n diag.error('error building LCP element attribution', error);\n }\n\n return attributes;\n};\n\nexport class WebVitalsInstrumentation extends MXLInstrumentationBase {\n private readonly _listeners: WebVitalListeners;\n private readonly _urlDocument: URLDocument;\n private readonly _urlAttribution: boolean;\n private readonly _includeRawAttribution: boolean;\n private readonly _softNavsActive: boolean;\n private readonly _pageManager: PageManager;\n private readonly _attributedPage: Record<\n Metric['name'],\n AttributedPage | undefined\n > = {\n CLS: undefined,\n FCP: undefined,\n INP: undefined,\n LCP: undefined,\n TTFB: undefined,\n };\n private _largestShiftTargetForCLS: string | undefined | null = null;\n private _clsMetricId: string | undefined = undefined;\n private _applyCustomLogRecordData?: (logRecord: LogRecord) => void;\n private _listenersRegistered = false;\n\n public constructor({\n diag,\n perf,\n listeners = WEB_VITALS_ID_TO_LISTENER,\n urlDocument,\n urlAttribution = true,\n includeRawAttribution = true,\n reportSoftNavs = true,\n pageManager,\n applyCustomLogRecordData,\n ...config\n }: WebVitalsInstrumentationArgs = {}) {\n super({\n config,\n diag,\n instrumentationName: 'WebVitalsInstrumentation',\n instrumentationVersion: '1.0.0',\n perf,\n });\n this._listeners = listeners;\n this._urlDocument = urlDocument ?? window.document;\n this._urlAttribution = urlAttribution;\n this._includeRawAttribution = includeRawAttribution;\n this._softNavsActive =\n reportSoftNavs && isEntryTypeSupported('soft-navigation');\n this._pageManager = pageManager ?? page.getPageManager();\n this._applyCustomLogRecordData = applyCustomLogRecordData;\n\n if (this._config.enabled !== false) {\n this.enable();\n }\n }\n\n public override enable(): void {\n if (typeof PerformanceObserver !== 'undefined') {\n super.enable();\n } else {\n this._diag.debug(\n 'PerformanceObserver not supported, web vitals will not be collected',\n );\n }\n }\n\n protected override onDisable(): void {\n // web-vitals library doesn't support removing listeners, so we pause emission\n // https://github.com/GoogleChrome/web-vitals/issues/357#issuecomment-1593439036\n this._diag.debug('WebVitalsInstrumentation disabled, pausing emission');\n }\n\n protected override onEnable(): void {\n // web-vitals library doesn't support removing listeners, so only register once\n if (this._listenersRegistered) {\n this._diag.debug(\n 'WebVitalsInstrumentation listeners already registered, resuming emission',\n );\n return;\n }\n this._listenersRegistered = true;\n\n ALL_WEB_VITALS.forEach((name) => {\n // web-vitals reports a hardcoded dummy value of zero for TTFB on soft navigations. That\n // is not a real measurement and would skew the data, so TTFB listeners keep soft\n // navigation reporting off.\n const reportSoftNavs = name !== 'TTFB' && this._softNavsActive;\n\n if (this._urlAttribution) {\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n if (metric.name === 'CLS') {\n const clsMetric = metric as CLSMetricWithAttribution;\n const target = clsMetric.attribution.largestShiftTarget;\n\n if (this._clsMetricId !== clsMetric.id) {\n // A new metric ID means CLS has reset for a soft navigation.\n this._clsMetricId = clsMetric.id;\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n } else if (this._largestShiftTargetForCLS !== target) {\n // When the largest shift target changes, make sure the attributed page is updated\n // to reflect the page where that shift occurred.\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n }\n } else {\n this._attributedPage[metric.name] = this._currentAttributedPage();\n }\n },\n { reportAllChanges: true, reportSoftNavs },\n );\n }\n\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n this._emitWebVital(metric);\n },\n { reportSoftNavs },\n );\n });\n }\n\n private _currentAttributedPage(): AttributedPage {\n return {\n fullURL: this._urlDocument.URL,\n label: this._pageManager.getPageLabel() ?? undefined,\n pageID: this._pageManager.getCurrentPageId() ?? undefined,\n path: this._pageManager.getCurrentRoute()?.path,\n };\n }\n\n private _getTimeForMetric(metric: MetricWithAttribution): number {\n // For INP use interactionTime, which is the start time of the user's interaction\n if (\n metric.name === 'INP' &&\n metric.attribution.interactionTime !== undefined\n ) {\n return this.perf.epochMillisFromOriginOffset(\n metric.attribution.interactionTime,\n );\n }\n\n // For CLS use the first layout shift's startTime, which is the beginning of\n // the session window. Fall back to largestShiftTime if the entries aren't\n // available for some reason.\n if (metric.name === 'CLS') {\n const windowStart =\n metric.entries.length > 0\n ? Math.min(...metric.entries.map((entry) => entry.startTime))\n : metric.attribution.largestShiftTime;\n\n if (windowStart !== undefined) {\n return this.perf.epochMillisFromOriginOffset(windowStart);\n }\n }\n\n // For TTFB use the \"zero\" time of the current session part\n if (metric.name === 'TTFB') {\n return this.perf.getZeroTime();\n }\n\n // For other metrics, use the startTime of the last entry. In practice, web-vitals does\n // not emit multiple entries for metrics other than CLS. However to future-proof this code,\n // we are assuming that the last entry is the most relevant one.\n const metricStartTime =\n metric.entries[metric.entries.length - 1]?.startTime;\n\n if (metricStartTime !== undefined) {\n return this.perf.epochMillisFromOriginOffset(metricStartTime);\n }\n\n // Fall back to when the metric was reported\n return this.perf.getNowMillis();\n }\n\n private _emitWebVital(metric: MetricWithAttribution): void {\n const attributedPage = this._attributedPage[metric.name];\n // Resolve by the metric's own event time rather than reading the\n // currently active part: web-vitals can defer a metric's report well\n // past when its underlying entry occurred (e.g. INP/CLS finalize on\n // visibilitychange), by which point the part active at report time may\n // not be the one the entry happened in.\n const metricTimeMillis = this._getTimeForMetric(metric);\n const sessionPartId =\n this.userSessionManager.getSessionPartIdAt(metricTimeMillis);\n const notRestoredReasons = getBfcacheNotRestoredReasons();\n const logRecord: LogRecord = {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n [KEY_BROWSER_WEB_VITAL_NAME]: metric.name.toLowerCase(),\n [KEY_BROWSER_WEB_VITAL_VALUE]: metric.value,\n [KEY_BROWSER_WEB_VITAL_DELTA]: metric.delta,\n [KEY_BROWSER_WEB_VITAL_RATING]: metric.rating,\n [KEY_BROWSER_WEB_VITAL_ID]: metric.id,\n [KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE]: metric.navigationType,\n ...(metric.navigationId !== undefined\n ? { [KEY_BROWSER_WEB_VITAL_NAVIGATION_ID]: metric.navigationId }\n : {}),\n ...(metric.navigationInteractionId !== undefined\n ? {\n [KEY_BROWSER_WEB_VITAL_INTERACTION_ID]:\n metric.navigationInteractionId,\n }\n : {}),\n ...(sessionPartId !== null\n ? { [KEY_MXL_SESSION_PART_ID]: sessionPartId }\n : {}),\n ...(notRestoredReasons?.length\n ? {\n [KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS]:\n notRestoredReasons,\n }\n : {}),\n ...(attributedPage\n ? {\n // The navigationURL emitted by web-vitals is authoritative for which URL the metric\n // belongs to, since it was captured when the metric occurred. When soft navigations\n // are not supported, we fall back to the attributed page.\n [KEY_BROWSER_URL_FULL]:\n metric.navigationURL != null &&\n (metric.navigationType === 'soft-navigation' ||\n this._softNavsActive)\n ? metric.navigationURL\n : attributedPage.fullURL,\n [KEY_MXL_PAGE_PATH]: attributedPage.path,\n [KEY_MXL_PAGE_ID]: attributedPage.pageID,\n [KEY_APP_SURFACE_LABEL]: attributedPage.label,\n }\n : {}),\n ...(metric.name === 'INP'\n ? loafScriptsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'INP' ? inpAttribution(metric, this._diag) : {}),\n ...(metric.name === 'TTFB'\n ? ttfbSubPartsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'CLS'\n ? clsLayoutShiftsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'LCP'\n ? lcpElementAttribution(metric, this._diag)\n : {}),\n },\n body:\n this._includeRawAttribution && metric.attribution != null\n ? JSON.stringify(\n Object.fromEntries(\n Object.entries(metric.attribution).filter(([, v]) =>\n isPrimitiveValue(v),\n ),\n ),\n )\n : undefined,\n eventName: WEB_VITAL_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n timestamp: millisToHrTime(metricTimeMillis),\n };\n\n if (this._applyCustomLogRecordData) {\n safeExecuteInTheMiddle(\n () => this._applyCustomLogRecordData?.(logRecord),\n (error) => {\n if (error) {\n this._diag.error('applyCustomLogRecordData hook failed', error);\n }\n },\n true,\n );\n }\n\n this.logger.emit(logRecord);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0DA,MAAM,cAAc,UAA0B,KAAK,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC;AAE5E,MAAM,aAAa,UAA4B;CAC7C,GAAG,KAAK,MAAM,MAAM,KAAK,EAAE;CAC3B,GAAG,KAAK,MAAM,MAAM,KAAK,EAAE;CAC3B,OAAO,KAAK,MAAM,MAAM,SAAS,EAAE;CACnC,QAAQ,KAAK,MAAM,MAAM,UAAU,EAAE;CACtC;AAED,MAAM,oBACJ,UACuC;CACvC,MAAM,OAAO,OAAO;AACpB,QAAO,SAAS,YAAY,SAAS,YAAY,SAAS;;AAG5D,MAAM,0BACJ,QACA,SACe;C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KAAK,mBACH,OAAO,gBACP,eAAe;MACpBC,6BAAAA,oBAAoB,eAAe;MACnCC,6BAAAA,kBAAkB,eAAe;MACjCC,6BAAAA,wBAAwB,eAAe;KACzC,GACD,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,uBAAuB,QAAQ,KAAK,MAAM,GAC1C,EAAE;IACN,GAAI,OAAO,SAAS,QAAQ,eAAe,QAAQ,KAAK,MAAM,GAAG,EAAE;IACnE,GAAI,OAAO,SAAS,SAChB,wBAAwB,QAAQ,KAAK,MAAM,GAC3C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,2BAA2B,QAAQ,KAAK,MAAM,GAC9C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,sBAAsB,QAAQ,KAAK,MAAM,GACzC,EAAE;IACP;GACD,MACE,KAAK,0BAA0B,OAAO,eAAe,OACjD,KAAK,UACH,OAAO,YACL,OAAO,QAAQ,OAAO,YAAY,CAAC,QAAQ,GAAG,OAC5C,iBAAiB,EAAE,CACpB,CACF,CACF,GACD,KAAA;GACN,WAAWC,uEAAAA;GACX,gBAAgBC,wBAAAA,eAAe;GAC/B,YAAA,GAAA,oBAAA,gBAA0B,iBAAiB;GAC5C;AAED,MAAI,KAAK,0BACP,EAAA,GAAA,+BAAA,8BACQ,KAAK,4BAA4B,UAAU,GAChD,UAAU;AACT,OAAI,MACF,MAAK,MAAM,MAAM,wCAAwC,MAAM;KAGnE,KACD;AAGH,OAAK,OAAO,KAAK,UAAU"}
|
|
1
|
+
{"version":3,"file":"WebVitalsInstrumentation.cjs","names":["MAX_LOAF_SCRIPT_URL_LENGTH","KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX","getSelector","MXLInstrumentationBase","isEntryTypeSupported","page","loadWebVitalListeners","getBfcacheNotRestoredReasons","KEY_MXL_TYPE","KEY_BROWSER_WEB_VITAL_NAME","KEY_BROWSER_WEB_VITAL_VALUE","KEY_BROWSER_WEB_VITAL_DELTA","KEY_BROWSER_WEB_VITAL_RATING","KEY_BROWSER_WEB_VITAL_ID","KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE","KEY_BROWSER_WEB_VITAL_NAVIGATION_ID","KEY_BROWSER_WEB_VITAL_INTERACTION_ID","KEY_MXL_SESSION_PART_ID","KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS","KEY_BROWSER_URL_FULL","KEY_MXL_PAGE_PATH","KEY_MXL_PAGE_ID","KEY_APP_SURFACE_LABEL","WEB_VITAL_EVENT_NAME","SeverityNumber"],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"sourcesContent":["import type { Attributes, DiagLogger } from '@opentelemetry/api';\nimport type { LogRecord } from '@opentelemetry/api';\nimport { SeverityNumber } from '@opentelemetry/api';\nimport { millisToHrTime } from '@opentelemetry/core';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type {\n CLSMetricWithAttribution,\n INPAttribution,\n LCPAttribution,\n Metric,\n MetricWithAttribution,\n TTFBAttribution,\n} from 'web-vitals/attribution';\nimport type { PageManager } from '../../../api-page/manager/types';\nimport { page } from '../../../api-page/pageAPI';\nimport type { URLDocument } from '../../../common/types';\nimport {\n KEY_APP_SURFACE_LABEL,\n KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS,\n KEY_BROWSER_URL_FULL,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_SESSION_PART_ID,\n KEY_MXL_TYPE,\n MXL_TYPES,\n} from '../../../constants/attributes';\nimport { getBfcacheNotRestoredReasons } from '../../../utils/getBfcacheNotRestoredReasons';\nimport { getSelector } from '../../../utils/getSelector';\nimport { isEntryTypeSupported } from '../../../utils/performanceObserver/performanceObserver';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/MXLInstrumentationBase';\nimport {\n KEY_BROWSER_WEB_VITAL_DELTA,\n KEY_BROWSER_WEB_VITAL_ID,\n KEY_BROWSER_WEB_VITAL_INTERACTION_ID,\n KEY_BROWSER_WEB_VITAL_NAME,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_ID,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE,\n KEY_BROWSER_WEB_VITAL_RATING,\n KEY_BROWSER_WEB_VITAL_VALUE,\n KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX,\n} from './attributes';\nimport {\n ALL_WEB_VITALS,\n MAX_CLS_LAYOUT_SHIFTS,\n MAX_LOAF_SCRIPT_ENTRIES,\n MAX_LOAF_SCRIPT_URL_LENGTH,\n WEB_VITAL_EVENT_NAME,\n loadWebVitalListeners,\n} from './constants';\nimport type { WebVitalListeners, WebVitalsInstrumentationArgs } from './types';\n\ntype AttributedPage = {\n fullURL: string;\n path?: string;\n pageID?: string;\n label?: string;\n};\n\nconst roundClamp = (value: number): number => Math.round(Math.max(0, value));\n\nconst roundRect = (rect?: DOMRectReadOnly) => ({\n x: Math.round(rect?.x ?? 0),\n y: Math.round(rect?.y ?? 0),\n width: Math.round(rect?.width ?? 0),\n height: Math.round(rect?.height ?? 0),\n});\n\nconst isPrimitiveValue = (\n value: unknown,\n): value is string | number | boolean => {\n const type = typeof value;\n return type === 'number' || type === 'string' || type === 'boolean';\n};\n\nconst loafScriptsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as INPAttribution;\n\n try {\n // Suppress LoAF baseline errors\n /* eslint-disable baseline-js/use-baseline */\n if (attribution.longAnimationFrameEntries.length > 0) {\n const scripts = new Map<\n string,\n {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n }\n >();\n for (const entry of attribution.longAnimationFrameEntries) {\n for (const script of entry.scripts) {\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_LOAF_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_LOAF_SCRIPT_URL_LENGTH)}...`;\n }\n const existing = scripts.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n scripts.set(url, {\n count: 1,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n totalDuration: script.duration,\n });\n }\n }\n }\n if (scripts.size > 0) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}loaf_scripts`] =\n JSON.stringify(\n Object.fromEntries(\n [...scripts]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_LOAF_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n count: script.count,\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n total_duration: Math.round(script.totalDuration),\n },\n ]),\n ),\n );\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building loaf scripts for INP', error);\n }\n\n return attributes;\n};\n\nconst clsLayoutShiftsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const entries = metric.entries as LayoutShift[];\n\n if (entries.length > 0) {\n const shifts = entries.slice(0, MAX_CLS_LAYOUT_SHIFTS).map((entry) => {\n // web-vitals exposes sources sorted by impact area descending, so the\n // first source is the element that contributed most to the shift.\n const source = entry.sources[0];\n return {\n selector: getSelector(source?.node ?? null),\n startRect: roundRect(source?.previousRect),\n endRect: roundRect(source?.currentRect),\n };\n });\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}clsLayoutShifts`] = JSON.stringify(shifts);\n\n if (entries.length > MAX_CLS_LAYOUT_SHIFTS) {\n attributes[`${prefix}clsLayoutShiftsDroppedCount`] =\n entries.length - MAX_CLS_LAYOUT_SHIFTS;\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building CLS layout shifts', error);\n }\n\n return attributes;\n};\n\nconst inpAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const target = (metric.entries as PerformanceEventTiming[]).find(\n (entry) => entry.target,\n )?.target as Element | null | undefined;\n\n const tagName = target?.tagName?.toLowerCase();\n\n if (tagName) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}element_type`] =\n tagName;\n }\n\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building INP element type attribution', error);\n }\n\n return attributes;\n};\n\nconst ttfbSubPartsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as TTFBAttribution;\n const entry = attribution.navigationEntry as\n | PerformanceNavigationTiming\n | undefined;\n\n if (entry) {\n try {\n const redirect = roundClamp(entry.redirectEnd - entry.redirectStart);\n const domainLookup = roundClamp(\n entry.domainLookupEnd - entry.domainLookupStart,\n );\n const tcpConnection = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.secureConnectionStart - entry.connectStart\n : entry.connectEnd - entry.connectStart,\n );\n const tlsNegotiation = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.connectEnd - entry.secureConnectionStart\n : 0,\n );\n const effectiveResponseStart = Math.max(\n // @ts-expect-error 103 Early hints are not supported in all browsers\n // https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/finalResponseHeadersStart\n entry.finalResponseHeadersStart ?? 0,\n entry.responseStart,\n );\n const serverResponse = roundClamp(\n effectiveResponseStart - entry.requestStart,\n );\n const total = Math.round(entry.responseEnd - entry.startTime);\n const unattributed = roundClamp(\n total -\n redirect -\n domainLookup -\n tcpConnection -\n tlsNegotiation -\n serverResponse,\n );\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}redirect`] = redirect;\n attributes[`${prefix}domainLookup`] = domainLookup;\n attributes[`${prefix}tcpConnection`] = tcpConnection;\n attributes[`${prefix}tlsNegotiation`] = tlsNegotiation;\n attributes[`${prefix}serverResponse`] = serverResponse;\n attributes[`${prefix}unattributed`] = unattributed;\n } catch (error) {\n diag.error('error computing TTFB timing breakdown', error);\n }\n } else {\n diag.debug('TTFB navigationEntry unavailable, skipping timing breakdown');\n }\n\n return attributes;\n};\n\nconst lcpElementAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n const attribution = metric.attribution as LCPAttribution;\n const element = attribution.lcpEntry?.element;\n\n if (element) {\n const elementType = element.tagName.toLowerCase();\n const elementBoundingRect = JSON.stringify(\n roundRect(element.getBoundingClientRect()),\n );\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}elementType`] = elementType;\n attributes[`${prefix}elementBoundingRect`] = elementBoundingRect;\n }\n } catch (error) {\n diag.error('error building LCP element attribution', error);\n }\n\n return attributes;\n};\n\nexport class WebVitalsInstrumentation extends MXLInstrumentationBase {\n private _listeners: WebVitalListeners;\n private readonly _urlDocument: URLDocument;\n private readonly _urlAttribution: boolean;\n private readonly _includeRawAttribution: boolean;\n private readonly _softNavsActive: boolean;\n private readonly _pageManager: PageManager;\n private readonly _attributedPage: Record<\n Metric['name'],\n AttributedPage | undefined\n > = {\n CLS: undefined,\n FCP: undefined,\n INP: undefined,\n LCP: undefined,\n TTFB: undefined,\n };\n private _largestShiftTargetForCLS: string | undefined | null = null;\n private _clsMetricId: string | undefined = undefined;\n private _applyCustomLogRecordData?: (logRecord: LogRecord) => void;\n private _listenersRegistered = false;\n\n public constructor({\n diag,\n perf,\n listeners,\n urlDocument,\n urlAttribution = true,\n includeRawAttribution = true,\n reportSoftNavs = true,\n pageManager,\n applyCustomLogRecordData,\n ...config\n }: WebVitalsInstrumentationArgs = {}) {\n super({\n config,\n diag,\n instrumentationName: 'WebVitalsInstrumentation',\n instrumentationVersion: '1.0.0',\n perf,\n });\n this._listeners = listeners ?? ({} as WebVitalListeners);\n this._urlDocument = urlDocument ?? window.document;\n this._urlAttribution = urlAttribution;\n this._includeRawAttribution = includeRawAttribution;\n this._softNavsActive =\n reportSoftNavs && isEntryTypeSupported('soft-navigation');\n this._pageManager = pageManager ?? page.getPageManager();\n this._applyCustomLogRecordData = applyCustomLogRecordData;\n this._listenersProvided = listeners !== undefined;\n }\n\n private readonly _listenersProvided: boolean;\n\n protected override onDisable(): void {\n // web-vitals library doesn't support removing listeners, so we pause emission\n // https://github.com/GoogleChrome/web-vitals/issues/357#issuecomment-1593439036\n this._diag.debug('WebVitalsInstrumentation disabled, pausing emission');\n }\n\n protected override onEnable(): void {\n // web-vitals library doesn't support removing listeners, so only register once\n if (this._listenersRegistered) {\n this._diag.debug(\n 'WebVitalsInstrumentation listeners already registered, resuming emission',\n );\n return;\n }\n this._listenersRegistered = true;\n\n if (this._listenersProvided) {\n this._registerListeners();\n return;\n }\n\n void loadWebVitalListeners().then((listeners) => {\n if (!this._isEnabled) {\n return;\n }\n this._listeners = listeners;\n this._registerListeners();\n });\n }\n\n private _registerListeners(): void {\n ALL_WEB_VITALS.forEach((name) => {\n // web-vitals reports a hardcoded dummy value of zero for TTFB on soft navigations. That\n // is not a real measurement and would skew the data, so TTFB listeners keep soft\n // navigation reporting off.\n const reportSoftNavs = name !== 'TTFB' && this._softNavsActive;\n\n if (this._urlAttribution) {\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n if (metric.name === 'CLS') {\n const clsMetric = metric as CLSMetricWithAttribution;\n const target = clsMetric.attribution.largestShiftTarget;\n\n if (this._clsMetricId !== clsMetric.id) {\n // A new metric ID means CLS has reset for a soft navigation.\n this._clsMetricId = clsMetric.id;\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n } else if (this._largestShiftTargetForCLS !== target) {\n // When the largest shift target changes, make sure the attributed page is updated\n // to reflect the page where that shift occurred.\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n }\n } else {\n this._attributedPage[metric.name] = this._currentAttributedPage();\n }\n },\n { reportAllChanges: true, reportSoftNavs },\n );\n }\n\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n this._emitWebVital(metric);\n },\n { reportSoftNavs },\n );\n });\n }\n\n private _currentAttributedPage(): AttributedPage {\n return {\n fullURL: this._urlDocument.URL,\n label: this._pageManager.getPageLabel() ?? undefined,\n pageID: this._pageManager.getCurrentPageId() ?? undefined,\n path: this._pageManager.getCurrentRoute()?.path,\n };\n }\n\n private _getTimeForMetric(metric: MetricWithAttribution): number {\n // For INP use interactionTime, which is the start time of the user's interaction\n if (\n metric.name === 'INP' &&\n metric.attribution.interactionTime !== undefined\n ) {\n return this.perf.offsetToAbsoluteTime(metric.attribution.interactionTime);\n }\n\n // For CLS use the first layout shift's startTime, which is the beginning of\n // the session window. Fall back to largestShiftTime if the entries aren't\n // available for some reason.\n if (metric.name === 'CLS') {\n const windowStart =\n metric.entries.length > 0\n ? Math.min(...metric.entries.map((entry) => entry.startTime))\n : metric.attribution.largestShiftTime;\n\n if (windowStart !== undefined) {\n return this.perf.offsetToAbsoluteTime(windowStart);\n }\n }\n\n // For TTFB use the \"zero\" time of the current session part\n if (metric.name === 'TTFB') {\n return this.perf.getZeroTime();\n }\n\n // For other metrics, use the startTime of the last entry. In practice, web-vitals does\n // not emit multiple entries for metrics other than CLS. However to future-proof this code,\n // we are assuming that the last entry is the most relevant one.\n const metricStartTime =\n metric.entries[metric.entries.length - 1]?.startTime;\n\n if (metricStartTime !== undefined) {\n return this.perf.offsetToAbsoluteTime(metricStartTime);\n }\n\n // Fall back to when the metric was reported\n return this.perf.getNow();\n }\n\n private _emitWebVital(metric: MetricWithAttribution): void {\n const attributedPage = this._attributedPage[metric.name];\n // Resolve by the metric's own event time rather than reading the\n // currently active part: web-vitals can defer a metric's report well\n // past when its underlying entry occurred (e.g. INP/CLS finalize on\n // visibilitychange), by which point the part active at report time may\n // not be the one the entry happened in.\n const metricTimeMillis = this._getTimeForMetric(metric);\n const sessionPartId =\n this.userSessionManager.getSessionPartIdAt(metricTimeMillis);\n const notRestoredReasons = getBfcacheNotRestoredReasons();\n const logRecord: LogRecord = {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n [KEY_BROWSER_WEB_VITAL_NAME]: metric.name.toLowerCase(),\n [KEY_BROWSER_WEB_VITAL_VALUE]: metric.value,\n [KEY_BROWSER_WEB_VITAL_DELTA]: metric.delta,\n [KEY_BROWSER_WEB_VITAL_RATING]: metric.rating,\n [KEY_BROWSER_WEB_VITAL_ID]: metric.id,\n [KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE]: metric.navigationType,\n [KEY_BROWSER_WEB_VITAL_NAVIGATION_ID]: metric.navigationId,\n ...(metric.navigationInteractionId !== undefined\n ? {\n [KEY_BROWSER_WEB_VITAL_INTERACTION_ID]:\n metric.navigationInteractionId,\n }\n : {}),\n ...(sessionPartId !== null\n ? { [KEY_MXL_SESSION_PART_ID]: sessionPartId }\n : {}),\n ...(notRestoredReasons?.length\n ? {\n [KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS]:\n notRestoredReasons,\n }\n : {}),\n ...(attributedPage\n ? {\n // The navigationURL emitted by web-vitals is authoritative for which URL the metric\n // belongs to, since it was captured when the metric occurred. When soft navigations\n // are not supported, we fall back to the attributed page.\n [KEY_BROWSER_URL_FULL]:\n metric.navigationURL != null &&\n (metric.navigationType === 'soft-navigation' ||\n this._softNavsActive)\n ? metric.navigationURL\n : attributedPage.fullURL,\n [KEY_MXL_PAGE_PATH]: attributedPage.path,\n [KEY_MXL_PAGE_ID]: attributedPage.pageID,\n [KEY_APP_SURFACE_LABEL]: attributedPage.label,\n }\n : {}),\n ...(metric.name === 'INP'\n ? loafScriptsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'INP' ? inpAttribution(metric, this._diag) : {}),\n ...(metric.name === 'TTFB'\n ? ttfbSubPartsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'CLS'\n ? clsLayoutShiftsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'LCP'\n ? lcpElementAttribution(metric, this._diag)\n : {}),\n },\n body: this._includeRawAttribution\n ? JSON.stringify(\n Object.fromEntries(\n Object.entries(metric.attribution).filter(([, v]) =>\n isPrimitiveValue(v),\n ),\n ),\n )\n : undefined,\n eventName: WEB_VITAL_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n timestamp: millisToHrTime(metricTimeMillis),\n };\n\n if (this._applyCustomLogRecordData) {\n safeExecuteInTheMiddle(\n () => this._applyCustomLogRecordData?.(logRecord),\n (error) => {\n if (error) {\n this._diag.error('applyCustomLogRecordData hook failed', error);\n }\n },\n true,\n );\n }\n\n this.logger.emit(logRecord);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0DA,MAAM,cAAc,UAA0B,KAAK,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC;AAE5E,MAAM,aAAa,UAA4B;CAC7C,GAAG,KAAK,MAAM,MAAM,KAAK,EAAE;CAC3B,GAAG,KAAK,MAAM,MAAM,KAAK,EAAE;CAC3B,OAAO,KAAK,MAAM,MAAM,SAAS,EAAE;CACnC,QAAQ,KAAK,MAAM,MAAM,UAAU,EAAE;CACtC;AAED,MAAM,oBACJ,UACuC;CACvC,MAAM,OAAO,OAAO;AACpB,QAAO,SAAS,YAAY,SAAS,YAAY,SAAS;;AAG5D,MAAM,0BACJ,QACA,SACe;CACf,MAAM,aAAyB,EAAE;CACjC,MAAM,cAAc,OAAO;AAE3B,KAAI;AAGF,MAAI,YAAY,0BAA0B,SAAS,GAAG;GACpD,MAAM,0BAAU,IAAI,KAOjB;AACH,QAAK,MAAM,SAAS,YAAY,0BAC9B,MAAK,MAAM,UAAU,MAAM,SAAS;IAClC,IAAI,MAAM,OAAO,aAAa;AAC9B,QAAI,IAAI,SAAA,KACN,OAAM,GAAG,IAAI,U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,KAAK,MAAM,GAAG,EAAE;IACnE,GAAI,OAAO,SAAS,SAChB,wBAAwB,QAAQ,KAAK,MAAM,GAC3C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,2BAA2B,QAAQ,KAAK,MAAM,GAC9C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,sBAAsB,QAAQ,KAAK,MAAM,GACzC,EAAE;IACP;GACD,MAAM,KAAK,yBACP,KAAK,UACH,OAAO,YACL,OAAO,QAAQ,OAAO,YAAY,CAAC,QAAQ,GAAG,OAC5C,iBAAiB,EAAE,CACpB,CACF,CACF,GACD,KAAA;GACJ,WAAWC,uEAAAA;GACX,gBAAgBC,mBAAAA,eAAe;GAC/B,YAAA,GAAA,oBAAA,gBAA0B,iBAAiB;GAC5C;AAED,MAAI,KAAK,0BACP,EAAA,GAAA,+BAAA,8BACQ,KAAK,4BAA4B,UAAU,GAChD,UAAU;AACT,OAAI,MACF,MAAK,MAAM,MAAM,wCAAwC,MAAM;KAGnE,KACD;AAGH,OAAK,OAAO,KAAK,UAAU"}
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { MXLInstrumentationBase } from "../../MXLInstrumentationBase/MXLInstrume
|
|
|
3
3
|
|
|
4
4
|
//#region src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts
|
|
5
5
|
declare class WebVitalsInstrumentation extends MXLInstrumentationBase {
|
|
6
|
-
private
|
|
6
|
+
private _listeners;
|
|
7
7
|
private readonly _urlDocument;
|
|
8
8
|
private readonly _urlAttribution;
|
|
9
9
|
private readonly _includeRawAttribution;
|
|
@@ -26,9 +26,10 @@ declare class WebVitalsInstrumentation extends MXLInstrumentationBase {
|
|
|
26
26
|
applyCustomLogRecordData,
|
|
27
27
|
...config
|
|
28
28
|
}?: WebVitalsInstrumentationArgs);
|
|
29
|
-
|
|
29
|
+
private readonly _listenersProvided;
|
|
30
30
|
protected onDisable(): void;
|
|
31
31
|
protected onEnable(): void;
|
|
32
|
+
private _registerListeners;
|
|
32
33
|
private _currentAttributedPage;
|
|
33
34
|
private _getTimeForMetric;
|
|
34
35
|
private _emitWebVital;
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebVitalsInstrumentation.d.cts","names":[],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"mappings":";;;;cAwSa,wBAAA,SAAiC,sBAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"WebVitalsInstrumentation.d.cts","names":[],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"mappings":";;;;cAwSa,wBAAA,SAAiC,sBAAA;EAAA,QACpC,UAAA;EAAA,iBACS,YAAA;EAAA,iBACA,eAAA;EAAA,iBACA,sBAAA;EAAA,iBACA,eAAA;EAAA,iBACA,YAAA;EAAA,iBACA,eAAA;EAAA,QAUT,yBAAA;EAAA,QACA,YAAA;EAAA,QACA,yBAAA;EAAA,QACA,oBAAA;;IAGN,IAAA;IACA,IAAA;IACA,SAAA;IACA,WAAA;IACA,cAAA;IACA,qBAAA;IACA,cAAA;IACA,WAAA;IACA,wBAAA;IAAA,GACG;EAAA,IACF,4BAAA;EAAA,iBAmBc,kBAAA;EAAA,UAEE,SAAA,CAAA;EAAA,UAMA,QAAA,CAAA;EAAA,QAwBX,kBAAA;EAAA,QAgDA,sBAAA;EAAA,QASA,iBAAA;EAAA,QA0CA,aAAA;AAAA"}
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { MXLInstrumentationBase } from "../../MXLInstrumentationBase/MXLInstrume
|
|
|
3
3
|
|
|
4
4
|
//#region src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts
|
|
5
5
|
declare class WebVitalsInstrumentation extends MXLInstrumentationBase {
|
|
6
|
-
private
|
|
6
|
+
private _listeners;
|
|
7
7
|
private readonly _urlDocument;
|
|
8
8
|
private readonly _urlAttribution;
|
|
9
9
|
private readonly _includeRawAttribution;
|
|
@@ -26,9 +26,10 @@ declare class WebVitalsInstrumentation extends MXLInstrumentationBase {
|
|
|
26
26
|
applyCustomLogRecordData,
|
|
27
27
|
...config
|
|
28
28
|
}?: WebVitalsInstrumentationArgs);
|
|
29
|
-
|
|
29
|
+
private readonly _listenersProvided;
|
|
30
30
|
protected onDisable(): void;
|
|
31
31
|
protected onEnable(): void;
|
|
32
|
+
private _registerListeners;
|
|
32
33
|
private _currentAttributedPage;
|
|
33
34
|
private _getTimeForMetric;
|
|
34
35
|
private _emitWebVital;
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebVitalsInstrumentation.d.ts","names":[],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"mappings":";;;;cAwSa,wBAAA,SAAiC,sBAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"WebVitalsInstrumentation.d.ts","names":[],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"mappings":";;;;cAwSa,wBAAA,SAAiC,sBAAA;EAAA,QACpC,UAAA;EAAA,iBACS,YAAA;EAAA,iBACA,eAAA;EAAA,iBACA,sBAAA;EAAA,iBACA,eAAA;EAAA,iBACA,YAAA;EAAA,iBACA,eAAA;EAAA,QAUT,yBAAA;EAAA,QACA,YAAA;EAAA,QACA,yBAAA;EAAA,QACA,oBAAA;;IAGN,IAAA;IACA,IAAA;IACA,SAAA;IACA,WAAA;IACA,cAAA;IACA,qBAAA;IACA,cAAA;IACA,WAAA;IACA,wBAAA;IAAA,GACG;EAAA,IACF,4BAAA;EAAA,iBAmBc,kBAAA;EAAA,UAEE,SAAA,CAAA;EAAA,UAMA,QAAA,CAAA;EAAA,QAwBX,kBAAA;EAAA,QAgDA,sBAAA;EAAA,QASA,iBAAA;EAAA,QA0CA,aAAA;AAAA"}
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.js
CHANGED
|
@@ -5,10 +5,10 @@ import { isEntryTypeSupported } from "../../../utils/performanceObserver/perform
|
|
|
5
5
|
import { getBfcacheNotRestoredReasons } from "../../../utils/getBfcacheNotRestoredReasons.js";
|
|
6
6
|
import { getSelector } from "../../../utils/getSelector.js";
|
|
7
7
|
import { KEY_BROWSER_WEB_VITAL_DELTA, KEY_BROWSER_WEB_VITAL_ID, KEY_BROWSER_WEB_VITAL_INTERACTION_ID, KEY_BROWSER_WEB_VITAL_NAME, KEY_BROWSER_WEB_VITAL_NAVIGATION_ID, KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE, KEY_BROWSER_WEB_VITAL_RATING, KEY_BROWSER_WEB_VITAL_VALUE, KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX } from "./attributes.js";
|
|
8
|
-
import { ALL_WEB_VITALS, MAX_LOAF_SCRIPT_URL_LENGTH,
|
|
9
|
-
import {
|
|
10
|
-
import { SeverityNumber } from "@opentelemetry/api-logs";
|
|
8
|
+
import { ALL_WEB_VITALS, MAX_LOAF_SCRIPT_URL_LENGTH, WEB_VITAL_EVENT_NAME, loadWebVitalListeners } from "./constants.js";
|
|
9
|
+
import { SeverityNumber } from "@opentelemetry/api";
|
|
11
10
|
import { safeExecuteInTheMiddle } from "@opentelemetry/instrumentation";
|
|
11
|
+
import { millisToHrTime } from "@opentelemetry/core";
|
|
12
12
|
//#region src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts
|
|
13
13
|
const roundClamp = (value) => Math.round(Math.max(0, value));
|
|
14
14
|
const roundRect = (rect) => ({
|
|
@@ -141,7 +141,7 @@ var WebVitalsInstrumentation = class extends MXLInstrumentationBase {
|
|
|
141
141
|
_clsMetricId = void 0;
|
|
142
142
|
_applyCustomLogRecordData;
|
|
143
143
|
_listenersRegistered = false;
|
|
144
|
-
constructor({ diag, perf, listeners
|
|
144
|
+
constructor({ diag, perf, listeners, urlDocument, urlAttribution = true, includeRawAttribution = true, reportSoftNavs = true, pageManager, applyCustomLogRecordData, ...config } = {}) {
|
|
145
145
|
super({
|
|
146
146
|
config,
|
|
147
147
|
diag,
|
|
@@ -149,19 +149,16 @@ var WebVitalsInstrumentation = class extends MXLInstrumentationBase {
|
|
|
149
149
|
instrumentationVersion: "1.0.0",
|
|
150
150
|
perf
|
|
151
151
|
});
|
|
152
|
-
this._listeners = listeners;
|
|
152
|
+
this._listeners = listeners ?? {};
|
|
153
153
|
this._urlDocument = urlDocument ?? window.document;
|
|
154
154
|
this._urlAttribution = urlAttribution;
|
|
155
155
|
this._includeRawAttribution = includeRawAttribution;
|
|
156
156
|
this._softNavsActive = reportSoftNavs && isEntryTypeSupported("soft-navigation");
|
|
157
157
|
this._pageManager = pageManager ?? page.getPageManager();
|
|
158
158
|
this._applyCustomLogRecordData = applyCustomLogRecordData;
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
enable() {
|
|
162
|
-
if (typeof PerformanceObserver !== "undefined") super.enable();
|
|
163
|
-
else this._diag.debug("PerformanceObserver not supported, web vitals will not be collected");
|
|
159
|
+
this._listenersProvided = listeners !== void 0;
|
|
164
160
|
}
|
|
161
|
+
_listenersProvided;
|
|
165
162
|
onDisable() {
|
|
166
163
|
this._diag.debug("WebVitalsInstrumentation disabled, pausing emission");
|
|
167
164
|
}
|
|
@@ -171,6 +168,17 @@ var WebVitalsInstrumentation = class extends MXLInstrumentationBase {
|
|
|
171
168
|
return;
|
|
172
169
|
}
|
|
173
170
|
this._listenersRegistered = true;
|
|
171
|
+
if (this._listenersProvided) {
|
|
172
|
+
this._registerListeners();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
loadWebVitalListeners().then((listeners) => {
|
|
176
|
+
if (!this._isEnabled) return;
|
|
177
|
+
this._listeners = listeners;
|
|
178
|
+
this._registerListeners();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
_registerListeners() {
|
|
174
182
|
ALL_WEB_VITALS.forEach((name) => {
|
|
175
183
|
const reportSoftNavs = name !== "TTFB" && this._softNavsActive;
|
|
176
184
|
if (this._urlAttribution) this._listeners[name]?.((metric) => {
|
|
@@ -206,15 +214,15 @@ var WebVitalsInstrumentation = class extends MXLInstrumentationBase {
|
|
|
206
214
|
};
|
|
207
215
|
}
|
|
208
216
|
_getTimeForMetric(metric) {
|
|
209
|
-
if (metric.name === "INP" && metric.attribution.interactionTime !== void 0) return this.perf.
|
|
217
|
+
if (metric.name === "INP" && metric.attribution.interactionTime !== void 0) return this.perf.offsetToAbsoluteTime(metric.attribution.interactionTime);
|
|
210
218
|
if (metric.name === "CLS") {
|
|
211
219
|
const windowStart = metric.entries.length > 0 ? Math.min(...metric.entries.map((entry) => entry.startTime)) : metric.attribution.largestShiftTime;
|
|
212
|
-
if (windowStart !== void 0) return this.perf.
|
|
220
|
+
if (windowStart !== void 0) return this.perf.offsetToAbsoluteTime(windowStart);
|
|
213
221
|
}
|
|
214
222
|
if (metric.name === "TTFB") return this.perf.getZeroTime();
|
|
215
223
|
const metricStartTime = metric.entries[metric.entries.length - 1]?.startTime;
|
|
216
|
-
if (metricStartTime !== void 0) return this.perf.
|
|
217
|
-
return this.perf.
|
|
224
|
+
if (metricStartTime !== void 0) return this.perf.offsetToAbsoluteTime(metricStartTime);
|
|
225
|
+
return this.perf.getNow();
|
|
218
226
|
}
|
|
219
227
|
_emitWebVital(metric) {
|
|
220
228
|
const attributedPage = this._attributedPage[metric.name];
|
|
@@ -230,7 +238,7 @@ var WebVitalsInstrumentation = class extends MXLInstrumentationBase {
|
|
|
230
238
|
[KEY_BROWSER_WEB_VITAL_RATING]: metric.rating,
|
|
231
239
|
[KEY_BROWSER_WEB_VITAL_ID]: metric.id,
|
|
232
240
|
[KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE]: metric.navigationType,
|
|
233
|
-
|
|
241
|
+
[KEY_BROWSER_WEB_VITAL_NAVIGATION_ID]: metric.navigationId,
|
|
234
242
|
...metric.navigationInteractionId !== void 0 ? { [KEY_BROWSER_WEB_VITAL_INTERACTION_ID]: metric.navigationInteractionId } : {},
|
|
235
243
|
...sessionPartId !== null ? { [KEY_MXL_SESSION_PART_ID]: sessionPartId } : {},
|
|
236
244
|
...notRestoredReasons?.length ? { [KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS]: notRestoredReasons } : {},
|
|
@@ -246,7 +254,7 @@ var WebVitalsInstrumentation = class extends MXLInstrumentationBase {
|
|
|
246
254
|
...metric.name === "CLS" ? clsLayoutShiftsAttribution(metric, this._diag) : {},
|
|
247
255
|
...metric.name === "LCP" ? lcpElementAttribution(metric, this._diag) : {}
|
|
248
256
|
},
|
|
249
|
-
body: this._includeRawAttribution
|
|
257
|
+
body: this._includeRawAttribution ? JSON.stringify(Object.fromEntries(Object.entries(metric.attribution).filter(([, v]) => isPrimitiveValue(v)))) : void 0,
|
|
250
258
|
eventName: WEB_VITAL_EVENT_NAME,
|
|
251
259
|
severityNumber: SeverityNumber.INFO,
|
|
252
260
|
timestamp: millisToHrTime(metricTimeMillis)
|
package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebVitalsInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"sourcesContent":["import type { Attributes, DiagLogger } from '@opentelemetry/api';\nimport type { LogRecord } from '@opentelemetry/api-logs';\nimport { SeverityNumber } from '@opentelemetry/api-logs';\nimport { millisToHrTime } from '@opentelemetry/core';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type {\n CLSMetricWithAttribution,\n INPAttribution,\n LCPAttribution,\n Metric,\n MetricWithAttribution,\n TTFBAttribution,\n} from 'web-vitals/attribution';\nimport type { PageManager } from '../../../api-page/manager/types';\nimport { page } from '../../../api-page/pageAPI';\nimport type { URLDocument } from '../../../common/types';\nimport {\n KEY_APP_SURFACE_LABEL,\n KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS,\n KEY_BROWSER_URL_FULL,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_SESSION_PART_ID,\n KEY_MXL_TYPE,\n MXL_TYPES,\n} from '../../../constants/attributes';\nimport { getBfcacheNotRestoredReasons } from '../../../utils/getBfcacheNotRestoredReasons';\nimport { getSelector } from '../../../utils/getSelector';\nimport { isEntryTypeSupported } from '../../../utils/performanceObserver/performanceObserver';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/MXLInstrumentationBase';\nimport {\n KEY_BROWSER_WEB_VITAL_DELTA,\n KEY_BROWSER_WEB_VITAL_ID,\n KEY_BROWSER_WEB_VITAL_INTERACTION_ID,\n KEY_BROWSER_WEB_VITAL_NAME,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_ID,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE,\n KEY_BROWSER_WEB_VITAL_RATING,\n KEY_BROWSER_WEB_VITAL_VALUE,\n KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX,\n} from './attributes';\nimport {\n ALL_WEB_VITALS,\n MAX_CLS_LAYOUT_SHIFTS,\n MAX_LOAF_SCRIPT_ENTRIES,\n MAX_LOAF_SCRIPT_URL_LENGTH,\n WEB_VITAL_EVENT_NAME,\n WEB_VITALS_ID_TO_LISTENER,\n} from './constants';\nimport type { WebVitalListeners, WebVitalsInstrumentationArgs } from './types';\n\ntype AttributedPage = {\n fullURL: string;\n path?: string;\n pageID?: string;\n label?: string;\n};\n\nconst roundClamp = (value: number): number => Math.round(Math.max(0, value));\n\nconst roundRect = (rect?: DOMRectReadOnly) => ({\n x: Math.round(rect?.x ?? 0),\n y: Math.round(rect?.y ?? 0),\n width: Math.round(rect?.width ?? 0),\n height: Math.round(rect?.height ?? 0),\n});\n\nconst isPrimitiveValue = (\n value: unknown,\n): value is string | number | boolean => {\n const type = typeof value;\n return type === 'number' || type === 'string' || type === 'boolean';\n};\n\nconst loafScriptsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as INPAttribution;\n\n try {\n // Suppress LoAF baseline errors\n /* eslint-disable baseline-js/use-baseline */\n if (attribution.longAnimationFrameEntries.length > 0) {\n const scripts = new Map<\n string,\n {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n }\n >();\n for (const entry of attribution.longAnimationFrameEntries) {\n for (const script of entry.scripts) {\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_LOAF_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_LOAF_SCRIPT_URL_LENGTH)}...`;\n }\n const existing = scripts.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n scripts.set(url, {\n count: 1,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n totalDuration: script.duration,\n });\n }\n }\n }\n if (scripts.size > 0) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}loaf_scripts`] =\n JSON.stringify(\n Object.fromEntries(\n [...scripts]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_LOAF_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n count: script.count,\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n total_duration: Math.round(script.totalDuration),\n },\n ]),\n ),\n );\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building loaf scripts for INP', error);\n }\n\n return attributes;\n};\n\nconst clsLayoutShiftsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const entries = metric.entries as LayoutShift[];\n\n if (entries.length > 0) {\n const shifts = entries.slice(0, MAX_CLS_LAYOUT_SHIFTS).map((entry) => {\n // web-vitals exposes sources sorted by impact area descending, so the\n // first source is the element that contributed most to the shift.\n const source = entry.sources[0];\n return {\n selector: getSelector(source?.node ?? null),\n startRect: roundRect(source?.previousRect),\n endRect: roundRect(source?.currentRect),\n };\n });\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}clsLayoutShifts`] = JSON.stringify(shifts);\n\n if (entries.length > MAX_CLS_LAYOUT_SHIFTS) {\n attributes[`${prefix}clsLayoutShiftsDroppedCount`] =\n entries.length - MAX_CLS_LAYOUT_SHIFTS;\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building CLS layout shifts', error);\n }\n\n return attributes;\n};\n\nconst inpAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const target = (metric.entries as PerformanceEventTiming[]).find(\n (entry) => entry.target,\n )?.target as Element | null | undefined;\n\n const tagName = target?.tagName?.toLowerCase();\n\n if (tagName) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}element_type`] =\n tagName;\n }\n\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building INP element type attribution', error);\n }\n\n return attributes;\n};\n\nconst ttfbSubPartsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as TTFBAttribution;\n const entry = attribution.navigationEntry as\n | PerformanceNavigationTiming\n | undefined;\n\n if (entry) {\n try {\n const redirect = roundClamp(entry.redirectEnd - entry.redirectStart);\n const domainLookup = roundClamp(\n entry.domainLookupEnd - entry.domainLookupStart,\n );\n const tcpConnection = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.secureConnectionStart - entry.connectStart\n : entry.connectEnd - entry.connectStart,\n );\n const tlsNegotiation = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.connectEnd - entry.secureConnectionStart\n : 0,\n );\n const effectiveResponseStart = Math.max(\n // @ts-expect-error 103 Early hints are not supported in all browsers\n // https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/finalResponseHeadersStart\n entry.finalResponseHeadersStart ?? 0,\n entry.responseStart,\n );\n const serverResponse = roundClamp(\n effectiveResponseStart - entry.requestStart,\n );\n const total = Math.round(entry.responseEnd - entry.startTime);\n const unattributed = roundClamp(\n total -\n redirect -\n domainLookup -\n tcpConnection -\n tlsNegotiation -\n serverResponse,\n );\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}redirect`] = redirect;\n attributes[`${prefix}domainLookup`] = domainLookup;\n attributes[`${prefix}tcpConnection`] = tcpConnection;\n attributes[`${prefix}tlsNegotiation`] = tlsNegotiation;\n attributes[`${prefix}serverResponse`] = serverResponse;\n attributes[`${prefix}unattributed`] = unattributed;\n } catch (error) {\n diag.error('error computing TTFB timing breakdown', error);\n }\n } else {\n diag.debug('TTFB navigationEntry unavailable, skipping timing breakdown');\n }\n\n return attributes;\n};\n\nconst lcpElementAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n const attribution = metric.attribution as LCPAttribution;\n const element = attribution.lcpEntry?.element;\n\n if (element) {\n const elementType = element.tagName.toLowerCase();\n const elementBoundingRect = JSON.stringify(\n roundRect(element.getBoundingClientRect()),\n );\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}elementType`] = elementType;\n attributes[`${prefix}elementBoundingRect`] = elementBoundingRect;\n }\n } catch (error) {\n diag.error('error building LCP element attribution', error);\n }\n\n return attributes;\n};\n\nexport class WebVitalsInstrumentation extends MXLInstrumentationBase {\n private readonly _listeners: WebVitalListeners;\n private readonly _urlDocument: URLDocument;\n private readonly _urlAttribution: boolean;\n private readonly _includeRawAttribution: boolean;\n private readonly _softNavsActive: boolean;\n private readonly _pageManager: PageManager;\n private readonly _attributedPage: Record<\n Metric['name'],\n AttributedPage | undefined\n > = {\n CLS: undefined,\n FCP: undefined,\n INP: undefined,\n LCP: undefined,\n TTFB: undefined,\n };\n private _largestShiftTargetForCLS: string | undefined | null = null;\n private _clsMetricId: string | undefined = undefined;\n private _applyCustomLogRecordData?: (logRecord: LogRecord) => void;\n private _listenersRegistered = false;\n\n public constructor({\n diag,\n perf,\n listeners = WEB_VITALS_ID_TO_LISTENER,\n urlDocument,\n urlAttribution = true,\n includeRawAttribution = true,\n reportSoftNavs = true,\n pageManager,\n applyCustomLogRecordData,\n ...config\n }: WebVitalsInstrumentationArgs = {}) {\n super({\n config,\n diag,\n instrumentationName: 'WebVitalsInstrumentation',\n instrumentationVersion: '1.0.0',\n perf,\n });\n this._listeners = listeners;\n this._urlDocument = urlDocument ?? window.document;\n this._urlAttribution = urlAttribution;\n this._includeRawAttribution = includeRawAttribution;\n this._softNavsActive =\n reportSoftNavs && isEntryTypeSupported('soft-navigation');\n this._pageManager = pageManager ?? page.getPageManager();\n this._applyCustomLogRecordData = applyCustomLogRecordData;\n\n if (this._config.enabled !== false) {\n this.enable();\n }\n }\n\n public override enable(): void {\n if (typeof PerformanceObserver !== 'undefined') {\n super.enable();\n } else {\n this._diag.debug(\n 'PerformanceObserver not supported, web vitals will not be collected',\n );\n }\n }\n\n protected override onDisable(): void {\n // web-vitals library doesn't support removing listeners, so we pause emission\n // https://github.com/GoogleChrome/web-vitals/issues/357#issuecomment-1593439036\n this._diag.debug('WebVitalsInstrumentation disabled, pausing emission');\n }\n\n protected override onEnable(): void {\n // web-vitals library doesn't support removing listeners, so only register once\n if (this._listenersRegistered) {\n this._diag.debug(\n 'WebVitalsInstrumentation listeners already registered, resuming emission',\n );\n return;\n }\n this._listenersRegistered = true;\n\n ALL_WEB_VITALS.forEach((name) => {\n // web-vitals reports a hardcoded dummy value of zero for TTFB on soft navigations. That\n // is not a real measurement and would skew the data, so TTFB listeners keep soft\n // navigation reporting off.\n const reportSoftNavs = name !== 'TTFB' && this._softNavsActive;\n\n if (this._urlAttribution) {\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n if (metric.name === 'CLS') {\n const clsMetric = metric as CLSMetricWithAttribution;\n const target = clsMetric.attribution.largestShiftTarget;\n\n if (this._clsMetricId !== clsMetric.id) {\n // A new metric ID means CLS has reset for a soft navigation.\n this._clsMetricId = clsMetric.id;\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n } else if (this._largestShiftTargetForCLS !== target) {\n // When the largest shift target changes, make sure the attributed page is updated\n // to reflect the page where that shift occurred.\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n }\n } else {\n this._attributedPage[metric.name] = this._currentAttributedPage();\n }\n },\n { reportAllChanges: true, reportSoftNavs },\n );\n }\n\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n this._emitWebVital(metric);\n },\n { reportSoftNavs },\n );\n });\n }\n\n private _currentAttributedPage(): AttributedPage {\n return {\n fullURL: this._urlDocument.URL,\n label: this._pageManager.getPageLabel() ?? undefined,\n pageID: this._pageManager.getCurrentPageId() ?? undefined,\n path: this._pageManager.getCurrentRoute()?.path,\n };\n }\n\n private _getTimeForMetric(metric: MetricWithAttribution): number {\n // For INP use interactionTime, which is the start time of the user's interaction\n if (\n metric.name === 'INP' &&\n metric.attribution.interactionTime !== undefined\n ) {\n return this.perf.epochMillisFromOriginOffset(\n metric.attribution.interactionTime,\n );\n }\n\n // For CLS use the first layout shift's startTime, which is the beginning of\n // the session window. Fall back to largestShiftTime if the entries aren't\n // available for some reason.\n if (metric.name === 'CLS') {\n const windowStart =\n metric.entries.length > 0\n ? Math.min(...metric.entries.map((entry) => entry.startTime))\n : metric.attribution.largestShiftTime;\n\n if (windowStart !== undefined) {\n return this.perf.epochMillisFromOriginOffset(windowStart);\n }\n }\n\n // For TTFB use the \"zero\" time of the current session part\n if (metric.name === 'TTFB') {\n return this.perf.getZeroTime();\n }\n\n // For other metrics, use the startTime of the last entry. In practice, web-vitals does\n // not emit multiple entries for metrics other than CLS. However to future-proof this code,\n // we are assuming that the last entry is the most relevant one.\n const metricStartTime =\n metric.entries[metric.entries.length - 1]?.startTime;\n\n if (metricStartTime !== undefined) {\n return this.perf.epochMillisFromOriginOffset(metricStartTime);\n }\n\n // Fall back to when the metric was reported\n return this.perf.getNowMillis();\n }\n\n private _emitWebVital(metric: MetricWithAttribution): void {\n const attributedPage = this._attributedPage[metric.name];\n // Resolve by the metric's own event time rather than reading the\n // currently active part: web-vitals can defer a metric's report well\n // past when its underlying entry occurred (e.g. INP/CLS finalize on\n // visibilitychange), by which point the part active at report time may\n // not be the one the entry happened in.\n const metricTimeMillis = this._getTimeForMetric(metric);\n const sessionPartId =\n this.userSessionManager.getSessionPartIdAt(metricTimeMillis);\n const notRestoredReasons = getBfcacheNotRestoredReasons();\n const logRecord: LogRecord = {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n [KEY_BROWSER_WEB_VITAL_NAME]: metric.name.toLowerCase(),\n [KEY_BROWSER_WEB_VITAL_VALUE]: metric.value,\n [KEY_BROWSER_WEB_VITAL_DELTA]: metric.delta,\n [KEY_BROWSER_WEB_VITAL_RATING]: metric.rating,\n [KEY_BROWSER_WEB_VITAL_ID]: metric.id,\n [KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE]: metric.navigationType,\n ...(metric.navigationId !== undefined\n ? { [KEY_BROWSER_WEB_VITAL_NAVIGATION_ID]: metric.navigationId }\n : {}),\n ...(metric.navigationInteractionId !== undefined\n ? {\n [KEY_BROWSER_WEB_VITAL_INTERACTION_ID]:\n metric.navigationInteractionId,\n }\n : {}),\n ...(sessionPartId !== null\n ? { [KEY_MXL_SESSION_PART_ID]: sessionPartId }\n : {}),\n ...(notRestoredReasons?.length\n ? {\n [KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS]:\n notRestoredReasons,\n }\n : {}),\n ...(attributedPage\n ? {\n // The navigationURL emitted by web-vitals is authoritative for which URL the metric\n // belongs to, since it was captured when the metric occurred. When soft navigations\n // are not supported, we fall back to the attributed page.\n [KEY_BROWSER_URL_FULL]:\n metric.navigationURL != null &&\n (metric.navigationType === 'soft-navigation' ||\n this._softNavsActive)\n ? metric.navigationURL\n : attributedPage.fullURL,\n [KEY_MXL_PAGE_PATH]: attributedPage.path,\n [KEY_MXL_PAGE_ID]: attributedPage.pageID,\n [KEY_APP_SURFACE_LABEL]: attributedPage.label,\n }\n : {}),\n ...(metric.name === 'INP'\n ? loafScriptsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'INP' ? inpAttribution(metric, this._diag) : {}),\n ...(metric.name === 'TTFB'\n ? ttfbSubPartsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'CLS'\n ? clsLayoutShiftsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'LCP'\n ? lcpElementAttribution(metric, this._diag)\n : {}),\n },\n body:\n this._includeRawAttribution && metric.attribution != null\n ? JSON.stringify(\n Object.fromEntries(\n Object.entries(metric.attribution).filter(([, v]) =>\n isPrimitiveValue(v),\n ),\n ),\n )\n : undefined,\n eventName: WEB_VITAL_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n timestamp: millisToHrTime(metricTimeMillis),\n };\n\n if (this._applyCustomLogRecordData) {\n safeExecuteInTheMiddle(\n () => this._applyCustomLogRecordData?.(logRecord),\n (error) => {\n if (error) {\n this._diag.error('applyCustomLogRecordData hook failed', error);\n }\n },\n true,\n );\n }\n\n this.logger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OAAO,yBACV,GACD,EAAE;IACN,GAAI,kBAAkB,OAClB,GAAG,0BAA0B,eAAe,GAC5C,EAAE;IACN,GAAI,oBAAoB,SACpB,GACG,qDACC,oBACH,GACD,EAAE;IACN,GAAI,iBACA;MAIG,uBACC,OAAO,iBAAiB,SACvB,OAAO,mBAAmB,qBACzB,KAAK,mBACH,OAAO,gBACP,eAAe;MACpB,oBAAoB,eAAe;MACnC,kBAAkB,eAAe;MACjC,wBAAwB,eAAe;KACzC,GACD,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,uBAAuB,QAAQ,KAAK,MAAM,GAC1C,EAAE;IACN,GAAI,OAAO,SAAS,QAAQ,eAAe,QAAQ,KAAK,MAAM,GAAG,EAAE;IACnE,GAAI,OAAO,SAAS,SAChB,wBAAwB,QAAQ,KAAK,MAAM,GAC3C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,2BAA2B,QAAQ,KAAK,MAAM,GAC9C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,sBAAsB,QAAQ,KAAK,MAAM,GACzC,EAAE;IACP;GACD,MACE,KAAK,0BAA0B,OAAO,eAAe,OACjD,KAAK,UACH,OAAO,YACL,OAAO,QAAQ,OAAO,YAAY,CAAC,QAAQ,GAAG,OAC5C,iBAAiB,EAAE,CACpB,CACF,CACF,GACD,KAAA;GACN,WAAW;GACX,gBAAgB,eAAe;GAC/B,WAAW,eAAe,iBAAiB;GAC5C;AAED,MAAI,KAAK,0BACP,8BACQ,KAAK,4BAA4B,UAAU,GAChD,UAAU;AACT,OAAI,MACF,MAAK,MAAM,MAAM,wCAAwC,MAAM;KAGnE,KACD;AAGH,OAAK,OAAO,KAAK,UAAU"}
|
|
1
|
+
{"version":3,"file":"WebVitalsInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.ts"],"sourcesContent":["import type { Attributes, DiagLogger } from '@opentelemetry/api';\nimport type { LogRecord } from '@opentelemetry/api';\nimport { SeverityNumber } from '@opentelemetry/api';\nimport { millisToHrTime } from '@opentelemetry/core';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type {\n CLSMetricWithAttribution,\n INPAttribution,\n LCPAttribution,\n Metric,\n MetricWithAttribution,\n TTFBAttribution,\n} from 'web-vitals/attribution';\nimport type { PageManager } from '../../../api-page/manager/types';\nimport { page } from '../../../api-page/pageAPI';\nimport type { URLDocument } from '../../../common/types';\nimport {\n KEY_APP_SURFACE_LABEL,\n KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS,\n KEY_BROWSER_URL_FULL,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_SESSION_PART_ID,\n KEY_MXL_TYPE,\n MXL_TYPES,\n} from '../../../constants/attributes';\nimport { getBfcacheNotRestoredReasons } from '../../../utils/getBfcacheNotRestoredReasons';\nimport { getSelector } from '../../../utils/getSelector';\nimport { isEntryTypeSupported } from '../../../utils/performanceObserver/performanceObserver';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/MXLInstrumentationBase';\nimport {\n KEY_BROWSER_WEB_VITAL_DELTA,\n KEY_BROWSER_WEB_VITAL_ID,\n KEY_BROWSER_WEB_VITAL_INTERACTION_ID,\n KEY_BROWSER_WEB_VITAL_NAME,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_ID,\n KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE,\n KEY_BROWSER_WEB_VITAL_RATING,\n KEY_BROWSER_WEB_VITAL_VALUE,\n KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX,\n} from './attributes';\nimport {\n ALL_WEB_VITALS,\n MAX_CLS_LAYOUT_SHIFTS,\n MAX_LOAF_SCRIPT_ENTRIES,\n MAX_LOAF_SCRIPT_URL_LENGTH,\n WEB_VITAL_EVENT_NAME,\n loadWebVitalListeners,\n} from './constants';\nimport type { WebVitalListeners, WebVitalsInstrumentationArgs } from './types';\n\ntype AttributedPage = {\n fullURL: string;\n path?: string;\n pageID?: string;\n label?: string;\n};\n\nconst roundClamp = (value: number): number => Math.round(Math.max(0, value));\n\nconst roundRect = (rect?: DOMRectReadOnly) => ({\n x: Math.round(rect?.x ?? 0),\n y: Math.round(rect?.y ?? 0),\n width: Math.round(rect?.width ?? 0),\n height: Math.round(rect?.height ?? 0),\n});\n\nconst isPrimitiveValue = (\n value: unknown,\n): value is string | number | boolean => {\n const type = typeof value;\n return type === 'number' || type === 'string' || type === 'boolean';\n};\n\nconst loafScriptsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as INPAttribution;\n\n try {\n // Suppress LoAF baseline errors\n /* eslint-disable baseline-js/use-baseline */\n if (attribution.longAnimationFrameEntries.length > 0) {\n const scripts = new Map<\n string,\n {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n }\n >();\n for (const entry of attribution.longAnimationFrameEntries) {\n for (const script of entry.scripts) {\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_LOAF_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_LOAF_SCRIPT_URL_LENGTH)}...`;\n }\n const existing = scripts.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n scripts.set(url, {\n count: 1,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n totalDuration: script.duration,\n });\n }\n }\n }\n if (scripts.size > 0) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}loaf_scripts`] =\n JSON.stringify(\n Object.fromEntries(\n [...scripts]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_LOAF_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n count: script.count,\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n total_duration: Math.round(script.totalDuration),\n },\n ]),\n ),\n );\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building loaf scripts for INP', error);\n }\n\n return attributes;\n};\n\nconst clsLayoutShiftsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const entries = metric.entries as LayoutShift[];\n\n if (entries.length > 0) {\n const shifts = entries.slice(0, MAX_CLS_LAYOUT_SHIFTS).map((entry) => {\n // web-vitals exposes sources sorted by impact area descending, so the\n // first source is the element that contributed most to the shift.\n const source = entry.sources[0];\n return {\n selector: getSelector(source?.node ?? null),\n startRect: roundRect(source?.previousRect),\n endRect: roundRect(source?.currentRect),\n };\n });\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}clsLayoutShifts`] = JSON.stringify(shifts);\n\n if (entries.length > MAX_CLS_LAYOUT_SHIFTS) {\n attributes[`${prefix}clsLayoutShiftsDroppedCount`] =\n entries.length - MAX_CLS_LAYOUT_SHIFTS;\n }\n }\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building CLS layout shifts', error);\n }\n\n return attributes;\n};\n\nconst inpAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n /* eslint-disable baseline-js/use-baseline */\n const target = (metric.entries as PerformanceEventTiming[]).find(\n (entry) => entry.target,\n )?.target as Element | null | undefined;\n\n const tagName = target?.tagName?.toLowerCase();\n\n if (tagName) {\n attributes[`${KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX}element_type`] =\n tagName;\n }\n\n /* eslint-enable baseline-js/use-baseline */\n } catch (error) {\n diag.error('error building INP element type attribution', error);\n }\n\n return attributes;\n};\n\nconst ttfbSubPartsAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n const attribution = metric.attribution as TTFBAttribution;\n const entry = attribution.navigationEntry as\n | PerformanceNavigationTiming\n | undefined;\n\n if (entry) {\n try {\n const redirect = roundClamp(entry.redirectEnd - entry.redirectStart);\n const domainLookup = roundClamp(\n entry.domainLookupEnd - entry.domainLookupStart,\n );\n const tcpConnection = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.secureConnectionStart - entry.connectStart\n : entry.connectEnd - entry.connectStart,\n );\n const tlsNegotiation = roundClamp(\n entry.secureConnectionStart > 0\n ? entry.connectEnd - entry.secureConnectionStart\n : 0,\n );\n const effectiveResponseStart = Math.max(\n // @ts-expect-error 103 Early hints are not supported in all browsers\n // https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/finalResponseHeadersStart\n entry.finalResponseHeadersStart ?? 0,\n entry.responseStart,\n );\n const serverResponse = roundClamp(\n effectiveResponseStart - entry.requestStart,\n );\n const total = Math.round(entry.responseEnd - entry.startTime);\n const unattributed = roundClamp(\n total -\n redirect -\n domainLookup -\n tcpConnection -\n tlsNegotiation -\n serverResponse,\n );\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}redirect`] = redirect;\n attributes[`${prefix}domainLookup`] = domainLookup;\n attributes[`${prefix}tcpConnection`] = tcpConnection;\n attributes[`${prefix}tlsNegotiation`] = tlsNegotiation;\n attributes[`${prefix}serverResponse`] = serverResponse;\n attributes[`${prefix}unattributed`] = unattributed;\n } catch (error) {\n diag.error('error computing TTFB timing breakdown', error);\n }\n } else {\n diag.debug('TTFB navigationEntry unavailable, skipping timing breakdown');\n }\n\n return attributes;\n};\n\nconst lcpElementAttribution = (\n metric: MetricWithAttribution,\n diag: DiagLogger,\n): Attributes => {\n const attributes: Attributes = {};\n\n try {\n const attribution = metric.attribution as LCPAttribution;\n const element = attribution.lcpEntry?.element;\n\n if (element) {\n const elementType = element.tagName.toLowerCase();\n const elementBoundingRect = JSON.stringify(\n roundRect(element.getBoundingClientRect()),\n );\n\n const prefix = KEY_MXL_WEB_VITAL_ATTRIBUTION_PREFIX;\n attributes[`${prefix}elementType`] = elementType;\n attributes[`${prefix}elementBoundingRect`] = elementBoundingRect;\n }\n } catch (error) {\n diag.error('error building LCP element attribution', error);\n }\n\n return attributes;\n};\n\nexport class WebVitalsInstrumentation extends MXLInstrumentationBase {\n private _listeners: WebVitalListeners;\n private readonly _urlDocument: URLDocument;\n private readonly _urlAttribution: boolean;\n private readonly _includeRawAttribution: boolean;\n private readonly _softNavsActive: boolean;\n private readonly _pageManager: PageManager;\n private readonly _attributedPage: Record<\n Metric['name'],\n AttributedPage | undefined\n > = {\n CLS: undefined,\n FCP: undefined,\n INP: undefined,\n LCP: undefined,\n TTFB: undefined,\n };\n private _largestShiftTargetForCLS: string | undefined | null = null;\n private _clsMetricId: string | undefined = undefined;\n private _applyCustomLogRecordData?: (logRecord: LogRecord) => void;\n private _listenersRegistered = false;\n\n public constructor({\n diag,\n perf,\n listeners,\n urlDocument,\n urlAttribution = true,\n includeRawAttribution = true,\n reportSoftNavs = true,\n pageManager,\n applyCustomLogRecordData,\n ...config\n }: WebVitalsInstrumentationArgs = {}) {\n super({\n config,\n diag,\n instrumentationName: 'WebVitalsInstrumentation',\n instrumentationVersion: '1.0.0',\n perf,\n });\n this._listeners = listeners ?? ({} as WebVitalListeners);\n this._urlDocument = urlDocument ?? window.document;\n this._urlAttribution = urlAttribution;\n this._includeRawAttribution = includeRawAttribution;\n this._softNavsActive =\n reportSoftNavs && isEntryTypeSupported('soft-navigation');\n this._pageManager = pageManager ?? page.getPageManager();\n this._applyCustomLogRecordData = applyCustomLogRecordData;\n this._listenersProvided = listeners !== undefined;\n }\n\n private readonly _listenersProvided: boolean;\n\n protected override onDisable(): void {\n // web-vitals library doesn't support removing listeners, so we pause emission\n // https://github.com/GoogleChrome/web-vitals/issues/357#issuecomment-1593439036\n this._diag.debug('WebVitalsInstrumentation disabled, pausing emission');\n }\n\n protected override onEnable(): void {\n // web-vitals library doesn't support removing listeners, so only register once\n if (this._listenersRegistered) {\n this._diag.debug(\n 'WebVitalsInstrumentation listeners already registered, resuming emission',\n );\n return;\n }\n this._listenersRegistered = true;\n\n if (this._listenersProvided) {\n this._registerListeners();\n return;\n }\n\n void loadWebVitalListeners().then((listeners) => {\n if (!this._isEnabled) {\n return;\n }\n this._listeners = listeners;\n this._registerListeners();\n });\n }\n\n private _registerListeners(): void {\n ALL_WEB_VITALS.forEach((name) => {\n // web-vitals reports a hardcoded dummy value of zero for TTFB on soft navigations. That\n // is not a real measurement and would skew the data, so TTFB listeners keep soft\n // navigation reporting off.\n const reportSoftNavs = name !== 'TTFB' && this._softNavsActive;\n\n if (this._urlAttribution) {\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n if (metric.name === 'CLS') {\n const clsMetric = metric as CLSMetricWithAttribution;\n const target = clsMetric.attribution.largestShiftTarget;\n\n if (this._clsMetricId !== clsMetric.id) {\n // A new metric ID means CLS has reset for a soft navigation.\n this._clsMetricId = clsMetric.id;\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n } else if (this._largestShiftTargetForCLS !== target) {\n // When the largest shift target changes, make sure the attributed page is updated\n // to reflect the page where that shift occurred.\n this._largestShiftTargetForCLS = target;\n this._attributedPage.CLS = this._currentAttributedPage();\n }\n } else {\n this._attributedPage[metric.name] = this._currentAttributedPage();\n }\n },\n { reportAllChanges: true, reportSoftNavs },\n );\n }\n\n this._listeners[name]?.(\n (metric) => {\n if (!this._isEnabled) {\n return;\n }\n this._emitWebVital(metric);\n },\n { reportSoftNavs },\n );\n });\n }\n\n private _currentAttributedPage(): AttributedPage {\n return {\n fullURL: this._urlDocument.URL,\n label: this._pageManager.getPageLabel() ?? undefined,\n pageID: this._pageManager.getCurrentPageId() ?? undefined,\n path: this._pageManager.getCurrentRoute()?.path,\n };\n }\n\n private _getTimeForMetric(metric: MetricWithAttribution): number {\n // For INP use interactionTime, which is the start time of the user's interaction\n if (\n metric.name === 'INP' &&\n metric.attribution.interactionTime !== undefined\n ) {\n return this.perf.offsetToAbsoluteTime(metric.attribution.interactionTime);\n }\n\n // For CLS use the first layout shift's startTime, which is the beginning of\n // the session window. Fall back to largestShiftTime if the entries aren't\n // available for some reason.\n if (metric.name === 'CLS') {\n const windowStart =\n metric.entries.length > 0\n ? Math.min(...metric.entries.map((entry) => entry.startTime))\n : metric.attribution.largestShiftTime;\n\n if (windowStart !== undefined) {\n return this.perf.offsetToAbsoluteTime(windowStart);\n }\n }\n\n // For TTFB use the \"zero\" time of the current session part\n if (metric.name === 'TTFB') {\n return this.perf.getZeroTime();\n }\n\n // For other metrics, use the startTime of the last entry. In practice, web-vitals does\n // not emit multiple entries for metrics other than CLS. However to future-proof this code,\n // we are assuming that the last entry is the most relevant one.\n const metricStartTime =\n metric.entries[metric.entries.length - 1]?.startTime;\n\n if (metricStartTime !== undefined) {\n return this.perf.offsetToAbsoluteTime(metricStartTime);\n }\n\n // Fall back to when the metric was reported\n return this.perf.getNow();\n }\n\n private _emitWebVital(metric: MetricWithAttribution): void {\n const attributedPage = this._attributedPage[metric.name];\n // Resolve by the metric's own event time rather than reading the\n // currently active part: web-vitals can defer a metric's report well\n // past when its underlying entry occurred (e.g. INP/CLS finalize on\n // visibilitychange), by which point the part active at report time may\n // not be the one the entry happened in.\n const metricTimeMillis = this._getTimeForMetric(metric);\n const sessionPartId =\n this.userSessionManager.getSessionPartIdAt(metricTimeMillis);\n const notRestoredReasons = getBfcacheNotRestoredReasons();\n const logRecord: LogRecord = {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n [KEY_BROWSER_WEB_VITAL_NAME]: metric.name.toLowerCase(),\n [KEY_BROWSER_WEB_VITAL_VALUE]: metric.value,\n [KEY_BROWSER_WEB_VITAL_DELTA]: metric.delta,\n [KEY_BROWSER_WEB_VITAL_RATING]: metric.rating,\n [KEY_BROWSER_WEB_VITAL_ID]: metric.id,\n [KEY_BROWSER_WEB_VITAL_NAVIGATION_TYPE]: metric.navigationType,\n [KEY_BROWSER_WEB_VITAL_NAVIGATION_ID]: metric.navigationId,\n ...(metric.navigationInteractionId !== undefined\n ? {\n [KEY_BROWSER_WEB_VITAL_INTERACTION_ID]:\n metric.navigationInteractionId,\n }\n : {}),\n ...(sessionPartId !== null\n ? { [KEY_MXL_SESSION_PART_ID]: sessionPartId }\n : {}),\n ...(notRestoredReasons?.length\n ? {\n [KEY_BROWSER_NAVIGATION_TIMING_NOT_RESTORED_REASONS]:\n notRestoredReasons,\n }\n : {}),\n ...(attributedPage\n ? {\n // The navigationURL emitted by web-vitals is authoritative for which URL the metric\n // belongs to, since it was captured when the metric occurred. When soft navigations\n // are not supported, we fall back to the attributed page.\n [KEY_BROWSER_URL_FULL]:\n metric.navigationURL != null &&\n (metric.navigationType === 'soft-navigation' ||\n this._softNavsActive)\n ? metric.navigationURL\n : attributedPage.fullURL,\n [KEY_MXL_PAGE_PATH]: attributedPage.path,\n [KEY_MXL_PAGE_ID]: attributedPage.pageID,\n [KEY_APP_SURFACE_LABEL]: attributedPage.label,\n }\n : {}),\n ...(metric.name === 'INP'\n ? loafScriptsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'INP' ? inpAttribution(metric, this._diag) : {}),\n ...(metric.name === 'TTFB'\n ? ttfbSubPartsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'CLS'\n ? clsLayoutShiftsAttribution(metric, this._diag)\n : {}),\n ...(metric.name === 'LCP'\n ? lcpElementAttribution(metric, this._diag)\n : {}),\n },\n body: this._includeRawAttribution\n ? JSON.stringify(\n Object.fromEntries(\n Object.entries(metric.attribution).filter(([, v]) =>\n isPrimitiveValue(v),\n ),\n ),\n )\n : undefined,\n eventName: WEB_VITAL_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n timestamp: millisToHrTime(metricTimeMillis),\n };\n\n if (this._applyCustomLogRecordData) {\n safeExecuteInTheMiddle(\n () => this._applyCustomLogRecordData?.(logRecord),\n (error) => {\n if (error) {\n this._diag.error('applyC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AAO;KAC/C,sCAAsC,OAAO;IAC9C,GAAI,OAAO,4BAA4B,KAAA,IACnC,GACG,uCACC,OAAO,yBACV,GACD,EAAE;IACN,GAAI,kBAAkB,OAClB,GAAG,0BAA0B,eAAe,GAC5C,EAAE;IACN,GAAI,oBAAoB,SACpB,GACG,qDACC,oBACH,GACD,EAAE;IACN,GAAI,iBACA;MAIG,uBACC,OAAO,iBAAiB,SACvB,OAAO,mBAAmB,qBACzB,KAAK,mBACH,OAAO,gBACP,eAAe;MACpB,oBAAoB,eAAe;MACnC,kBAAkB,eAAe;MACjC,wBAAwB,eAAe;KACzC,GACD,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,uBAAuB,QAAQ,KAAK,MAAM,GAC1C,EAAE;IACN,GAAI,OAAO,SAAS,QAAQ,eAAe,QAAQ,KAAK,MAAM,GAAG,EAAE;IACnE,GAAI,OAAO,SAAS,SAChB,wBAAwB,QAAQ,KAAK,MAAM,GAC3C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,2BAA2B,QAAQ,KAAK,MAAM,GAC9C,EAAE;IACN,GAAI,OAAO,SAAS,QAChB,sBAAsB,QAAQ,KAAK,MAAM,GACzC,EAAE;IACP;GACD,MAAM,KAAK,yBACP,KAAK,UACH,OAAO,YACL,OAAO,QAAQ,OAAO,YAAY,CAAC,QAAQ,GAAG,OAC5C,iBAAiB,EAAE,CACpB,CACF,CACF,GACD,KAAA;GACJ,WAAW;GACX,gBAAgB,eAAe;GAC/B,WAAW,eAAe,iBAAiB;GAC5C;AAED,MAAI,KAAK,0BACP,8BACQ,KAAK,4BAA4B,UAAU,GAChD,UAAU;AACT,OAAI,MACF,MAAK,MAAM,MAAM,wCAAwC,MAAM;KAGnE,KACD;AAGH,OAAK,OAAO,KAAK,UAAU"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
let web_vitals_attribution = require("web-vitals/attribution");
|
|
4
2
|
//#region src/instrumentations/web-vitals/WebVitalsInstrumentation/constants.ts
|
|
5
3
|
const WEB_VITAL_EVENT_NAME = "browser.web_vital";
|
|
6
4
|
const MAX_LOAF_SCRIPT_URL_LENGTH = 2048;
|
|
@@ -13,73 +11,23 @@ const ALL_WEB_VITALS = [
|
|
|
13
11
|
"FCP",
|
|
14
12
|
"TTFB"
|
|
15
13
|
];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* a single page load.
|
|
27
|
-
*
|
|
28
|
-
* SPA Note: Since this is cumulative it could be misleading in a SPA, e.g. you might cross the threshold from
|
|
29
|
-
* good -> bad on Page 3 but the largest contributor to your score might have occurred on Page 1
|
|
30
|
-
*/
|
|
31
|
-
CLS: web_vitals_attribution.onCLS,
|
|
32
|
-
/**
|
|
33
|
-
* First Contentful Paint (FCP)
|
|
34
|
-
* https://web.dev/articles/fcp
|
|
35
|
-
*
|
|
36
|
-
* Measures from first hard page load to when the first "content" (text, image, svg elements, etc.) is rendered
|
|
37
|
-
*
|
|
38
|
-
* Only measured once per page load
|
|
39
|
-
*/
|
|
40
|
-
FCP: web_vitals_attribution.onFCP,
|
|
41
|
-
/**
|
|
42
|
-
* Largest Contentful Paint (LCP)
|
|
43
|
-
* https://web.dev/articles/lcp
|
|
44
|
-
*
|
|
45
|
-
* Uses heuristics to try and measure when the "main" content has been rendered on the page. Size is a factor, but
|
|
46
|
-
* certain elements that likely represent backgrounds or splash screens are excluded.
|
|
47
|
-
*
|
|
48
|
-
* As the page loads the element considered the largest could change, once the user interacts with the page these
|
|
49
|
-
* entries stop getting reported and the metric is ready
|
|
50
|
-
*
|
|
51
|
-
* Only measured once per page load
|
|
52
|
-
*/
|
|
53
|
-
LCP: web_vitals_attribution.onLCP,
|
|
54
|
-
/**
|
|
55
|
-
* Interaction to Next Paint (INP)
|
|
56
|
-
* https://web.dev/articles/inp
|
|
57
|
-
*
|
|
58
|
-
* Measures how long it takes from a user interaction until the next paint. The final INP value is the longest
|
|
59
|
-
* interaction observed, ignoring outliers.
|
|
60
|
-
*
|
|
61
|
-
* onINP is always called when the page's visibility state changes to hidden and may be called multiple times for
|
|
62
|
-
* a single page load.
|
|
63
|
-
*
|
|
64
|
-
* Each interaction is not reported even when setting reportAllChanges=true, just when an interaction causes an
|
|
65
|
-
* increase to INP.
|
|
66
|
-
*/
|
|
67
|
-
INP: web_vitals_attribution.onINP,
|
|
68
|
-
/**
|
|
69
|
-
* Time to First Byte (TTFB)
|
|
70
|
-
* https://web.dev/articles/ttfb
|
|
71
|
-
*
|
|
72
|
-
* Measures the time between the request for a resource and when the first byte of a response begins to arrive.
|
|
73
|
-
*/
|
|
74
|
-
TTFB: web_vitals_attribution.onTTFB,
|
|
75
|
-
FID: void 0
|
|
14
|
+
const loadWebVitalListeners = async () => {
|
|
15
|
+
const { onCLS, onFCP, onINP, onLCP, onTTFB } = await import("web-vitals/attribution");
|
|
16
|
+
return {
|
|
17
|
+
CLS: onCLS,
|
|
18
|
+
FCP: onFCP,
|
|
19
|
+
LCP: onLCP,
|
|
20
|
+
INP: onINP,
|
|
21
|
+
TTFB: onTTFB,
|
|
22
|
+
FID: void 0
|
|
23
|
+
};
|
|
76
24
|
};
|
|
77
25
|
//#endregion
|
|
78
26
|
exports.ALL_WEB_VITALS = ALL_WEB_VITALS;
|
|
79
27
|
exports.MAX_CLS_LAYOUT_SHIFTS = MAX_CLS_LAYOUT_SHIFTS;
|
|
80
28
|
exports.MAX_LOAF_SCRIPT_ENTRIES = MAX_LOAF_SCRIPT_ENTRIES;
|
|
81
29
|
exports.MAX_LOAF_SCRIPT_URL_LENGTH = MAX_LOAF_SCRIPT_URL_LENGTH;
|
|
82
|
-
exports.WEB_VITALS_ID_TO_LISTENER = WEB_VITALS_ID_TO_LISTENER;
|
|
83
30
|
exports.WEB_VITAL_EVENT_NAME = WEB_VITAL_EVENT_NAME;
|
|
31
|
+
exports.loadWebVitalListeners = loadWebVitalListeners;
|
|
84
32
|
|
|
85
33
|
//# sourceMappingURL=constants.cjs.map
|