@atlaskit/react-ufo 1.1.0 → 2.0.0
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/CHANGELOG.md +24 -0
- package/README.md +5 -0
- package/additional-payload/package.json +15 -0
- package/bundle-eval-timing/package.json +15 -0
- package/coinflip/package.json +15 -0
- package/common/package.json +5 -5
- package/config/package.json +15 -0
- package/create-payload/package.json +15 -0
- package/create-post-interaction-log-payload/package.json +15 -0
- package/custom-data/package.json +15 -0
- package/custom-mark/package.json +15 -0
- package/custom-spans/package.json +15 -0
- package/custom-timings/package.json +15 -0
- package/dist/cjs/additional-payload/index.js +25 -0
- package/dist/cjs/additional-payload/utils/cache-hit-ratio/index.js +69 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/cls/index.js +53 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/const.js +10 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/index.js +29 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/tbt/index.js +25 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +38 -0
- package/dist/cjs/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +37 -0
- package/dist/cjs/bundle-eval-timing/index.js +48 -0
- package/dist/cjs/coinflip/index.js +22 -0
- package/dist/cjs/common/common/types.js +5 -0
- package/dist/cjs/common/constants.js +7 -0
- package/dist/cjs/common/index.js +1 -0
- package/dist/cjs/common/vc/types.js +11 -0
- package/dist/cjs/config/index.js +222 -0
- package/dist/cjs/create-payload/common/types.js +1 -0
- package/dist/cjs/create-payload/common/utils/index.js +15 -0
- package/dist/cjs/create-payload/index.js +784 -0
- package/dist/cjs/create-post-interaction-log-payload/index.js +207 -0
- package/dist/cjs/custom-data/index.js +31 -0
- package/dist/cjs/custom-data/types.js +5 -0
- package/dist/cjs/custom-mark/index.js +45 -0
- package/dist/cjs/custom-spans/index.js +14 -0
- package/dist/cjs/custom-timings/index.js +65 -0
- package/dist/cjs/experience-trace-id-context/index.js +40 -0
- package/dist/cjs/experience-trace-id-context/types.js +1 -0
- package/dist/cjs/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +12 -0
- package/dist/cjs/feature-flags-accessed/common/constants.js +7 -0
- package/dist/cjs/feature-flags-accessed/common/types.js +5 -0
- package/dist/cjs/feature-flags-accessed/common/utils/index.js +38 -0
- package/dist/cjs/feature-flags-accessed/index.js +32 -0
- package/dist/cjs/generate-id/index.js +12 -0
- package/dist/cjs/global-error-handler/index.js +74 -0
- package/dist/cjs/hidden-timing/index.js +94 -0
- package/dist/cjs/initial-page-load-extra-timing/index.js +49 -0
- package/dist/cjs/interaction-context/index.js +14 -0
- package/dist/cjs/interaction-id-context/index.js +27 -0
- package/dist/cjs/interaction-metrics/common/constants.js +8 -0
- package/dist/cjs/interaction-metrics/index.js +810 -1
- package/dist/cjs/interaction-metrics/post-interaction-log.js +190 -0
- package/dist/cjs/interaction-metrics-init/index.js +89 -0
- package/dist/cjs/label/UFOLabel.js +45 -0
- package/dist/cjs/label/index.js +9 -0
- package/dist/cjs/load-hold/UFOLoadHold.js +76 -0
- package/dist/cjs/load-hold/index.js +9 -0
- package/dist/cjs/placeholder/Placeholder.js +34 -0
- package/dist/cjs/placeholder/index.js +9 -0
- package/dist/cjs/placeholder/loosely-lazy/index.js +19 -0
- package/dist/cjs/placeholder/loosely-lazy/lazy-suspense.js +80 -0
- package/dist/cjs/placeholder/loosely-lazy/types.js +5 -0
- package/dist/cjs/placeholder/loosely-lazy/wait-context.js +15 -0
- package/dist/cjs/resource-timing/common/types.js +1 -0
- package/dist/cjs/resource-timing/common/utils/config.js +70 -0
- package/dist/cjs/resource-timing/common/utils/resource-timing-buffer.js +111 -0
- package/dist/cjs/resource-timing/index.js +26 -0
- package/dist/cjs/resource-timing/main.js +141 -0
- package/dist/cjs/resource-timing/utils.js +10 -0
- package/dist/cjs/round-number/index.js +11 -0
- package/dist/cjs/route-name/index.js +12 -0
- package/dist/cjs/route-name-context/index.js +11 -0
- package/dist/cjs/segment/index.js +9 -0
- package/dist/cjs/segment/segment-highlight.js +40 -0
- package/dist/cjs/segment/segment.js +247 -0
- package/dist/cjs/set-interaction-error/index.js +17 -0
- package/dist/cjs/short-id/index.js +15 -0
- package/dist/cjs/ssr/index.js +70 -0
- package/dist/cjs/trace-interaction/index.js +48 -0
- package/dist/cjs/trace-pageload/index.js +58 -0
- package/dist/cjs/trace-press/index.js +34 -0
- package/dist/cjs/trace-redirect/index.js +17 -0
- package/dist/cjs/trace-transition/index.js +60 -0
- package/dist/cjs/trace-transition/utils/generate-span-id/index.js +11 -0
- package/dist/cjs/trace-transition/utils/set-interaction-active-trace/index.js +11 -0
- package/dist/cjs/typing-performance-tracing/index.js +262 -0
- package/dist/cjs/use-press-tracing/index.js +19 -0
- package/dist/cjs/vc/index.js +15 -0
- package/dist/cjs/vc/vc-observer/attachAbortListeners.js +40 -0
- package/dist/cjs/vc/vc-observer/getViewport.js +27 -0
- package/dist/cjs/vc/vc-observer/index.js +562 -0
- package/dist/cjs/vc/vc-observer/media-wrapper/index.js +15 -0
- package/dist/cjs/vc/vc-observer/media-wrapper/vc-utils.js +16 -0
- package/dist/cjs/vc/vc-observer/observers/index.js +270 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +183 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +22 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +20 -0
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +19 -0
- package/dist/cjs/vc/vc-observer/observers/types.js +5 -0
- package/dist/es2019/additional-payload/index.js +2 -0
- package/dist/es2019/additional-payload/utils/cache-hit-ratio/index.js +63 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/cls/index.js +33 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/const.js +4 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/index.js +23 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/tbt/index.js +15 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +23 -0
- package/dist/es2019/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
- package/dist/es2019/bundle-eval-timing/index.js +43 -0
- package/dist/es2019/coinflip/index.js +16 -0
- package/dist/es2019/common/common/types.js +1 -0
- package/dist/es2019/common/constants.js +1 -0
- package/dist/es2019/common/vc/types.js +5 -0
- package/dist/es2019/config/index.js +215 -0
- package/dist/es2019/create-payload/common/types.js +0 -0
- package/dist/es2019/create-payload/common/utils/index.js +8 -0
- package/dist/es2019/create-payload/index.js +792 -0
- package/dist/es2019/create-post-interaction-log-payload/index.js +188 -0
- package/dist/es2019/custom-data/index.js +24 -0
- package/dist/es2019/custom-data/types.js +1 -0
- package/dist/es2019/custom-mark/index.js +38 -0
- package/dist/es2019/custom-spans/index.js +6 -0
- package/dist/es2019/custom-timings/index.js +57 -0
- package/dist/es2019/experience-trace-id-context/index.js +31 -0
- package/dist/es2019/experience-trace-id-context/types.js +0 -0
- package/dist/es2019/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +4 -0
- package/dist/es2019/feature-flags-accessed/common/constants.js +1 -0
- package/dist/es2019/feature-flags-accessed/common/types.js +1 -0
- package/dist/es2019/feature-flags-accessed/common/utils/index.js +24 -0
- package/dist/es2019/feature-flags-accessed/index.js +21 -0
- package/dist/es2019/generate-id/index.js +6 -0
- package/dist/es2019/global-error-handler/index.js +64 -0
- package/dist/es2019/hidden-timing/index.js +87 -0
- package/dist/es2019/initial-page-load-extra-timing/index.js +43 -0
- package/dist/es2019/interaction-context/index.js +6 -0
- package/dist/es2019/interaction-id-context/index.js +18 -0
- package/dist/es2019/interaction-metrics/common/constants.js +2 -0
- package/dist/es2019/interaction-metrics/index.js +736 -0
- package/dist/es2019/interaction-metrics/post-interaction-log.js +158 -0
- package/dist/es2019/interaction-metrics-init/index.js +72 -0
- package/dist/es2019/label/UFOLabel.js +34 -0
- package/dist/es2019/label/index.js +2 -0
- package/dist/es2019/load-hold/UFOLoadHold.js +66 -0
- package/dist/es2019/load-hold/index.js +2 -0
- package/dist/es2019/placeholder/Placeholder.js +25 -0
- package/dist/es2019/placeholder/index.js +2 -0
- package/dist/es2019/placeholder/loosely-lazy/index.js +2 -0
- package/dist/es2019/placeholder/loosely-lazy/lazy-suspense.js +63 -0
- package/dist/es2019/placeholder/loosely-lazy/types.js +1 -0
- package/dist/es2019/placeholder/loosely-lazy/wait-context.js +5 -0
- package/dist/es2019/resource-timing/common/types.js +0 -0
- package/dist/es2019/resource-timing/common/utils/config.js +44 -0
- package/dist/es2019/resource-timing/common/utils/resource-timing-buffer.js +88 -0
- package/dist/es2019/resource-timing/index.js +3 -0
- package/dist/es2019/resource-timing/main.js +130 -0
- package/dist/es2019/resource-timing/utils.js +4 -0
- package/dist/es2019/round-number/index.js +4 -0
- package/dist/es2019/route-name/index.js +6 -0
- package/dist/es2019/route-name-context/index.js +5 -0
- package/dist/es2019/segment/index.js +2 -0
- package/dist/es2019/segment/segment-highlight.js +27 -0
- package/dist/es2019/segment/segment.js +218 -0
- package/dist/es2019/set-interaction-error/index.js +11 -0
- package/dist/es2019/short-id/index.js +8 -0
- package/dist/es2019/ssr/index.js +54 -0
- package/dist/es2019/trace-interaction/index.js +41 -0
- package/dist/es2019/trace-pageload/index.js +48 -0
- package/dist/es2019/trace-press/index.js +27 -0
- package/dist/es2019/trace-redirect/index.js +10 -0
- package/dist/es2019/trace-transition/index.js +48 -0
- package/dist/es2019/trace-transition/utils/generate-span-id/index.js +1 -0
- package/dist/es2019/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
- package/dist/es2019/typing-performance-tracing/index.js +255 -0
- package/dist/es2019/use-press-tracing/index.js +12 -0
- package/dist/es2019/vc/index.js +8 -0
- package/dist/es2019/vc/vc-observer/attachAbortListeners.js +34 -0
- package/dist/es2019/vc/vc-observer/getViewport.js +18 -0
- package/dist/es2019/vc/vc-observer/index.js +522 -0
- package/dist/es2019/vc/vc-observer/media-wrapper/index.js +9 -0
- package/dist/es2019/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
- package/dist/es2019/vc/vc-observer/observers/index.js +231 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +146 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
- package/dist/es2019/vc/vc-observer/observers/types.js +1 -0
- package/dist/esm/additional-payload/index.js +2 -0
- package/dist/esm/additional-payload/utils/cache-hit-ratio/index.js +63 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/index.js +47 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/cls/types.js +0 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/const.js +4 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/index.js +22 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/tbt/index.js +19 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/buffer/index.js +31 -0
- package/dist/esm/additional-payload/utils/lighthouse-metrics/utils/observer/index.js +31 -0
- package/dist/esm/bundle-eval-timing/index.js +41 -0
- package/dist/esm/coinflip/index.js +16 -0
- package/dist/esm/common/common/types.js +1 -0
- package/dist/esm/common/constants.js +1 -0
- package/dist/esm/common/index.js +0 -0
- package/dist/esm/common/vc/types.js +5 -0
- package/dist/esm/config/index.js +206 -0
- package/dist/esm/create-payload/common/types.js +0 -0
- package/dist/esm/create-payload/common/utils/index.js +8 -0
- package/dist/esm/create-payload/index.js +774 -0
- package/dist/esm/create-post-interaction-log-payload/index.js +200 -0
- package/dist/esm/custom-data/index.js +23 -0
- package/dist/esm/custom-data/types.js +1 -0
- package/dist/esm/custom-mark/index.js +36 -0
- package/dist/esm/custom-spans/index.js +8 -0
- package/dist/esm/custom-timings/index.js +56 -0
- package/dist/esm/experience-trace-id-context/index.js +34 -0
- package/dist/esm/experience-trace-id-context/types.js +0 -0
- package/dist/esm/experience-trace-id-context/utils/make-trace-http-request-headers/index.js +6 -0
- package/dist/esm/feature-flags-accessed/common/constants.js +1 -0
- package/dist/esm/feature-flags-accessed/common/types.js +1 -0
- package/dist/esm/feature-flags-accessed/common/utils/index.js +31 -0
- package/dist/esm/feature-flags-accessed/index.js +21 -0
- package/dist/esm/generate-id/index.js +6 -0
- package/dist/esm/global-error-handler/index.js +67 -0
- package/dist/esm/hidden-timing/index.js +87 -0
- package/dist/esm/initial-page-load-extra-timing/index.js +42 -0
- package/dist/esm/interaction-context/index.js +6 -0
- package/dist/esm/interaction-id-context/index.js +22 -0
- package/dist/esm/interaction-metrics/common/constants.js +2 -0
- package/dist/esm/interaction-metrics/index.js +773 -0
- package/dist/esm/interaction-metrics/post-interaction-log.js +184 -0
- package/dist/esm/interaction-metrics-init/index.js +77 -0
- package/dist/esm/label/UFOLabel.js +36 -0
- package/dist/esm/label/index.js +2 -0
- package/dist/esm/load-hold/UFOLoadHold.js +66 -0
- package/dist/esm/load-hold/index.js +2 -0
- package/dist/esm/placeholder/Placeholder.js +25 -0
- package/dist/esm/placeholder/index.js +2 -0
- package/dist/esm/placeholder/loosely-lazy/index.js +2 -0
- package/dist/esm/placeholder/loosely-lazy/lazy-suspense.js +70 -0
- package/dist/esm/placeholder/loosely-lazy/types.js +1 -0
- package/dist/esm/placeholder/loosely-lazy/wait-context.js +9 -0
- package/dist/esm/resource-timing/common/types.js +0 -0
- package/dist/esm/resource-timing/common/utils/config.js +62 -0
- package/dist/esm/resource-timing/common/utils/resource-timing-buffer.js +104 -0
- package/dist/esm/resource-timing/index.js +3 -0
- package/dist/esm/resource-timing/main.js +134 -0
- package/dist/esm/resource-timing/utils.js +4 -0
- package/dist/esm/round-number/index.js +5 -0
- package/dist/esm/route-name/index.js +6 -0
- package/dist/esm/route-name-context/index.js +5 -0
- package/dist/esm/segment/index.js +2 -0
- package/dist/esm/segment/segment-highlight.js +30 -0
- package/dist/esm/segment/segment.js +235 -0
- package/dist/esm/set-interaction-error/index.js +11 -0
- package/dist/esm/short-id/index.js +9 -0
- package/dist/esm/ssr/index.js +59 -0
- package/dist/esm/trace-interaction/index.js +41 -0
- package/dist/esm/trace-pageload/index.js +50 -0
- package/dist/esm/trace-press/index.js +27 -0
- package/dist/esm/trace-redirect/index.js +10 -0
- package/dist/esm/trace-transition/index.js +49 -0
- package/dist/esm/trace-transition/utils/generate-span-id/index.js +5 -0
- package/dist/esm/trace-transition/utils/set-interaction-active-trace/index.js +5 -0
- package/dist/esm/typing-performance-tracing/index.js +255 -0
- package/dist/esm/use-press-tracing/index.js +12 -0
- package/dist/esm/vc/index.js +9 -0
- package/dist/esm/vc/vc-observer/attachAbortListeners.js +34 -0
- package/dist/esm/vc/vc-observer/getViewport.js +20 -0
- package/dist/esm/vc/vc-observer/index.js +555 -0
- package/dist/esm/vc/vc-observer/media-wrapper/index.js +7 -0
- package/dist/esm/vc/vc-observer/media-wrapper/vc-utils.js +10 -0
- package/dist/esm/vc/vc-observer/observers/index.js +263 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +176 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.js +16 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +14 -0
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.js +2 -0
- package/dist/esm/vc/vc-observer/observers/types.js +1 -0
- package/dist/types/additional-payload/index.d.ts +2 -0
- package/dist/types/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
- package/dist/types/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
- package/dist/types/bundle-eval-timing/index.d.ts +16 -0
- package/dist/types/coinflip/index.d.ts +8 -0
- package/dist/types/common/common/types.d.ts +201 -0
- package/dist/types/common/constants.d.ts +1 -0
- package/dist/types/common/index.d.ts +5 -0
- package/dist/types/common/vc/types.d.ts +91 -0
- package/dist/types/config/index.d.ts +91 -0
- package/dist/types/create-payload/common/types.d.ts +4 -0
- package/dist/types/create-payload/common/utils/index.d.ts +3 -0
- package/dist/types/create-payload/index.d.ts +2969 -0
- package/dist/types/create-post-interaction-log-payload/index.d.ts +45 -0
- package/dist/types/custom-data/index.d.ts +5 -0
- package/dist/types/custom-data/types.d.ts +4 -0
- package/dist/types/custom-mark/index.d.ts +10 -0
- package/dist/types/custom-spans/index.d.ts +1 -0
- package/dist/types/custom-timings/index.d.ts +19 -0
- package/dist/types/experience-trace-id-context/index.d.ts +10 -0
- package/dist/types/experience-trace-id-context/types.d.ts +8 -0
- package/dist/types/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
- package/dist/types/feature-flags-accessed/common/constants.d.ts +1 -0
- package/dist/types/feature-flags-accessed/common/types.d.ts +2 -0
- package/dist/types/feature-flags-accessed/common/utils/index.d.ts +3 -0
- package/dist/types/feature-flags-accessed/index.d.ts +14 -0
- package/dist/types/generate-id/index.d.ts +2 -0
- package/dist/types/global-error-handler/index.d.ts +3 -0
- package/dist/types/hidden-timing/index.d.ts +7 -0
- package/dist/types/initial-page-load-extra-timing/index.d.ts +9 -0
- package/dist/types/interaction-context/index.d.ts +33 -0
- package/dist/types/interaction-id-context/index.d.ts +9 -0
- package/dist/types/interaction-metrics/common/constants.d.ts +3 -0
- package/dist/types/interaction-metrics/index.d.ts +65 -1
- package/dist/types/interaction-metrics/post-interaction-log.d.ts +69 -0
- package/dist/types/interaction-metrics-init/index.d.ts +11 -0
- package/dist/types/label/UFOLabel.d.ts +13 -0
- package/dist/types/label/index.d.ts +2 -0
- package/dist/types/load-hold/UFOLoadHold.d.ts +53 -0
- package/dist/types/load-hold/index.d.ts +2 -0
- package/dist/types/placeholder/Placeholder.d.ts +13 -0
- package/dist/types/placeholder/index.d.ts +2 -0
- package/dist/types/placeholder/loosely-lazy/index.d.ts +3 -0
- package/dist/types/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
- package/dist/types/placeholder/loosely-lazy/types.d.ts +20 -0
- package/dist/types/placeholder/loosely-lazy/wait-context.d.ts +3 -0
- package/dist/types/resource-timing/common/types.d.ts +41 -0
- package/dist/types/resource-timing/common/utils/config.d.ts +3 -0
- package/dist/types/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
- package/dist/types/resource-timing/index.d.ts +4 -0
- package/dist/types/resource-timing/main.d.ts +2 -0
- package/dist/types/resource-timing/utils.d.ts +1 -0
- package/dist/types/round-number/index.d.ts +1 -0
- package/dist/types/route-name/index.d.ts +4 -0
- package/dist/types/route-name-context/index.d.ts +5 -0
- package/dist/types/segment/index.d.ts +2 -0
- package/dist/types/segment/segment-highlight.d.ts +6 -0
- package/dist/types/segment/segment.d.ts +8 -0
- package/dist/types/set-interaction-error/index.d.ts +4 -0
- package/dist/types/short-id/index.d.ts +1 -0
- package/dist/types/ssr/index.d.ts +21 -0
- package/dist/types/trace-interaction/index.d.ts +2 -0
- package/dist/types/trace-pageload/index.d.ts +2 -0
- package/dist/types/trace-press/index.d.ts +1 -0
- package/dist/types/trace-redirect/index.d.ts +1 -0
- package/dist/types/trace-transition/index.d.ts +2 -0
- package/dist/types/trace-transition/utils/generate-span-id/index.d.ts +1 -0
- package/dist/types/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
- package/dist/types/typing-performance-tracing/index.d.ts +2 -0
- package/dist/types/use-press-tracing/index.d.ts +1 -0
- package/dist/types/vc/index.d.ts +2 -0
- package/dist/types/vc/vc-observer/attachAbortListeners.d.ts +6 -0
- package/dist/types/vc/vc-observer/getViewport.d.ts +2 -0
- package/dist/types/vc/vc-observer/index.d.ts +98 -0
- package/dist/types/vc/vc-observer/media-wrapper/index.d.ts +7 -0
- package/dist/types/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/index.d.ts +39 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
- package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
- package/dist/types/vc/vc-observer/observers/types.d.ts +11 -0
- package/dist/types-ts4.5/additional-payload/index.d.ts +2 -0
- package/dist/types-ts4.5/additional-payload/utils/cache-hit-ratio/index.d.ts +8 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/index.d.ts +2 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/cls/types.d.ts +3 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/const.d.ts +5 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/index.d.ts +7 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/tbt/index.d.ts +5 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/buffer/index.d.ts +13 -0
- package/dist/types-ts4.5/additional-payload/utils/lighthouse-metrics/utils/observer/index.d.ts +2 -0
- package/dist/types-ts4.5/bundle-eval-timing/index.d.ts +16 -0
- package/dist/types-ts4.5/coinflip/index.d.ts +8 -0
- package/dist/types-ts4.5/common/common/types.d.ts +201 -0
- package/dist/types-ts4.5/common/constants.d.ts +1 -0
- package/dist/types-ts4.5/common/index.d.ts +5 -0
- package/dist/types-ts4.5/common/vc/types.d.ts +91 -0
- package/dist/types-ts4.5/config/index.d.ts +95 -0
- package/dist/types-ts4.5/create-payload/common/types.d.ts +4 -0
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +2969 -0
- package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +45 -0
- package/dist/types-ts4.5/custom-data/index.d.ts +5 -0
- package/dist/types-ts4.5/custom-data/types.d.ts +4 -0
- package/dist/types-ts4.5/custom-mark/index.d.ts +10 -0
- package/dist/types-ts4.5/custom-spans/index.d.ts +1 -0
- package/dist/types-ts4.5/custom-timings/index.d.ts +19 -0
- package/dist/types-ts4.5/experience-trace-id-context/index.d.ts +10 -0
- package/dist/types-ts4.5/experience-trace-id-context/types.d.ts +8 -0
- package/dist/types-ts4.5/experience-trace-id-context/utils/make-trace-http-request-headers/index.d.ts +4 -0
- package/dist/types-ts4.5/feature-flags-accessed/common/constants.d.ts +1 -0
- package/dist/types-ts4.5/feature-flags-accessed/common/types.d.ts +2 -0
- package/dist/types-ts4.5/feature-flags-accessed/common/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/feature-flags-accessed/index.d.ts +14 -0
- package/dist/types-ts4.5/generate-id/index.d.ts +2 -0
- package/dist/types-ts4.5/global-error-handler/index.d.ts +3 -0
- package/dist/types-ts4.5/hidden-timing/index.d.ts +7 -0
- package/dist/types-ts4.5/initial-page-load-extra-timing/index.d.ts +9 -0
- package/dist/types-ts4.5/interaction-context/index.d.ts +33 -0
- package/dist/types-ts4.5/interaction-id-context/index.d.ts +9 -0
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -0
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +65 -1
- package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +69 -0
- package/dist/types-ts4.5/interaction-metrics-init/index.d.ts +11 -0
- package/dist/types-ts4.5/label/UFOLabel.d.ts +13 -0
- package/dist/types-ts4.5/label/index.d.ts +2 -0
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +53 -0
- package/dist/types-ts4.5/load-hold/index.d.ts +2 -0
- package/dist/types-ts4.5/placeholder/Placeholder.d.ts +13 -0
- package/dist/types-ts4.5/placeholder/index.d.ts +2 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/index.d.ts +3 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/lazy-suspense.d.ts +6 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/types.d.ts +20 -0
- package/dist/types-ts4.5/placeholder/loosely-lazy/wait-context.d.ts +3 -0
- package/dist/types-ts4.5/resource-timing/common/types.d.ts +41 -0
- package/dist/types-ts4.5/resource-timing/common/utils/config.d.ts +3 -0
- package/dist/types-ts4.5/resource-timing/common/utils/resource-timing-buffer.d.ts +11 -0
- package/dist/types-ts4.5/resource-timing/index.d.ts +4 -0
- package/dist/types-ts4.5/resource-timing/main.d.ts +2 -0
- package/dist/types-ts4.5/resource-timing/utils.d.ts +1 -0
- package/dist/types-ts4.5/round-number/index.d.ts +1 -0
- package/dist/types-ts4.5/route-name/index.d.ts +4 -0
- package/dist/types-ts4.5/route-name-context/index.d.ts +5 -0
- package/dist/types-ts4.5/segment/index.d.ts +2 -0
- package/dist/types-ts4.5/segment/segment-highlight.d.ts +6 -0
- package/dist/types-ts4.5/segment/segment.d.ts +8 -0
- package/dist/types-ts4.5/set-interaction-error/index.d.ts +4 -0
- package/dist/types-ts4.5/short-id/index.d.ts +1 -0
- package/dist/types-ts4.5/ssr/index.d.ts +21 -0
- package/dist/types-ts4.5/trace-interaction/index.d.ts +2 -0
- package/dist/types-ts4.5/trace-pageload/index.d.ts +2 -0
- package/dist/types-ts4.5/trace-press/index.d.ts +1 -0
- package/dist/types-ts4.5/trace-redirect/index.d.ts +1 -0
- package/dist/types-ts4.5/trace-transition/index.d.ts +2 -0
- package/dist/types-ts4.5/trace-transition/utils/generate-span-id/index.d.ts +1 -0
- package/dist/types-ts4.5/trace-transition/utils/set-interaction-active-trace/index.d.ts +1 -0
- package/dist/types-ts4.5/typing-performance-tracing/index.d.ts +2 -0
- package/dist/types-ts4.5/use-press-tracing/index.d.ts +1 -0
- package/dist/types-ts4.5/vc/index.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/attachAbortListeners.d.ts +6 -0
- package/dist/types-ts4.5/vc/vc-observer/getViewport.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/index.d.ts +98 -0
- package/dist/types-ts4.5/vc/vc-observer/media-wrapper/index.d.ts +7 -0
- package/dist/types-ts4.5/vc/vc-observer/media-wrapper/vc-utils.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +39 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +23 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/bindAbortListeners.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/index.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/observers/types.d.ts +11 -0
- package/experience-trace-id-context/package.json +15 -0
- package/feature-flags-accessed/package.json +15 -0
- package/generate-id/package.json +15 -0
- package/global-error-handler/package.json +15 -0
- package/hidden-timing/package.json +15 -0
- package/initial-page-load-extra-timing/package.json +15 -0
- package/interaction-context/package.json +15 -0
- package/interaction-id-context/package.json +15 -0
- package/interaction-metrics-init/package.json +15 -0
- package/label/package.json +15 -0
- package/load-hold/package.json +15 -0
- package/package.json +55 -3
- package/placeholder/package.json +15 -0
- package/resource-timing/package.json +15 -0
- package/round-number/package.json +15 -0
- package/route-name/package.json +15 -0
- package/route-name-context/package.json +15 -0
- package/segment/package.json +15 -0
- package/set-interaction-error/package.json +15 -0
- package/short-id/package.json +15 -0
- package/ssr/package.json +15 -0
- package/ssr-scripts/package.json +15 -0
- package/trace-interaction/package.json +15 -0
- package/trace-pageload/package.json +15 -0
- package/trace-press/package.json +15 -0
- package/trace-redirect/package.json +15 -0
- package/trace-transition/package.json +15 -0
- package/typing-performance-tracing/package.json +15 -0
- package/use-press-tracing/package.json +15 -0
- package/vc/media/package.json +15 -0
- package/vc/package.json +15 -0
- package/dist/types/common/types.d.ts +0 -17
- package/dist/types-ts4.5/common/types.d.ts +0 -17
- /package/dist/cjs/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
- /package/dist/es2019/{common → additional-payload/utils/lighthouse-metrics/cls}/types.js +0 -0
- /package/dist/{esm/common/types.js → es2019/common/index.js} +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { getConfig } from '../config';
|
|
3
|
+
import { VCObserver } from '../vc/vc-observer';
|
|
4
|
+
const POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT = 3000;
|
|
5
|
+
export default class PostInteractionLog {
|
|
6
|
+
constructor() {
|
|
7
|
+
/**
|
|
8
|
+
* Basic info about interaction that has just finished
|
|
9
|
+
*/
|
|
10
|
+
_defineProperty(this, "lastInteractionFinish", null);
|
|
11
|
+
/**
|
|
12
|
+
* Array of observed react render timings
|
|
13
|
+
*/
|
|
14
|
+
_defineProperty(this, "reactProfilerTimings", []);
|
|
15
|
+
/**
|
|
16
|
+
* Store the scheduled sink timeout Id so that it can be cancelled when needed
|
|
17
|
+
*/
|
|
18
|
+
_defineProperty(this, "sinkTimeoutId", null);
|
|
19
|
+
/**
|
|
20
|
+
* independent VC observer, that observes until `custom.post-interaction-logs` event is sent
|
|
21
|
+
*/
|
|
22
|
+
_defineProperty(this, "vcObserver", null);
|
|
23
|
+
_defineProperty(this, "vcObserverSSRConfig", null);
|
|
24
|
+
/**
|
|
25
|
+
* Handler function to process / send the observation data
|
|
26
|
+
*/
|
|
27
|
+
_defineProperty(this, "sinkHandlerFn", () => {});
|
|
28
|
+
}
|
|
29
|
+
initializeVCObserver(options) {
|
|
30
|
+
if (this.vcObserver === null) {
|
|
31
|
+
this.vcObserver = new VCObserver({
|
|
32
|
+
...options,
|
|
33
|
+
isPostInteraction: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
startVCObserver({
|
|
38
|
+
startTime
|
|
39
|
+
}) {
|
|
40
|
+
var _this$vcObserver;
|
|
41
|
+
(_this$vcObserver = this.vcObserver) === null || _this$vcObserver === void 0 ? void 0 : _this$vcObserver.start({
|
|
42
|
+
startTime
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
setVCObserverSSRConfig(vcObserverSSRConfig) {
|
|
46
|
+
this.vcObserverSSRConfig = vcObserverSSRConfig;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Set the VC result as per the last interaction
|
|
51
|
+
* Used to compare diffs of VC updates vs post interaction VC observer
|
|
52
|
+
* @param result - VC result as calculated by UFO create payload
|
|
53
|
+
*/
|
|
54
|
+
setLastInteractionFinishVCResult(result) {
|
|
55
|
+
this.lastInteractionFinishVCResult = result;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set the fn that would be invoked to process / send the observation data
|
|
59
|
+
*/
|
|
60
|
+
sinkHandler(sinkHandlerFn) {
|
|
61
|
+
this.sinkHandlerFn = sinkHandlerFn;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Reset state of the log
|
|
66
|
+
*/
|
|
67
|
+
reset() {
|
|
68
|
+
this.lastInteractionFinish = null;
|
|
69
|
+
this.reactProfilerTimings = [];
|
|
70
|
+
if (this.sinkTimeoutId != null) {
|
|
71
|
+
clearTimeout(this.sinkTimeoutId);
|
|
72
|
+
this.sinkTimeoutId = null;
|
|
73
|
+
}
|
|
74
|
+
this.setVCObserverSSRConfig(null);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Check if there is data in the log
|
|
79
|
+
*/
|
|
80
|
+
hasData() {
|
|
81
|
+
var _this$reactProfilerTi;
|
|
82
|
+
return ((_this$reactProfilerTi = this.reactProfilerTimings) === null || _this$reactProfilerTi === void 0 ? void 0 : _this$reactProfilerTi.length) > 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Send the log if there is data
|
|
87
|
+
*/
|
|
88
|
+
sendPostInteractionLog() {
|
|
89
|
+
var _this$vcObserver2;
|
|
90
|
+
if (!this.hasData() || !this.lastInteractionFinish || !this.sinkHandlerFn) {
|
|
91
|
+
this.reset();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.sinkHandlerFn({
|
|
95
|
+
lastInteractionFinish: this.lastInteractionFinish,
|
|
96
|
+
reactProfilerTimings: this.reactProfilerTimings,
|
|
97
|
+
// NOTE: invoking `getVCResult` at latest possible point in time here (not earlier) to get the most accurate result (from performance.now())
|
|
98
|
+
postInteractionFinishVCResult: (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 ? void 0 : _this$vcObserver2.getVCResult({
|
|
99
|
+
start: this.lastInteractionFinish.start,
|
|
100
|
+
stop: performance.now(),
|
|
101
|
+
tti: -1,
|
|
102
|
+
// no need for TTI value here
|
|
103
|
+
prefix: 'ufo',
|
|
104
|
+
...this.vcObserverSSRConfig
|
|
105
|
+
}),
|
|
106
|
+
lastInteractionFinishVCResult: this.lastInteractionFinishVCResult
|
|
107
|
+
});
|
|
108
|
+
this.reset();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This fn should be invoked when an interaction has finished
|
|
113
|
+
* Basic details about the finished interaction will be recorded
|
|
114
|
+
* A timeout will be setup to send the post interaction observation after some time.
|
|
115
|
+
*/
|
|
116
|
+
onInteractionComplete({
|
|
117
|
+
ufoName,
|
|
118
|
+
start,
|
|
119
|
+
end,
|
|
120
|
+
id,
|
|
121
|
+
abortReason,
|
|
122
|
+
abortedByInteractionName,
|
|
123
|
+
routeName,
|
|
124
|
+
type
|
|
125
|
+
}) {
|
|
126
|
+
var _getConfig;
|
|
127
|
+
this.lastInteractionFinish = {
|
|
128
|
+
ufoName,
|
|
129
|
+
start,
|
|
130
|
+
end,
|
|
131
|
+
id,
|
|
132
|
+
abortReason,
|
|
133
|
+
abortedByInteractionName,
|
|
134
|
+
routeName,
|
|
135
|
+
type
|
|
136
|
+
};
|
|
137
|
+
const timeout = ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
|
|
138
|
+
this.sinkTimeoutId = window.setTimeout(() => {
|
|
139
|
+
this.sendPostInteractionLog();
|
|
140
|
+
}, timeout);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* This fn should be invoked when a React render happens after interaction has finished
|
|
145
|
+
*/
|
|
146
|
+
addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime) {
|
|
147
|
+
if (this.lastInteractionFinish != null) {
|
|
148
|
+
this.reactProfilerTimings.push({
|
|
149
|
+
type,
|
|
150
|
+
actualDuration,
|
|
151
|
+
baseDuration,
|
|
152
|
+
startTime,
|
|
153
|
+
commitTime,
|
|
154
|
+
labelStack
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
2
|
+
import { startLighthouseObserver } from '../additional-payload';
|
|
3
|
+
import { setUFOConfig } from '../config';
|
|
4
|
+
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
5
|
+
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
6
|
+
import { getVCObserver } from '../vc';
|
|
7
|
+
let initialized = false;
|
|
8
|
+
function sinkInteraction(instance, payloadPackage) {
|
|
9
|
+
sinkInteractionHandler((interactionId, interaction) => {
|
|
10
|
+
scheduleCallback(idlePriority, () => {
|
|
11
|
+
const payloads = payloadPackage.createPayloads(interactionId, interaction);
|
|
12
|
+
payloads === null || payloads === void 0 ? void 0 : payloads.forEach(payload => {
|
|
13
|
+
instance.sendOperationalEvent(payload);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
19
|
+
sinkPostInteractionLogHandler(logOutput => {
|
|
20
|
+
scheduleCallback(idlePriority, () => {
|
|
21
|
+
const payload = createPostInteractionLogPayload(logOutput);
|
|
22
|
+
if (payload) {
|
|
23
|
+
instance.sendOperationalEvent(payload);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export const init = (analyticsWebClientAsync, config) => {
|
|
29
|
+
var _config$vc;
|
|
30
|
+
if (initialized) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setUFOConfig(config);
|
|
34
|
+
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
35
|
+
const vcOptions = {
|
|
36
|
+
heatmapSize: config.vc.heatmapSize,
|
|
37
|
+
oldDomUpdates: config.vc.oldDomUpdates,
|
|
38
|
+
devToolsEnabled: config.vc.devToolsEnabled,
|
|
39
|
+
selectorConfig: config.vc.selectorConfig
|
|
40
|
+
};
|
|
41
|
+
getVCObserver(vcOptions).start({
|
|
42
|
+
startTime: 0
|
|
43
|
+
});
|
|
44
|
+
postInteractionLog.initializeVCObserver(vcOptions);
|
|
45
|
+
postInteractionLog.startVCObserver({
|
|
46
|
+
startTime: 0
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
setupHiddenTimingCapture();
|
|
50
|
+
startLighthouseObserver();
|
|
51
|
+
initialized = true;
|
|
52
|
+
Promise.all([analyticsWebClientAsync,
|
|
53
|
+
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
54
|
+
import( /* webpackChunkName: "create-payloads" */'../create-payload'),
|
|
55
|
+
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
56
|
+
import( /* webpackChunkName: "create-post-intreaction-log-payload" */'../create-post-interaction-log-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage]) => {
|
|
57
|
+
if (awc.getAnalyticsWebClientPromise) {
|
|
58
|
+
awc.getAnalyticsWebClientPromise().then(client => {
|
|
59
|
+
const instance = client.getInstance();
|
|
60
|
+
sinkInteraction(instance, payloadPackage);
|
|
61
|
+
if (config.captureLateReRenders) {
|
|
62
|
+
sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} else if (awc.sendOperationalEvent) {
|
|
66
|
+
sinkInteraction(awc, payloadPackage);
|
|
67
|
+
if (config.captureLateReRenders) {
|
|
68
|
+
sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import InteractionContext, { useInteractionContext } from '../interaction-context';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Annotate part of the react tree with a product name
|
|
6
|
+
* ```
|
|
7
|
+
* <UFOLabel name="card">
|
|
8
|
+
* <Card card={data} />
|
|
9
|
+
* </UFOLabel>
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export default function UFOLabel({
|
|
13
|
+
name,
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
16
|
+
const context = useInteractionContext();
|
|
17
|
+
const newContext = useMemo(() => {
|
|
18
|
+
if (context) {
|
|
19
|
+
return {
|
|
20
|
+
...context,
|
|
21
|
+
labelStack: context.labelStack == null ? [{
|
|
22
|
+
name
|
|
23
|
+
}] : [...context.labelStack, {
|
|
24
|
+
name
|
|
25
|
+
}]
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
}, [context, name]);
|
|
31
|
+
return context ? /*#__PURE__*/React.createElement(InteractionContext.Provider, {
|
|
32
|
+
value: newContext
|
|
33
|
+
}, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
import UFOInteractionContext from '../interaction-context';
|
|
3
|
+
const useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Render this whenever you're loading.
|
|
7
|
+
*
|
|
8
|
+
* Wrap loading elements
|
|
9
|
+
* ```js
|
|
10
|
+
* if (isLoading){
|
|
11
|
+
* return (
|
|
12
|
+
* <UFOLoadHold name="card">
|
|
13
|
+
* <Skeleton />
|
|
14
|
+
* </UFOLoadHold>
|
|
15
|
+
* )
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Or render it as a sibling
|
|
20
|
+
* ```
|
|
21
|
+
* if (isLoading){
|
|
22
|
+
* return (
|
|
23
|
+
* <>
|
|
24
|
+
* <Skeleton />
|
|
25
|
+
* <UFOLoadHold name="card">
|
|
26
|
+
* </UFOLoadHold>
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Or wrap your content conditionally
|
|
32
|
+
* ```
|
|
33
|
+
* return (
|
|
34
|
+
* <UFOLoadHold name="card" hold={isLoading}>
|
|
35
|
+
* <Card />
|
|
36
|
+
* </UFOLoadHold>
|
|
37
|
+
* )
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* Or render as a sibling conditionally
|
|
41
|
+
* ```
|
|
42
|
+
* return (
|
|
43
|
+
* <>
|
|
44
|
+
* <Card />
|
|
45
|
+
* <UFOLoadHold name="card" hold={isLoading} />
|
|
46
|
+
* </>
|
|
47
|
+
* )
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export default function UFOLoadHold({
|
|
52
|
+
children,
|
|
53
|
+
name,
|
|
54
|
+
hold = true
|
|
55
|
+
}) {
|
|
56
|
+
// react-18: useId instead
|
|
57
|
+
const context = useContext(UFOInteractionContext);
|
|
58
|
+
useLayoutEffectSAFE(() => {
|
|
59
|
+
if (hold && context != null) {
|
|
60
|
+
return context.hold(name);
|
|
61
|
+
}
|
|
62
|
+
}, [hold, context, name]);
|
|
63
|
+
|
|
64
|
+
// react-18: can return children directly
|
|
65
|
+
return children != null ? /*#__PURE__*/React.createElement(React.Fragment, null, children) : null;
|
|
66
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import UFOLoadHold from '../load-hold';
|
|
3
|
+
import { LazySuspense, WaitContext } from './loosely-lazy';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides a placeholder for lazily loaded content, improving perceived performance.
|
|
7
|
+
*
|
|
8
|
+
* Named placeholders are especially useful for analyzing page load breakdowns
|
|
9
|
+
* in performance monitoring tools like Performance Portal.
|
|
10
|
+
*/
|
|
11
|
+
export default function Placeholder({
|
|
12
|
+
name,
|
|
13
|
+
children,
|
|
14
|
+
fallback = null
|
|
15
|
+
}) {
|
|
16
|
+
const waitContext = useContext(WaitContext);
|
|
17
|
+
const shouldHold = !waitContext || !!waitContext.currentValue();
|
|
18
|
+
return /*#__PURE__*/React.createElement(LazySuspense, {
|
|
19
|
+
fallback: /*#__PURE__*/React.createElement(React.Fragment, null, fallback, /*#__PURE__*/React.createElement(UFOLoadHold, {
|
|
20
|
+
name: name,
|
|
21
|
+
hold: shouldHold
|
|
22
|
+
})),
|
|
23
|
+
name: name
|
|
24
|
+
}, children);
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { createContext, Fragment, Suspense, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
const isNodeEnvironment = () => {
|
|
3
|
+
return typeof window === 'undefined' || window.name === 'nodejs';
|
|
4
|
+
};
|
|
5
|
+
const LazySuspenseContext = /*#__PURE__*/createContext({
|
|
6
|
+
fallback: /*#__PURE__*/React.createElement(Fragment, null),
|
|
7
|
+
setFallback: () => {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.warn('Missing <LooselySuspense /> boundary');
|
|
10
|
+
},
|
|
11
|
+
name: ''
|
|
12
|
+
});
|
|
13
|
+
const DynamicFallback = ({
|
|
14
|
+
children,
|
|
15
|
+
outsideSuspense
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
fallback,
|
|
19
|
+
setFallback
|
|
20
|
+
} = React.useContext(LazySuspenseContext);
|
|
21
|
+
useLayoutEffect(() => {
|
|
22
|
+
return () => {
|
|
23
|
+
if (!outsideSuspense) {
|
|
24
|
+
setFallback(null);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, [outsideSuspense, setFallback]);
|
|
28
|
+
return children(outsideSuspense ? null : fallback);
|
|
29
|
+
};
|
|
30
|
+
DynamicFallback.displayName = 'DynamicFallback';
|
|
31
|
+
export const LazySuspense = ({
|
|
32
|
+
fallback,
|
|
33
|
+
children,
|
|
34
|
+
name
|
|
35
|
+
}) => {
|
|
36
|
+
const [hydrationFallback, setHydrationFallback] = useState(null);
|
|
37
|
+
const mountedRef = useRef(false);
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
mountedRef.current = true;
|
|
40
|
+
return () => {
|
|
41
|
+
mountedRef.current = false;
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
const contextValue = useMemo(() => ({
|
|
45
|
+
fallback,
|
|
46
|
+
setFallback: newFallback => {
|
|
47
|
+
if (hydrationFallback === newFallback) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setHydrationFallback(newFallback);
|
|
51
|
+
},
|
|
52
|
+
name
|
|
53
|
+
}), [fallback, hydrationFallback, name]);
|
|
54
|
+
const renderFallback = outsideSuspense => /*#__PURE__*/React.createElement(DynamicFallback, {
|
|
55
|
+
outsideSuspense: outsideSuspense
|
|
56
|
+
}, resolvedFallback => outsideSuspense && hydrationFallback ? hydrationFallback : resolvedFallback);
|
|
57
|
+
return /*#__PURE__*/React.createElement(LazySuspenseContext.Provider, {
|
|
58
|
+
value: contextValue
|
|
59
|
+
}, isNodeEnvironment() ? children : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Suspense, {
|
|
60
|
+
fallback: renderFallback(false)
|
|
61
|
+
}, children), (!mountedRef.current || hydrationFallback) && renderFallback(true)));
|
|
62
|
+
};
|
|
63
|
+
LazySuspense.displayName = 'LazySuspense';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getConfig as getConfigUFO } from '../../../config';
|
|
2
|
+
const defaultAllowedParams = ['operationName', 'operation', 'q'];
|
|
3
|
+
const getAllowedParams = () => {
|
|
4
|
+
const config = getConfigUFO();
|
|
5
|
+
return (config === null || config === void 0 ? void 0 : config.allowedResourcesParams) || defaultAllowedParams;
|
|
6
|
+
};
|
|
7
|
+
const handleQueryParams = urlString => {
|
|
8
|
+
try {
|
|
9
|
+
if (typeof urlString !== 'string') {
|
|
10
|
+
return urlString;
|
|
11
|
+
}
|
|
12
|
+
const url = new URL(urlString);
|
|
13
|
+
const params = new URLSearchParams(url.search);
|
|
14
|
+
const allowedParams = getAllowedParams();
|
|
15
|
+
for (const [key] of params) {
|
|
16
|
+
if (!allowedParams.includes(key)) {
|
|
17
|
+
url.searchParams.delete(key);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return url.toString();
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return urlString;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
let config = {
|
|
26
|
+
mapResources: url => url,
|
|
27
|
+
sanitiseEndpoints: url => {
|
|
28
|
+
return handleQueryParams(url);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export function configure(resourceTimingConfig) {
|
|
32
|
+
const newConfig = {
|
|
33
|
+
mapResources: resourceTimingConfig.mapResources,
|
|
34
|
+
sanitiseEndpoints: url => {
|
|
35
|
+
const sanitised = resourceTimingConfig.sanitiseEndpoints(url);
|
|
36
|
+
if (sanitised) {
|
|
37
|
+
return handleQueryParams(sanitised);
|
|
38
|
+
}
|
|
39
|
+
return sanitised;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
config = newConfig;
|
|
43
|
+
}
|
|
44
|
+
export const getConfig = () => config;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { roundEpsilon } from '../../../round-number';
|
|
2
|
+
const getPerformanceObject = () => {
|
|
3
|
+
var _window;
|
|
4
|
+
return ((_window = window) !== null && _window !== void 0 ? _window : {}).performance;
|
|
5
|
+
};
|
|
6
|
+
const getPerformanceObserverObject = () => {
|
|
7
|
+
var _window2;
|
|
8
|
+
return ((_window2 = window) !== null && _window2 !== void 0 ? _window2 : {}).PerformanceObserver;
|
|
9
|
+
};
|
|
10
|
+
export const resourceTimingBuffer = {
|
|
11
|
+
timings: [],
|
|
12
|
+
maxSize: 1000,
|
|
13
|
+
observer: null,
|
|
14
|
+
transformResource: entry => {
|
|
15
|
+
var _entry$serverTiming, _entry$serverTiming2;
|
|
16
|
+
const duration = roundEpsilon(entry.duration);
|
|
17
|
+
|
|
18
|
+
// prioritising atl-edge
|
|
19
|
+
const totalBackendTimeEntry = ((_entry$serverTiming = entry.serverTiming) === null || _entry$serverTiming === void 0 ? void 0 : _entry$serverTiming.find(timing => timing.name === 'atl-edge')) || ((_entry$serverTiming2 = entry.serverTiming) === null || _entry$serverTiming2 === void 0 ? void 0 : _entry$serverTiming2.find(
|
|
20
|
+
// timing name should come from per-product config in the future
|
|
21
|
+
timing => timing.name === 'total' || timing.name === 'filter-request-papi'));
|
|
22
|
+
const serverTime = totalBackendTimeEntry ? roundEpsilon(totalBackendTimeEntry.duration) : undefined;
|
|
23
|
+
const networkTime = serverTime ? duration - serverTime : undefined;
|
|
24
|
+
return {
|
|
25
|
+
name: entry.name,
|
|
26
|
+
initiatorType: entry.initiatorType,
|
|
27
|
+
transferSize: entry.transferSize,
|
|
28
|
+
startTime: roundEpsilon(entry.startTime),
|
|
29
|
+
duration: roundEpsilon(entry.duration),
|
|
30
|
+
fetchStart: roundEpsilon(entry.fetchStart || 0),
|
|
31
|
+
workerStart: roundEpsilon(entry.workerStart || 0),
|
|
32
|
+
responseStart: roundEpsilon(entry.responseStart || 0),
|
|
33
|
+
requestStart: roundEpsilon(entry.requestStart || 0),
|
|
34
|
+
serverTime,
|
|
35
|
+
networkTime,
|
|
36
|
+
encodedSize: roundEpsilon(entry.encodedBodySize),
|
|
37
|
+
decodedSize: roundEpsilon(entry.decodedBodySize)
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
start: () => {
|
|
41
|
+
var _performance$getEntri;
|
|
42
|
+
const performance = getPerformanceObject();
|
|
43
|
+
const PerformanceObserver = getPerformanceObserverObject();
|
|
44
|
+
if (!PerformanceObserver || !performance || typeof PerformanceObserver === 'undefined') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (resourceTimingBuffer.observer) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const resources = (_performance$getEntri = performance.getEntriesByType) === null || _performance$getEntri === void 0 ? void 0 : _performance$getEntri.call(performance, 'resource');
|
|
51
|
+
if (resources) {
|
|
52
|
+
resourceTimingBuffer.timings = resources.map(resource => resourceTimingBuffer.transformResource(resource));
|
|
53
|
+
}
|
|
54
|
+
resourceTimingBuffer.observer = new PerformanceObserver(resourceTimingBuffer.addTimings);
|
|
55
|
+
resourceTimingBuffer.observer.observe({
|
|
56
|
+
entryTypes: ['resource']
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
stop: () => {
|
|
60
|
+
if (resourceTimingBuffer.observer) {
|
|
61
|
+
resourceTimingBuffer.observer.disconnect();
|
|
62
|
+
resourceTimingBuffer.observer = null;
|
|
63
|
+
}
|
|
64
|
+
resourceTimingBuffer.timings = [];
|
|
65
|
+
},
|
|
66
|
+
addTimings: list => {
|
|
67
|
+
const entries = list.getEntries().map(entry => resourceTimingBuffer.transformResource(entry));
|
|
68
|
+
const overflow = resourceTimingBuffer.timings.length + entries.length;
|
|
69
|
+
if (overflow > resourceTimingBuffer.maxSize) {
|
|
70
|
+
const fieldsToRemove = overflow - resourceTimingBuffer.maxSize;
|
|
71
|
+
resourceTimingBuffer.timings.splice(0, fieldsToRemove);
|
|
72
|
+
}
|
|
73
|
+
resourceTimingBuffer.timings.push(...entries);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const isValidTiming = (timing, startTime, endTime) => timing.startTime >= startTime && timing.startTime + timing.duration <= endTime;
|
|
77
|
+
export const filterResourceTimings = (startTime, endTime) => {
|
|
78
|
+
const performance = getPerformanceObject();
|
|
79
|
+
const PerformanceObserver = getPerformanceObserverObject();
|
|
80
|
+
if (!PerformanceObserver || !resourceTimingBuffer.observer) {
|
|
81
|
+
const resources = performance === null || performance === void 0 ? void 0 : performance.getEntriesByType('resource');
|
|
82
|
+
if (resources) {
|
|
83
|
+
return resources.filter(timing => isValidTiming(timing, startTime, endTime));
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return resourceTimingBuffer.timings.filter(timing => isValidTiming(timing, startTime, endTime));
|
|
88
|
+
};
|