@newrelic/browser-agent 0.1.229 → 0.1.230
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 +40 -1
- package/dist/cjs/common/config/state/configurable.js +2 -1
- package/dist/cjs/common/config/state/runtime.js +1 -0
- package/dist/cjs/common/constants/environment-variables.js +1 -1
- package/dist/cjs/common/context/shared-context.js +2 -1
- package/dist/cjs/common/drain/drain.js +9 -3
- 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 +13 -2
- package/dist/cjs/common/util/console.js +1 -1
- 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/submit-data.js +11 -3
- package/dist/cjs/common/window/page-visibility.js +2 -1
- package/dist/cjs/common/window/session-storage.js +56 -11
- package/dist/cjs/common/wrap/index.js +11 -4
- package/dist/cjs/common/wrap/wrap-console.js +54 -0
- package/dist/cjs/common/wrap/wrap-events.js +4 -1
- package/dist/cjs/common/wrap/wrap-fetch.js +0 -2
- package/dist/cjs/common/wrap/wrap-function.js +4 -18
- package/dist/cjs/common/wrap/wrap-promise.js +4 -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/format-stack-trace.test.js +5 -4
- package/dist/cjs/features/jserrors/aggregate/index.js +32 -11
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +5 -4
- package/dist/cjs/features/jserrors/instrument/index.js +7 -10
- package/dist/cjs/features/metrics/aggregate/index.js +11 -0
- package/dist/cjs/features/metrics/instrument/index.js +27 -1
- package/dist/cjs/features/metrics/instrument/workers-helper.js +4 -1
- package/dist/cjs/features/page_action/aggregate/index.js +11 -3
- package/dist/cjs/features/page_action/instrument/index.js +2 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +8 -4
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -1
- package/dist/cjs/features/page_view_timing/aggregate/index.js +54 -35
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -1
- package/dist/cjs/features/session_trace/aggregate/index.js +53 -13
- 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 +2 -1
- package/dist/cjs/index.js +9 -9
- package/dist/cjs/loaders/agent.js +2 -1
- package/dist/cjs/loaders/api/api.js +86 -21
- package/dist/cjs/loaders/api/apiAsync.js +3 -3
- package/dist/cjs/loaders/configure/configure.js +13 -7
- package/dist/cjs/loaders/micro-agent.js +18 -13
- package/dist/esm/common/config/state/configurable.js +2 -1
- package/dist/esm/common/config/state/runtime.js +1 -0
- package/dist/esm/common/constants/environment-variables.js +1 -1
- package/dist/esm/common/context/shared-context.js +2 -1
- package/dist/esm/common/drain/drain.js +9 -3
- 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 +13 -2
- package/dist/esm/common/util/console.js +1 -1
- 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/submit-data.js +11 -3
- package/dist/esm/common/window/page-visibility.js +2 -1
- package/dist/esm/common/window/session-storage.js +54 -13
- package/dist/esm/common/wrap/index.js +5 -4
- package/dist/esm/common/wrap/wrap-console.js +46 -0
- package/dist/esm/common/wrap/wrap-events.js +5 -2
- package/dist/esm/common/wrap/wrap-fetch.js +1 -3
- package/dist/esm/common/wrap/wrap-function.js +4 -17
- package/dist/esm/common/wrap/wrap-history.js +1 -1
- package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +4 -1
- package/dist/esm/common/wrap/wrap-raf.js +1 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/common/wrap/wrap-xhr.js +2 -2
- 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/format-stack-trace.test.js +5 -4
- package/dist/esm/features/jserrors/aggregate/index.js +32 -11
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +5 -4
- package/dist/esm/features/jserrors/instrument/index.js +7 -10
- package/dist/esm/features/metrics/aggregate/index.js +11 -0
- package/dist/esm/features/metrics/instrument/index.js +27 -1
- package/dist/esm/features/metrics/instrument/workers-helper.js +4 -1
- package/dist/esm/features/page_action/aggregate/index.js +11 -3
- package/dist/esm/features/page_action/instrument/index.js +2 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +8 -4
- package/dist/esm/features/page_view_event/instrument/index.js +2 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +54 -35
- package/dist/esm/features/page_view_timing/instrument/index.js +2 -1
- package/dist/esm/features/session_trace/aggregate/index.js +53 -13
- 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 +2 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/loaders/agent.js +2 -1
- 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/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/environment-variables.d.ts +4 -0
- package/dist/types/common/constants/environment-variables.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 +2 -0
- package/dist/types/common/ids/id.d.ts.map +1 -0
- package/dist/types/common/ids/unique-id.d.ts +5 -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 +5 -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 +2 -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 +7 -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 +12 -0
- package/dist/types/common/wrap/index.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-console.d.ts +16 -0
- package/dist/types/common/wrap/wrap-console.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 +7 -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 +33 -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 +61 -32
- 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 +10 -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 +45 -0
- package/src/common/constants/environment-variables.js +11 -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/handle.js +17 -0
- package/src/common/event-emitter/register-handler.js +25 -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 +23 -0
- package/src/common/ids/unique-id.js +81 -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 +70 -0
- package/src/common/timing/now.js +9 -0
- package/src/common/unload/eol.js +63 -0
- package/src/common/url/clean-url.js +10 -0
- package/src/common/url/encode.js +75 -0
- package/src/common/url/location.js +8 -0
- package/src/common/url/parse-url.js +71 -0
- package/src/common/url/protocol.js +19 -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 +48 -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 +18 -0
- package/src/common/wrap/wrap-console.js +47 -0
- package/src/common/wrap/wrap-events.js +106 -0
- package/src/common/wrap/wrap-fetch.js +109 -0
- package/src/common/wrap/wrap-function.js +248 -0
- package/src/common/wrap/wrap-history.js +48 -0
- package/src/common/wrap/wrap-jsonp.js +134 -0
- package/src/common/wrap/wrap-mutation.js +55 -0
- package/src/common/wrap/wrap-promise.js +165 -0
- package/src/common/wrap/wrap-raf.js +50 -0
- package/src/common/wrap/wrap-timer.js +67 -0
- package/src/common/wrap/wrap-xhr.js +213 -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 +149 -0
- package/src/features/metrics/aggregate/index.js +134 -0
- package/src/features/metrics/constants.js +7 -0
- package/src/features/metrics/index.js +1 -0
- package/src/features/metrics/instrument/index.js +44 -0
- package/src/features/metrics/instrument/workers-helper.js +110 -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 +134 -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 +246 -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 +410 -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 +126 -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 +112 -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/util/reduce.js +0 -22
- package/dist/cjs/common/window/top-level-callers.js +0 -23
- 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,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { globalScope } from '../util/global-scope'
|
|
7
|
+
|
|
8
|
+
export function generateUuid () {
|
|
9
|
+
var randomVals = null
|
|
10
|
+
var rvIndex = 0
|
|
11
|
+
var crypto = globalScope?.crypto || globalScope?.msCrypto
|
|
12
|
+
if (crypto && crypto.getRandomValues) {
|
|
13
|
+
// eslint-disable-next-line
|
|
14
|
+
randomVals = crypto.getRandomValues(new Uint8Array(31))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getRandomValue () {
|
|
18
|
+
if (randomVals) {
|
|
19
|
+
// same as % 16
|
|
20
|
+
return randomVals[rvIndex++] & 15
|
|
21
|
+
} else {
|
|
22
|
+
return Math.random() * 16 | 0
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// v4 UUID
|
|
27
|
+
var template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
|
28
|
+
var id = ''
|
|
29
|
+
var c
|
|
30
|
+
for (var i = 0; i < template.length; i++) {
|
|
31
|
+
c = template[i]
|
|
32
|
+
if (c === 'x') {
|
|
33
|
+
id += getRandomValue().toString(16)
|
|
34
|
+
} else if (c === 'y') {
|
|
35
|
+
// this is the uuid variant per spec (8, 9, a, b)
|
|
36
|
+
// % 4, then shift to get values 8-11
|
|
37
|
+
c = getRandomValue() & 0x3 | 0x8
|
|
38
|
+
id += c.toString(16)
|
|
39
|
+
} else {
|
|
40
|
+
id += c
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return id
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 16-character hex string (per DT spec)
|
|
48
|
+
export function generateSpanId () {
|
|
49
|
+
return generateRandomHexString(16)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 32-character hex string (per DT spec)
|
|
53
|
+
export function generateTraceId () {
|
|
54
|
+
return generateRandomHexString(32)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function generateRandomHexString (length) {
|
|
58
|
+
var randomVals = null
|
|
59
|
+
var rvIndex = 0
|
|
60
|
+
var crypto = self.crypto || self.msCrypto
|
|
61
|
+
// eslint-disable-next-line
|
|
62
|
+
if (crypto && crypto.getRandomValues && Uint8Array) {
|
|
63
|
+
// eslint-disable-next-line
|
|
64
|
+
randomVals = crypto.getRandomValues(new Uint8Array(31))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var chars = []
|
|
68
|
+
for (var i = 0; i < length; i++) {
|
|
69
|
+
chars.push(getRandomValue().toString(16))
|
|
70
|
+
}
|
|
71
|
+
return chars.join('')
|
|
72
|
+
|
|
73
|
+
function getRandomValue () {
|
|
74
|
+
if (randomVals) {
|
|
75
|
+
// same as % 16
|
|
76
|
+
return randomVals[rvIndex++] & 15
|
|
77
|
+
} else {
|
|
78
|
+
return Math.random() * 16 | 0
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isBrowserScope } from '../util/global-scope'
|
|
2
|
+
|
|
3
|
+
var FRAMEWORKS = {
|
|
4
|
+
REACT: 'React',
|
|
5
|
+
ANGULAR: 'Angular',
|
|
6
|
+
ANGULARJS: 'AngularJS',
|
|
7
|
+
BACKBONE: 'Backbone',
|
|
8
|
+
EMBER: 'Ember',
|
|
9
|
+
VUE: 'Vue',
|
|
10
|
+
METEOR: 'Meteor',
|
|
11
|
+
ZEPTO: 'Zepto',
|
|
12
|
+
JQUERY: 'Jquery'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getFrameworks () {
|
|
16
|
+
if (!isBrowserScope) return [] // don't bother detecting frameworks if not in the main window context
|
|
17
|
+
|
|
18
|
+
var frameworks = []
|
|
19
|
+
try {
|
|
20
|
+
if (detectReact()) frameworks.push(FRAMEWORKS.REACT)
|
|
21
|
+
if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS)
|
|
22
|
+
if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR)
|
|
23
|
+
if (window.Backbone) frameworks.push(FRAMEWORKS.BACKBONE)
|
|
24
|
+
if (window.Ember) frameworks.push(FRAMEWORKS.EMBER)
|
|
25
|
+
if (window.Vue) frameworks.push(FRAMEWORKS.VUE)
|
|
26
|
+
if (window.Meteor) frameworks.push(FRAMEWORKS.METEOR)
|
|
27
|
+
if (window.Zepto) frameworks.push(FRAMEWORKS.ZEPTO)
|
|
28
|
+
if (window.jQuery) frameworks.push(FRAMEWORKS.JQUERY)
|
|
29
|
+
} catch (err) {
|
|
30
|
+
// not supported?
|
|
31
|
+
}
|
|
32
|
+
return frameworks
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function detectReact () {
|
|
36
|
+
try {
|
|
37
|
+
if (!!window.React || !!window.ReactDOM || !!window.ReactRedux) return true
|
|
38
|
+
if (document.querySelector('[data-reactroot], [data-reactid]')) return true
|
|
39
|
+
var divs = document.querySelectorAll('body > div')
|
|
40
|
+
for (var i = 0; i < divs.length; i++) {
|
|
41
|
+
if (Object.keys(divs[i]).indexOf('_reactRootContainer') >= 0) return true
|
|
42
|
+
}
|
|
43
|
+
return false
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// not supported?
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function detectAngularJs () {
|
|
51
|
+
try {
|
|
52
|
+
if (window.angular) return true
|
|
53
|
+
if (document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]')) return true
|
|
54
|
+
if (document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]')) return true
|
|
55
|
+
return false
|
|
56
|
+
} catch (err) {
|
|
57
|
+
// not supported?
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function detectAngular () {
|
|
63
|
+
try {
|
|
64
|
+
// eslint-disable-next-line
|
|
65
|
+
if (window.hasOwnProperty('ng') && window.ng.hasOwnProperty('coreTokens') && window.ng.coreTokens.hasOwnProperty('NgZone')) return true
|
|
66
|
+
return !!document.querySelectorAll('[ng-version]').length
|
|
67
|
+
} catch (err) {
|
|
68
|
+
// not supported?
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { mapOwn } from '../util/map-own'
|
|
7
|
+
import { stringify } from '../util/stringify'
|
|
8
|
+
import { Obfuscator } from '../util/obfuscate'
|
|
9
|
+
|
|
10
|
+
var hasOwnProp = Object.prototype.hasOwnProperty
|
|
11
|
+
var MAX_ATTRIBUTES = 64
|
|
12
|
+
|
|
13
|
+
export function nullable (val, fn, comma) {
|
|
14
|
+
return val || val === 0 || val === ''
|
|
15
|
+
? fn(val) + (comma ? ',' : '')
|
|
16
|
+
: '!'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function numeric (n, noDefault) {
|
|
20
|
+
if (noDefault) {
|
|
21
|
+
return Math.floor(n).toString(36)
|
|
22
|
+
}
|
|
23
|
+
return (n === undefined || n === 0) ? '' : Math.floor(n).toString(36)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getAddStringContext (agentIdentifier) {
|
|
27
|
+
// eslint-disable-next-line
|
|
28
|
+
var stringTable = Object.hasOwnProperty('create') ? Object.create(null) : {}
|
|
29
|
+
var stringTableIdx = 0
|
|
30
|
+
|
|
31
|
+
return addString
|
|
32
|
+
|
|
33
|
+
function addString (str) {
|
|
34
|
+
if (typeof str === 'undefined' || str === '') return ''
|
|
35
|
+
var obfuscator = new Obfuscator({ agentIdentifier: agentIdentifier })
|
|
36
|
+
str = String(str)
|
|
37
|
+
if (obfuscator.shouldObfuscate()) str = obfuscator.obfuscateString(str)
|
|
38
|
+
if (hasOwnProp.call(stringTable, str)) {
|
|
39
|
+
return numeric(stringTable[str], true)
|
|
40
|
+
} else {
|
|
41
|
+
stringTable[str] = stringTableIdx++
|
|
42
|
+
return quoteString(str)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function addCustomAttributes (attrs, addString) {
|
|
48
|
+
var attrParts = []
|
|
49
|
+
|
|
50
|
+
mapOwn(attrs, function (key, val) {
|
|
51
|
+
if (attrParts.length >= MAX_ATTRIBUTES) return
|
|
52
|
+
var type = 5
|
|
53
|
+
var serializedValue
|
|
54
|
+
// add key to string table first
|
|
55
|
+
key = addString(key)
|
|
56
|
+
|
|
57
|
+
switch (typeof val) {
|
|
58
|
+
case 'object':
|
|
59
|
+
if (val) {
|
|
60
|
+
// serialize objects to strings
|
|
61
|
+
serializedValue = addString(stringify(val))
|
|
62
|
+
} else {
|
|
63
|
+
// null attribute type
|
|
64
|
+
type = 9
|
|
65
|
+
}
|
|
66
|
+
break
|
|
67
|
+
case 'number':
|
|
68
|
+
type = 6
|
|
69
|
+
// make sure numbers contain a `.` so they are parsed as doubles
|
|
70
|
+
serializedValue = val % 1 ? val : val + '.'
|
|
71
|
+
break
|
|
72
|
+
case 'boolean':
|
|
73
|
+
type = val ? 7 : 8
|
|
74
|
+
break
|
|
75
|
+
case 'undefined':
|
|
76
|
+
// we treat undefined as a null attribute (since dirac does not have a concept of undefined)
|
|
77
|
+
type = 9
|
|
78
|
+
break
|
|
79
|
+
default:
|
|
80
|
+
serializedValue = addString(val)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
attrParts.push([type, key + (serializedValue ? ',' + serializedValue : '')])
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
return attrParts
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var escapable = /([,\\;])/g
|
|
90
|
+
|
|
91
|
+
function quoteString (str) {
|
|
92
|
+
return "'" + str.replace(escapable, '\\$1')
|
|
93
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// We don't use JSON.stringify directly on the performance timing data for these reasons:
|
|
7
|
+
// * Chrome has extra data in the performance object that we don't want to send all the time (wasteful)
|
|
8
|
+
// * Firefox fails to stringify the native object due to - http://code.google.com/p/v8/issues/detail?id=1223
|
|
9
|
+
// * The variable names are long and wasteful to transmit
|
|
10
|
+
|
|
11
|
+
// Add Performance Timing values to the given object.
|
|
12
|
+
// * Values are written relative to an offset to reduce their length (i.e. number of characters).
|
|
13
|
+
// * The offset is sent with the data
|
|
14
|
+
// * 0's are not included unless the value is a 'relative zero'
|
|
15
|
+
//
|
|
16
|
+
|
|
17
|
+
var START = 'Start'
|
|
18
|
+
var END = 'End'
|
|
19
|
+
var UNLOAD_EVENT = 'unloadEvent'
|
|
20
|
+
var REDIRECT = 'redirect'
|
|
21
|
+
var DOMAIN_LOOKUP = 'domainLookup'
|
|
22
|
+
var ONNECT = 'onnect'
|
|
23
|
+
var REQUEST = 'request'
|
|
24
|
+
var RESPONSE = 'response'
|
|
25
|
+
var LOAD_EVENT = 'loadEvent'
|
|
26
|
+
var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent'
|
|
27
|
+
|
|
28
|
+
export var navTimingValues = []
|
|
29
|
+
|
|
30
|
+
export function addPT (offset, pt, v) {
|
|
31
|
+
v.of = offset
|
|
32
|
+
addRel(offset, offset, v, 'n')
|
|
33
|
+
addRel(pt[UNLOAD_EVENT + START], offset, v, 'u')
|
|
34
|
+
addRel(pt[REDIRECT + START], offset, v, 'r')
|
|
35
|
+
addRel(pt[UNLOAD_EVENT + END], offset, v, 'ue')
|
|
36
|
+
addRel(pt[REDIRECT + END], offset, v, 're')
|
|
37
|
+
addRel(pt['fetch' + START], offset, v, 'f')
|
|
38
|
+
addRel(pt[DOMAIN_LOOKUP + START], offset, v, 'dn')
|
|
39
|
+
addRel(pt[DOMAIN_LOOKUP + END], offset, v, 'dne')
|
|
40
|
+
addRel(pt['c' + ONNECT + START], offset, v, 'c')
|
|
41
|
+
addRel(pt['secureC' + ONNECT + 'ion' + START], offset, v, 's')
|
|
42
|
+
addRel(pt['c' + ONNECT + END], offset, v, 'ce')
|
|
43
|
+
addRel(pt[REQUEST + START], offset, v, 'rq')
|
|
44
|
+
addRel(pt[RESPONSE + START], offset, v, 'rp')
|
|
45
|
+
addRel(pt[RESPONSE + END], offset, v, 'rpe')
|
|
46
|
+
addRel(pt.domLoading, offset, v, 'dl')
|
|
47
|
+
addRel(pt.domInteractive, offset, v, 'di')
|
|
48
|
+
addRel(pt[DOM_CONTENT_LOAD_EVENT + START], offset, v, 'ds')
|
|
49
|
+
addRel(pt[DOM_CONTENT_LOAD_EVENT + END], offset, v, 'de')
|
|
50
|
+
addRel(pt.domComplete, offset, v, 'dc')
|
|
51
|
+
addRel(pt[LOAD_EVENT + START], offset, v, 'l')
|
|
52
|
+
addRel(pt[LOAD_EVENT + END], offset, v, 'le')
|
|
53
|
+
return v
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Add Performance Navigation values to the given object
|
|
57
|
+
export function addPN (pn, v) {
|
|
58
|
+
addRel(pn.type, 0, v, 'ty')
|
|
59
|
+
addRel(pn.redirectCount, 0, v, 'rc')
|
|
60
|
+
return v
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function addRel (value, offset, obj, prop) {
|
|
64
|
+
var relativeValue
|
|
65
|
+
if (typeof (value) === 'number' && (value > 0)) {
|
|
66
|
+
relativeValue = Math.max(Math.round(value - offset), 0)
|
|
67
|
+
obj[prop] = relativeValue
|
|
68
|
+
}
|
|
69
|
+
navTimingValues.push(relativeValue)
|
|
70
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// This is our own layer around performance.now. It's not strictly necessary, but we keep it in case of future mod-ing of the value for refactor purpose.
|
|
7
|
+
export function now () {
|
|
8
|
+
return Math.round(performance.now())
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { ffVersion } from '../browser-version/firefox-version'
|
|
6
|
+
import { windowAddEventListener } from '../event-listener/event-listener-opts'
|
|
7
|
+
import { single } from '../util/single'
|
|
8
|
+
import { globalScope, isWorkerScope, isBrowserScope } from '../util/global-scope'
|
|
9
|
+
import { subscribeToVisibilityChange } from '../window/page-visibility'
|
|
10
|
+
|
|
11
|
+
if (isWorkerScope) {
|
|
12
|
+
globalScope.cleanupTasks = [] // create new list on WorkerGlobalScope to track funcs to run before exiting thread
|
|
13
|
+
|
|
14
|
+
const origClose = globalScope.close
|
|
15
|
+
globalScope.close = () => { // on worker's EoL signal, execute all "listeners", e.g. final harvests
|
|
16
|
+
for (let task of globalScope.cleanupTasks) {
|
|
17
|
+
task()
|
|
18
|
+
}
|
|
19
|
+
origClose()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Subscribes a provided callback to the time/event when the agent should treat it as end-of-life.
|
|
25
|
+
* This is used, for example, to submit a final harvest and send all remaining data on best-effort.
|
|
26
|
+
* @param {function} cb - func to run before or during the last reliable event or time of an env's life span
|
|
27
|
+
* @param {boolean} allowBFCache - (temp) feature flag to gate new v1222 BFC support
|
|
28
|
+
*/
|
|
29
|
+
export function subscribeToEOL (cb, allowBFCache) {
|
|
30
|
+
if (isBrowserScope) {
|
|
31
|
+
if (allowBFCache) {
|
|
32
|
+
subscribeToVisibilityChange(cb, true) // when user switches tab or hides window, esp. mobile scenario
|
|
33
|
+
windowAddEventListener('pagehide', cb) // when user navigates away, and because safari iOS v14.4- doesn't fully support vis change
|
|
34
|
+
// --this ought to be removed once support for version below 14.5 phases out
|
|
35
|
+
} else {
|
|
36
|
+
var oneCall = single(cb)
|
|
37
|
+
|
|
38
|
+
// Firefox has a bug wherein a slow-loading resource loaded from the 'pagehide'
|
|
39
|
+
// or 'unload' event will delay the 'load' event firing on the next page load.
|
|
40
|
+
// In Firefox versions that support sendBeacon, this doesn't matter, because
|
|
41
|
+
// we'll use it instead of an image load for our final harvest.
|
|
42
|
+
//
|
|
43
|
+
// Some Safari versions never fire the 'unload' event for pages that are being
|
|
44
|
+
// put into the WebKit page cache, so we *need* to use the pagehide event for
|
|
45
|
+
// the final submission from Safari.
|
|
46
|
+
//
|
|
47
|
+
// Generally speaking, we will try to submit our final harvest from either
|
|
48
|
+
// pagehide or unload, whichever comes first, but in Firefox, we need to avoid
|
|
49
|
+
// attempting to submit from pagehide to ensure that we don't slow down loading
|
|
50
|
+
// of the next page.
|
|
51
|
+
if (!ffVersion || navigator.sendBeacon) {
|
|
52
|
+
windowAddEventListener('pagehide', oneCall)
|
|
53
|
+
} else {
|
|
54
|
+
windowAddEventListener('beforeunload', oneCall)
|
|
55
|
+
}
|
|
56
|
+
windowAddEventListener('unload', oneCall)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (isWorkerScope) {
|
|
60
|
+
globalScope.cleanupTasks.push(cb) // close() should run these tasks before quitting thread
|
|
61
|
+
}
|
|
62
|
+
// By default (for other env), this fn has no effect.
|
|
63
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
var withHash = /([^?#]*)[^#]*(#[^?]*|$).*/
|
|
7
|
+
var withoutHash = /([^?#]*)().*/
|
|
8
|
+
export function cleanURL (url, keepHash) {
|
|
9
|
+
return url.replace(keepHash ? withHash : withoutHash, '$1$2')
|
|
10
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { mapOwn } from '../util/map-own'
|
|
7
|
+
import { stringify } from '../util/stringify'
|
|
8
|
+
|
|
9
|
+
// Characters that are safe in a qs, but get encoded.
|
|
10
|
+
var charMap = {
|
|
11
|
+
'%2C': ',',
|
|
12
|
+
'%3A': ':',
|
|
13
|
+
'%2F': '/',
|
|
14
|
+
'%40': '@',
|
|
15
|
+
'%24': '$',
|
|
16
|
+
'%3B': ';'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var charList = mapOwn(charMap, function (k) { return k })
|
|
20
|
+
var safeEncoded = new RegExp(charList.join('|'), 'g')
|
|
21
|
+
|
|
22
|
+
function real (c) {
|
|
23
|
+
return charMap[c]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Encode as URI Component, then unescape anything that is ok in the
|
|
27
|
+
// query string position.
|
|
28
|
+
export function qs (value) {
|
|
29
|
+
if (value === null || value === undefined) return 'null'
|
|
30
|
+
return encodeURIComponent(value).replace(safeEncoded, real)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function fromArray (qs, maxBytes) {
|
|
34
|
+
var bytes = 0
|
|
35
|
+
for (var i = 0; i < qs.length; i++) {
|
|
36
|
+
bytes += qs[i].length
|
|
37
|
+
if (bytes > maxBytes) return qs.slice(0, i).join('')
|
|
38
|
+
}
|
|
39
|
+
return qs.join('')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function obj (payload, maxBytes) {
|
|
43
|
+
var total = 0
|
|
44
|
+
var result = ''
|
|
45
|
+
|
|
46
|
+
mapOwn(payload, function (feature, dataArray) {
|
|
47
|
+
var intermediate = []
|
|
48
|
+
var next
|
|
49
|
+
var i
|
|
50
|
+
|
|
51
|
+
if (typeof dataArray === 'string') {
|
|
52
|
+
next = '&' + feature + '=' + qs(dataArray)
|
|
53
|
+
total += next.length
|
|
54
|
+
result += next
|
|
55
|
+
} else if (dataArray.length) {
|
|
56
|
+
total += 9
|
|
57
|
+
for (i = 0; i < dataArray.length; i++) {
|
|
58
|
+
next = qs(stringify(dataArray[i]))
|
|
59
|
+
total += next.length
|
|
60
|
+
if (typeof maxBytes !== 'undefined' && total >= maxBytes) break
|
|
61
|
+
intermediate.push(next)
|
|
62
|
+
}
|
|
63
|
+
result += '&' + feature + '=%5B' + intermediate.join(',') + '%5D'
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
return result
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Constructs an HTTP parameter to add to the BAM router URL
|
|
70
|
+
export function param (name, value) {
|
|
71
|
+
if (value && typeof (value) === 'string') {
|
|
72
|
+
return '&' + name + '=' + qs(value)
|
|
73
|
+
}
|
|
74
|
+
return ''
|
|
75
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { globalScope, isBrowserScope } from '../util/global-scope'
|
|
7
|
+
|
|
8
|
+
var stringsToParsedUrls = {}
|
|
9
|
+
|
|
10
|
+
export function parseUrl (url) {
|
|
11
|
+
if (url in stringsToParsedUrls) {
|
|
12
|
+
return stringsToParsedUrls[url]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Return if URL is a data URL, parseUrl assumes urls are http/https
|
|
16
|
+
if ((url || '').indexOf('data:') === 0) {
|
|
17
|
+
return {
|
|
18
|
+
protocol: 'data'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let urlEl
|
|
23
|
+
var location = globalScope?.location
|
|
24
|
+
var ret = {}
|
|
25
|
+
|
|
26
|
+
if (isBrowserScope) {
|
|
27
|
+
// Use an anchor dom element to resolve the url natively.
|
|
28
|
+
urlEl = document.createElement('a')
|
|
29
|
+
urlEl.href = url
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
try {
|
|
33
|
+
urlEl = new URL(url, location.href)
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return ret
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ret.port = urlEl.port
|
|
40
|
+
|
|
41
|
+
var firstSplit = urlEl.href.split('://')
|
|
42
|
+
|
|
43
|
+
if (!ret.port && firstSplit[1]) {
|
|
44
|
+
ret.port = firstSplit[1].split('/')[0].split('@').pop().split(':')[1]
|
|
45
|
+
}
|
|
46
|
+
if (!ret.port || ret.port === '0') ret.port = (firstSplit[0] === 'https' ? '443' : '80')
|
|
47
|
+
|
|
48
|
+
// Host not provided in IE for relative urls
|
|
49
|
+
ret.hostname = (urlEl.hostname || location.hostname)
|
|
50
|
+
|
|
51
|
+
ret.pathname = urlEl.pathname
|
|
52
|
+
|
|
53
|
+
ret.protocol = firstSplit[0]
|
|
54
|
+
|
|
55
|
+
// Pathname sometimes doesn't have leading slash (IE 8 and 9)
|
|
56
|
+
if (ret.pathname.charAt(0) !== '/') ret.pathname = '/' + ret.pathname
|
|
57
|
+
|
|
58
|
+
// urlEl.protocol is ':' in old ie when protocol is not specified
|
|
59
|
+
var sameProtocol = !urlEl.protocol || urlEl.protocol === ':' || urlEl.protocol === location.protocol
|
|
60
|
+
var sameDomain = urlEl.hostname === location.hostname && urlEl.port === location.port
|
|
61
|
+
|
|
62
|
+
// urlEl.hostname is not provided by IE for relative urls, but relative urls are also same-origin
|
|
63
|
+
ret.sameOrigin = sameProtocol && (!urlEl.hostname || sameDomain)
|
|
64
|
+
|
|
65
|
+
// Only cache if url doesn't have a path
|
|
66
|
+
if (ret.pathname === '/') {
|
|
67
|
+
stringsToParsedUrls[url] = ret
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return ret
|
|
71
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { getGlobalScope } from '../util/global-scope'
|
|
6
|
+
|
|
7
|
+
export const protocol = {
|
|
8
|
+
isFileProtocol: isFileProtocol,
|
|
9
|
+
supportabilityMetricSent: false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isFileProtocol () {
|
|
13
|
+
let isFile = Boolean(getGlobalScope()?.location?.protocol === 'file:')
|
|
14
|
+
if (isFile) {
|
|
15
|
+
//metrics.recordSupportability('Generic/FileProtocol/Detected') -- may be implemented later? Probably make sure it's once per window
|
|
16
|
+
protocol.supportabilityMetricSent = true
|
|
17
|
+
}
|
|
18
|
+
return isFile
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A helper method to warn to the console with New Relic: decoration
|
|
3
|
+
* @param {string} message - The primary message to warn
|
|
4
|
+
* @param {*} secondary - Secondary data to include, usually an error or object
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function warn (message, secondary) {
|
|
8
|
+
if (typeof console.warn !== 'function') return
|
|
9
|
+
console.warn(`New Relic: ${message}`)
|
|
10
|
+
if (secondary) console.warn(secondary)
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { stringify } from './stringify'
|
|
7
|
+
|
|
8
|
+
export function dataSize (data) {
|
|
9
|
+
if (typeof data === 'string' && data.length) return data.length
|
|
10
|
+
if (typeof data !== 'object') return undefined
|
|
11
|
+
// eslint-disable-next-line
|
|
12
|
+
if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer && data.byteLength) return data.byteLength
|
|
13
|
+
if (typeof Blob !== 'undefined' && data instanceof Blob && data.size) return data.size
|
|
14
|
+
if (typeof FormData !== 'undefined' && data instanceof FormData) return undefined
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
return stringify(data).length
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return undefined
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { mapOwn } from './map-own'
|
|
6
|
+
import { ee } from '../event-emitter/contextual-ee'
|
|
7
|
+
import { handle } from '../event-emitter/handle'
|
|
8
|
+
import { drain } from '../drain/drain'
|
|
9
|
+
import { FEATURE_NAMES } from '../../loaders/features/features'
|
|
10
|
+
|
|
11
|
+
const bucketMap = {
|
|
12
|
+
stn: [FEATURE_NAMES.sessionTrace],
|
|
13
|
+
err: [FEATURE_NAMES.jserrors, FEATURE_NAMES.metrics],
|
|
14
|
+
ins: [FEATURE_NAMES.pageAction],
|
|
15
|
+
spa: [FEATURE_NAMES.spa]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function activateFeatures (flags, agentIdentifier) {
|
|
19
|
+
var sharedEE = ee.get(agentIdentifier)
|
|
20
|
+
if (!(flags && typeof flags === 'object')) return
|
|
21
|
+
mapOwn(flags, function (flag, val) {
|
|
22
|
+
if (!val) {
|
|
23
|
+
return (bucketMap[flag] || []).forEach(feat => {
|
|
24
|
+
handle('block-' + flag, [], undefined, feat, sharedEE)
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (activatedFeatures[flag]) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handle('feat-' + flag, [], undefined, bucketMap[flag], sharedEE)
|
|
33
|
+
activatedFeatures[flag] = true
|
|
34
|
+
})
|
|
35
|
+
drain(agentIdentifier, FEATURE_NAMES.pageViewEvent)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const activatedFeatures = {}
|