@newrelic/browser-agent 0.1.229 → 0.1.231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -2
- package/dist/cjs/common/browser-version/ios-version.js +4 -3
- package/dist/cjs/common/config/state/configurable.js +3 -2
- package/dist/cjs/common/config/state/info.js +1 -1
- package/dist/cjs/common/config/state/init.js +1 -1
- package/dist/cjs/common/config/state/loader-config.js +1 -1
- package/dist/cjs/common/config/state/runtime.js +6 -5
- package/dist/cjs/common/constants/env.cdn.js +29 -0
- package/dist/cjs/common/constants/env.js +32 -0
- package/dist/cjs/common/constants/env.npm.js +30 -0
- package/dist/cjs/common/context/shared-context.js +2 -1
- package/dist/cjs/common/drain/drain.js +9 -3
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +282 -0
- package/dist/cjs/common/event-emitter/handle.test.js +58 -0
- package/dist/cjs/common/event-emitter/register-handler.test.js +55 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
- package/dist/cjs/common/harvest/harvest-scheduler.js +2 -1
- package/dist/cjs/common/harvest/harvest.js +15 -4
- package/dist/cjs/common/ids/id.js +14 -6
- package/dist/cjs/common/ids/id.test.js +85 -0
- package/dist/cjs/common/ids/unique-id.js +75 -51
- package/dist/cjs/common/ids/unique-id.test.js +49 -0
- package/dist/cjs/common/timing/nav-timing.js +51 -30
- package/dist/cjs/common/timing/nav-timing.test.js +192 -0
- package/dist/cjs/common/url/clean-url.test.js +9 -0
- package/dist/cjs/common/url/encode.test.js +74 -0
- package/dist/cjs/common/url/location.js +4 -0
- package/dist/cjs/common/url/location.test.js +13 -0
- package/dist/cjs/common/url/parse-url.test.js +111 -0
- package/dist/cjs/common/url/protocol.js +2 -12
- package/dist/cjs/common/url/protocol.test.js +16 -0
- package/dist/cjs/common/util/console.js +2 -2
- package/dist/cjs/common/util/map-own.js +21 -14
- package/dist/cjs/common/util/map-own.test.js +49 -0
- package/dist/cjs/common/util/obfuscate.js +1 -1
- package/dist/cjs/common/util/submit-data.js +11 -3
- package/dist/cjs/common/window/page-visibility.js +4 -2
- package/dist/cjs/common/window/session-storage.js +56 -11
- package/dist/cjs/common/wrap/index.js +4 -4
- package/dist/cjs/common/wrap/wrap-events.js +10 -10
- package/dist/cjs/common/wrap/wrap-fetch.js +6 -8
- package/dist/cjs/common/wrap/wrap-function.js +4 -18
- package/dist/cjs/common/wrap/wrap-history.js +7 -6
- package/dist/cjs/common/wrap/wrap-jsonp.js +7 -6
- package/dist/cjs/common/wrap/wrap-mutation.js +7 -6
- package/dist/cjs/common/wrap/wrap-promise.js +11 -7
- package/dist/cjs/common/wrap/wrap-promise.test.js +119 -0
- package/dist/cjs/common/wrap/wrap-raf.js +6 -6
- package/dist/cjs/common/wrap/wrap-timer.js +6 -6
- package/dist/cjs/common/wrap/wrap-xhr.js +5 -6
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- package/dist/cjs/features/ajax/instrument/index.js +2 -1
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +5 -4
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -2
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +6 -5
- package/dist/cjs/features/jserrors/aggregate/index.js +35 -14
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +5 -4
- package/dist/cjs/features/jserrors/instrument/index.js +9 -12
- package/dist/cjs/features/metrics/aggregate/index.js +16 -6
- package/dist/cjs/features/metrics/instrument/index.js +2 -1
- package/dist/cjs/features/metrics/instrument/workers-helper.js +9 -6
- package/dist/cjs/features/page_action/aggregate/index.js +12 -4
- package/dist/cjs/features/page_action/instrument/index.js +2 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +25 -10
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -1
- package/dist/cjs/features/page_view_timing/aggregate/index.js +90 -61
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -1
- package/dist/cjs/features/session_trace/aggregate/index.js +69 -26
- package/dist/cjs/features/session_trace/instrument/index.js +2 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -1
- package/dist/cjs/features/utils/instrument-base.js +8 -3
- package/dist/cjs/features/utils/lazy-loader.js +1 -1
- package/dist/cjs/index.js +9 -9
- package/dist/cjs/loaders/agent.js +3 -2
- package/dist/cjs/loaders/api/api.js +90 -22
- package/dist/cjs/loaders/api/apiAsync.js +3 -3
- package/dist/cjs/loaders/configure/configure.js +13 -7
- package/dist/cjs/loaders/features/enabled-features.js +1 -1
- package/dist/cjs/loaders/micro-agent.js +20 -14
- package/dist/esm/common/browser-version/ios-version.js +4 -3
- package/dist/esm/common/config/state/configurable.js +3 -2
- package/dist/esm/common/config/state/info.js +1 -1
- package/dist/esm/common/config/state/init.js +1 -1
- package/dist/esm/common/config/state/loader-config.js +1 -1
- package/dist/esm/common/config/state/runtime.js +3 -2
- package/dist/esm/common/constants/env.cdn.js +20 -0
- package/dist/esm/common/constants/env.js +23 -0
- package/dist/esm/common/constants/env.npm.js +21 -0
- package/dist/esm/common/context/shared-context.js +2 -1
- package/dist/esm/common/drain/drain.js +9 -3
- package/dist/esm/common/event-emitter/contextual-ee.test.js +278 -0
- package/dist/esm/common/event-emitter/handle.test.js +54 -0
- package/dist/esm/common/event-emitter/register-handler.test.js +51 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
- package/dist/esm/common/harvest/harvest-scheduler.js +2 -1
- package/dist/esm/common/harvest/harvest.js +14 -3
- package/dist/esm/common/ids/id.js +16 -6
- package/dist/esm/common/ids/id.test.js +81 -0
- package/dist/esm/common/ids/unique-id.js +75 -51
- package/dist/esm/common/ids/unique-id.test.js +44 -0
- package/dist/esm/common/timing/nav-timing.js +51 -29
- package/dist/esm/common/timing/nav-timing.test.js +190 -0
- package/dist/esm/common/url/clean-url.test.js +7 -0
- package/dist/esm/common/url/encode.test.js +70 -0
- package/dist/esm/common/url/location.js +4 -0
- package/dist/esm/common/url/location.test.js +11 -0
- package/dist/esm/common/url/parse-url.test.js +107 -0
- package/dist/esm/common/url/protocol.js +3 -12
- package/dist/esm/common/url/protocol.test.js +14 -0
- package/dist/esm/common/util/console.js +2 -2
- package/dist/esm/common/util/map-own.js +19 -13
- package/dist/esm/common/util/map-own.test.js +47 -0
- package/dist/esm/common/util/obfuscate.js +2 -2
- package/dist/esm/common/util/submit-data.js +11 -3
- package/dist/esm/common/window/page-visibility.js +4 -2
- package/dist/esm/common/window/session-storage.js +54 -13
- package/dist/esm/common/wrap/index.js +3 -3
- package/dist/esm/common/wrap/wrap-events.js +11 -11
- package/dist/esm/common/wrap/wrap-fetch.js +7 -9
- package/dist/esm/common/wrap/wrap-function.js +4 -17
- package/dist/esm/common/wrap/wrap-history.js +8 -7
- package/dist/esm/common/wrap/wrap-jsonp.js +8 -7
- package/dist/esm/common/wrap/wrap-mutation.js +7 -6
- package/dist/esm/common/wrap/wrap-promise.js +11 -7
- package/dist/esm/common/wrap/wrap-promise.test.js +115 -0
- package/dist/esm/common/wrap/wrap-raf.js +7 -7
- package/dist/esm/common/wrap/wrap-timer.js +7 -7
- package/dist/esm/common/wrap/wrap-xhr.js +7 -8
- package/dist/esm/features/ajax/aggregate/index.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +2 -1
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +5 -4
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -2
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +6 -5
- package/dist/esm/features/jserrors/aggregate/index.js +35 -14
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +5 -4
- package/dist/esm/features/jserrors/instrument/index.js +9 -12
- package/dist/esm/features/metrics/aggregate/index.js +17 -7
- package/dist/esm/features/metrics/instrument/index.js +2 -1
- package/dist/esm/features/metrics/instrument/workers-helper.js +9 -6
- package/dist/esm/features/page_action/aggregate/index.js +12 -4
- package/dist/esm/features/page_action/instrument/index.js +2 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +25 -10
- package/dist/esm/features/page_view_event/instrument/index.js +2 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +90 -61
- package/dist/esm/features/page_view_timing/instrument/index.js +2 -1
- package/dist/esm/features/session_trace/aggregate/index.js +69 -26
- package/dist/esm/features/session_trace/instrument/index.js +2 -1
- package/dist/esm/features/spa/instrument/index.js +2 -1
- package/dist/esm/features/utils/instrument-base.js +3 -2
- package/dist/esm/features/utils/lazy-loader.js +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/loaders/agent.js +3 -2
- package/dist/esm/loaders/api/api.js +85 -21
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/configure/configure.js +14 -8
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/micro-agent.js +18 -13
- package/dist/types/cdn/lite.d.ts +2 -0
- package/dist/types/cdn/lite.d.ts.map +1 -0
- package/dist/types/cdn/polyfills/lite.d.ts +2 -0
- package/dist/types/cdn/polyfills/lite.d.ts.map +1 -0
- package/dist/types/cdn/polyfills/pro.d.ts +2 -0
- package/dist/types/cdn/polyfills/pro.d.ts.map +1 -0
- package/dist/types/cdn/polyfills/spa.d.ts +2 -0
- package/dist/types/cdn/polyfills/spa.d.ts.map +1 -0
- package/dist/types/cdn/polyfills.d.ts +2 -0
- package/dist/types/cdn/polyfills.d.ts.map +1 -0
- package/dist/types/cdn/pro.d.ts +2 -0
- package/dist/types/cdn/pro.d.ts.map +1 -0
- package/dist/types/cdn/spa.d.ts +2 -0
- package/dist/types/cdn/spa.d.ts.map +1 -0
- package/dist/types/cdn/worker.d.ts +2 -0
- package/dist/types/cdn/worker.d.ts.map +1 -0
- package/dist/types/common/aggregate/aggregator.d.ts +11 -0
- package/dist/types/common/aggregate/aggregator.d.ts.map +1 -0
- package/dist/types/common/browser-version/firefox-version.d.ts +2 -0
- package/dist/types/common/browser-version/firefox-version.d.ts.map +1 -0
- package/dist/types/common/browser-version/ios-version.d.ts +3 -0
- package/dist/types/common/browser-version/ios-version.d.ts.map +1 -0
- package/dist/types/common/config/config.d.ts +13 -0
- package/dist/types/common/config/config.d.ts.map +1 -0
- package/dist/types/common/config/state/configurable.d.ts +4 -0
- package/dist/types/common/config/state/configurable.d.ts.map +1 -0
- package/dist/types/common/config/state/info.d.ts +4 -0
- package/dist/types/common/config/state/info.d.ts.map +1 -0
- package/dist/types/common/config/state/init.d.ts +4 -0
- package/dist/types/common/config/state/init.d.ts.map +1 -0
- package/dist/types/common/config/state/loader-config.d.ts +3 -0
- package/dist/types/common/config/state/loader-config.d.ts.map +1 -0
- package/dist/types/common/config/state/originals.d.ts +2 -0
- package/dist/types/common/config/state/originals.d.ts.map +1 -0
- package/dist/types/common/config/state/runtime.d.ts +3 -0
- package/dist/types/common/config/state/runtime.d.ts.map +1 -0
- package/dist/types/common/constants/env.cdn.d.ts +18 -0
- package/dist/types/common/constants/env.cdn.d.ts.map +1 -0
- package/dist/types/common/constants/env.d.ts +13 -0
- package/dist/types/common/constants/env.d.ts.map +1 -0
- package/dist/types/common/constants/env.npm.d.ts +19 -0
- package/dist/types/common/constants/env.npm.d.ts.map +1 -0
- package/dist/types/common/context/shared-context.d.ts +5 -0
- package/dist/types/common/context/shared-context.d.ts.map +1 -0
- package/dist/types/common/deny-list/deny-list.d.ts +12 -0
- package/dist/types/common/deny-list/deny-list.d.ts.map +1 -0
- package/dist/types/common/drain/drain.d.ts +17 -0
- package/dist/types/common/drain/drain.d.ts.map +1 -0
- package/dist/types/common/event-emitter/contextual-ee.d.ts +4 -0
- package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -0
- package/dist/types/common/event-emitter/handle.d.ts +3 -0
- package/dist/types/common/event-emitter/handle.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +8 -0
- package/dist/types/common/event-emitter/register-handler.d.ts.map +1 -0
- package/dist/types/common/event-listener/event-listener-opts.d.ts +10 -0
- package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts +21 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest.d.ts +58 -0
- package/dist/types/common/harvest/harvest.d.ts.map +1 -0
- package/dist/types/common/ids/id.d.ts +12 -0
- package/dist/types/common/ids/id.d.ts.map +1 -0
- package/dist/types/common/ids/unique-id.d.ts +28 -0
- package/dist/types/common/ids/unique-id.d.ts.map +1 -0
- package/dist/types/common/metrics/framework-detection.d.ts +2 -0
- package/dist/types/common/metrics/framework-detection.d.ts.map +1 -0
- package/dist/types/common/metrics/paint-metrics.d.ts +2 -0
- package/dist/types/common/metrics/paint-metrics.d.ts.map +1 -0
- package/dist/types/common/serialize/bel-serializer.d.ts +5 -0
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -0
- package/dist/types/common/timing/nav-timing.d.ts +4 -0
- package/dist/types/common/timing/nav-timing.d.ts.map +1 -0
- package/dist/types/common/timing/now.d.ts +2 -0
- package/dist/types/common/timing/now.d.ts.map +1 -0
- package/dist/types/common/unload/eol.d.ts +8 -0
- package/dist/types/common/unload/eol.d.ts.map +1 -0
- package/dist/types/common/url/clean-url.d.ts +2 -0
- package/dist/types/common/url/clean-url.d.ts.map +1 -0
- package/dist/types/common/url/encode.d.ts +5 -0
- package/dist/types/common/url/encode.d.ts.map +1 -0
- package/dist/types/common/url/location.d.ts +6 -0
- package/dist/types/common/url/location.d.ts.map +1 -0
- package/dist/types/common/url/parse-url.d.ts +2 -0
- package/dist/types/common/url/parse-url.d.ts.map +1 -0
- package/dist/types/common/url/protocol.d.ts +2 -0
- package/dist/types/common/url/protocol.d.ts.map +1 -0
- package/dist/types/common/util/console.d.ts +8 -0
- package/dist/types/common/util/console.d.ts.map +1 -0
- package/dist/types/common/util/data-size.d.ts +2 -0
- package/dist/types/common/util/data-size.d.ts.map +1 -0
- package/dist/types/common/util/feature-flags.d.ts +3 -0
- package/dist/types/common/util/feature-flags.d.ts.map +1 -0
- package/dist/types/common/util/get-or-set.d.ts +2 -0
- package/dist/types/common/util/get-or-set.d.ts.map +1 -0
- package/dist/types/common/util/global-scope.d.ts +13 -0
- package/dist/types/common/util/global-scope.d.ts.map +1 -0
- package/dist/types/common/util/map-own.d.ts +3 -0
- package/dist/types/common/util/map-own.d.ts.map +1 -0
- package/dist/types/common/util/obfuscate.d.ts +8 -0
- package/dist/types/common/util/obfuscate.d.ts.map +1 -0
- package/dist/types/common/util/s-hash.d.ts +2 -0
- package/dist/types/common/util/s-hash.d.ts.map +1 -0
- package/dist/types/common/util/single.d.ts +2 -0
- package/dist/types/common/util/single.d.ts.map +1 -0
- package/dist/types/common/util/stringify.d.ts +8 -0
- package/dist/types/common/util/stringify.d.ts.map +1 -0
- package/dist/types/common/util/submit-data.d.ts +35 -0
- package/dist/types/common/util/submit-data.d.ts.map +1 -0
- package/dist/types/common/util/traverse.d.ts +2 -0
- package/dist/types/common/util/traverse.d.ts.map +1 -0
- package/dist/types/common/util/user-agent.d.ts +5 -0
- package/dist/types/common/util/user-agent.d.ts.map +1 -0
- package/dist/types/common/window/load.d.ts +3 -0
- package/dist/types/common/window/load.d.ts.map +1 -0
- package/dist/types/common/window/nreum.d.ts +14 -0
- package/dist/types/common/window/nreum.d.ts.map +1 -0
- package/dist/types/common/window/page-visibility.d.ts +7 -0
- package/dist/types/common/window/page-visibility.d.ts.map +1 -0
- package/dist/types/common/window/session-storage.d.ts +18 -0
- package/dist/types/common/window/session-storage.d.ts.map +1 -0
- package/dist/types/common/window/supports-performance-observer.d.ts +2 -0
- package/dist/types/common/window/supports-performance-observer.d.ts.map +1 -0
- package/dist/types/common/wrap/index.d.ts +11 -0
- package/dist/types/common/wrap/index.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-events.d.ts +17 -0
- package/dist/types/common/wrap/wrap-events.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-fetch.d.ts +18 -0
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-function.d.ts +28 -0
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-history.d.ts +16 -0
- package/dist/types/common/wrap/wrap-history.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-jsonp.d.ts +16 -0
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-mutation.d.ts +16 -0
- package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-promise.d.ts +17 -0
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-raf.d.ts +16 -0
- package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-timer.d.ts +17 -0
- package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-xhr.d.ts +16 -0
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -0
- package/dist/types/features/ajax/aggregate/index.d.ts +16 -0
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/ajax/constants.d.ts +2 -0
- package/dist/types/features/ajax/constants.d.ts.map +1 -0
- package/dist/types/features/ajax/index.d.ts +2 -0
- package/dist/types/features/ajax/index.d.ts.map +1 -0
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +19 -0
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -0
- package/dist/types/features/ajax/instrument/index.d.ts +9 -0
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -0
- package/dist/types/features/ajax/instrument/response-size.d.ts +2 -0
- package/dist/types/features/ajax/instrument/response-size.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts +2 -0
- package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts +22 -0
- package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/format-stack-trace.d.ts +3 -0
- package/dist/types/features/jserrors/aggregate/format-stack-trace.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/index.d.ts +24 -0
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/jserrors/aggregate/string-hash-code.d.ts +2 -0
- package/dist/types/features/jserrors/aggregate/string-hash-code.d.ts.map +1 -0
- package/dist/types/features/jserrors/constants.d.ts +3 -0
- package/dist/types/features/jserrors/constants.d.ts.map +1 -0
- package/dist/types/features/jserrors/index.d.ts +2 -0
- package/dist/types/features/jserrors/index.d.ts.map +1 -0
- package/dist/types/features/jserrors/instrument/debug.d.ts +2 -0
- package/dist/types/features/jserrors/instrument/debug.d.ts.map +1 -0
- package/dist/types/features/jserrors/instrument/index.d.ts +22 -0
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/index.d.ts +12 -0
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/metrics/constants.d.ts +6 -0
- package/dist/types/features/metrics/constants.d.ts.map +1 -0
- package/dist/types/features/metrics/index.d.ts +2 -0
- package/dist/types/features/metrics/index.d.ts.map +1 -0
- package/dist/types/features/metrics/instrument/index.d.ts +6 -0
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -0
- package/dist/types/features/metrics/instrument/workers-helper.d.ts +7 -0
- package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -0
- package/dist/types/features/page_action/aggregate/index.d.ts +24 -0
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/page_action/constants.d.ts +2 -0
- package/dist/types/features/page_action/constants.d.ts.map +1 -0
- package/dist/types/features/page_action/index.d.ts +2 -0
- package/dist/types/features/page_action/index.d.ts.map +1 -0
- package/dist/types/features/page_action/instrument/index.d.ts +6 -0
- package/dist/types/features/page_action/instrument/index.d.ts.map +1 -0
- package/dist/types/features/page_view_event/aggregate/index.d.ts +9 -0
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts +8 -0
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -0
- package/dist/types/features/page_view_event/constants.d.ts +5 -0
- package/dist/types/features/page_view_event/constants.d.ts.map +1 -0
- package/dist/types/features/page_view_event/index.d.ts +2 -0
- package/dist/types/features/page_view_event/index.d.ts.map +1 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts +6 -0
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +32 -0
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/constants.d.ts +2 -0
- package/dist/types/features/page_view_timing/constants.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/first-paint.d.ts +2 -0
- package/dist/types/features/page_view_timing/first-paint.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/index.d.ts +2 -0
- package/dist/types/features/page_view_timing/index.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/instrument/index.d.ts +6 -0
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -0
- package/dist/types/features/page_view_timing/long-tasks.d.ts +2 -0
- package/dist/types/features/page_view_timing/long-tasks.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +77 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/session_trace/constants.d.ts +13 -0
- package/dist/types/features/session_trace/constants.d.ts.map +1 -0
- package/dist/types/features/session_trace/index.d.ts +2 -0
- package/dist/types/features/session_trace/index.d.ts.map +1 -0
- package/dist/types/features/session_trace/instrument/index.d.ts +11 -0
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -0
- package/dist/types/features/spa/aggregate/index.d.ts +25 -0
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/spa/aggregate/interaction-node.d.ts +15 -0
- package/dist/types/features/spa/aggregate/interaction-node.d.ts.map +1 -0
- package/dist/types/features/spa/aggregate/interaction.d.ts +20 -0
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -0
- package/dist/types/features/spa/aggregate/serializer.d.ts +15 -0
- package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -0
- package/dist/types/features/spa/constants.d.ts +23 -0
- package/dist/types/features/spa/constants.d.ts.map +1 -0
- package/dist/types/features/spa/index.d.ts +2 -0
- package/dist/types/features/spa/index.d.ts.map +1 -0
- package/dist/types/features/spa/instrument/index.d.ts +8 -0
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts +4 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
- package/dist/types/features/utils/feature-base.d.ts +23 -0
- package/dist/types/features/utils/feature-base.d.ts.map +1 -0
- package/dist/types/features/utils/handler-cache.d.ts +22 -0
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts +27 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -0
- package/dist/types/features/utils/lazy-loader.d.ts +13 -0
- package/dist/types/features/utils/lazy-loader.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/loaders/agent.d.ts +20 -0
- package/dist/types/loaders/agent.d.ts.map +1 -0
- package/dist/types/loaders/api/api.d.ts +17 -0
- package/dist/types/loaders/api/api.d.ts.map +1 -0
- package/dist/types/loaders/api/apiAsync.d.ts +2 -0
- package/dist/types/loaders/api/apiAsync.d.ts.map +1 -0
- package/dist/types/loaders/browser-agent.d.ts +9 -0
- package/dist/types/loaders/browser-agent.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts +10 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -0
- package/dist/types/loaders/features/enabled-features.d.ts +2 -0
- package/dist/types/loaders/features/enabled-features.d.ts.map +1 -0
- package/dist/types/loaders/features/featureDependencies.d.ts +3 -0
- package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -0
- package/dist/types/loaders/features/features.d.ts +18 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -0
- package/dist/types/loaders/micro-agent.d.ts +25 -0
- package/dist/types/loaders/micro-agent.d.ts.map +1 -0
- package/dist/types/loaders/worker-agent.d.ts +8 -0
- package/dist/types/loaders/worker-agent.d.ts.map +1 -0
- package/package.json +67 -59
- package/src/cdn/lite.js +18 -0
- package/src/cdn/polyfills/lite.js +7 -0
- package/src/cdn/polyfills/pro.js +7 -0
- package/src/cdn/polyfills/spa.js +7 -0
- package/src/cdn/polyfills.js +17 -0
- package/src/cdn/pro.js +27 -0
- package/src/cdn/spa.js +28 -0
- package/src/cdn/worker.js +21 -0
- package/src/common/aggregate/aggregator.js +171 -0
- package/src/common/browser-version/firefox-version.js +10 -0
- package/src/common/browser-version/ios-version.js +11 -0
- package/src/common/config/config.js +12 -0
- package/src/common/config/state/configurable.js +26 -0
- package/src/common/config/state/info.js +49 -0
- package/src/common/config/state/init.js +56 -0
- package/src/common/config/state/loader-config.js +25 -0
- package/src/common/config/state/originals.js +3 -0
- package/src/common/config/state/runtime.js +47 -0
- package/src/common/constants/env.cdn.js +20 -0
- package/src/common/constants/env.js +23 -0
- package/src/common/constants/env.npm.js +21 -0
- package/src/common/context/shared-context.js +21 -0
- package/src/common/deny-list/deny-list.js +116 -0
- package/src/common/drain/drain.js +119 -0
- package/src/common/event-emitter/contextual-ee.js +159 -0
- package/src/common/event-emitter/contextual-ee.test.js +310 -0
- package/src/common/event-emitter/handle.js +17 -0
- package/src/common/event-emitter/handle.test.js +56 -0
- package/src/common/event-emitter/register-handler.js +25 -0
- package/src/common/event-emitter/register-handler.test.js +61 -0
- package/src/common/event-listener/event-listener-opts.js +41 -0
- package/src/common/harvest/harvest-scheduler.js +112 -0
- package/src/common/harvest/harvest.js +248 -0
- package/src/common/ids/id.js +32 -0
- package/src/common/ids/id.test.js +92 -0
- package/src/common/ids/unique-id.js +104 -0
- package/src/common/ids/unique-id.test.js +58 -0
- package/src/common/metrics/framework-detection.js +71 -0
- package/src/common/metrics/paint-metrics.js +6 -0
- package/src/common/serialize/bel-serializer.js +93 -0
- package/src/common/timing/nav-timing.js +90 -0
- package/src/common/timing/nav-timing.test.js +161 -0
- package/src/common/timing/now.js +9 -0
- package/src/common/unload/eol.js +62 -0
- package/src/common/url/clean-url.js +10 -0
- package/src/common/url/clean-url.test.js +25 -0
- package/src/common/url/encode.js +75 -0
- package/src/common/url/encode.test.js +80 -0
- package/src/common/url/location.js +12 -0
- package/src/common/url/location.test.js +15 -0
- package/src/common/url/parse-url.js +70 -0
- package/src/common/url/parse-url.test.js +110 -0
- package/src/common/url/protocol.js +9 -0
- package/src/common/url/protocol.test.js +18 -0
- package/src/common/util/console.js +11 -0
- package/src/common/util/data-size.js +21 -0
- package/src/common/util/feature-flags.js +38 -0
- package/src/common/util/get-or-set.js +34 -0
- package/src/common/util/global-scope.js +47 -0
- package/src/common/util/map-own.js +22 -0
- package/src/common/util/map-own.test.js +52 -0
- package/src/common/util/obfuscate.js +73 -0
- package/src/common/util/s-hash.js +14 -0
- package/src/common/util/single.js +18 -0
- package/src/common/util/stringify.js +42 -0
- package/src/common/util/submit-data.js +101 -0
- package/src/common/util/traverse.js +36 -0
- package/src/common/util/user-agent.js +56 -0
- package/src/common/window/load.js +15 -0
- package/src/common/window/nreum.js +110 -0
- package/src/common/window/page-visibility.js +24 -0
- package/src/common/window/session-storage.js +75 -0
- package/src/common/window/supports-performance-observer.js +10 -0
- package/src/common/wrap/index.js +17 -0
- package/src/common/wrap/wrap-events.js +106 -0
- package/src/common/wrap/wrap-fetch.js +110 -0
- package/src/common/wrap/wrap-function.js +248 -0
- package/src/common/wrap/wrap-history.js +51 -0
- package/src/common/wrap/wrap-jsonp.js +136 -0
- package/src/common/wrap/wrap-mutation.js +58 -0
- package/src/common/wrap/wrap-promise.js +166 -0
- package/src/common/wrap/wrap-promise.test.js +140 -0
- package/src/common/wrap/wrap-raf.js +52 -0
- package/src/common/wrap/wrap-timer.js +69 -0
- package/src/common/wrap/wrap-xhr.js +214 -0
- package/src/features/ajax/aggregate/index.js +248 -0
- package/src/features/ajax/constants.js +3 -0
- package/src/features/ajax/index.js +1 -0
- package/src/features/ajax/instrument/distributed-tracing.js +166 -0
- package/src/features/ajax/instrument/index.js +380 -0
- package/src/features/ajax/instrument/response-size.js +18 -0
- package/src/features/jserrors/aggregate/canonical-function-name.js +14 -0
- package/src/features/jserrors/aggregate/canonical-function-name.test.js +13 -0
- package/src/features/jserrors/aggregate/compute-stack-trace.js +231 -0
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +297 -0
- package/src/features/jserrors/aggregate/format-stack-trace.js +30 -0
- package/src/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
- package/src/features/jserrors/aggregate/index.js +310 -0
- package/src/features/jserrors/aggregate/string-hash-code.js +17 -0
- package/src/features/jserrors/aggregate/string-hash-code.test.js +12 -0
- package/src/features/jserrors/constants.js +4 -0
- package/src/features/jserrors/index.js +1 -0
- package/src/features/jserrors/instrument/debug.js +36 -0
- package/src/features/jserrors/instrument/index.js +151 -0
- package/src/features/metrics/aggregate/index.js +133 -0
- package/src/features/metrics/constants.js +7 -0
- package/src/features/metrics/index.js +1 -0
- package/src/features/metrics/instrument/index.js +14 -0
- package/src/features/metrics/instrument/workers-helper.js +113 -0
- package/src/features/page_action/aggregate/index.js +113 -0
- package/src/features/page_action/constants.js +3 -0
- package/src/features/page_action/index.js +1 -0
- package/src/features/page_action/instrument/index.js +15 -0
- package/src/features/page_view_event/aggregate/index.js +143 -0
- package/src/features/page_view_event/aggregate/initialized-features.js +31 -0
- package/src/features/page_view_event/constants.js +6 -0
- package/src/features/page_view_event/index.js +1 -0
- package/src/features/page_view_event/instrument/index.js +33 -0
- package/src/features/page_view_timing/aggregate/index.js +257 -0
- package/src/features/page_view_timing/constants.js +3 -0
- package/src/features/page_view_timing/first-paint.js +41 -0
- package/src/features/page_view_timing/index.js +1 -0
- package/src/features/page_view_timing/instrument/index.js +30 -0
- package/src/features/page_view_timing/long-tasks.js +60 -0
- package/src/features/session_trace/aggregate/index.js +413 -0
- package/src/features/session_trace/constants.js +15 -0
- package/src/features/session_trace/index.js +1 -0
- package/src/features/session_trace/instrument/index.js +127 -0
- package/src/features/spa/aggregate/index.js +738 -0
- package/src/features/spa/aggregate/interaction-node.js +85 -0
- package/src/features/spa/aggregate/interaction-node.test.js +17 -0
- package/src/features/spa/aggregate/interaction.js +112 -0
- package/src/features/spa/aggregate/serializer.js +198 -0
- package/src/features/spa/constants.js +36 -0
- package/src/features/spa/index.js +1 -0
- package/src/features/spa/instrument/index.js +114 -0
- package/src/features/utils/aggregate-base.js +7 -0
- package/src/features/utils/feature-base.js +51 -0
- package/src/features/utils/handler-cache.js +60 -0
- package/src/features/utils/instrument-base.js +68 -0
- package/src/features/utils/lazy-loader.js +37 -0
- package/src/index.js +15 -0
- package/src/loaders/agent.js +80 -0
- package/src/loaders/api/api.js +175 -0
- package/src/loaders/api/apiAsync.js +92 -0
- package/src/loaders/browser-agent.js +33 -0
- package/src/loaders/configure/configure.js +39 -0
- package/src/loaders/features/enabled-features.js +16 -0
- package/src/loaders/features/featureDependencies.js +26 -0
- package/src/loaders/features/features.js +25 -0
- package/src/loaders/micro-agent.js +84 -0
- package/src/loaders/worker-agent.js +24 -0
- package/dist/cjs/common/constants/environment-variables.js +0 -20
- package/dist/cjs/common/util/reduce.js +0 -22
- package/dist/cjs/common/window/top-level-callers.js +0 -23
- package/dist/esm/common/constants/environment-variables.js +0 -11
- package/dist/esm/common/util/reduce.js +0 -16
- package/dist/esm/common/window/top-level-callers.js +0 -17
- package/types.ts +0 -221
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _faker = require("@faker-js/faker");
|
|
4
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
5
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
6
|
+
jest.mock('./handle', () => ({
|
|
7
|
+
__esModule: true,
|
|
8
|
+
handleEE: {}
|
|
9
|
+
}));
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.resetModules();
|
|
12
|
+
jest.resetAllMocks();
|
|
13
|
+
});
|
|
14
|
+
test('should default group to "feature"', async () => {
|
|
15
|
+
const {
|
|
16
|
+
handleEE
|
|
17
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./handle')));
|
|
18
|
+
const {
|
|
19
|
+
registerHandler
|
|
20
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./register-handler')));
|
|
21
|
+
const eventType = _faker.faker.datatype.uuid();
|
|
22
|
+
const eventHandler = jest.fn();
|
|
23
|
+
registerHandler(eventType, eventHandler);
|
|
24
|
+
expect(registerHandler.handlers['feature']).toEqual(expect.objectContaining({
|
|
25
|
+
[eventType]: [expect.arrayContaining([handleEE, eventHandler])]
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
test('should use the provided group', async () => {
|
|
29
|
+
const {
|
|
30
|
+
handleEE
|
|
31
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./handle')));
|
|
32
|
+
const {
|
|
33
|
+
registerHandler
|
|
34
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./register-handler')));
|
|
35
|
+
const eventType = _faker.faker.datatype.uuid();
|
|
36
|
+
const eventGroup = _faker.faker.datatype.uuid();
|
|
37
|
+
const eventHandler = jest.fn();
|
|
38
|
+
registerHandler(eventType, eventHandler, eventGroup);
|
|
39
|
+
expect(registerHandler.handlers[eventGroup]).toEqual(expect.objectContaining({
|
|
40
|
+
[eventType]: [expect.arrayContaining([handleEE, eventHandler])]
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
test('should use the provided event-emitter', async () => {
|
|
44
|
+
const {
|
|
45
|
+
registerHandler
|
|
46
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./register-handler')));
|
|
47
|
+
const scopedEE = {};
|
|
48
|
+
const eventType = _faker.faker.datatype.uuid();
|
|
49
|
+
const eventGroup = _faker.faker.datatype.uuid();
|
|
50
|
+
const eventHandler = jest.fn();
|
|
51
|
+
registerHandler(eventType, eventHandler, eventGroup, scopedEE);
|
|
52
|
+
expect(registerHandler.handlers[eventGroup]).toEqual(expect.objectContaining({
|
|
53
|
+
[eventType]: [expect.arrayContaining([scopedEE, eventHandler])]
|
|
54
|
+
}));
|
|
55
|
+
});
|
|
@@ -37,10 +37,12 @@ function eventListenerOpts(useCapture, abortSignal) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Do not use this within the worker context. */
|
|
40
|
-
function windowAddEventListener(event, listener
|
|
40
|
+
function windowAddEventListener(event, listener) {
|
|
41
|
+
let capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
41
42
|
window.addEventListener(event, listener, eventListenerOpts(capture));
|
|
42
43
|
}
|
|
43
44
|
/** Do not use this within the worker context. */
|
|
44
|
-
function documentAddEventListener(event, listener
|
|
45
|
+
function documentAddEventListener(event, listener) {
|
|
46
|
+
let capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
45
47
|
document.addEventListener(event, listener, eventListenerOpts(capture));
|
|
46
48
|
}
|
|
@@ -43,7 +43,8 @@ class HarvestScheduler extends _sharedContext.SharedContext {
|
|
|
43
43
|
this.started = true;
|
|
44
44
|
this.scheduleHarvest(initialDelay != null ? initialDelay : this.interval);
|
|
45
45
|
}
|
|
46
|
-
stopTimer(
|
|
46
|
+
stopTimer() {
|
|
47
|
+
let permanently = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
47
48
|
this.aborted = permanently; // stopping permanently is same as aborting, but this function also cleans up the setTimeout loop
|
|
48
49
|
this.started = false;
|
|
49
50
|
if (this.timeoutHandle) {
|
|
@@ -17,7 +17,7 @@ var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
|
17
17
|
var _obfuscate = require("../util/obfuscate");
|
|
18
18
|
var _traverse = require("../util/traverse");
|
|
19
19
|
var _sharedContext = require("../context/shared-context");
|
|
20
|
-
var
|
|
20
|
+
var _env = require("../constants/env.npm");
|
|
21
21
|
var _globalScope = require("../util/global-scope");
|
|
22
22
|
/*
|
|
23
23
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -71,6 +71,7 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
71
71
|
* @param {bool} opts.unload - Specify whether the call is a final harvest during page unload.
|
|
72
72
|
*/
|
|
73
73
|
send(endpoint, singlePayload, opts, submitMethod, cbFinished) {
|
|
74
|
+
var _this = this;
|
|
74
75
|
var makeBody = createAccumulator();
|
|
75
76
|
var makeQueryString = createAccumulator();
|
|
76
77
|
if (singlePayload.body) (0, _mapOwn.mapOwn)(singlePayload.body, makeBody);
|
|
@@ -79,11 +80,18 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
79
80
|
body: makeBody(),
|
|
80
81
|
qs: makeQueryString()
|
|
81
82
|
};
|
|
82
|
-
var caller = this.obfuscator.shouldObfuscate() ?
|
|
83
|
+
var caller = this.obfuscator.shouldObfuscate() ? function () {
|
|
84
|
+
return _this.obfuscateAndSend(...arguments);
|
|
85
|
+
} : function () {
|
|
86
|
+
return _this._send(...arguments);
|
|
87
|
+
};
|
|
83
88
|
return caller(endpoint, payload, opts, submitMethod, cbFinished);
|
|
84
89
|
}
|
|
85
90
|
obfuscateAndSend(endpoint, payload, opts, submitMethod, cbFinished) {
|
|
86
|
-
|
|
91
|
+
var _this2 = this;
|
|
92
|
+
(0, _traverse.applyFnToProps)(payload, function () {
|
|
93
|
+
return _this2.obfuscator.obfuscateString(...arguments);
|
|
94
|
+
}, 'string', ['e']);
|
|
87
95
|
return this._send(endpoint, payload, opts, submitMethod, cbFinished);
|
|
88
96
|
}
|
|
89
97
|
_send(endpoint, payload, opts, submitMethod, cbFinished) {
|
|
@@ -117,6 +125,9 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
117
125
|
fullUrl = url + (0, _encode.obj)(payload.body, agentRuntime.maxBytes);
|
|
118
126
|
}
|
|
119
127
|
|
|
128
|
+
// Get bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
|
|
129
|
+
agentRuntime.bytesSent[endpoint] = (agentRuntime.bytesSent[endpoint] || 0) + body?.length || 0;
|
|
130
|
+
|
|
120
131
|
/* Since workers don't support sendBeacon right now, or Image(), they can only use XHR method.
|
|
121
132
|
Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
|
|
122
133
|
we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon. */
|
|
@@ -154,7 +165,7 @@ class Harvest extends _sharedContext.SharedContext {
|
|
|
154
165
|
var info = (0, _config.getInfo)(this.sharedContext.agentIdentifier);
|
|
155
166
|
var location = (0, _cleanUrl.cleanURL)((0, _location.getLocation)());
|
|
156
167
|
var ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location;
|
|
157
|
-
return ['?a=' + info.applicationID, (0, _encode.param)('sa', info.sa ? '' + info.sa : ''), (0, _encode.param)('v',
|
|
168
|
+
return ['?a=' + info.applicationID, (0, _encode.param)('sa', info.sa ? '' + info.sa : ''), (0, _encode.param)('v', _env.VERSION), transactionNameParam(info), (0, _encode.param)('ct', runtime.customTransaction), '&rst=' + (0, _now.now)(), '&ck=0',
|
|
158
169
|
// ck param DEPRECATED - still expected by backend
|
|
159
170
|
'&s=' + (runtime.sessionId || '0'),
|
|
160
171
|
// the 0 id encaps all untrackable and default traffic
|
|
@@ -11,15 +11,23 @@ var _globalScope = require("../util/global-scope");
|
|
|
11
11
|
* SPDX-License-Identifier: Apache-2.0
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
// Start assigning ids at 1 so 0 can always be used for
|
|
14
|
+
// Start assigning ids at 1 so 0 can always be used for Window or WorkerGlobalScope, without
|
|
15
15
|
// actually setting it (which would create a global variable).
|
|
16
|
+
let index = 1;
|
|
17
|
+
const prop = 'nr@id';
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Tags a specified object with an identifier if it does not already
|
|
21
|
+
* have one. If the object is the global scope, zero will be returned
|
|
22
|
+
* and the object will not be modified. If the object already contains
|
|
23
|
+
* an identifier, it will be returned without modification. If the passed
|
|
24
|
+
* value is not an object, function, or array, -1 will be returned without
|
|
25
|
+
* modifying the passed value.
|
|
26
|
+
* @param {object|function|array} obj Object to be tagged with an identifier
|
|
27
|
+
* @returns {number} Identifier of the given object
|
|
28
|
+
*/
|
|
21
29
|
function id(obj) {
|
|
22
|
-
|
|
30
|
+
const type = typeof obj;
|
|
23
31
|
// We can only tag objects, functions, and arrays with ids.
|
|
24
32
|
// For all primitive values we instead return -1.
|
|
25
33
|
if (!obj || !(type === 'object' || type === 'function')) return -1;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
4
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
5
|
+
let idFn;
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
idFn = (await Promise.resolve().then(() => _interopRequireWildcard(require('./id')))).id;
|
|
8
|
+
});
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
jest.resetModules();
|
|
11
|
+
jest.clearAllMocks();
|
|
12
|
+
});
|
|
13
|
+
test.each([{
|
|
14
|
+
input: undefined,
|
|
15
|
+
expected: -1,
|
|
16
|
+
title: 'id of undefined is -1'
|
|
17
|
+
}, {
|
|
18
|
+
input: null,
|
|
19
|
+
expected: -1,
|
|
20
|
+
title: 'id of null is -1'
|
|
21
|
+
}, {
|
|
22
|
+
input: 2,
|
|
23
|
+
expected: -1,
|
|
24
|
+
title: 'id of number is -1'
|
|
25
|
+
}, {
|
|
26
|
+
input: 'foo',
|
|
27
|
+
expected: -1,
|
|
28
|
+
title: 'id of string is -1'
|
|
29
|
+
}])('$title', _ref => {
|
|
30
|
+
let {
|
|
31
|
+
input,
|
|
32
|
+
expected
|
|
33
|
+
} = _ref;
|
|
34
|
+
const result = idFn(input);
|
|
35
|
+
expect(typeof result).toEqual('number');
|
|
36
|
+
expect(result).toEqual(expected);
|
|
37
|
+
});
|
|
38
|
+
test('id values increment sequentially', () => {
|
|
39
|
+
const inputA = {};
|
|
40
|
+
const inputB = {};
|
|
41
|
+
const resultA = idFn(inputA);
|
|
42
|
+
const resultB = idFn(inputB);
|
|
43
|
+
expect(resultA - resultB).toEqual(-1);
|
|
44
|
+
});
|
|
45
|
+
test('id is correctly assigned to function type', () => {
|
|
46
|
+
const input = jest.fn();
|
|
47
|
+
const result = idFn(input);
|
|
48
|
+
expect(result).toEqual(1);
|
|
49
|
+
expect(input['nr@id']).toEqual(1);
|
|
50
|
+
});
|
|
51
|
+
test('id is correctly assigned to object type', () => {
|
|
52
|
+
const input = {};
|
|
53
|
+
const result = idFn(input);
|
|
54
|
+
expect(result).toEqual(1);
|
|
55
|
+
expect(input['nr@id']).toEqual(1);
|
|
56
|
+
});
|
|
57
|
+
test('id is the same when called twice on the same input', () => {
|
|
58
|
+
const input = {};
|
|
59
|
+
const result1 = idFn(input);
|
|
60
|
+
const result2 = idFn(input);
|
|
61
|
+
expect(result1).toEqual(1);
|
|
62
|
+
expect(result2).toEqual(1);
|
|
63
|
+
expect(input['nr@id']).toEqual(1);
|
|
64
|
+
});
|
|
65
|
+
test('id is zero on global scope', async () => {
|
|
66
|
+
const result = idFn(global);
|
|
67
|
+
expect(result).toEqual(0);
|
|
68
|
+
});
|
|
69
|
+
test('id on prototype is correctly inherited', () => {
|
|
70
|
+
const fn = jest.fn();
|
|
71
|
+
const a = {};
|
|
72
|
+
idFn(a);
|
|
73
|
+
fn.prototype = a;
|
|
74
|
+
const b = new fn();
|
|
75
|
+
expect(b['nr@id']).toEqual(a['nr@id']);
|
|
76
|
+
});
|
|
77
|
+
test('id on prototype is different from instance', () => {
|
|
78
|
+
const fn = jest.fn();
|
|
79
|
+
const a = {};
|
|
80
|
+
idFn(a);
|
|
81
|
+
fn.prototype = a;
|
|
82
|
+
const b = new fn();
|
|
83
|
+
const result = idFn(b);
|
|
84
|
+
expect(b['nr@id']).toEqual(result);
|
|
85
|
+
});
|
|
@@ -13,72 +13,96 @@ var _globalScope = require("../util/global-scope");
|
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
const uuidv4Template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a random single hexadecimal value from a provided random value
|
|
20
|
+
* table and corresponding index. If a random value table is not provided,
|
|
21
|
+
* Math.random will be used to generate the value.
|
|
22
|
+
*
|
|
23
|
+
* @param {Uint8Array} valueTable Random value table typically generated using
|
|
24
|
+
* the built-in crypto engine.
|
|
25
|
+
* @param {int} tableIndex The index of the value table to use for generating
|
|
26
|
+
* the hexadecimal value.
|
|
27
|
+
* @returns {int} single hexadecimal value in decimal format
|
|
28
|
+
*/
|
|
29
|
+
function getRandomValue(valueTable, tableIndex) {
|
|
30
|
+
if (valueTable) {
|
|
31
|
+
/**
|
|
32
|
+
* The value table could have any number value in the given index. Use
|
|
33
|
+
* bitwise AND to ensure the value we generate is a valid hex value.
|
|
34
|
+
* x & 15 will ensure the value converted to hex using `toString(16)`
|
|
35
|
+
* falls within the range of 0 and 15 inclusively.
|
|
36
|
+
*/
|
|
37
|
+
return valueTable[tableIndex] & 15;
|
|
38
|
+
} else {
|
|
39
|
+
return Math.random() * 16 | 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generates a RFC compliant UUIDv4 using native browser crypto engine. If the browser
|
|
45
|
+
* does not support the crypto engine, the function will fallback to insecure Math.random()
|
|
46
|
+
* @returns {string} uuid version 4 string
|
|
47
|
+
*/
|
|
16
48
|
function generateUuid() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
49
|
+
const crypto = _globalScope.globalScope?.crypto || _globalScope.globalScope?.msCrypto;
|
|
50
|
+
let randomValueTable;
|
|
51
|
+
let randomValueIndex = 0;
|
|
20
52
|
if (crypto && crypto.getRandomValues) {
|
|
21
53
|
// eslint-disable-next-line
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
function getRandomValue() {
|
|
25
|
-
if (randomVals) {
|
|
26
|
-
// same as % 16
|
|
27
|
-
return randomVals[rvIndex++] & 15;
|
|
28
|
-
} else {
|
|
29
|
-
return Math.random() * 16 | 0;
|
|
30
|
-
}
|
|
54
|
+
randomValueTable = crypto.getRandomValues(new Uint8Array(31));
|
|
31
55
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var c;
|
|
37
|
-
for (var i = 0; i < template.length; i++) {
|
|
38
|
-
c = template[i];
|
|
39
|
-
if (c === 'x') {
|
|
40
|
-
id += getRandomValue().toString(16);
|
|
41
|
-
} else if (c === 'y') {
|
|
56
|
+
return uuidv4Template.split('').map(templateInput => {
|
|
57
|
+
if (templateInput === 'x') {
|
|
58
|
+
return getRandomValue(randomValueTable, ++randomValueIndex).toString(16);
|
|
59
|
+
} else if (templateInput === 'y') {
|
|
42
60
|
// this is the uuid variant per spec (8, 9, a, b)
|
|
43
61
|
// % 4, then shift to get values 8-11
|
|
44
|
-
|
|
45
|
-
id += c.toString(16);
|
|
62
|
+
return (getRandomValue() & 0x3 | 0x8).toString(16);
|
|
46
63
|
} else {
|
|
47
|
-
|
|
64
|
+
return templateInput;
|
|
48
65
|
}
|
|
66
|
+
}).join('');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Generates a string of the given length containing only hexadecimal
|
|
71
|
+
* value 0-9 and a-f.
|
|
72
|
+
* @param {int} length length of the string to generate
|
|
73
|
+
* @returns {string} generated hex string
|
|
74
|
+
*/
|
|
75
|
+
function generateRandomHexString(length) {
|
|
76
|
+
const crypto = _globalScope.globalScope?.crypto || _globalScope.globalScope?.msCrypto;
|
|
77
|
+
let randomValueTable;
|
|
78
|
+
let randomValueIndex = 0;
|
|
79
|
+
if (crypto && crypto.getRandomValues) {
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
randomValueTable = crypto.getRandomValues(new Uint8Array(31));
|
|
49
82
|
}
|
|
50
|
-
|
|
83
|
+
const chars = [];
|
|
84
|
+
for (var i = 0; i < length; i++) {
|
|
85
|
+
chars.push(getRandomValue(randomValueTable, ++randomValueIndex).toString(16));
|
|
86
|
+
}
|
|
87
|
+
return chars.join('');
|
|
51
88
|
}
|
|
52
89
|
|
|
53
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Generates a 16 character length hexadecimal string.
|
|
92
|
+
* per DT-spec.
|
|
93
|
+
* @see generateRandomHexString
|
|
94
|
+
* @returns {string} generated hex string
|
|
95
|
+
*/
|
|
54
96
|
function generateSpanId() {
|
|
55
97
|
return generateRandomHexString(16);
|
|
56
98
|
}
|
|
57
99
|
|
|
58
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Generates a 32 character length hexadecimal string.
|
|
102
|
+
* per DT-spec.
|
|
103
|
+
* @see generateRandomHexString
|
|
104
|
+
* @returns {string} generated hex string
|
|
105
|
+
*/
|
|
59
106
|
function generateTraceId() {
|
|
60
107
|
return generateRandomHexString(32);
|
|
61
|
-
}
|
|
62
|
-
function generateRandomHexString(length) {
|
|
63
|
-
var randomVals = null;
|
|
64
|
-
var rvIndex = 0;
|
|
65
|
-
var crypto = self.crypto || self.msCrypto;
|
|
66
|
-
// eslint-disable-next-line
|
|
67
|
-
if (crypto && crypto.getRandomValues && Uint8Array) {
|
|
68
|
-
// eslint-disable-next-line
|
|
69
|
-
randomVals = crypto.getRandomValues(new Uint8Array(31));
|
|
70
|
-
}
|
|
71
|
-
var chars = [];
|
|
72
|
-
for (var i = 0; i < length; i++) {
|
|
73
|
-
chars.push(getRandomValue().toString(16));
|
|
74
|
-
}
|
|
75
|
-
return chars.join('');
|
|
76
|
-
function getRandomValue() {
|
|
77
|
-
if (randomVals) {
|
|
78
|
-
// same as % 16
|
|
79
|
-
return randomVals[rvIndex++] & 15;
|
|
80
|
-
} else {
|
|
81
|
-
return Math.random() * 16 | 0;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
108
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
4
|
+
var uniqueId = _interopRequireWildcard(require("./unique-id"));
|
|
5
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
6
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
const getRandomValues = jest.fn(arr => _crypto.default.randomBytes(arr.length));
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
delete global.crypto;
|
|
11
|
+
});
|
|
12
|
+
describe('generateUuid', () => {
|
|
13
|
+
const uuidv4Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
14
|
+
test('should generate a uuidv4 that matches the expected format', () => {
|
|
15
|
+
const id = uniqueId.generateUuid();
|
|
16
|
+
expect(uuidv4Regex.test(id)).toEqual(true);
|
|
17
|
+
});
|
|
18
|
+
test('should support using native crypto library', () => {
|
|
19
|
+
global.crypto = {
|
|
20
|
+
getRandomValues
|
|
21
|
+
};
|
|
22
|
+
const id = uniqueId.generateUuid();
|
|
23
|
+
expect(uuidv4Regex.test(id)).toEqual(true);
|
|
24
|
+
expect(getRandomValues).toHaveBeenCalledTimes(1);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('generateRandomHexString', () => {
|
|
28
|
+
const hexRegex = /^[0-9a-f]{8}$/;
|
|
29
|
+
test('should generate a valid hex string', () => {
|
|
30
|
+
const id = uniqueId.generateRandomHexString(8);
|
|
31
|
+
expect(hexRegex.test(id)).toEqual(true);
|
|
32
|
+
});
|
|
33
|
+
test('should support using native crypto library', () => {
|
|
34
|
+
global.crypto = {
|
|
35
|
+
getRandomValues
|
|
36
|
+
};
|
|
37
|
+
const id = uniqueId.generateRandomHexString(8);
|
|
38
|
+
expect(hexRegex.test(id)).toEqual(true);
|
|
39
|
+
expect(getRandomValues).toHaveBeenCalledTimes(1);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
test('generateSpanId should generate a 16 character hex string', () => {
|
|
43
|
+
const id = uniqueId.generateSpanId();
|
|
44
|
+
expect(/^[0-9a-f]{16}$/.test(id)).toEqual(true);
|
|
45
|
+
});
|
|
46
|
+
test('generateTraceId should generate a 32 character hex string', () => {
|
|
47
|
+
const id = uniqueId.generateTraceId();
|
|
48
|
+
expect(/^[0-9a-f]{32}$/.test(id)).toEqual(true);
|
|
49
|
+
});
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.addPN = addPN;
|
|
7
7
|
exports.addPT = addPT;
|
|
8
|
-
exports.addRel = addRel;
|
|
9
8
|
exports.navTimingValues = void 0;
|
|
10
9
|
/*
|
|
11
10
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -35,43 +34,65 @@ var LOAD_EVENT = 'loadEvent';
|
|
|
35
34
|
var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent';
|
|
36
35
|
var navTimingValues = [];
|
|
37
36
|
exports.navTimingValues = navTimingValues;
|
|
38
|
-
function
|
|
37
|
+
function getPntType(type) {
|
|
38
|
+
if (typeof type == 'number') return type;
|
|
39
|
+
const types = {
|
|
40
|
+
navigate: undefined,
|
|
41
|
+
reload: 1,
|
|
42
|
+
back_forward: 2,
|
|
43
|
+
prerender: 3
|
|
44
|
+
};
|
|
45
|
+
return types[type];
|
|
46
|
+
}
|
|
47
|
+
function addPT(offset, pt) {
|
|
48
|
+
let v = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
49
|
+
let isL1Api = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
50
|
+
if (!pt) return;
|
|
39
51
|
v.of = offset;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
handleValue(v.of, v, 'n', true);
|
|
53
|
+
handleValue(pt[UNLOAD_EVENT + START], v, 'u', isL1Api);
|
|
54
|
+
handleValue(pt[REDIRECT + START], v, 'r', isL1Api);
|
|
55
|
+
handleValue(pt[UNLOAD_EVENT + END], v, 'ue', isL1Api);
|
|
56
|
+
handleValue(pt[REDIRECT + END], v, 're', isL1Api);
|
|
57
|
+
handleValue(pt['fetch' + START], v, 'f', isL1Api);
|
|
58
|
+
handleValue(pt[DOMAIN_LOOKUP + START], v, 'dn', isL1Api);
|
|
59
|
+
handleValue(pt[DOMAIN_LOOKUP + END], v, 'dne', isL1Api);
|
|
60
|
+
handleValue(pt['c' + ONNECT + START], v, 'c', isL1Api);
|
|
61
|
+
handleValue(pt['secureC' + ONNECT + 'ion' + START], v, 's', isL1Api);
|
|
62
|
+
handleValue(pt['c' + ONNECT + END], v, 'ce', isL1Api);
|
|
63
|
+
handleValue(pt[REQUEST + START], v, 'rq', isL1Api);
|
|
64
|
+
handleValue(pt[RESPONSE + START], v, 'rp', isL1Api);
|
|
65
|
+
handleValue(pt[RESPONSE + END], v, 'rpe', isL1Api);
|
|
66
|
+
handleValue(pt.domLoading, v, 'dl', isL1Api);
|
|
67
|
+
handleValue(pt.domInteractive, v, 'di', isL1Api);
|
|
68
|
+
handleValue(pt[DOM_CONTENT_LOAD_EVENT + START], v, 'ds', isL1Api);
|
|
69
|
+
handleValue(pt[DOM_CONTENT_LOAD_EVENT + END], v, 'de', isL1Api);
|
|
70
|
+
handleValue(pt.domComplete, v, 'dc', isL1Api);
|
|
71
|
+
handleValue(pt[LOAD_EVENT + START], v, 'l', isL1Api);
|
|
72
|
+
handleValue(pt[LOAD_EVENT + END], v, 'le', isL1Api);
|
|
61
73
|
return v;
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
// Add Performance Navigation values to the given object
|
|
65
77
|
function addPN(pn, v) {
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
handleValue(getPntType(pn.type), v, 'ty');
|
|
79
|
+
handleValue(pn.redirectCount, v, 'rc');
|
|
68
80
|
return v;
|
|
69
81
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
82
|
+
function handleValue(value, obj, prop, isOldApi) {
|
|
83
|
+
/*
|
|
84
|
+
For L2 Timing API, the value will already be a relative-to-previous-document DOMHighResTimeStamp.
|
|
85
|
+
For L1 (deprecated) Timing, the value is an UNIX epoch timestamp, which we will convert to a relative time using our offset.
|
|
86
|
+
PNT.type is reported as undefined, 1, 2, etc -- note that zero-value properties will be recorded as 'undefined', however DEM interprets undefined "types" as "navigate"
|
|
87
|
+
*/
|
|
72
88
|
if (typeof value === 'number' && value > 0) {
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
// note that zero-value properties will be recorded as 'undefined'
|
|
90
|
+
if (isOldApi) {
|
|
91
|
+
const offset = obj?.of > 0 ? obj.of : 0; // expect an epoch timestamp, if called by addPT
|
|
92
|
+
value = Math.max(value - offset, 0);
|
|
93
|
+
}
|
|
94
|
+
value = Math.round(value);
|
|
95
|
+
obj[prop] = value;
|
|
75
96
|
}
|
|
76
|
-
navTimingValues.push(
|
|
97
|
+
navTimingValues.push(value);
|
|
77
98
|
}
|