@sentry/browser-utils 10.70.0 → 11.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/htmlTreeAsString.js.map +1 -1
- package/build/cjs/index.js +30 -28
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrumentation/dom.js.map +1 -0
- package/build/cjs/instrumentation/history.js.map +1 -0
- package/build/cjs/instrumentation/location.js.map +1 -0
- package/build/cjs/{metrics/instrument.js → instrumentation/performanceObserver.js} +44 -32
- package/build/cjs/instrumentation/performanceObserver.js.map +1 -0
- package/build/cjs/instrumentation/xhr.js.map +1 -0
- package/build/cjs/{metrics → performance}/elementTiming.js +2 -2
- package/build/cjs/performance/elementTiming.js.map +1 -0
- package/build/cjs/{metrics/browserMetrics.js → performance/entries.js} +43 -262
- package/build/cjs/performance/entries.js.map +1 -0
- package/build/cjs/performance/resourceTiming.js.map +1 -0
- package/build/cjs/performance/userTiming.js +119 -0
- package/build/cjs/performance/userTiming.js.map +1 -0
- package/build/cjs/performance/utils.js +68 -0
- package/build/cjs/performance/utils.js.map +1 -0
- package/build/cjs/{metrics → web-vitals}/inp.js +4 -61
- package/build/cjs/web-vitals/inp.js.map +1 -0
- package/build/cjs/web-vitals/lcp.js +10 -0
- package/build/cjs/web-vitals/lcp.js.map +1 -0
- package/build/cjs/web-vitals/reportEvents.js +31 -0
- package/build/cjs/web-vitals/reportEvents.js.map +1 -0
- package/build/cjs/{metrics/webVitalSpans.js → web-vitals/spans.js} +36 -19
- package/build/cjs/web-vitals/spans.js.map +1 -0
- package/build/cjs/web-vitals/tracking.js +164 -0
- package/build/cjs/web-vitals/tracking.js.map +1 -0
- package/build/cjs/web-vitals/utils.js +99 -0
- package/build/cjs/web-vitals/utils.js.map +1 -0
- package/build/esm/htmlTreeAsString.js.map +1 -1
- package/build/esm/index.js +14 -12
- package/build/esm/index.js.map +1 -1
- package/build/esm/instrumentation/dom.js.map +1 -0
- package/build/esm/instrumentation/history.js.map +1 -0
- package/build/esm/instrumentation/location.js.map +1 -0
- package/build/esm/{metrics/instrument.js → instrumentation/performanceObserver.js} +42 -30
- package/build/esm/instrumentation/performanceObserver.js.map +1 -0
- package/build/esm/instrumentation/xhr.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/{metrics → performance}/elementTiming.js +1 -1
- package/build/esm/performance/elementTiming.js.map +1 -0
- package/build/esm/{metrics/browserMetrics.js → performance/entries.js} +36 -252
- package/build/esm/performance/entries.js.map +1 -0
- package/build/esm/performance/resourceTiming.js.map +1 -0
- package/build/esm/performance/userTiming.js +116 -0
- package/build/esm/performance/userTiming.js.map +1 -0
- package/build/esm/performance/utils.js +61 -0
- package/build/esm/performance/utils.js.map +1 -0
- package/build/esm/{metrics → web-vitals}/inp.js +3 -57
- package/build/esm/web-vitals/inp.js.map +1 -0
- package/build/esm/web-vitals/lcp.js +7 -0
- package/build/esm/web-vitals/lcp.js.map +1 -0
- package/build/esm/web-vitals/reportEvents.js +29 -0
- package/build/esm/web-vitals/reportEvents.js.map +1 -0
- package/build/esm/{metrics/webVitalSpans.js → web-vitals/spans.js} +32 -15
- package/build/esm/web-vitals/spans.js.map +1 -0
- package/build/esm/web-vitals/tracking.js +161 -0
- package/build/esm/web-vitals/tracking.js.map +1 -0
- package/build/esm/web-vitals/utils.js +91 -0
- package/build/esm/web-vitals/utils.js.map +1 -0
- package/build/types/index.d.ts +13 -11
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentation/dom.d.ts.map +1 -0
- package/build/types/instrumentation/history.d.ts.map +1 -0
- package/build/types/instrumentation/location.d.ts.map +1 -0
- package/build/types/{metrics/instrument.d.ts → instrumentation/performanceObserver.d.ts} +3 -3
- package/build/types/instrumentation/performanceObserver.d.ts.map +1 -0
- package/build/types/instrumentation/xhr.d.ts.map +1 -0
- package/build/types/performance/elementTiming.d.ts.map +1 -0
- package/build/types/performance/entries.d.ts +49 -0
- package/build/types/performance/entries.d.ts.map +1 -0
- package/build/types/performance/resourceTiming.d.ts.map +1 -0
- package/build/types/performance/userTiming.d.ts +37 -0
- package/build/types/performance/userTiming.d.ts.map +1 -0
- package/build/types/performance/utils.d.ts +33 -0
- package/build/types/performance/utils.d.ts.map +1 -0
- package/build/types/types.d.ts +1 -1
- package/build/types/{metrics → web-vitals}/inp.d.ts +0 -13
- package/build/types/web-vitals/inp.d.ts.map +1 -0
- package/build/types/web-vitals/lcp.d.ts +6 -0
- package/build/types/web-vitals/lcp.d.ts.map +1 -0
- package/build/types/web-vitals/reportEvents.d.ts +18 -0
- package/build/types/web-vitals/reportEvents.d.ts.map +1 -0
- package/build/types/{metrics/webVitalSpans.d.ts → web-vitals/spans.d.ts} +18 -12
- package/build/types/web-vitals/spans.d.ts.map +1 -0
- package/build/types/web-vitals/tracking.d.ts +46 -0
- package/build/types/web-vitals/tracking.d.ts.map +1 -0
- package/build/types/{metrics/web-vitals/lib/globalListeners.d.ts → web-vitals/utils.d.ts} +16 -1
- package/build/types/web-vitals/utils.d.ts.map +1 -0
- package/package.json +8 -16
- package/build/cjs/instrument/dom.js.map +0 -1
- package/build/cjs/instrument/history.js.map +0 -1
- package/build/cjs/instrument/location.js.map +0 -1
- package/build/cjs/instrument/xhr.js.map +0 -1
- package/build/cjs/metrics/browserMetrics.js.map +0 -1
- package/build/cjs/metrics/cls.js +0 -64
- package/build/cjs/metrics/cls.js.map +0 -1
- package/build/cjs/metrics/elementTiming.js.map +0 -1
- package/build/cjs/metrics/inp.js.map +0 -1
- package/build/cjs/metrics/instrument.js.map +0 -1
- package/build/cjs/metrics/lcp.js +0 -77
- package/build/cjs/metrics/lcp.js.map +0 -1
- package/build/cjs/metrics/resourceTiming.js.map +0 -1
- package/build/cjs/metrics/utils.js +0 -137
- package/build/cjs/metrics/utils.js.map +0 -1
- package/build/cjs/metrics/web-vitals/getCLS.js +0 -46
- package/build/cjs/metrics/web-vitals/getCLS.js.map +0 -1
- package/build/cjs/metrics/web-vitals/getINP.js +0 -60
- package/build/cjs/metrics/web-vitals/getINP.js.map +0 -1
- package/build/cjs/metrics/web-vitals/getLCP.js +0 -62
- package/build/cjs/metrics/web-vitals/getLCP.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/InteractionManager.js +0 -87
- package/build/cjs/metrics/web-vitals/lib/InteractionManager.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/LCPEntryManager.js +0 -11
- package/build/cjs/metrics/web-vitals/lib/LCPEntryManager.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/LayoutShiftManager.js +0 -27
- package/build/cjs/metrics/web-vitals/lib/LayoutShiftManager.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/bindReporter.js +0 -31
- package/build/cjs/metrics/web-vitals/lib/bindReporter.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/generateUniqueID.js +0 -8
- package/build/cjs/metrics/web-vitals/lib/generateUniqueID.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/getActivationStart.js +0 -11
- package/build/cjs/metrics/web-vitals/lib/getActivationStart.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/getNavigationEntry.js +0 -17
- package/build/cjs/metrics/web-vitals/lib/getNavigationEntry.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/getVisibilityWatcher.js +0 -48
- package/build/cjs/metrics/web-vitals/lib/getVisibilityWatcher.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/globalListeners.js +0 -18
- package/build/cjs/metrics/web-vitals/lib/globalListeners.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/initMetric.js +0 -34
- package/build/cjs/metrics/web-vitals/lib/initMetric.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/initUnique.js +0 -16
- package/build/cjs/metrics/web-vitals/lib/initUnique.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/observe.js +0 -20
- package/build/cjs/metrics/web-vitals/lib/observe.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/onHidden.js +0 -17
- package/build/cjs/metrics/web-vitals/lib/onHidden.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js +0 -32
- package/build/cjs/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/runOnce.js +0 -14
- package/build/cjs/metrics/web-vitals/lib/runOnce.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/whenActivated.js +0 -14
- package/build/cjs/metrics/web-vitals/lib/whenActivated.js.map +0 -1
- package/build/cjs/metrics/web-vitals/lib/whenIdleOrHidden.js +0 -24
- package/build/cjs/metrics/web-vitals/lib/whenIdleOrHidden.js.map +0 -1
- package/build/cjs/metrics/web-vitals/onFCP.js +0 -37
- package/build/cjs/metrics/web-vitals/onFCP.js.map +0 -1
- package/build/cjs/metrics/web-vitals/onTTFB.js +0 -35
- package/build/cjs/metrics/web-vitals/onTTFB.js.map +0 -1
- package/build/cjs/metrics/webVitalSpans.js.map +0 -1
- package/build/esm/instrument/dom.js.map +0 -1
- package/build/esm/instrument/history.js.map +0 -1
- package/build/esm/instrument/location.js.map +0 -1
- package/build/esm/instrument/xhr.js.map +0 -1
- package/build/esm/metrics/browserMetrics.js.map +0 -1
- package/build/esm/metrics/cls.js +0 -61
- package/build/esm/metrics/cls.js.map +0 -1
- package/build/esm/metrics/elementTiming.js.map +0 -1
- package/build/esm/metrics/inp.js.map +0 -1
- package/build/esm/metrics/instrument.js.map +0 -1
- package/build/esm/metrics/lcp.js +0 -72
- package/build/esm/metrics/lcp.js.map +0 -1
- package/build/esm/metrics/resourceTiming.js.map +0 -1
- package/build/esm/metrics/utils.js +0 -128
- package/build/esm/metrics/utils.js.map +0 -1
- package/build/esm/metrics/web-vitals/getCLS.js +0 -43
- package/build/esm/metrics/web-vitals/getCLS.js.map +0 -1
- package/build/esm/metrics/web-vitals/getINP.js +0 -57
- package/build/esm/metrics/web-vitals/getINP.js.map +0 -1
- package/build/esm/metrics/web-vitals/getLCP.js +0 -59
- package/build/esm/metrics/web-vitals/getLCP.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/InteractionManager.js +0 -85
- package/build/esm/metrics/web-vitals/lib/InteractionManager.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/LCPEntryManager.js +0 -9
- package/build/esm/metrics/web-vitals/lib/LCPEntryManager.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/LayoutShiftManager.js +0 -25
- package/build/esm/metrics/web-vitals/lib/LayoutShiftManager.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/bindReporter.js +0 -29
- package/build/esm/metrics/web-vitals/lib/bindReporter.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/generateUniqueID.js +0 -6
- package/build/esm/metrics/web-vitals/lib/generateUniqueID.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/getActivationStart.js +0 -9
- package/build/esm/metrics/web-vitals/lib/getActivationStart.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/getNavigationEntry.js +0 -15
- package/build/esm/metrics/web-vitals/lib/getNavigationEntry.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/getVisibilityWatcher.js +0 -46
- package/build/esm/metrics/web-vitals/lib/getVisibilityWatcher.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/globalListeners.js +0 -15
- package/build/esm/metrics/web-vitals/lib/globalListeners.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/initMetric.js +0 -32
- package/build/esm/metrics/web-vitals/lib/initMetric.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/initUnique.js +0 -14
- package/build/esm/metrics/web-vitals/lib/initUnique.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/observe.js +0 -18
- package/build/esm/metrics/web-vitals/lib/observe.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/onHidden.js +0 -15
- package/build/esm/metrics/web-vitals/lib/onHidden.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js +0 -29
- package/build/esm/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/runOnce.js +0 -12
- package/build/esm/metrics/web-vitals/lib/runOnce.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/whenActivated.js +0 -12
- package/build/esm/metrics/web-vitals/lib/whenActivated.js.map +0 -1
- package/build/esm/metrics/web-vitals/lib/whenIdleOrHidden.js +0 -22
- package/build/esm/metrics/web-vitals/lib/whenIdleOrHidden.js.map +0 -1
- package/build/esm/metrics/web-vitals/onFCP.js +0 -34
- package/build/esm/metrics/web-vitals/onFCP.js.map +0 -1
- package/build/esm/metrics/web-vitals/onTTFB.js +0 -32
- package/build/esm/metrics/web-vitals/onTTFB.js.map +0 -1
- package/build/esm/metrics/webVitalSpans.js.map +0 -1
- package/build/types/instrument/dom.d.ts.map +0 -1
- package/build/types/instrument/history.d.ts.map +0 -1
- package/build/types/instrument/location.d.ts.map +0 -1
- package/build/types/instrument/xhr.d.ts.map +0 -1
- package/build/types/metrics/browserMetrics.d.ts +0 -116
- package/build/types/metrics/browserMetrics.d.ts.map +0 -1
- package/build/types/metrics/cls.d.ts +0 -17
- package/build/types/metrics/cls.d.ts.map +0 -1
- package/build/types/metrics/elementTiming.d.ts.map +0 -1
- package/build/types/metrics/inp.d.ts.map +0 -1
- package/build/types/metrics/instrument.d.ts.map +0 -1
- package/build/types/metrics/lcp.d.ts +0 -22
- package/build/types/metrics/lcp.d.ts.map +0 -1
- package/build/types/metrics/resourceTiming.d.ts.map +0 -1
- package/build/types/metrics/utils.d.ts +0 -73
- package/build/types/metrics/utils.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/getCLS.d.ts +0 -26
- package/build/types/metrics/web-vitals/getCLS.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/getINP.d.ts +0 -34
- package/build/types/metrics/web-vitals/getINP.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/getLCP.d.ts +0 -16
- package/build/types/metrics/web-vitals/getLCP.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/InteractionManager.d.ts +0 -37
- package/build/types/metrics/web-vitals/lib/InteractionManager.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/LCPEntryManager.d.ts +0 -5
- package/build/types/metrics/web-vitals/lib/LCPEntryManager.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/LayoutShiftManager.d.ts +0 -7
- package/build/types/metrics/web-vitals/lib/LayoutShiftManager.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/bindReporter.d.ts +0 -7
- package/build/types/metrics/web-vitals/lib/bindReporter.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/generateUniqueID.d.ts +0 -7
- package/build/types/metrics/web-vitals/lib/generateUniqueID.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/getActivationStart.d.ts +0 -2
- package/build/types/metrics/web-vitals/lib/getActivationStart.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/getNavigationEntry.d.ts +0 -2
- package/build/types/metrics/web-vitals/lib/getNavigationEntry.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/getVisibilityWatcher.d.ts +0 -5
- package/build/types/metrics/web-vitals/lib/getVisibilityWatcher.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/globalListeners.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/initMetric.d.ts +0 -21
- package/build/types/metrics/web-vitals/lib/initMetric.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/initUnique.d.ts +0 -7
- package/build/types/metrics/web-vitals/lib/initUnique.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/observe.d.ts +0 -23
- package/build/types/metrics/web-vitals/lib/observe.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/onHidden.d.ts +0 -27
- package/build/types/metrics/web-vitals/lib/onHidden.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.d.ts +0 -15
- package/build/types/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/runOnce.d.ts +0 -2
- package/build/types/metrics/web-vitals/lib/runOnce.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/whenActivated.d.ts +0 -2
- package/build/types/metrics/web-vitals/lib/whenActivated.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/lib/whenIdleOrHidden.d.ts +0 -6
- package/build/types/metrics/web-vitals/lib/whenIdleOrHidden.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/onFCP.d.ts +0 -11
- package/build/types/metrics/web-vitals/onFCP.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/onTTFB.d.ts +0 -20
- package/build/types/metrics/web-vitals/onTTFB.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types/base.d.ts +0 -103
- package/build/types/metrics/web-vitals/types/base.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types/cls.d.ts +0 -58
- package/build/types/metrics/web-vitals/types/cls.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types/fcp.d.ts +0 -47
- package/build/types/metrics/web-vitals/types/fcp.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types/inp.d.ts +0 -150
- package/build/types/metrics/web-vitals/types/inp.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types/lcp.d.ts +0 -74
- package/build/types/metrics/web-vitals/types/lcp.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types/ttfb.d.ts +0 -60
- package/build/types/metrics/web-vitals/types/ttfb.d.ts.map +0 -1
- package/build/types/metrics/web-vitals/types.d.ts +0 -78
- package/build/types/metrics/web-vitals/types.d.ts.map +0 -1
- package/build/types/metrics/webVitalSpans.d.ts.map +0 -1
- package/build/types-ts3.8/debug-build.d.ts +0 -7
- package/build/types-ts3.8/getNativeImplementation.d.ts +0 -69
- package/build/types-ts3.8/htmlTreeAsString.d.ts +0 -11
- package/build/types-ts3.8/index.d.ts +0 -17
- package/build/types-ts3.8/instrument/dom.d.ts +0 -11
- package/build/types-ts3.8/instrument/history.d.ts +0 -15
- package/build/types-ts3.8/instrument/location.d.ts +0 -13
- package/build/types-ts3.8/instrument/xhr.d.ts +0 -14
- package/build/types-ts3.8/is.d.ts +0 -7
- package/build/types-ts3.8/metrics/browserMetrics.d.ts +0 -119
- package/build/types-ts3.8/metrics/cls.d.ts +0 -17
- package/build/types-ts3.8/metrics/elementTiming.d.ts +0 -21
- package/build/types-ts3.8/metrics/inp.d.ts +0 -35
- package/build/types-ts3.8/metrics/instrument.d.ts +0 -121
- package/build/types-ts3.8/metrics/lcp.d.ts +0 -22
- package/build/types-ts3.8/metrics/resourceTiming.d.ts +0 -13
- package/build/types-ts3.8/metrics/utils.d.ts +0 -73
- package/build/types-ts3.8/metrics/web-vitals/getCLS.d.ts +0 -26
- package/build/types-ts3.8/metrics/web-vitals/getINP.d.ts +0 -34
- package/build/types-ts3.8/metrics/web-vitals/getLCP.d.ts +0 -16
- package/build/types-ts3.8/metrics/web-vitals/lib/InteractionManager.d.ts +0 -37
- package/build/types-ts3.8/metrics/web-vitals/lib/LCPEntryManager.d.ts +0 -5
- package/build/types-ts3.8/metrics/web-vitals/lib/LayoutShiftManager.d.ts +0 -7
- package/build/types-ts3.8/metrics/web-vitals/lib/bindReporter.d.ts +0 -7
- package/build/types-ts3.8/metrics/web-vitals/lib/generateUniqueID.d.ts +0 -7
- package/build/types-ts3.8/metrics/web-vitals/lib/getActivationStart.d.ts +0 -2
- package/build/types-ts3.8/metrics/web-vitals/lib/getNavigationEntry.d.ts +0 -2
- package/build/types-ts3.8/metrics/web-vitals/lib/getVisibilityWatcher.d.ts +0 -5
- package/build/types-ts3.8/metrics/web-vitals/lib/globalListeners.d.ts +0 -11
- package/build/types-ts3.8/metrics/web-vitals/lib/initMetric.d.ts +0 -21
- package/build/types-ts3.8/metrics/web-vitals/lib/initUnique.d.ts +0 -7
- package/build/types-ts3.8/metrics/web-vitals/lib/observe.d.ts +0 -23
- package/build/types-ts3.8/metrics/web-vitals/lib/onHidden.d.ts +0 -27
- package/build/types-ts3.8/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.d.ts +0 -15
- package/build/types-ts3.8/metrics/web-vitals/lib/runOnce.d.ts +0 -2
- package/build/types-ts3.8/metrics/web-vitals/lib/whenActivated.d.ts +0 -2
- package/build/types-ts3.8/metrics/web-vitals/lib/whenIdleOrHidden.d.ts +0 -6
- package/build/types-ts3.8/metrics/web-vitals/onFCP.d.ts +0 -11
- package/build/types-ts3.8/metrics/web-vitals/onTTFB.d.ts +0 -20
- package/build/types-ts3.8/metrics/web-vitals/types/base.d.ts +0 -106
- package/build/types-ts3.8/metrics/web-vitals/types/cls.d.ts +0 -58
- package/build/types-ts3.8/metrics/web-vitals/types/fcp.d.ts +0 -47
- package/build/types-ts3.8/metrics/web-vitals/types/inp.d.ts +0 -150
- package/build/types-ts3.8/metrics/web-vitals/types/lcp.d.ts +0 -74
- package/build/types-ts3.8/metrics/web-vitals/types/ttfb.d.ts +0 -60
- package/build/types-ts3.8/metrics/web-vitals/types.d.ts +0 -78
- package/build/types-ts3.8/metrics/webVitalSpans.d.ts +0 -65
- package/build/types-ts3.8/networkUtils.d.ts +0 -28
- package/build/types-ts3.8/types.d.ts +0 -15
- /package/build/cjs/{instrument → instrumentation}/dom.js +0 -0
- /package/build/cjs/{instrument → instrumentation}/history.js +0 -0
- /package/build/cjs/{instrument → instrumentation}/location.js +0 -0
- /package/build/cjs/{instrument → instrumentation}/xhr.js +0 -0
- /package/build/cjs/{metrics → performance}/resourceTiming.js +0 -0
- /package/build/esm/{instrument → instrumentation}/dom.js +0 -0
- /package/build/esm/{instrument → instrumentation}/history.js +0 -0
- /package/build/esm/{instrument → instrumentation}/location.js +0 -0
- /package/build/esm/{instrument → instrumentation}/xhr.js +0 -0
- /package/build/esm/{metrics → performance}/resourceTiming.js +0 -0
- /package/build/types/{instrument → instrumentation}/dom.d.ts +0 -0
- /package/build/types/{instrument → instrumentation}/history.d.ts +0 -0
- /package/build/types/{instrument → instrumentation}/location.d.ts +0 -0
- /package/build/types/{instrument → instrumentation}/xhr.d.ts +0 -0
- /package/build/types/{metrics → performance}/elementTiming.d.ts +0 -0
- /package/build/types/{metrics → performance}/resourceTiming.d.ts +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
|
|
5
|
-
const getNavigationEntry = (checkResponseStart = true) => {
|
|
6
|
-
const navigationEntry = types.WINDOW.performance?.getEntriesByType?.("navigation")[0];
|
|
7
|
-
if (
|
|
8
|
-
// sentry-specific change:
|
|
9
|
-
// We don't want to check for responseStart for our own use of `getNavigationEntry`
|
|
10
|
-
!checkResponseStart || navigationEntry && navigationEntry.responseStart > 0 && navigationEntry.responseStart < performance.now()
|
|
11
|
-
) {
|
|
12
|
-
return navigationEntry;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.getNavigationEntry = getNavigationEntry;
|
|
17
|
-
//# sourceMappingURL=getNavigationEntry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNavigationEntry.js","sources":["../../../../../src/metrics/web-vitals/lib/getNavigationEntry.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../../types';\n\n// sentry-specific change:\n// add optional param to not check for responseStart (see comment below)\nexport const getNavigationEntry = (checkResponseStart = true): PerformanceNavigationTiming | void => {\n const navigationEntry = WINDOW.performance?.getEntriesByType?.('navigation')[0];\n // Check to ensure the `responseStart` property is present and valid.\n // In some cases a zero value is reported by the browser (for\n // privacy/security reasons), and in other cases (bugs) the value is\n // negative or is larger than the current page time. Ignore these cases:\n // - https://github.com/GoogleChrome/web-vitals/issues/137\n // - https://github.com/GoogleChrome/web-vitals/issues/162\n // - https://github.com/GoogleChrome/web-vitals/issues/275\n if (\n // sentry-specific change:\n // We don't want to check for responseStart for our own use of `getNavigationEntry`\n !checkResponseStart ||\n (navigationEntry && navigationEntry.responseStart > 0 && navigationEntry.responseStart < performance.now())\n ) {\n return navigationEntry;\n }\n};\n"],"names":["WINDOW"],"mappings":";;;;AAoBO,MAAM,kBAAA,GAAqB,CAAC,kBAAA,GAAqB,IAAA,KAA6C;AACnG,EAAA,MAAM,kBAAkBA,YAAA,CAAO,WAAA,EAAa,gBAAA,GAAmB,YAAY,EAAE,CAAC,CAAA;AAQ9E,EAAA;AAAA;AAAA;AAAA,IAGE,CAAC,sBACA,eAAA,IAAmB,eAAA,CAAgB,gBAAgB,CAAA,IAAK,eAAA,CAAgB,aAAA,GAAgB,WAAA,CAAY,GAAA;AAAI,IACzG;AACA,IAAA,OAAO,eAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
const getActivationStart = require('./getActivationStart.js');
|
|
5
|
-
const globalListeners = require('./globalListeners.js');
|
|
6
|
-
|
|
7
|
-
let firstHiddenTime = -1;
|
|
8
|
-
const onHiddenFunctions = /* @__PURE__ */ new Set();
|
|
9
|
-
const initHiddenTime = () => {
|
|
10
|
-
return types.WINDOW.document?.visibilityState === "hidden" && !types.WINDOW.document?.prerendering ? 0 : Infinity;
|
|
11
|
-
};
|
|
12
|
-
const onVisibilityUpdate = (event) => {
|
|
13
|
-
if (isPageHidden(event) && firstHiddenTime > -1) {
|
|
14
|
-
if (event.type === "visibilitychange" || event.type === "pagehide") {
|
|
15
|
-
for (const onHiddenFunction of onHiddenFunctions) {
|
|
16
|
-
onHiddenFunction();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (!isFinite(firstHiddenTime)) {
|
|
20
|
-
firstHiddenTime = event.type === "visibilitychange" ? event.timeStamp : 0;
|
|
21
|
-
globalListeners.removePageListener("prerenderingchange", onVisibilityUpdate, true);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const getVisibilityWatcher = () => {
|
|
26
|
-
if (types.WINDOW.document && firstHiddenTime < 0) {
|
|
27
|
-
const activationStart = getActivationStart.getActivationStart();
|
|
28
|
-
const firstVisibilityStateHiddenTime = !types.WINDOW.document.prerendering ? globalThis.performance.getEntriesByType("visibility-state").filter((e) => e.name === "hidden" && e.startTime > activationStart)[0]?.startTime : void 0;
|
|
29
|
-
firstHiddenTime = firstVisibilityStateHiddenTime ?? initHiddenTime();
|
|
30
|
-
globalListeners.addPageListener("visibilitychange", onVisibilityUpdate, true);
|
|
31
|
-
globalListeners.addPageListener("pagehide", onVisibilityUpdate, true);
|
|
32
|
-
globalListeners.addPageListener("prerenderingchange", onVisibilityUpdate, true);
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
get firstHiddenTime() {
|
|
36
|
-
return firstHiddenTime;
|
|
37
|
-
},
|
|
38
|
-
onHidden(cb) {
|
|
39
|
-
onHiddenFunctions.add(cb);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
function isPageHidden(event) {
|
|
44
|
-
return event.type === "pagehide" || types.WINDOW.document?.visibilityState === "hidden";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports.getVisibilityWatcher = getVisibilityWatcher;
|
|
48
|
-
//# sourceMappingURL=getVisibilityWatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getVisibilityWatcher.js","sources":["../../../../../src/metrics/web-vitals/lib/getVisibilityWatcher.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../../types';\nimport { getActivationStart } from './getActivationStart';\nimport { addPageListener, removePageListener } from './globalListeners';\n\nlet firstHiddenTime = -1;\nconst onHiddenFunctions: Set<() => void> = new Set();\n\nconst initHiddenTime = () => {\n // If the document is hidden when this code runs, assume it was always\n // hidden and the page was loaded in the background, with the one exception\n // that visibility state is always 'hidden' during prerendering, so we have\n // to ignore that case until prerendering finishes (see: `prerenderingchange`\n // event logic below).\n return WINDOW.document?.visibilityState === 'hidden' && !WINDOW.document?.prerendering ? 0 : Infinity;\n};\n\nconst onVisibilityUpdate = (event: Event) => {\n // Handle changes to hidden state\n if (isPageHidden(event) && firstHiddenTime > -1) {\n // Sentry-specific change: Also call onHidden callbacks for pagehide events\n // to support older browsers (Safari <14.4) that don't properly fire visibilitychange\n if (event.type === 'visibilitychange' || event.type === 'pagehide') {\n for (const onHiddenFunction of onHiddenFunctions) {\n onHiddenFunction();\n }\n }\n\n // If the document is 'hidden' and no previous hidden timestamp has been\n // set (so is infinity), update it based on the current event data.\n if (!isFinite(firstHiddenTime)) {\n // If the event is a 'visibilitychange' event, it means the page was\n // visible prior to this change, so the event timestamp is the first\n // hidden time.\n // However, if the event is not a 'visibilitychange' event, then it must\n // be a 'prerenderingchange' or 'pagehide' event, and the fact that the document is\n // still 'hidden' from the above check means the tab was activated\n // in a background state and so has always been hidden.\n firstHiddenTime = event.type === 'visibilitychange' ? event.timeStamp : 0;\n\n // We no longer need the `prerenderingchange` event listener now we've\n // set an initial init time so remove that\n // (we'll keep the visibilitychange and pagehide ones for onHiddenFunction above)\n removePageListener('prerenderingchange', onVisibilityUpdate, true);\n }\n }\n};\n\nexport const getVisibilityWatcher = () => {\n if (WINDOW.document && firstHiddenTime < 0) {\n // Check if we have a previous hidden `visibility-state` performance entry.\n const activationStart = getActivationStart();\n const firstVisibilityStateHiddenTime = !WINDOW.document.prerendering\n ? globalThis.performance\n .getEntriesByType('visibility-state')\n .filter(e => e.name === 'hidden' && e.startTime > activationStart)[0]?.startTime\n : undefined;\n\n // Prefer that, but if it's not available and the document is hidden when\n // this code runs, assume it was hidden since navigation start. This isn't\n // a perfect heuristic, but it's the best we can do until the\n // `visibility-state` performance entry becomes available in all browsers.\n firstHiddenTime = firstVisibilityStateHiddenTime ?? initHiddenTime();\n // Listen for visibility changes so we can handle things like bfcache\n // restores and/or prerender without having to examine individual\n // timestamps in detail and also for onHidden function calls.\n addPageListener('visibilitychange', onVisibilityUpdate, true);\n\n // Sentry-specific change: Some browsers have buggy implementations of visibilitychange,\n // so we use pagehide in addition, just to be safe. This is also required for older\n // Safari versions (<14.4) that we still support.\n addPageListener('pagehide', onVisibilityUpdate, true);\n\n // IMPORTANT: when a page is prerendering, its `visibilityState` is\n // 'hidden', so in order to account for cases where this module checks for\n // visibility during prerendering, an additional check after prerendering\n // completes is also required.\n addPageListener('prerenderingchange', onVisibilityUpdate, true);\n }\n\n return {\n get firstHiddenTime() {\n return firstHiddenTime;\n },\n onHidden(cb: () => void) {\n onHiddenFunctions.add(cb);\n },\n };\n};\n\n/**\n * Check if the page is hidden, uses the `pagehide` event for older browsers support that we used to have in `onHidden` function.\n * Some browsers we still support (Safari <14.4) don't fully support `visibilitychange`\n * or have known bugs w.r.t the `visibilitychange` event.\n * // TODO (v11): If we decide to drop support for Safari 14.4, we can use the logic from web-vitals 4.2.4\n */\nfunction isPageHidden(event: Event) {\n return event.type === 'pagehide' || WINDOW.document?.visibilityState === 'hidden';\n}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AA,eAAA,GAAkB,kCAAkC,cAAA,EAAe;AAInE,IAAAG,+BAAA,CAAgB,kBAAA,EAAoB,oBAAoB,IAAI,CAAA;AAK5D,IAAAA,+BAAA,CAAgB,UAAA,EAAY,oBAAoB,IAAI,CAAA;AAMpD,IAAAA,+BAAA,CAAgB,oBAAA,EAAsB,oBAAoB,IAAI,CAAA;AAAA,EAChE;AAEA,EAAA,OAAO;AAAA,IACL,IAAI,eAAA,GAAkB;AACpB,MAAA,OAAO,eAAA;AAAA,IACT,CAAA;AAAA,IACA,SAAS,EAAA,EAAgB;AACvB,MAAA,iBAAA,CAAkB,IAAI,EAAE,CAAA;AAAA,IAC1B;AAAA,GACF;AACF;AAQA,SAAS,aAAa,KAAA,EAAc;AAClC,EAAA,OAAO,KAAA,CAAM,IAAA,KAAS,UAAA,IAAcH,YAAA,CAAO,UAAU,eAAA,KAAoB,QAAA;AAC3E;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
|
|
5
|
-
function addPageListener(type, listener, options) {
|
|
6
|
-
if (types.WINDOW.document) {
|
|
7
|
-
types.WINDOW.addEventListener(type, listener, options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function removePageListener(type, listener, options) {
|
|
11
|
-
if (types.WINDOW.document) {
|
|
12
|
-
types.WINDOW.removeEventListener(type, listener, options);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exports.addPageListener = addPageListener;
|
|
17
|
-
exports.removePageListener = removePageListener;
|
|
18
|
-
//# sourceMappingURL=globalListeners.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globalListeners.js","sources":["../../../../../src/metrics/web-vitals/lib/globalListeners.ts"],"sourcesContent":["import { WINDOW } from '../../../types';\n\n/**\n * web-vitals 5.1.0 switched listeners to be added on the window rather than the document.\n * Instead of having to check for window/document every time we add a listener, we can use this function.\n */\nexport function addPageListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions) {\n if (WINDOW.document) {\n WINDOW.addEventListener(type, listener, options);\n }\n}\n/**\n * web-vitals 5.1.0 switched listeners to be removed from the window rather than the document.\n * Instead of having to check for window/document every time we remove a listener, we can use this function.\n */\nexport function removePageListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions) {\n if (WINDOW.document) {\n WINDOW.removeEventListener(type, listener, options);\n }\n}\n"],"names":["WINDOW"],"mappings":";;;;AAMO,SAAS,eAAA,CAAgB,IAAA,EAAc,QAAA,EAAyB,OAAA,EAA6C;AAClH,EAAA,IAAIA,aAAO,QAAA,EAAU;AACnB,IAAAA,YAAA,CAAO,gBAAA,CAAiB,IAAA,EAAM,QAAA,EAAU,OAAO,CAAA;AAAA,EACjD;AACF;AAKO,SAAS,kBAAA,CAAmB,IAAA,EAAc,QAAA,EAAyB,OAAA,EAA6C;AACrH,EAAA,IAAIA,aAAO,QAAA,EAAU;AACnB,IAAAA,YAAA,CAAO,mBAAA,CAAoB,IAAA,EAAM,QAAA,EAAU,OAAO,CAAA;AAAA,EACpD;AACF;;;;;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
const generateUniqueID = require('./generateUniqueID.js');
|
|
5
|
-
const getActivationStart = require('./getActivationStart.js');
|
|
6
|
-
const getNavigationEntry = require('./getNavigationEntry.js');
|
|
7
|
-
|
|
8
|
-
const initMetric = (name, value = -1) => {
|
|
9
|
-
const navEntry = getNavigationEntry.getNavigationEntry();
|
|
10
|
-
let navigationType = "navigate";
|
|
11
|
-
if (navEntry) {
|
|
12
|
-
if (types.WINDOW.document?.prerendering || getActivationStart.getActivationStart() > 0) {
|
|
13
|
-
navigationType = "prerender";
|
|
14
|
-
} else if (types.WINDOW.document?.wasDiscarded) {
|
|
15
|
-
navigationType = "restore";
|
|
16
|
-
} else if (navEntry.type) {
|
|
17
|
-
navigationType = navEntry.type.replace(/_/g, "-");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const entries = [];
|
|
21
|
-
return {
|
|
22
|
-
name,
|
|
23
|
-
value,
|
|
24
|
-
rating: "good",
|
|
25
|
-
// If needed, will be updated when reported. `const` to keep the type from widening to `string`.
|
|
26
|
-
delta: 0,
|
|
27
|
-
entries,
|
|
28
|
-
id: generateUniqueID.generateUniqueID(),
|
|
29
|
-
navigationType
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.initMetric = initMetric;
|
|
34
|
-
//# sourceMappingURL=initMetric.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initMetric.js","sources":["../../../../../src/metrics/web-vitals/lib/initMetric.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../../types';\nimport type { MetricType } from '../types';\nimport { generateUniqueID } from './generateUniqueID';\nimport { getActivationStart } from './getActivationStart';\nimport { getNavigationEntry } from './getNavigationEntry';\n\nexport const initMetric = <MetricName extends MetricType['name']>(name: MetricName, value: number = -1) => {\n const navEntry = getNavigationEntry();\n let navigationType: MetricType['navigationType'] = 'navigate';\n\n if (navEntry) {\n if (WINDOW.document?.prerendering || getActivationStart() > 0) {\n navigationType = 'prerender';\n } else if (WINDOW.document?.wasDiscarded) {\n navigationType = 'restore';\n } else if (navEntry.type) {\n navigationType = navEntry.type.replace(/_/g, '-') as MetricType['navigationType'];\n }\n }\n\n // Use `entries` type specific for the metric.\n const entries: Extract<MetricType, { name: MetricName }>['entries'] = [];\n\n return {\n name,\n value,\n rating: 'good' as const, // If needed, will be updated when reported. `const` to keep the type from widening to `string`.\n delta: 0,\n entries,\n id: generateUniqueID(),\n navigationType,\n };\n};\n"],"names":["getNavigationEntry","WINDOW","getActivationStart","generateUniqueID"],"mappings":";;;;;;;AAsBO,MAAM,UAAA,GAAa,CAAwC,IAAA,EAAkB,KAAA,GAAgB,EAAA,KAAO;AACzG,EAAA,MAAM,WAAWA,qCAAA,EAAmB;AACpC,EAAA,IAAI,cAAA,GAA+C,UAAA;AAEnD,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,IAAIC,YAAA,CAAO,QAAA,EAAU,YAAA,IAAgBC,qCAAA,KAAuB,CAAA,EAAG;AAC7D,MAAA,cAAA,GAAiB,WAAA;AAAA,IACnB,CAAA,MAAA,IAAWD,YAAA,CAAO,QAAA,EAAU,YAAA,EAAc;AACxC,MAAA,cAAA,GAAiB,SAAA;AAAA,IACnB,CAAA,MAAA,IAAW,SAAS,IAAA,EAAM;AACxB,MAAA,cAAA,GAAiB,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA;AAAA,IAClD;AAAA,EACF;AAGA,EAAA,MAAM,UAAgE,EAAC;AAEvE,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA,EAAQ,MAAA;AAAA;AAAA,IACR,KAAA,EAAO,CAAA;AAAA,IACP,OAAA;AAAA,IACA,IAAIE,iCAAA,EAAiB;AAAA,IACrB;AAAA,GACF;AACF;;;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const instanceMap = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
function initUnique(identityObj, ClassObj) {
|
|
5
|
-
try {
|
|
6
|
-
if (!instanceMap.get(identityObj)) {
|
|
7
|
-
instanceMap.set(identityObj, new ClassObj());
|
|
8
|
-
}
|
|
9
|
-
return instanceMap.get(identityObj);
|
|
10
|
-
} catch (_e) {
|
|
11
|
-
return new ClassObj();
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.initUnique = initUnique;
|
|
16
|
-
//# sourceMappingURL=initUnique.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initUnique.js","sources":["../../../../../src/metrics/web-vitals/lib/initUnique.ts"],"sourcesContent":["/*\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst instanceMap: WeakMap<object, unknown> = new WeakMap();\n\n/**\n * A function that accepts and identity object and a class object and returns\n * either a new instance of that class or an existing instance, if the\n * identity object was previously used.\n */\nexport function initUnique<T>(identityObj: object, ClassObj: new () => T): T {\n try {\n if (!instanceMap.get(identityObj)) {\n instanceMap.set(identityObj, new ClassObj());\n }\n return instanceMap.get(identityObj)! as T;\n } catch (_e) {\n // --- START Sentry-custom code (try/catch wrapping) ---\n // Fix for cases where identityObj is not a valid key for WeakMap (sometimes a problem in Safari)\n // Just return a new instance without caching it in instanceMap\n return new ClassObj();\n }\n // --- END Sentry-custom code ---\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,WAAA,uBAA4C,OAAA,EAAQ;AAOnD,SAAS,UAAA,CAAc,aAAqB,QAAA,EAA0B;AAC3E,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,WAAA,CAAY,GAAA,CAAI,WAAW,CAAA,EAAG;AACjC,MAAA,WAAA,CAAY,GAAA,CAAI,WAAA,EAAa,IAAI,QAAA,EAAU,CAAA;AAAA,IAC7C;AACA,IAAA,OAAO,WAAA,CAAY,IAAI,WAAW,CAAA;AAAA,EACpC,SAAS,EAAA,EAAI;AAIX,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB;AAEF;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const observe = (type, callback, opts = {}) => {
|
|
4
|
-
try {
|
|
5
|
-
if (PerformanceObserver.supportedEntryTypes.includes(type)) {
|
|
6
|
-
const po = new PerformanceObserver((list) => {
|
|
7
|
-
Promise.resolve().then(() => {
|
|
8
|
-
callback(list.getEntries());
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
po.observe({ type, buffered: true, ...opts });
|
|
12
|
-
return po;
|
|
13
|
-
}
|
|
14
|
-
} catch {
|
|
15
|
-
}
|
|
16
|
-
return;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.observe = observe;
|
|
20
|
-
//# sourceMappingURL=observe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observe.js","sources":["../../../../../src/metrics/web-vitals/lib/observe.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ninterface PerformanceEntryMap {\n event: PerformanceEventTiming[];\n 'first-input': PerformanceEventTiming[];\n 'layout-shift': LayoutShift[];\n 'largest-contentful-paint': LargestContentfulPaint[];\n 'long-animation-frame': PerformanceLongAnimationFrameTiming[];\n paint: PerformancePaintTiming[];\n navigation: PerformanceNavigationTiming[];\n resource: PerformanceResourceTiming[];\n // Sentry-specific change:\n // We add longtask as a supported entry type as we use this in\n // our `instrumentPerformanceObserver` function also observes 'longtask'\n // entries.\n longtask: PerformanceEntry[];\n // Sentry-specific change:\n // We add element as a supported entry type for ElementTiming API\n element: PerformanceEntry[];\n}\n\n/**\n * Takes a performance entry type and a callback function, and creates a\n * `PerformanceObserver` instance that will observe the specified entry type\n * with buffering enabled and call the callback _for each entry_.\n *\n * This function also feature-detects entry support and wraps the logic in a\n * try/catch to avoid errors in unsupporting browsers.\n */\nexport const observe = <K extends keyof PerformanceEntryMap>(\n type: K,\n callback: (entries: PerformanceEntryMap[K]) => void,\n opts: PerformanceObserverInit = {},\n): PerformanceObserver | undefined => {\n try {\n if (PerformanceObserver.supportedEntryTypes.includes(type)) {\n const po = new PerformanceObserver(list => {\n // Delay by a microtask to workaround a bug in Safari where the\n // callback is invoked immediately, rather than in a separate task.\n // See: https://github.com/GoogleChrome/web-vitals/issues/277\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n callback(list.getEntries() as PerformanceEntryMap[K]);\n });\n });\n po.observe({ type, buffered: true, ...opts });\n return po;\n }\n } catch {\n // Do nothing.\n }\n return;\n};\n"],"names":[],"mappings":";;AA2CO,MAAM,UAAU,CACrB,IAAA,EACA,QAAA,EACA,IAAA,GAAgC,EAAC,KACG;AACpC,EAAA,IAAI;AACF,IAAA,IAAI,mBAAA,CAAoB,mBAAA,CAAoB,QAAA,CAAS,IAAI,CAAA,EAAG;AAC1D,MAAA,MAAM,EAAA,GAAK,IAAI,mBAAA,CAAoB,CAAA,IAAA,KAAQ;AAKzC,QAAA,OAAA,CAAQ,OAAA,EAAQ,CAAE,IAAA,CAAK,MAAM;AAC3B,UAAA,QAAA,CAAS,IAAA,CAAK,YAAsC,CAAA;AAAA,QACtD,CAAC,CAAA;AAAA,MACH,CAAC,CAAA;AACD,MAAA,EAAA,CAAG,QAAQ,EAAE,IAAA,EAAM,UAAU,IAAA,EAAM,GAAG,MAAM,CAAA;AAC5C,MAAA,OAAO,EAAA;AAAA,IACT;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA;AACF;;;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
const globalListeners = require('./globalListeners.js');
|
|
5
|
-
|
|
6
|
-
const onHidden = (cb) => {
|
|
7
|
-
const onHiddenOrPageHide = (event) => {
|
|
8
|
-
if (event.type === "pagehide" || types.WINDOW.document?.visibilityState === "hidden") {
|
|
9
|
-
cb(event);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
globalListeners.addPageListener("visibilitychange", onHiddenOrPageHide, { capture: true, once: true });
|
|
13
|
-
globalListeners.addPageListener("pagehide", onHiddenOrPageHide, { capture: true, once: true });
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.onHidden = onHidden;
|
|
17
|
-
//# sourceMappingURL=onHidden.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onHidden.js","sources":["../../../../../src/metrics/web-vitals/lib/onHidden.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../../types';\nimport { addPageListener } from './globalListeners';\n\nexport interface OnHiddenCallback {\n (event: Event): void;\n}\n\n/**\n * Sentry-specific change:\n *\n * This function's logic was NOT updated to web-vitals 4.2.4 or 5.x but we continue\n * to use the web-vitals 3.5.2 version due to having stricter browser support.\n *\n * PR with context that made the changes:\n * https://github.com/GoogleChrome/web-vitals/pull/442/files#r1530492402\n *\n * The PR removed listening to the `pagehide` event, in favour of only listening to\n * the `visibilitychange` event. This is \"more correct\" but some browsers we still\n * support (Safari <14.4) don't fully support `visibilitychange` or have known bugs\n * with respect to the `visibilitychange` event.\n *\n * TODO (v11): If we decide to drop support for Safari 14.4, we can use the logic\n * from web-vitals 4.2.4. In this case, we also need to update the integration tests\n * that currently trigger the `pagehide` event to simulate the page being hidden.\n *\n * @param {OnHiddenCallback} cb - Callback to be executed when the page is hidden or unloaded.\n *\n * @deprecated use `whenIdleOrHidden` or `addPageListener('visibilitychange')` instead\n */\nexport const onHidden = (cb: OnHiddenCallback) => {\n const onHiddenOrPageHide = (event: Event) => {\n if (event.type === 'pagehide' || WINDOW.document?.visibilityState === 'hidden') {\n cb(event);\n }\n };\n\n addPageListener('visibilitychange', onHiddenOrPageHide, { capture: true, once: true });\n // Some browsers have buggy implementations of visibilitychange,\n // so we use pagehide in addition, just to be safe.\n addPageListener('pagehide', onHiddenOrPageHide, { capture: true, once: true });\n};\n"],"names":["WINDOW","addPageListener"],"mappings":";;;;;AA6CO,MAAM,QAAA,GAAW,CAAC,EAAA,KAAyB;AAChD,EAAA,MAAM,kBAAA,GAAqB,CAAC,KAAA,KAAiB;AAC3C,IAAA,IAAI,MAAM,IAAA,KAAS,UAAA,IAAcA,YAAA,CAAO,QAAA,EAAU,oBAAoB,QAAA,EAAU;AAC9E,MAAA,EAAA,CAAG,KAAK,CAAA;AAAA,IACV;AAAA,EACF,CAAA;AAEA,EAAAC,+BAAA,CAAgB,oBAAoB,kBAAA,EAAoB,EAAE,SAAS,IAAA,EAAM,IAAA,EAAM,MAAM,CAAA;AAGrF,EAAAA,+BAAA,CAAgB,YAAY,kBAAA,EAAoB,EAAE,SAAS,IAAA,EAAM,IAAA,EAAM,MAAM,CAAA;AAC/E;;;;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const observe = require('../observe.js');
|
|
4
|
-
|
|
5
|
-
let interactionCountEstimate = 0;
|
|
6
|
-
let minKnownInteractionId = Infinity;
|
|
7
|
-
let maxKnownInteractionId = 0;
|
|
8
|
-
const updateEstimate = (entries) => {
|
|
9
|
-
entries.forEach((e) => {
|
|
10
|
-
if (e.interactionId) {
|
|
11
|
-
minKnownInteractionId = Math.min(minKnownInteractionId, e.interactionId);
|
|
12
|
-
maxKnownInteractionId = Math.max(maxKnownInteractionId, e.interactionId);
|
|
13
|
-
interactionCountEstimate = maxKnownInteractionId ? (maxKnownInteractionId - minKnownInteractionId) / 7 + 1 : 0;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
let po;
|
|
18
|
-
const getInteractionCount = () => {
|
|
19
|
-
return po ? interactionCountEstimate : performance.interactionCount || 0;
|
|
20
|
-
};
|
|
21
|
-
const initInteractionCountPolyfill = () => {
|
|
22
|
-
if ("interactionCount" in performance || po) return;
|
|
23
|
-
po = observe.observe("event", updateEstimate, {
|
|
24
|
-
type: "event",
|
|
25
|
-
buffered: true,
|
|
26
|
-
durationThreshold: 0
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.getInteractionCount = getInteractionCount;
|
|
31
|
-
exports.initInteractionCountPolyfill = initInteractionCountPolyfill;
|
|
32
|
-
//# sourceMappingURL=interactionCountPolyfill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactionCountPolyfill.js","sources":["../../../../../../src/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { observe } from '../observe';\n\ndeclare global {\n interface Performance {\n interactionCount: number;\n }\n}\n\nlet interactionCountEstimate = 0;\nlet minKnownInteractionId = Infinity;\nlet maxKnownInteractionId = 0;\n\nconst updateEstimate = (entries: PerformanceEventTiming[]) => {\n entries.forEach(e => {\n if (e.interactionId) {\n minKnownInteractionId = Math.min(minKnownInteractionId, e.interactionId);\n maxKnownInteractionId = Math.max(maxKnownInteractionId, e.interactionId);\n\n interactionCountEstimate = maxKnownInteractionId ? (maxKnownInteractionId - minKnownInteractionId) / 7 + 1 : 0;\n }\n });\n};\n\nlet po: PerformanceObserver | undefined;\n\n/**\n * Returns the `interactionCount` value using the native API (if available)\n * or the polyfill estimate in this module.\n */\nexport const getInteractionCount = (): number => {\n return po ? interactionCountEstimate : performance.interactionCount || 0;\n};\n\n/**\n * Feature detects native support or initializes the polyfill if needed.\n */\nexport const initInteractionCountPolyfill = (): void => {\n if ('interactionCount' in performance || po) return;\n\n po = observe('event', updateEstimate, {\n type: 'event',\n buffered: true,\n durationThreshold: 0,\n } as PerformanceObserverInit);\n};\n"],"names":["observe"],"mappings":";;;;AAwBA,IAAI,wBAAA,GAA2B,CAAA;AAC/B,IAAI,qBAAA,GAAwB,QAAA;AAC5B,IAAI,qBAAA,GAAwB,CAAA;AAE5B,MAAM,cAAA,GAAiB,CAAC,OAAA,KAAsC;AAC5D,EAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA,KAAK;AACnB,IAAA,IAAI,EAAE,aAAA,EAAe;AACnB,MAAA,qBAAA,GAAwB,IAAA,CAAK,GAAA,CAAI,qBAAA,EAAuB,CAAA,CAAE,aAAa,CAAA;AACvE,MAAA,qBAAA,GAAwB,IAAA,CAAK,GAAA,CAAI,qBAAA,EAAuB,CAAA,CAAE,aAAa,CAAA;AAEvE,MAAA,wBAAA,GAA2B,qBAAA,GAAA,CAAyB,qBAAA,GAAwB,qBAAA,IAAyB,CAAA,GAAI,CAAA,GAAI,CAAA;AAAA,IAC/G;AAAA,EACF,CAAC,CAAA;AACH,CAAA;AAEA,IAAI,EAAA;AAMG,MAAM,sBAAsB,MAAc;AAC/C,EAAA,OAAO,EAAA,GAAK,wBAAA,GAA2B,WAAA,CAAY,gBAAA,IAAoB,CAAA;AACzE;AAKO,MAAM,+BAA+B,MAAY;AACtD,EAAA,IAAI,kBAAA,IAAsB,eAAe,EAAA,EAAI;AAE7C,EAAA,EAAA,GAAKA,eAAA,CAAQ,SAAS,cAAA,EAAgB;AAAA,IACpC,IAAA,EAAM,OAAA;AAAA,IACN,QAAA,EAAU,IAAA;AAAA,IACV,iBAAA,EAAmB;AAAA,GACO,CAAA;AAC9B;;;;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const runOnce = (cb) => {
|
|
4
|
-
let called = false;
|
|
5
|
-
return () => {
|
|
6
|
-
if (!called) {
|
|
7
|
-
cb();
|
|
8
|
-
called = true;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.runOnce = runOnce;
|
|
14
|
-
//# sourceMappingURL=runOnce.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runOnce.js","sources":["../../../../../src/metrics/web-vitals/lib/runOnce.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const runOnce = (cb: () => void) => {\n let called = false;\n return () => {\n if (!called) {\n cb();\n called = true;\n }\n };\n};\n"],"names":[],"mappings":";;AAgBO,MAAM,OAAA,GAAU,CAAC,EAAA,KAAmB;AACzC,EAAA,IAAI,MAAA,GAAS,KAAA;AACb,EAAA,OAAO,MAAM;AACX,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,EAAA,EAAG;AACH,MAAA,MAAA,GAAS,IAAA;AAAA,IACX;AAAA,EACF,CAAA;AACF;;;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
|
|
5
|
-
const whenActivated = (callback) => {
|
|
6
|
-
if (types.WINDOW.document?.prerendering) {
|
|
7
|
-
addEventListener("prerenderingchange", () => callback(), true);
|
|
8
|
-
} else {
|
|
9
|
-
callback();
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.whenActivated = whenActivated;
|
|
14
|
-
//# sourceMappingURL=whenActivated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whenActivated.js","sources":["../../../../../src/metrics/web-vitals/lib/whenActivated.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../../types';\n\nexport const whenActivated = (callback: () => void) => {\n if (WINDOW.document?.prerendering) {\n addEventListener('prerenderingchange', () => callback(), true);\n } else {\n callback();\n }\n};\n"],"names":["WINDOW"],"mappings":";;;;AAkBO,MAAM,aAAA,GAAgB,CAAC,QAAA,KAAyB;AACrD,EAAA,IAAIA,YAAA,CAAO,UAAU,YAAA,EAAc;AACjC,IAAA,gBAAA,CAAiB,oBAAA,EAAsB,MAAM,QAAA,EAAS,EAAG,IAAI,CAAA;AAAA,EAC/D,CAAA,MAAO;AACL,IAAA,QAAA,EAAS;AAAA,EACX;AACF;;;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../../types.js');
|
|
4
|
-
const globalListeners = require('./globalListeners.js');
|
|
5
|
-
const runOnce = require('./runOnce.js');
|
|
6
|
-
|
|
7
|
-
const whenIdleOrHidden = (cb) => {
|
|
8
|
-
const rIC = types.WINDOW.requestIdleCallback || types.WINDOW.setTimeout;
|
|
9
|
-
if (types.WINDOW.document?.visibilityState === "hidden") {
|
|
10
|
-
cb();
|
|
11
|
-
} else {
|
|
12
|
-
cb = runOnce.runOnce(cb);
|
|
13
|
-
globalListeners.addPageListener("visibilitychange", cb, { once: true, capture: true });
|
|
14
|
-
globalListeners.addPageListener("pagehide", cb, { once: true, capture: true });
|
|
15
|
-
rIC(() => {
|
|
16
|
-
cb();
|
|
17
|
-
globalListeners.removePageListener("visibilitychange", cb, { capture: true });
|
|
18
|
-
globalListeners.removePageListener("pagehide", cb, { capture: true });
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.whenIdleOrHidden = whenIdleOrHidden;
|
|
24
|
-
//# sourceMappingURL=whenIdleOrHidden.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whenIdleOrHidden.js","sources":["../../../../../src/metrics/web-vitals/lib/whenIdleOrHidden.ts"],"sourcesContent":["/*\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../../types.js';\nimport { addPageListener, removePageListener } from './globalListeners.js';\nimport { runOnce } from './runOnce.js';\n\n/**\n * Runs the passed callback during the next idle period, or immediately\n * if the browser's visibility state is (or becomes) hidden.\n */\nexport const whenIdleOrHidden = (cb: () => void) => {\n const rIC = WINDOW.requestIdleCallback || WINDOW.setTimeout;\n\n // If the document is hidden, run the callback immediately, otherwise\n // race an idle callback with the next `visibilitychange` event.\n if (WINDOW.document?.visibilityState === 'hidden') {\n cb();\n } else {\n // eslint-disable-next-line no-param-reassign\n cb = runOnce(cb);\n addPageListener('visibilitychange', cb, { once: true, capture: true });\n // sentry: we use pagehide instead of directly listening to visibilitychange\n // because some browsers we still support (Safari <14.4) don't fully support\n // `visibilitychange` or have known bugs w.r.t the `visibilitychange` event.\n // TODO(v11): remove this once we drop support for Safari <14.4\n addPageListener('pagehide', cb, { once: true, capture: true });\n rIC(() => {\n cb();\n // Remove the above event listener since no longer required.\n // See: https://github.com/GoogleChrome/web-vitals/issues/622\n removePageListener('visibilitychange', cb, { capture: true });\n // TODO(v11): remove this once we drop support for Safari <14.4\n removePageListener('pagehide', cb, { capture: true });\n });\n }\n};\n"],"names":["WINDOW","runOnce","addPageListener","removePageListener"],"mappings":";;;;;;AAwBO,MAAM,gBAAA,GAAmB,CAAC,EAAA,KAAmB;AAClD,EAAA,MAAM,GAAA,GAAMA,YAAA,CAAO,mBAAA,IAAuBA,YAAA,CAAO,UAAA;AAIjD,EAAA,IAAIA,YAAA,CAAO,QAAA,EAAU,eAAA,KAAoB,QAAA,EAAU;AACjD,IAAA,EAAA,EAAG;AAAA,EACL,CAAA,MAAO;AAEL,IAAA,EAAA,GAAKC,gBAAQ,EAAE,CAAA;AACf,IAAAC,+BAAA,CAAgB,oBAAoB,EAAA,EAAI,EAAE,MAAM,IAAA,EAAM,OAAA,EAAS,MAAM,CAAA;AAKrE,IAAAA,+BAAA,CAAgB,YAAY,EAAA,EAAI,EAAE,MAAM,IAAA,EAAM,OAAA,EAAS,MAAM,CAAA;AAC7D,IAAA,GAAA,CAAI,MAAM;AACR,MAAA,EAAA,EAAG;AAGH,MAAAC,kCAAA,CAAmB,kBAAA,EAAoB,EAAA,EAAI,EAAE,OAAA,EAAS,MAAM,CAAA;AAE5D,MAAAA,kCAAA,CAAmB,UAAA,EAAY,EAAA,EAAI,EAAE,OAAA,EAAS,MAAM,CAAA;AAAA,IACtD,CAAC,CAAA;AAAA,EACH;AACF;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const bindReporter = require('./lib/bindReporter.js');
|
|
4
|
-
const getActivationStart = require('./lib/getActivationStart.js');
|
|
5
|
-
const getVisibilityWatcher = require('./lib/getVisibilityWatcher.js');
|
|
6
|
-
const initMetric = require('./lib/initMetric.js');
|
|
7
|
-
const observe = require('./lib/observe.js');
|
|
8
|
-
const whenActivated = require('./lib/whenActivated.js');
|
|
9
|
-
|
|
10
|
-
const FCPThresholds = [1800, 3e3];
|
|
11
|
-
const onFCP = (onReport, opts = {}) => {
|
|
12
|
-
whenActivated.whenActivated(() => {
|
|
13
|
-
const visibilityWatcher = getVisibilityWatcher.getVisibilityWatcher();
|
|
14
|
-
const metric = initMetric.initMetric("FCP");
|
|
15
|
-
let report;
|
|
16
|
-
const handleEntries = (entries) => {
|
|
17
|
-
for (const entry of entries) {
|
|
18
|
-
if (entry.name === "first-contentful-paint") {
|
|
19
|
-
po.disconnect();
|
|
20
|
-
if (entry.startTime < visibilityWatcher.firstHiddenTime) {
|
|
21
|
-
metric.value = Math.max(entry.startTime - getActivationStart.getActivationStart(), 0);
|
|
22
|
-
metric.entries.push(entry);
|
|
23
|
-
report(true);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const po = observe.observe("paint", handleEntries);
|
|
29
|
-
if (po) {
|
|
30
|
-
report = bindReporter.bindReporter(onReport, metric, FCPThresholds, opts.reportAllChanges);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.FCPThresholds = FCPThresholds;
|
|
36
|
-
exports.onFCP = onFCP;
|
|
37
|
-
//# sourceMappingURL=onFCP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onFCP.js","sources":["../../../../src/metrics/web-vitals/onFCP.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { bindReporter } from './lib/bindReporter';\nimport { getActivationStart } from './lib/getActivationStart';\nimport { getVisibilityWatcher } from './lib/getVisibilityWatcher';\nimport { initMetric } from './lib/initMetric';\nimport { observe } from './lib/observe';\nimport { whenActivated } from './lib/whenActivated';\nimport type { FCPMetric, MetricRatingThresholds, ReportOpts } from './types';\n\n/** Thresholds for FCP. See https://web.dev/articles/fcp#what_is_a_good_fcp_score */\nexport const FCPThresholds: MetricRatingThresholds = [1800, 3000];\n\n/**\n * Calculates the [FCP](https://web.dev/articles/fcp) value for the current page and\n * calls the `callback` function once the value is ready, along with the\n * relevant `paint` performance entry used to determine the value. The reported\n * value is a `DOMHighResTimeStamp`.\n */\nexport const onFCP = (onReport: (metric: FCPMetric) => void, opts: ReportOpts = {}) => {\n whenActivated(() => {\n const visibilityWatcher = getVisibilityWatcher();\n const metric = initMetric('FCP');\n let report: ReturnType<typeof bindReporter>;\n\n const handleEntries = (entries: FCPMetric['entries']) => {\n for (const entry of entries) {\n if (entry.name === 'first-contentful-paint') {\n po!.disconnect();\n\n // Only report if the page wasn't hidden prior to the first paint.\n if (entry.startTime < visibilityWatcher.firstHiddenTime) {\n // The activationStart reference is used because FCP should be\n // relative to page activation rather than navigation start if the\n // page was prerendered. But in cases where `activationStart` occurs\n // after the FCP, this time should be clamped at 0.\n metric.value = Math.max(entry.startTime - getActivationStart(), 0);\n metric.entries.push(entry);\n report(true);\n }\n }\n }\n };\n\n const po = observe('paint', handleEntries);\n\n if (po) {\n report = bindReporter(onReport, metric, FCPThresholds, opts.reportAllChanges);\n }\n });\n};\n"],"names":["whenActivated","getVisibilityWatcher","initMetric","getActivationStart","observe","bindReporter"],"mappings":";;;;;;;;;AAyBO,MAAM,aAAA,GAAwC,CAAC,IAAA,EAAM,GAAI;AAQzD,MAAM,KAAA,GAAQ,CAAC,QAAA,EAAuC,IAAA,GAAmB,EAAC,KAAM;AACrF,EAAAA,2BAAA,CAAc,MAAM;AAClB,IAAA,MAAM,oBAAoBC,yCAAA,EAAqB;AAC/C,IAAA,MAAM,MAAA,GAASC,sBAAW,KAAK,CAAA;AAC/B,IAAA,IAAI,MAAA;AAEJ,IAAA,MAAM,aAAA,GAAgB,CAAC,OAAA,KAAkC;AACvD,MAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC3B,QAAA,IAAI,KAAA,CAAM,SAAS,wBAAA,EAA0B;AAC3C,UAAA,EAAA,CAAI,UAAA,EAAW;AAGf,UAAA,IAAI,KAAA,CAAM,SAAA,GAAY,iBAAA,CAAkB,eAAA,EAAiB;AAKvD,YAAA,MAAA,CAAO,QAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,SAAA,GAAYC,qCAAA,IAAsB,CAAC,CAAA;AACjE,YAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,KAAK,CAAA;AACzB,YAAA,MAAA,CAAO,IAAI,CAAA;AAAA,UACb;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,EAAA,GAAKC,eAAA,CAAQ,OAAA,EAAS,aAAa,CAAA;AAEzC,IAAA,IAAI,EAAA,EAAI;AACN,MAAA,MAAA,GAASC,yBAAA,CAAa,QAAA,EAAU,MAAA,EAAQ,aAAA,EAAe,KAAK,gBAAgB,CAAA;AAAA,IAC9E;AAAA,EACF,CAAC,CAAA;AACH;;;;;"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const types = require('../../types.js');
|
|
4
|
-
const bindReporter = require('./lib/bindReporter.js');
|
|
5
|
-
const getActivationStart = require('./lib/getActivationStart.js');
|
|
6
|
-
const getNavigationEntry = require('./lib/getNavigationEntry.js');
|
|
7
|
-
const initMetric = require('./lib/initMetric.js');
|
|
8
|
-
const whenActivated = require('./lib/whenActivated.js');
|
|
9
|
-
|
|
10
|
-
const TTFBThresholds = [800, 1800];
|
|
11
|
-
const whenReady = (callback) => {
|
|
12
|
-
if (types.WINDOW.document?.prerendering) {
|
|
13
|
-
whenActivated.whenActivated(() => whenReady(callback));
|
|
14
|
-
} else if (types.WINDOW.document?.readyState !== "complete") {
|
|
15
|
-
addEventListener("load", () => whenReady(callback), true);
|
|
16
|
-
} else {
|
|
17
|
-
setTimeout(callback);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const onTTFB = (onReport, opts = {}) => {
|
|
21
|
-
const metric = initMetric.initMetric("TTFB");
|
|
22
|
-
const report = bindReporter.bindReporter(onReport, metric, TTFBThresholds, opts.reportAllChanges);
|
|
23
|
-
whenReady(() => {
|
|
24
|
-
const navigationEntry = getNavigationEntry.getNavigationEntry();
|
|
25
|
-
if (navigationEntry) {
|
|
26
|
-
metric.value = Math.max(navigationEntry.responseStart - getActivationStart.getActivationStart(), 0);
|
|
27
|
-
metric.entries = [navigationEntry];
|
|
28
|
-
report(true);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.TTFBThresholds = TTFBThresholds;
|
|
34
|
-
exports.onTTFB = onTTFB;
|
|
35
|
-
//# sourceMappingURL=onTTFB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onTTFB.js","sources":["../../../../src/metrics/web-vitals/onTTFB.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../types';\nimport { bindReporter } from './lib/bindReporter';\nimport { getActivationStart } from './lib/getActivationStart';\nimport { getNavigationEntry } from './lib/getNavigationEntry';\nimport { initMetric } from './lib/initMetric';\nimport { whenActivated } from './lib/whenActivated';\nimport type { MetricRatingThresholds, ReportOpts, TTFBMetric } from './types';\n\n/** Thresholds for TTFB. See https://web.dev/articles/ttfb#what_is_a_good_ttfb_score */\nexport const TTFBThresholds: MetricRatingThresholds = [800, 1800];\n\n/**\n * Runs in the next task after the page is done loading and/or prerendering.\n * @param callback\n */\nconst whenReady = (callback: () => void) => {\n if (WINDOW.document?.prerendering) {\n whenActivated(() => whenReady(callback));\n } else if (WINDOW.document?.readyState !== 'complete') {\n addEventListener('load', () => whenReady(callback), true);\n } else {\n // Queue a task so the callback runs after `loadEventEnd`.\n setTimeout(callback);\n }\n};\n\n/**\n * Calculates the [TTFB](https://web.dev/articles/ttfb) value for the\n * current page and calls the `callback` function once the page has loaded,\n * along with the relevant `navigation` performance entry used to determine the\n * value. The reported value is a `DOMHighResTimeStamp`.\n *\n * Note, this function waits until after the page is loaded to call `callback`\n * in order to ensure all properties of the `navigation` entry are populated.\n * This is useful if you want to report on other metrics exposed by the\n * [Navigation Timing API](https://w3c.github.io/navigation-timing/). For\n * example, the TTFB metric starts from the page's [time\n * origin](https://www.w3.org/TR/hr-time-2/#sec-time-origin), which means it\n * includes time spent on DNS lookup, connection negotiation, network latency,\n * and server processing time.\n */\nexport const onTTFB = (onReport: (metric: TTFBMetric) => void, opts: ReportOpts = {}) => {\n const metric = initMetric('TTFB');\n const report = bindReporter(onReport, metric, TTFBThresholds, opts.reportAllChanges);\n\n whenReady(() => {\n const navigationEntry = getNavigationEntry();\n\n if (navigationEntry) {\n // The activationStart reference is used because TTFB should be\n // relative to page activation rather than navigation start if the\n // page was prerendered. But in cases where `activationStart` occurs\n // after the first byte is received, this time should be clamped at 0.\n metric.value = Math.max(navigationEntry.responseStart - getActivationStart(), 0);\n\n metric.entries = [navigationEntry];\n report(true);\n }\n });\n};\n"],"names":["WINDOW","whenActivated","initMetric","bindReporter","getNavigationEntry","getActivationStart"],"mappings":";;;;;;;;;AAyBO,MAAM,cAAA,GAAyC,CAAC,GAAA,EAAK,IAAI;AAMhE,MAAM,SAAA,GAAY,CAAC,QAAA,KAAyB;AAC1C,EAAA,IAAIA,YAAA,CAAO,UAAU,YAAA,EAAc;AACjC,IAAAC,2BAAA,CAAc,MAAM,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA,EACzC,CAAA,MAAA,IAAWD,YAAA,CAAO,QAAA,EAAU,UAAA,KAAe,UAAA,EAAY;AACrD,IAAA,gBAAA,CAAiB,MAAA,EAAQ,MAAM,SAAA,CAAU,QAAQ,GAAG,IAAI,CAAA;AAAA,EAC1D,CAAA,MAAO;AAEL,IAAA,UAAA,CAAW,QAAQ,CAAA;AAAA,EACrB;AACF,CAAA;AAiBO,MAAM,MAAA,GAAS,CAAC,QAAA,EAAwC,IAAA,GAAmB,EAAC,KAAM;AACvF,EAAA,MAAM,MAAA,GAASE,sBAAW,MAAM,CAAA;AAChC,EAAA,MAAM,SAASC,yBAAA,CAAa,QAAA,EAAU,MAAA,EAAQ,cAAA,EAAgB,KAAK,gBAAgB,CAAA;AAEnF,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,kBAAkBC,qCAAA,EAAmB;AAE3C,IAAA,IAAI,eAAA,EAAiB;AAKnB,MAAA,MAAA,CAAO,QAAQ,IAAA,CAAK,GAAA,CAAI,gBAAgB,aAAA,GAAgBC,qCAAA,IAAsB,CAAC,CAAA;AAE/E,MAAA,MAAA,CAAO,OAAA,GAAU,CAAC,eAAe,CAAA;AACjC,MAAA,MAAA,CAAO,IAAI,CAAA;AAAA,IACb;AAAA,EACF,CAAC,CAAA;AACH;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webVitalSpans.js","sources":["../../../src/metrics/webVitalSpans.ts"],"sourcesContent":["import type { Client, Span, SpanAttributes } from '@sentry/core';\nimport {\n browserPerformanceTimeOrigin,\n debug,\n getActiveSpan,\n getCurrentScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToStreamedSpanJSON,\n startInactiveSpan,\n timestampInSeconds,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { htmlTreeAsString } from '../htmlTreeAsString';\nimport { WINDOW } from '../types';\nimport { getCachedInteractionContext, INP_ENTRY_MAP, MAX_PLAUSIBLE_INP_DURATION } from './inp';\nimport type { InstrumentationHandlerCallback } from './instrument';\nimport { addClsInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler } from './instrument';\nimport { isValidLcpMetric } from './lcp';\nimport type { WebVitalReportEvent } from './utils';\nimport { getBrowserPerformanceAPI, listenForWebVitalReportEvents, msToSec, supportsWebVital } from './utils';\nimport type { PerformanceEventTiming } from './instrument';\nimport { SENTRY_SEGMENT_NAME, SENTRY_TRANSACTION } from '@sentry/conventions/attributes';\n\n// Locally-defined interfaces to avoid leaking bare global type references into the\n// generated .d.ts. The `declare global` augmentations in web-vitals/types.ts make these\n// available during this package's compilation but are NOT carried to consumers.\n// This mirrors the pattern used for PerformanceEventTiming in instrument.ts.\nexport interface LayoutShift extends PerformanceEntry {\n value: number;\n sources: Array<{ node: Node | null }>;\n hadRecentInput: boolean;\n}\n\nexport interface LargestContentfulPaint extends PerformanceEntry {\n readonly renderTime: DOMHighResTimeStamp;\n readonly loadTime: DOMHighResTimeStamp;\n readonly size: number;\n readonly id: string;\n readonly url: string;\n readonly element: Element | null;\n}\n\ninterface WebVitalSpanOptions {\n name: string;\n op: string;\n origin: string;\n metricName: 'lcp' | 'cls' | 'inp';\n value: number;\n attributes?: SpanAttributes;\n parentSpan?: Span;\n reportEvent?: WebVitalReportEvent;\n startTime: number;\n endTime?: number;\n}\n\n/**\n * Emits a web vital span that flows through the span streaming pipeline.\n */\nexport function _emitWebVitalSpan(options: WebVitalSpanOptions): void {\n const {\n name,\n op,\n origin,\n metricName,\n value,\n attributes: passedAttributes,\n parentSpan,\n reportEvent,\n startTime,\n endTime,\n } = options;\n\n const routeName = getCurrentScope().getScopeData().transactionName;\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,\n [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: 0,\n [`browser.web_vital.${metricName}.value`]: value,\n // oxlint-disable-next-line typescript-eslint/no-deprecated\n [SENTRY_TRANSACTION]: routeName,\n [SENTRY_SEGMENT_NAME]: routeName,\n // Web vital score calculation relies on the user agent\n 'user_agent.original': WINDOW.navigator?.userAgent,\n ...passedAttributes,\n };\n\n if (parentSpan && spanToStreamedSpanJSON(parentSpan).attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'pageload') {\n // for LCP and CLS, we collect the pageload span id as an attribute\n attributes['sentry.pageload.span_id'] = parentSpan.spanContext().spanId;\n }\n\n if (reportEvent) {\n attributes[`browser.web_vital.${metricName}.report_event`] = reportEvent;\n }\n\n const span = startInactiveSpan({\n name,\n attributes,\n startTime,\n // if we have a pageload span, we let the web vital span start as its parent. This ensures that\n // it is not started as a segment span, without having to manually set it to a \"standalone\" v2 span\n // that has `segment: false` but no actual parent span.\n parentSpan: parentSpan,\n });\n\n if (span) {\n span.end(endTime ?? startTime);\n }\n}\n\n/**\n * Tracks LCP as a streamed span.\n */\nexport function trackLcpAsSpan(client: Client): void {\n let lcpValue = 0;\n let lcpEntry: LargestContentfulPaint | undefined;\n\n if (!supportsWebVital('largest-contentful-paint')) {\n return;\n }\n\n const cleanupLcpHandler = addLcpInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1] as LargestContentfulPaint | undefined;\n if (!entry || !isValidLcpMetric(metric.value)) {\n return;\n }\n lcpValue = metric.value;\n lcpEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, (reportEvent, _, pageloadSpan) => {\n _sendLcpSpan(lcpValue, lcpEntry, pageloadSpan, reportEvent);\n cleanupLcpHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendLcpSpan(\n lcpValue: number,\n entry: LargestContentfulPaint | undefined,\n pageloadSpan?: Span,\n reportEvent?: WebVitalReportEvent,\n): void {\n if (!isValidLcpMetric(lcpValue)) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Sending LCP span (${lcpValue})`);\n\n const performanceTimeOrigin = browserPerformanceTimeOrigin() || 0;\n const timeOrigin = msToSec(performanceTimeOrigin);\n const endTime = msToSec(performanceTimeOrigin + (entry?.startTime || 0));\n const name = entry ? htmlTreeAsString(entry.element) : 'Largest contentful paint';\n\n const attributes: SpanAttributes = {};\n\n entry?.element && (attributes['browser.web_vital.lcp.element'] = htmlTreeAsString(entry.element));\n entry?.id && (attributes['browser.web_vital.lcp.id'] = entry.id);\n entry?.url && (attributes['browser.web_vital.lcp.url'] = entry.url);\n entry?.loadTime != null && (attributes['browser.web_vital.lcp.load_time'] = entry.loadTime);\n entry?.renderTime != null && (attributes['browser.web_vital.lcp.render_time'] = entry.renderTime);\n entry?.size != null && (attributes['browser.web_vital.lcp.size'] = entry.size);\n\n _emitWebVitalSpan({\n name,\n op: 'ui.webvital.lcp',\n origin: 'auto.http.browser.lcp',\n metricName: 'lcp',\n value: lcpValue,\n attributes,\n parentSpan: pageloadSpan,\n reportEvent,\n startTime: timeOrigin,\n endTime,\n });\n}\n\n/**\n * Tracks CLS as a streamed span.\n */\nexport function trackClsAsSpan(client: Client): void {\n let clsValue = 0;\n let clsEntry: LayoutShift | undefined;\n\n if (!supportsWebVital('layout-shift')) {\n return;\n }\n\n const cleanupClsHandler = addClsInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1] as LayoutShift | undefined;\n if (!entry) {\n return;\n }\n clsValue = metric.value;\n clsEntry = entry;\n }, true);\n\n listenForWebVitalReportEvents(client, (reportEvent, _, pageloadSpan) => {\n _sendClsSpan(clsValue, clsEntry, pageloadSpan, reportEvent);\n cleanupClsHandler();\n });\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendClsSpan(\n clsValue: number,\n entry: LayoutShift | undefined,\n pageloadSpan?: Span,\n reportEvent?: WebVitalReportEvent,\n): void {\n DEBUG_BUILD && debug.log(`Sending CLS span (${clsValue})`);\n\n const startTime = entry ? msToSec((browserPerformanceTimeOrigin() || 0) + entry.startTime) : timestampInSeconds();\n const name = entry ? htmlTreeAsString(entry.sources[0]?.node) : 'Layout shift';\n\n const attributes: SpanAttributes = {};\n\n if (entry?.sources) {\n entry.sources.forEach((source, index) => {\n attributes[`browser.web_vital.cls.source.${index + 1}`] = htmlTreeAsString(source.node);\n });\n }\n\n _emitWebVitalSpan({\n name,\n op: 'ui.webvital.cls',\n origin: 'auto.http.browser.cls',\n metricName: 'cls',\n value: clsValue,\n attributes,\n parentSpan: pageloadSpan,\n reportEvent,\n startTime,\n });\n}\n\n/**\n * Tracks INP as a streamed span.\n *\n * This mirrors the standalone INP tracking logic (`startTrackingINP`) but emits\n * spans through the streaming pipeline instead of as standalone spans.\n * Requires `registerInpInteractionListener()` to be called separately for\n * cached element names and root spans per interaction.\n */\nexport function trackInpAsSpan(): void {\n const performance = getBrowserPerformanceAPI();\n if (!performance || !browserPerformanceTimeOrigin()) {\n return;\n }\n\n const onInp: InstrumentationHandlerCallback = ({ metric }) => {\n if (metric.value == null) {\n return;\n }\n\n const duration = msToSec(metric.value);\n\n if (duration > MAX_PLAUSIBLE_INP_DURATION) {\n return;\n }\n\n const entry = metric.entries.find(e => e.duration === metric.value && INP_ENTRY_MAP[e.name]);\n\n if (!entry) {\n return;\n }\n\n _sendInpSpan(metric.value, entry);\n };\n\n addInpInstrumentationHandler(onInp);\n}\n\n/**\n * Exported only for testing.\n */\nexport function _sendInpSpan(inpValue: number, entry: PerformanceEventTiming): void {\n DEBUG_BUILD && debug.log(`Sending INP span (${inpValue})`);\n\n const startTime = msToSec((browserPerformanceTimeOrigin() as number) + entry.startTime);\n const duration = msToSec(inpValue);\n const interactionType = INP_ENTRY_MAP[entry.name];\n\n const cachedContext = getCachedInteractionContext(entry.interactionId);\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;\n\n const spanToUse = cachedContext?.span || rootSpan;\n const routeName = spanToUse\n ? spanToStreamedSpanJSON(spanToUse).name\n : getCurrentScope().getScopeData().transactionName;\n const name = cachedContext?.elementName || htmlTreeAsString(entry.target);\n\n _emitWebVitalSpan({\n name,\n op: `ui.interaction.${interactionType}`,\n origin: 'auto.http.browser.inp',\n metricName: 'inp',\n value: inpValue,\n attributes: {\n [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry.duration,\n // oxlint-disable-next-line typescript-eslint/no-deprecated\n [SENTRY_TRANSACTION]: routeName,\n [SENTRY_SEGMENT_NAME]: routeName,\n },\n startTime,\n endTime: startTime + duration,\n parentSpan: spanToUse,\n });\n}\n"],"names":["getCurrentScope","attributes","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME","SENTRY_TRANSACTION","SENTRY_SEGMENT_NAME","WINDOW","spanToStreamedSpanJSON","startInactiveSpan","supportsWebVital","addLcpInstrumentationHandler","isValidLcpMetric","listenForWebVitalReportEvents","DEBUG_BUILD","debug","browserPerformanceTimeOrigin","msToSec","htmlTreeAsString","addClsInstrumentationHandler","timestampInSeconds","getBrowserPerformanceAPI","MAX_PLAUSIBLE_INP_DURATION","INP_ENTRY_MAP","addInpInstrumentationHandler","getCachedInteractionContext","getActiveSpan","getRootSpan"],"mappings":";;;;;;;;;;;;AA6DO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA,EAAY,gBAAA;AAAA,IACZ,UAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,SAAA,GAAYA,oBAAA,EAAgB,CAAE,YAAA,EAAa,CAAE,eAAA;AAEnD,EAAA,MAAMC,YAAA,GAA6B;AAAA,IACjC,CAACC,qCAAgC,GAAG,MAAA;AAAA,IACpC,CAACC,iCAA4B,GAAG,EAAA;AAAA,IAChC,CAACC,sCAAiC,GAAG,CAAA;AAAA,IACrC,CAAC,CAAA,kBAAA,EAAqB,UAAU,CAAA,MAAA,CAAQ,GAAG,KAAA;AA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AAA,IAAekB,iCAAA,CAAiB,MAAM,MAAM,CAAA;AAExE,EAAA,iBAAA,CAAkB;AAAA,IAChB,IAAA;AAAA,IACA,EAAA,EAAI,kBAAkB,eAAe,CAAA,CAAA;AAAA,IACrC,MAAA,EAAQ,uBAAA;AAAA,IACR,UAAA,EAAY,KAAA;AAAA,IACZ,KAAA,EAAO,QAAA;AAAA,IACP,UAAA,EAAY;AAAA,MACV,CAACd,sCAAiC,GAAG,KAAA,CAAM,QAAA;AAAA;AAAA,MAE3C,CAACC,6BAAkB,GAAG,SAAA;AAAA,MACtB,CAACC,8BAAmB,GAAG;AAAA,KACzB;AAAA,IACA,SAAA;AAAA,IACA,SAAS,SAAA,GAAY,QAAA;AAAA,IACrB,UAAA,EAAY;AAAA,GACb,CAAA;AACH;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sources":["../../../src/instrument/dom.ts"],"sourcesContent":["import type { HandlerDataDom } from '@sentry/core';\nimport { addHandler, addNonEnumerableProperty, fill, maybeInstrument, triggerHandlers, uuid4 } from '@sentry/core';\nimport { WINDOW } from '../types';\n\ntype SentryWrappedTarget = HTMLElement & { _sentryId?: string };\n\ntype AddEventListener = (\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n) => void;\ntype RemoveEventListener = (\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n) => void;\n\ntype InstrumentedElement = Element & {\n __sentry_instrumentation_handlers__?: {\n [key in 'click' | 'keypress']?: {\n handler?: unknown;\n /** The number of custom listeners attached to this element */\n refCount: number;\n };\n };\n};\n\nconst DEBOUNCE_DURATION = 1000;\n\nlet debounceTimerID: number | undefined;\nlet lastCapturedEventType: string | undefined;\nlet lastCapturedEventTargetId: string | undefined;\n\n/**\n * Add an instrumentation handler for when a click or a keypress happens.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addClickKeypressInstrumentationHandler(handler: (data: HandlerDataDom) => void): void {\n const type = 'dom';\n addHandler(type, handler);\n maybeInstrument(type, instrumentDOM);\n}\n\n/** Exported for tests only. */\nexport function instrumentDOM(): void {\n if (!WINDOW.document) {\n return;\n }\n\n // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom\n // handlers. (Normally we have only one, which captures a breadcrumb for each click or keypress.) Do this before\n // we instrument `addEventListener` so that we don't end up attaching this handler twice.\n const triggerDOMHandler = triggerHandlers.bind(null, 'dom');\n const globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);\n WINDOW.document.addEventListener('click', globalDOMEventHandler, false);\n WINDOW.document.addEventListener('keypress', globalDOMEventHandler, false);\n\n // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled\n // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That\n // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler\n // could potentially prevent the event from bubbling up to our global listeners. This way, our handler are still\n // guaranteed to fire at least once.)\n ['EventTarget', 'Node'].forEach((target: string) => {\n const globalObject = WINDOW as unknown as Record<string, { prototype?: object }>;\n const proto = globalObject[target]?.prototype;\n\n // eslint-disable-next-line no-prototype-builtins\n if (!proto?.hasOwnProperty?.('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (originalAddEventListener: AddEventListener): AddEventListener {\n return function (this: InstrumentedElement, type, listener, options): AddEventListener {\n if (type === 'click' || type == 'keypress') {\n try {\n const handlers = (this.__sentry_instrumentation_handlers__ =\n this.__sentry_instrumentation_handlers__ || {});\n const handlerForType = (handlers[type] = handlers[type] || { refCount: 0 });\n\n if (!handlerForType.handler) {\n const handler = makeDOMEventHandler(triggerDOMHandler);\n handlerForType.handler = handler;\n originalAddEventListener.call(this, type, handler, options);\n }\n\n handlerForType.refCount++;\n } catch {\n // Accessing dom properties is always fragile.\n // Also allows us to skip `addEventListeners` calls with no proper `this` context.\n }\n }\n\n return originalAddEventListener.call(this, type, listener, options);\n };\n });\n\n fill(\n proto,\n 'removeEventListener',\n function (originalRemoveEventListener: RemoveEventListener): RemoveEventListener {\n return function (this: InstrumentedElement, type, listener, options): () => void {\n if (type === 'click' || type == 'keypress') {\n try {\n const handlers = this.__sentry_instrumentation_handlers__ || {};\n const handlerForType = handlers[type];\n\n if (handlerForType) {\n handlerForType.refCount--;\n // If there are no longer any custom handlers of the current type on this element, we can remove ours, too.\n if (handlerForType.refCount <= 0) {\n originalRemoveEventListener.call(this, type, handlerForType.handler, options);\n handlerForType.handler = undefined;\n delete handlers[type]; // eslint-disable-line @typescript-eslint/no-dynamic-delete\n }\n\n // If there are no longer any custom handlers of any type on this element, cleanup everything.\n if (Object.keys(handlers).length === 0) {\n delete this.__sentry_instrumentation_handlers__;\n }\n }\n } catch {\n // Accessing dom properties is always fragile.\n // Also allows us to skip `addEventListeners` calls with no proper `this` context.\n }\n }\n\n return originalRemoveEventListener.call(this, type, listener, options);\n };\n },\n );\n });\n}\n\n/**\n * Check whether the event is similar to the last captured one. For example, two click events on the same button.\n */\nfunction isSimilarToLastCapturedEvent(event: Event): boolean {\n // If both events have different type, then user definitely performed two separate actions. e.g. click + keypress.\n if (event.type !== lastCapturedEventType) {\n return false;\n }\n\n try {\n // If both events have the same type, it's still possible that actions were performed on different targets.\n // e.g. 2 clicks on different buttons.\n if (!event.target || (event.target as SentryWrappedTarget)._sentryId !== lastCapturedEventTargetId) {\n return false;\n }\n } catch {\n // just accessing `target` property can throw an exception in some rare circumstances\n // see: https://github.com/getsentry/sentry-javascript/issues/838\n }\n\n // If both events have the same type _and_ same `target` (an element which triggered an event, _not necessarily_\n // to which an event listener was attached), we treat them as the same action, as we want to capture\n // only one breadcrumb. e.g. multiple clicks on the same button, or typing inside a user input box.\n return true;\n}\n\n/**\n * Decide whether an event should be captured.\n * @param event event to be captured\n */\nfunction shouldSkipDOMEvent(eventType: string, target: SentryWrappedTarget | null): boolean {\n // We are only interested in filtering `keypress` events for now.\n if (eventType !== 'keypress') {\n return false;\n }\n\n if (!target?.tagName) {\n return true;\n }\n\n // Only consider keypress events on actual input elements. This will disregard keypresses targeting body\n // e.g.tabbing through elements, hotkeys, etc.\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Wraps addEventListener to capture UI breadcrumbs\n */\nfunction makeDOMEventHandler(\n handler: (data: HandlerDataDom) => void,\n globalListener: boolean = false,\n): (event: Event) => void {\n return (event: Event & { _sentryCaptured?: true }): void => {\n // It's possible this handler might trigger multiple times for the same\n // event (e.g. event propagation through node ancestors).\n // Ignore if we've already captured that event.\n if (!event || event['_sentryCaptured']) {\n return;\n }\n\n const target = getEventTarget(event);\n\n // We always want to skip _some_ events.\n if (shouldSkipDOMEvent(event.type, target)) {\n return;\n }\n\n // Mark event as \"seen\"\n addNonEnumerableProperty(event, '_sentryCaptured', true);\n\n if (target && !target._sentryId) {\n // Add UUID to event target so we can identify if\n addNonEnumerableProperty(target, '_sentryId', uuid4());\n }\n\n const name = event.type === 'keypress' ? 'input' : event.type;\n\n // If there is no last captured event, it means that we can safely capture the new event and store it for future comparisons.\n // If there is a last captured event, see if the new event is different enough to treat it as a unique one.\n // If that's the case, emit the previous event and store locally the newly-captured DOM event.\n if (!isSimilarToLastCapturedEvent(event)) {\n const handlerData: HandlerDataDom = { event, name, global: globalListener };\n handler(handlerData);\n lastCapturedEventType = event.type;\n lastCapturedEventTargetId = target ? target._sentryId : undefined;\n }\n\n // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.\n clearTimeout(debounceTimerID);\n debounceTimerID = WINDOW.setTimeout(() => {\n lastCapturedEventTargetId = undefined;\n lastCapturedEventType = undefined;\n }, DEBOUNCE_DURATION);\n };\n}\n\nfunction getEventTarget(event: Event): SentryWrappedTarget | null {\n try {\n return event.target as SentryWrappedTarget | null;\n } catch {\n // just accessing `target` property can throw an exception in some rare circumstances\n // see: https://github.com/getsentry/sentry-javascript/issues/838\n return null;\n }\n}\n"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ourcesContent":["import type { HandlerDataHistory } from '@sentry/core';\nimport { addHandler, fill, maybeInstrument, supportsHistory, triggerHandlers } from '@sentry/core';\nimport { WINDOW } from '../types';\n\nlet lastHref: string | undefined;\n\n/**\n * Add an instrumentation handler for when a fetch request happens.\n * The handler function is called once when the request starts and once when it ends,\n * which can be identified by checking if it has an `endTimestamp`.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addHistoryInstrumentationHandler(handler: (data: HandlerDataHistory) => void): void {\n const type = 'history';\n addHandler(type, handler);\n maybeInstrument(type, instrumentHistory);\n}\n\n/**\n * Exported just for testing\n */\nexport function instrumentHistory(): void {\n // The `popstate` event may also be triggered on `pushState`, but it may not always reliably be emitted by the browser\n // Which is why we also monkey-patch methods below, in addition to this\n WINDOW.addEventListener('popstate', () => {\n const to = WINDOW.location.href;\n // keep track of the current URL state, as we always receive only the updated state\n const from = lastHref;\n lastHref = to;\n\n if (from === to) {\n return;\n }\n\n const handlerData = { from, to } satisfies HandlerDataHistory;\n triggerHandlers('history', handlerData);\n });\n\n // Just guard against this not being available, in weird environments\n if (!supportsHistory()) {\n return;\n }\n\n function historyReplacementFunction(originalHistoryFunction: () => void): () => void {\n return function (this: History, ...args: unknown[]): void {\n const url = args.length > 2 ? args[2] : undefined;\n if (url) {\n const from = lastHref;\n\n // Ensure the URL is absolute\n // this can be either a path, then it is relative to the current origin\n // or a full URL of the current origin - other origins are not allowed\n // See: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState#url\n // coerce to string (this is what pushState does)\n const to = getAbsoluteUrl(String(url));\n\n // keep track of the current URL state, as we always receive only the updated state\n lastHref = to;\n\n if (from === to) {\n return originalHistoryFunction.apply(this, args);\n }\n\n const handlerData = { from, to } satisfies HandlerDataHistory;\n triggerHandlers('history', handlerData);\n }\n return originalHistoryFunction.apply(this, args);\n };\n }\n\n fill(WINDOW.history, 'pushState', historyReplacementFunction);\n fill(WINDOW.history, 'replaceState', historyReplacementFunction);\n}\n\nfunction getAbsoluteUrl(urlOrPath: string): string {\n try {\n const url = new URL(urlOrPath, WINDOW.location.origin);\n return url.toString();\n } catch {\n // fallback, just do nothing\n return urlOrPath;\n }\n}\n"],"names":[],"mappings":";;;AAIA,IAAI,QAAA;AAUG,SAAS,iCAAiC,OAAA,EAAmD;AAClG,EAAA,MAAM,IAAA,GAAO,SAAA;AACb,EAAA,UAAA,CAAW,MAAM,OAAO,CAAA;AACxB,EAAA,eAAA,CAAgB,MAAM,iBAAiB,CAAA;AACzC;AAKO,SAAS,iBAAA,GAA0B;AAGxC,EAAA,MAAA,CAAO,gBAAA,CAAiB,YAAY,MAAM;AACxC,IAAA,MAAM,EAAA,GAAK,OAAO,QAAA,CAAS,IAAA;AAE3B,IAAA,MAAM,IAAA,GAAO,QAAA;AACb,IAAA,QAAA,GAAW,EAAA;AAEX,IAAA,IAAI,SAAS,EAAA,EAAI;AACf,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,WAAA,GAAc,EAAE,IAAA,EAAM,EAAA,EAAG;AAC/B,IAAA,eAAA,CAAgB,WAAW,WAAW,CAAA;AAAA,EACxC,CAAC,CAAA;AAGD,EAAA,IAAI,CAAC,iBAAgB,EAAG;AACtB,IAAA;AAAA,EACF;AAEA,EAAA,SAAS,2BAA2B,uBAAA,EAAiD;AACnF,IAAA,OAAO,YAA4B,IAAA,EAAuB;AACxD,MAAA,MAAM,MAAM,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,IAAA,CAAK,CAAC,CAAA,GAAI,MAAA;AACxC,MAAA,IAAI,GAAA,EAAK;AACP,QAAA,MAAM,IAAA,GAAO,QAAA;AAOb,QAAA,MAAM,EAAA,GAAK,cAAA,CAAe,MAAA,CAAO,GAAG,CAAC,CAAA;AAGrC,QAAA,QAAA,GAAW,EAAA;AAEX,QAAA,IAAI,SAAS,EAAA,EAAI;AACf,UAAA,OAAO,uBAAA,CAAwB,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAAA,QACjD;AAEA,QAAA,MAAM,WAAA,GAAc,EAAE,IAAA,EAAM,EAAA,EAAG;AAC/B,QAAA,eAAA,CAAgB,WAAW,WAAW,CAAA;AAAA,MACxC;AACA,MAAA,OAAO,uBAAA,CAAwB,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAAA,IACjD,CAAA;AAAA,EACF;AAEA,EAAA,IAAA,CAAK,MAAA,CAAO,OAAA,EAAS,WAAA,EAAa,0BAA0B,CAAA;AAC5D,EAAA,IAAA,CAAK,MAAA,CAAO,OAAA,EAAS,cAAA,EAAgB,0BAA0B,CAAA;AACjE;AAEA,SAAS,eAAe,SAAA,EAA2B;AACjD,EAAA,IAAI;AACF,IAAA,MAAM,MAAM,IAAI,GAAA,CAAI,SAAA,EAAW,MAAA,CAAO,SAAS,MAAM,CAAA;AACrD,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,SAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"location.js","sources":["../../../src/instrument/location.ts"],"sourcesContent":["import { WINDOW } from '../types';\n\n/**\n *\n * @param urlOrPath - The URL or path to convert to an absolute URL.\n *\n * @return the absolute URL when handed a relative URL path, by\n * combining the current `window.location.origin` with param urlOrPath.\n *\n * If param urlOrPath is already a full or an invalid URL,\n * or URL determination fails, the original param urlOrPath is returned unchanged.\n *\n */\nexport function getAbsoluteUrl(urlOrPath: string): string {\n try {\n const url = new URL(urlOrPath, WINDOW.location.origin);\n return url.toString();\n } catch {\n // fallback, just do nothing\n return urlOrPath;\n }\n}\n"],"names":[],"mappings":";;AAaO,SAAS,eAAe,SAAA,EAA2B;AACxD,EAAA,IAAI;AACF,IAAA,MAAM,MAAM,IAAI,GAAA,CAAI,SAAA,EAAW,MAAA,CAAO,SAAS,MAAM,CAAA;AACrD,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,SAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xhr.js","sources":["../../../src/instrument/xhr.ts"],"sourcesContent":["import type { HandlerDataXhr, SentryWrappedXMLHttpRequest } from '@sentry/core';\nimport { addHandler, isString, maybeInstrument, timestampInSeconds, triggerHandlers } from '@sentry/core';\nimport { WINDOW } from '../types';\n\nexport const SENTRY_XHR_DATA_KEY = '__sentry_xhr_v3__';\n\ntype WindowWithXhr = Window & { XMLHttpRequest?: typeof XMLHttpRequest };\n\n/**\n * Add an instrumentation handler for when an XHR request happens.\n * The handler function is called once when the request starts and once when it ends,\n * which can be identified by checking if it has an `endTimestamp`.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nexport function addXhrInstrumentationHandler(handler: (data: HandlerDataXhr) => void): void {\n const type = 'xhr';\n addHandler(type, handler);\n maybeInstrument(type, instrumentXHR);\n}\n\n/** Exported only for tests. */\nexport function instrumentXHR(): void {\n if (!(WINDOW as WindowWithXhr).XMLHttpRequest) {\n return;\n }\n\n const xhrproto = XMLHttpRequest.prototype;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n xhrproto.open = new Proxy(xhrproto.open, {\n apply(\n originalOpen,\n xhrOpenThisArg: XMLHttpRequest & SentryWrappedXMLHttpRequest,\n xhrOpenArgArray:\n | [method: string, url: string | URL]\n | [method: string, url: string | URL, async: boolean, username?: string | null, password?: string | null],\n ) {\n // NOTE: If you are a Sentry user, and you are seeing this stack frame,\n // it means the error, that was caused by your XHR call did not\n // have a stack trace. If you are using HttpClient integration,\n // this is the expected behavior, as we are using this virtual error to capture\n // the location of your XHR call, and group your HttpClient events accordingly.\n const virtualError = new Error();\n\n const startTimestamp = timestampInSeconds() * 1000;\n\n // open() should always be called with two or more arguments\n // But to be on the safe side, we actually validate this and bail out if we don't have a method & url\n const method = isString(xhrOpenArgArray[0]) ? xhrOpenArgArray[0].toUpperCase() : undefined;\n const url = parseXhrUrlArg(xhrOpenArgArray[1]);\n\n if (!method || !url) {\n return originalOpen.apply(xhrOpenThisArg, xhrOpenArgArray);\n }\n\n xhrOpenThisArg[SENTRY_XHR_DATA_KEY] = {\n method,\n url,\n request_headers: {},\n };\n\n // if Sentry key appears in URL, don't capture it as a request\n if (method === 'POST' && url.match(/sentry_key/)) {\n xhrOpenThisArg.__sentry_own_request__ = true;\n }\n\n const onreadystatechangeHandler: () => void = () => {\n // For whatever reason, this is not the same instance here as from the outer method\n const xhrInfo = xhrOpenThisArg[SENTRY_XHR_DATA_KEY];\n\n if (!xhrInfo) {\n return;\n }\n\n if (xhrOpenThisArg.readyState === 4) {\n try {\n // touching statusCode in some platforms throws\n // an exception\n xhrInfo.status_code = xhrOpenThisArg.status;\n } catch {\n /* do nothing */\n }\n\n const handlerData: HandlerDataXhr = {\n endTimestamp: timestampInSeconds() * 1000,\n startTimestamp,\n xhr: xhrOpenThisArg,\n virtualError,\n };\n triggerHandlers('xhr', handlerData);\n\n // In the `addEventListener` branch below, this handler is the only\n // `readystatechange` listener we add, so detach it once the request is\n // done to avoid pinning the XMLHttpRequest and its captured\n // `virtualError` per HTTP call on long-lived pages. In the\n // `onreadystatechange` proxy branch the handler isn't registered via\n // `addEventListener`, so this is a harmless no-op there.\n xhrOpenThisArg.removeEventListener('readystatechange', onreadystatechangeHandler);\n }\n };\n\n if ('onreadystatechange' in xhrOpenThisArg && typeof xhrOpenThisArg.onreadystatechange === 'function') {\n xhrOpenThisArg.onreadystatechange = new Proxy(xhrOpenThisArg.onreadystatechange, {\n apply(originalOnreadystatechange, onreadystatechangeThisArg, onreadystatechangeArgArray: unknown[]) {\n onreadystatechangeHandler();\n return originalOnreadystatechange.apply(onreadystatechangeThisArg, onreadystatechangeArgArray);\n },\n });\n } else {\n xhrOpenThisArg.addEventListener('readystatechange', onreadystatechangeHandler);\n }\n\n // Intercepting `setRequestHeader` to access the request headers of XHR instance.\n // This will only work for user/library defined headers, not for the default/browser-assigned headers.\n // Request cookies are also unavailable for XHR, as `Cookie` header can't be defined by `setRequestHeader`.\n xhrOpenThisArg.setRequestHeader = new Proxy(xhrOpenThisArg.setRequestHeader, {\n apply(\n originalSetRequestHeader,\n setRequestHeaderThisArg: SentryWrappedXMLHttpRequest,\n setRequestHeaderArgArray: unknown[],\n ) {\n const [header, value] = setRequestHeaderArgArray;\n\n const xhrInfo = setRequestHeaderThisArg[SENTRY_XHR_DATA_KEY];\n\n if (xhrInfo && isString(header) && isString(value)) {\n xhrInfo.request_headers[header.toLowerCase()] = value;\n }\n\n return originalSetRequestHeader.apply(setRequestHeaderThisArg, setRequestHeaderArgArray);\n },\n });\n\n return originalOpen.apply(xhrOpenThisArg, xhrOpenArgArray);\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n xhrproto.send = new Proxy(xhrproto.send, {\n apply(originalSend, sendThisArg: XMLHttpRequest & SentryWrappedXMLHttpRequest, sendArgArray: unknown[]) {\n const sentryXhrData = sendThisArg[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return originalSend.apply(sendThisArg, sendArgArray);\n }\n\n if (sendArgArray[0] !== undefined) {\n sentryXhrData.body = sendArgArray[0];\n }\n\n const handlerData: HandlerDataXhr = {\n startTimestamp: timestampInSeconds() * 1000,\n xhr: sendThisArg,\n };\n triggerHandlers('xhr', handlerData);\n\n return originalSend.apply(sendThisArg, sendArgArray);\n },\n });\n}\n\n/**\n * Parses the URL argument of a XHR method to a string.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open#url\n * url: A string or any other object with a stringifier — including a URL object — that provides the URL of the resource to send the request to.\n *\n * @param url - The URL argument of an XHR method\n * @returns The parsed URL string or undefined if the URL is invalid\n */\nfunction parseXhrUrlArg(url: unknown): string | undefined {\n if (isString(url)) {\n return url;\n }\n\n try {\n // If the passed in argument is not a string, it should have a `toString` method as a stringifier.\n // If that fails, we just return undefined (like in IE11 where URL is not available)\n return (url as URL).toString();\n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