@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
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getAllStorageItemsOfGroup = getAllStorageItemsOfGroup;
|
|
6
7
|
exports.getCurrentSessionIdOrMakeNew = getCurrentSessionIdOrMakeNew;
|
|
8
|
+
exports.putInBrowserStorage = putInBrowserStorage;
|
|
9
|
+
exports.removeFromBrowserStorage = removeFromBrowserStorage;
|
|
7
10
|
var _uniqueId = require("../ids/unique-id");
|
|
8
|
-
var _globalScope = require("../util/global-scope");
|
|
9
11
|
/**
|
|
10
12
|
* Interface for Agents' usage of the Window.sessionStorage as a replacement to third-party cookies.
|
|
11
13
|
* (All agents on a tab|window will share the same sessionStorage.)
|
|
@@ -14,29 +16,72 @@ var _globalScope = require("../util/global-scope");
|
|
|
14
16
|
* @environment Browser script
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
|
-
const
|
|
19
|
+
const AGENT_PREFIX = 'NRBA/';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} key
|
|
23
|
+
* @param {string} value
|
|
24
|
+
* @returns true, if item was set successfully. false, if storage is full or setItem threw an exception.
|
|
25
|
+
*/
|
|
26
|
+
function putInBrowserStorage(key, value) {
|
|
27
|
+
let subgroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
28
|
+
try {
|
|
29
|
+
window.sessionStorage.setItem(AGENT_PREFIX + subgroup + key, value);
|
|
30
|
+
return true;
|
|
31
|
+
} catch (ex) {
|
|
32
|
+
// Session storage may be full.
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem}
|
|
38
|
+
* @param {string} key
|
|
39
|
+
*/
|
|
40
|
+
function getFromBrowserStorage(key) {
|
|
41
|
+
let subgroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
42
|
+
return window.sessionStorage.getItem(AGENT_PREFIX + subgroup + key);
|
|
43
|
+
}
|
|
44
|
+
function removeFromBrowserStorage(key) {
|
|
45
|
+
let subgroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
46
|
+
try {
|
|
47
|
+
window.sessionStorage.removeItem(AGENT_PREFIX + subgroup + key);
|
|
48
|
+
} catch (e) {}
|
|
49
|
+
}
|
|
18
50
|
|
|
19
51
|
/**
|
|
20
52
|
* @returns {string} This tab|window's session identifier, or a new ID if not found in storage
|
|
21
53
|
*/
|
|
22
54
|
function getCurrentSessionIdOrMakeNew() {
|
|
23
|
-
if (!_globalScope.isBrowserScope) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
55
|
try {
|
|
27
56
|
let sessionId;
|
|
28
|
-
if ((sessionId =
|
|
57
|
+
if ((sessionId = getFromBrowserStorage('SESSION_ID')) === null) {
|
|
29
58
|
// Generate a new one if storage is empty (no previous ID was created or currently exists)
|
|
30
59
|
sessionId = (0, _uniqueId.generateRandomHexString)(16);
|
|
31
|
-
|
|
60
|
+
putInBrowserStorage('SESSION_ID', sessionId);
|
|
32
61
|
}
|
|
33
62
|
return sessionId;
|
|
34
63
|
} catch (ex) {
|
|
35
|
-
//
|
|
36
|
-
// OR the agent is running in a security context that does not allow
|
|
37
|
-
// access to the browser sessionStorage
|
|
64
|
+
// The agent is running in a security context that does not allow access to the sessionStorage or is not in browser window context.
|
|
38
65
|
return null;
|
|
39
66
|
}
|
|
40
67
|
}
|
|
41
68
|
|
|
42
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Look through the page's sessionStorage items and gather the ones that was set under some grouping label, if applicable.
|
|
71
|
+
* @param {string} [subgroup] - empty string by default, which will return all items set by browser agent
|
|
72
|
+
* @returns An object of the key-value items from putInBrowserStorage calls from agents with access to the same storage space.
|
|
73
|
+
*/
|
|
74
|
+
function getAllStorageItemsOfGroup() {
|
|
75
|
+
let subgroup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
76
|
+
const prefixFilter = AGENT_PREFIX + subgroup;
|
|
77
|
+
const groupItems = {};
|
|
78
|
+
try {
|
|
79
|
+
for (let i = 0; i < window.sessionStorage.length; i++) {
|
|
80
|
+
let key = window.sessionStorage.key(i);
|
|
81
|
+
if (!key.startsWith(prefixFilter)) continue;else key = key.slice(prefixFilter.length); // this removes the "NRBA/<subgroup>" prefix so we get back the original key putInBrowserStorage
|
|
82
|
+
|
|
83
|
+
groupItems[key] = getFromBrowserStorage(key, subgroup);
|
|
84
|
+
}
|
|
85
|
+
} catch (ex) {}
|
|
86
|
+
return groupItems;
|
|
87
|
+
}
|
|
@@ -57,12 +57,12 @@ Object.defineProperty(exports, "wrapXhr", {
|
|
|
57
57
|
return _wrapXhr.wrapXhr;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
var _wrapEvents = require("./wrap-events");
|
|
60
61
|
var _wrapFetch = require("./wrap-fetch");
|
|
61
|
-
var _wrapTimer = require("./wrap-timer");
|
|
62
|
-
var _wrapRaf = require("./wrap-raf");
|
|
63
62
|
var _wrapHistory = require("./wrap-history");
|
|
64
63
|
var _wrapJsonp = require("./wrap-jsonp");
|
|
65
64
|
var _wrapMutation = require("./wrap-mutation");
|
|
66
65
|
var _wrapPromise = require("./wrap-promise");
|
|
67
|
-
var
|
|
68
|
-
var
|
|
66
|
+
var _wrapRaf = require("./wrap-raf");
|
|
67
|
+
var _wrapTimer = require("./wrap-timer");
|
|
68
|
+
var _wrapXhr = require("./wrap-xhr");
|
|
@@ -33,19 +33,16 @@ const REMOVE_EVENT_LISTENER = 'removeEventListener';
|
|
|
33
33
|
*/
|
|
34
34
|
function wrapEvents(sharedEE) {
|
|
35
35
|
var ee = scopedEE(sharedEE);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
wrapped[ee.debugId] = 1;
|
|
36
|
+
|
|
37
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
38
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
39
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
40
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap events
|
|
42
41
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee, true);
|
|
43
42
|
|
|
44
43
|
// Guard against instrumenting environments w/o necessary features
|
|
45
44
|
if ('getPrototypeOf' in Object) {
|
|
46
|
-
if (_globalScope.isBrowserScope)
|
|
47
|
-
findEventListenerProtoAndCb(document, wrapNode);
|
|
48
|
-
}
|
|
45
|
+
if (_globalScope.isBrowserScope) findEventListenerProtoAndCb(document, wrapNode);
|
|
49
46
|
findEventListenerProtoAndCb(_globalScope.globalScope, wrapNode);
|
|
50
47
|
findEventListenerProtoAndCb(XHR.prototype, wrapNode);
|
|
51
48
|
}
|
|
@@ -85,11 +82,14 @@ function wrapEvents(sharedEE) {
|
|
|
85
82
|
* @param {Function} cb - the function to run on the ancestral object once found, accepts an object as a arg
|
|
86
83
|
* @param {Array} rest - [optional] any additional arguments to pass to the cb
|
|
87
84
|
*/
|
|
88
|
-
function findEventListenerProtoAndCb(object, cb
|
|
85
|
+
function findEventListenerProtoAndCb(object, cb) {
|
|
89
86
|
let step = object;
|
|
90
87
|
while (typeof step === 'object' && !Object.prototype.hasOwnProperty.call(step, ADD_EVENT_LISTENER)) {
|
|
91
88
|
step = Object.getPrototypeOf(step);
|
|
92
89
|
}
|
|
90
|
+
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
91
|
+
rest[_key - 2] = arguments[_key];
|
|
92
|
+
}
|
|
93
93
|
if (step) cb(step, ...rest);
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -41,12 +41,12 @@ function wrapFetch(sharedEE) {
|
|
|
41
41
|
if (!(Req && Res && _globalScope.globalScope.fetch)) {
|
|
42
42
|
return ee;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
|
|
45
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
46
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
47
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
48
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap fetch
|
|
49
|
+
|
|
50
50
|
bodyMethods.forEach(method => {
|
|
51
51
|
wrapPromiseMethod(Req[proto], method, bodyPrefix);
|
|
52
52
|
wrapPromiseMethod(Res[proto], method, bodyPrefix);
|
|
@@ -95,10 +95,8 @@ function wrapFetch(sharedEE) {
|
|
|
95
95
|
throw err;
|
|
96
96
|
});
|
|
97
97
|
};
|
|
98
|
-
target[name][_wrapFunction.flag] = fn; // track original similar to in wrap-function.js, so that they can be unwrapped with ease
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
|
|
102
100
|
return ee;
|
|
103
101
|
}
|
|
104
102
|
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createWrapperWithEmitter = createWrapperWithEmitter;
|
|
7
7
|
exports.flag = exports.default = void 0;
|
|
8
|
-
exports.unwrapFunction = unwrapFunction;
|
|
9
8
|
exports.wrapFunction = wrapFunction;
|
|
10
9
|
exports.wrapInPlace = wrapInPlace;
|
|
11
10
|
var _contextualEe = require("../event-emitter/contextual-ee");
|
|
@@ -115,7 +114,8 @@ function createWrapperWithEmitter(emitter, always) {
|
|
|
115
114
|
* Creates wrapper functions around each of an array of methods on a specified object.
|
|
116
115
|
* @param {Object} obj - The object to which the specified methods belong.
|
|
117
116
|
* @param {string[]} methods - An array of method names to be wrapped.
|
|
118
|
-
* @param {string} [prefix=''] - A prefix to add to the names of emitted events.
|
|
117
|
+
* @param {string} [prefix=''] - A prefix to add to the names of emitted events. If `-` is the first character, also
|
|
118
|
+
* adds the method name before the prefix.
|
|
119
119
|
* @param {function|object} [getContext] - The function or object that will serve as the 'this' context for handlers
|
|
120
120
|
* of events emitted by this wrapper.
|
|
121
121
|
* @param {boolean} [bubble=false] - If `true`, emitted events should also bubble up to the old emitter upon which
|
|
@@ -123,8 +123,7 @@ function createWrapperWithEmitter(emitter, always) {
|
|
|
123
123
|
*/
|
|
124
124
|
function inPlace(obj, methods, prefix, getContext, bubble) {
|
|
125
125
|
if (!prefix) prefix = '';
|
|
126
|
-
// If prefix starts with '-' set this boolean to add the method name to
|
|
127
|
-
// the prefix before passing each one to wrap.
|
|
126
|
+
// If prefix starts with '-' set this boolean to add the method name to the prefix before passing each one to wrap.
|
|
128
127
|
var prependMethodPrefix = prefix.charAt(0) === '-';
|
|
129
128
|
var fn;
|
|
130
129
|
var method;
|
|
@@ -133,8 +132,7 @@ function createWrapperWithEmitter(emitter, always) {
|
|
|
133
132
|
method = methods[i];
|
|
134
133
|
fn = obj[method];
|
|
135
134
|
|
|
136
|
-
// Unless fn is both wrappable and unwrapped bail
|
|
137
|
-
// so we don't add extra properties with undefined values.
|
|
135
|
+
// Unless fn is both wrappable and unwrapped, bail so we don't add extra properties with undefined values.
|
|
138
136
|
if (notWrappable(fn)) continue;
|
|
139
137
|
obj[method] = wrapFn(fn, prependMethodPrefix ? method + prefix : prefix, getContext, method, bubble);
|
|
140
138
|
}
|
|
@@ -254,16 +252,4 @@ function wrapFunction(fn, wrapper) {
|
|
|
254
252
|
function wrapInPlace(obj, fnName, wrapper) {
|
|
255
253
|
var fn = obj[fnName];
|
|
256
254
|
obj[fnName] = wrapFunction(fn, wrapper);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* If a function property on an object (e.g. window) was previously wrapped (by this module), removes the wrapper.
|
|
261
|
-
* @param {Object} obj - The object on which the named function is a property.
|
|
262
|
-
* @param {string} fnName - The name of the function to be unwrapped.
|
|
263
|
-
*/
|
|
264
|
-
function unwrapFunction(obj, fnName) {
|
|
265
|
-
if (obj?.[fnName]?.[flag]) {
|
|
266
|
-
// previous state of the function property is stored under our wrapper's "flag"; we don't wrap properties that *were* undefined to begin with
|
|
267
|
-
obj[fnName] = obj[fnName][flag];
|
|
268
|
-
}
|
|
269
255
|
}
|
|
@@ -28,12 +28,13 @@ const HISTORY_FNS = ['pushState', 'replaceState'];
|
|
|
28
28
|
*/
|
|
29
29
|
function wrapHistory(sharedEE) {
|
|
30
30
|
const ee = scopedEE(sharedEE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
wrapped[ee.debugId] = 1;
|
|
31
|
+
|
|
32
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
|
+
// then we increment the count to track # of feats using this at runtime. History API is only
|
|
34
|
+
// available in browser DOM context.
|
|
35
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]++) return ee;
|
|
36
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap history
|
|
37
|
+
|
|
37
38
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
38
39
|
/*
|
|
39
40
|
* For objects that will be instantiated more than once, we wrap the object's prototype methods. The history object
|
|
@@ -29,12 +29,13 @@ const domInsertMethods = ['appendChild', 'insertBefore', 'replaceChild'];
|
|
|
29
29
|
*/
|
|
30
30
|
function wrapJsonP(sharedEE) {
|
|
31
31
|
const ee = scopedEE(sharedEE);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
wrapped[ee.debugId] = true;
|
|
32
|
+
|
|
33
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
34
|
+
// then we increment the count to track # of feats using this at runtime. JSONP deals with DOM
|
|
35
|
+
// tags so browser window env is required.
|
|
36
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]) return ee;
|
|
37
|
+
wrapped[ee.debugId] = true; // otherwise, first feature to wrap JSONP
|
|
38
|
+
|
|
38
39
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
39
40
|
var CALLBACK_REGEX = /[?&](?:callback|cb)=([^&#]+)/;
|
|
40
41
|
var PARENT_REGEX = /(.*)\.([^.]+)/;
|
|
@@ -28,12 +28,13 @@ const wrapped = {};
|
|
|
28
28
|
*/
|
|
29
29
|
function wrapMutation(sharedEE) {
|
|
30
30
|
const ee = scopedEE(sharedEE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
wrapped[ee.debugId] = true;
|
|
31
|
+
|
|
32
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
|
+
// then we increment the count to track # of feats using this at runtime. Mutations API is only
|
|
34
|
+
// available in browser DOM context.
|
|
35
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]) return ee;
|
|
36
|
+
wrapped[ee.debugId] = true; // otherwise, first feature to wrap mutations
|
|
37
|
+
|
|
37
38
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
38
39
|
var OriginalObserver = _config.originals.MO;
|
|
39
40
|
if (OriginalObserver) {
|
|
@@ -29,10 +29,12 @@ const wrapped = {};
|
|
|
29
29
|
*/
|
|
30
30
|
function wrapPromise(sharedEE) {
|
|
31
31
|
const promiseEE = scopedEE(sharedEE);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
wrapped[promiseEE.debugId]
|
|
32
|
+
|
|
33
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
34
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
35
|
+
if (wrapped[promiseEE.debugId]) return promiseEE;
|
|
36
|
+
wrapped[promiseEE.debugId] = true; // otherwise, first feature to wrap promise
|
|
37
|
+
|
|
36
38
|
var getContext = _contextualEe.getOrSetContext;
|
|
37
39
|
var promiseWrapper = (0, _wrapFunction.createWrapperWithEmitter)(promiseEE);
|
|
38
40
|
var prevPromiseObj = _config.originals.PR;
|
|
@@ -74,8 +76,7 @@ function wrapPromise(sharedEE) {
|
|
|
74
76
|
WrappedPromise[method] = function (subPromises) {
|
|
75
77
|
// use our own wrapped version of "Promise.all" and ".race" static fns
|
|
76
78
|
let finalized = false;
|
|
77
|
-
subPromises
|
|
78
|
-
// eslint-disable-next-line
|
|
79
|
+
Array.from(subPromises || []).forEach(sub => {
|
|
79
80
|
this.resolve(sub).then(setNrId(method === 'all'), setNrId(false));
|
|
80
81
|
});
|
|
81
82
|
const origFnCallWithThis = prevStaticFn.apply(this, arguments);
|
|
@@ -111,10 +112,13 @@ function wrapPromise(sharedEE) {
|
|
|
111
112
|
|
|
112
113
|
// Note that this wrapping affects the same originals.PR (prototype) object.
|
|
113
114
|
const prevPromiseOrigThen = prevPromiseObj.prototype.then;
|
|
114
|
-
prevPromiseObj.prototype.then = function wrappedThen(
|
|
115
|
+
prevPromiseObj.prototype.then = function wrappedThen() {
|
|
115
116
|
var originalThis = this;
|
|
116
117
|
var ctx = getContext(originalThis);
|
|
117
118
|
ctx.promise = originalThis;
|
|
119
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
120
|
+
args[_key] = arguments[_key];
|
|
121
|
+
}
|
|
118
122
|
args[0] = promiseWrapper(args[0], 'cb-', ctx, null, false);
|
|
119
123
|
args[1] = promiseWrapper(args[1], 'cb-', ctx, null, false);
|
|
120
124
|
const origFnCallWithThis = prevPromiseOrigThen.apply(this, args);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _faker = require("@faker-js/faker");
|
|
4
|
+
var _globalScope = require("../util/global-scope");
|
|
5
|
+
var _config = require("../config/config");
|
|
6
|
+
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); }
|
|
7
|
+
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; }
|
|
8
|
+
jest.mock('./wrap-function', () => ({
|
|
9
|
+
__esModule: true,
|
|
10
|
+
createWrapperWithEmitter: jest.fn(() => fn => function () {
|
|
11
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
|
+
args[_key] = arguments[_key];
|
|
13
|
+
}
|
|
14
|
+
return fn.apply(null, args);
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
17
|
+
jest.mock('../event-emitter/contextual-ee', () => ({
|
|
18
|
+
__esModule: true,
|
|
19
|
+
getOrSetContext: jest.fn(() => ({})),
|
|
20
|
+
ee: {
|
|
21
|
+
get: jest.fn(name => ({
|
|
22
|
+
debugId: name,
|
|
23
|
+
on: jest.fn(),
|
|
24
|
+
context: jest.fn(() => ({})),
|
|
25
|
+
emit: jest.fn()
|
|
26
|
+
}))
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
jest.mock('../config/config', () => ({
|
|
30
|
+
__esModule: true,
|
|
31
|
+
originals: {}
|
|
32
|
+
}));
|
|
33
|
+
jest.mock('../util/global-scope', () => ({
|
|
34
|
+
__esModule: true,
|
|
35
|
+
globalScope: {
|
|
36
|
+
NREUM: {}
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
let promiseConstructorCalls;
|
|
40
|
+
beforeEach(async () => {
|
|
41
|
+
promiseConstructorCalls = [];
|
|
42
|
+
|
|
43
|
+
// Proxy the global Promise to prevent the wrapping from
|
|
44
|
+
// messing with Jest internal promises
|
|
45
|
+
_config.originals.PR = new Proxy(class extends Promise {}, {
|
|
46
|
+
construct(target, args) {
|
|
47
|
+
promiseConstructorCalls.push(args);
|
|
48
|
+
return Reflect.construct(target, args);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
(await Promise.resolve().then(() => _interopRequireWildcard(require('./wrap-promise')))).wrapPromise();
|
|
52
|
+
});
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
jest.resetModules();
|
|
55
|
+
});
|
|
56
|
+
test('should wrap promise constructor', async () => {
|
|
57
|
+
const promiseInstance = new _globalScope.globalScope.Promise(jest.fn());
|
|
58
|
+
expect(promiseInstance).toBeInstanceOf(Promise);
|
|
59
|
+
expect(promiseConstructorCalls.length).toEqual(1);
|
|
60
|
+
expect(_globalScope.globalScope.Promise.toString()).toMatch(/\[native code\]/);
|
|
61
|
+
expect(_globalScope.globalScope.Promise.name).toEqual('Promise');
|
|
62
|
+
});
|
|
63
|
+
describe('all', () => {
|
|
64
|
+
test('should work with acceptable iterables', async () => {
|
|
65
|
+
const resolveValue = _faker.faker.datatype.uuid();
|
|
66
|
+
const customIterable = new CustomIterable([new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))]);
|
|
67
|
+
const arrayIterable = [new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))];
|
|
68
|
+
const setIterable = new Set();
|
|
69
|
+
setIterable.add(new _globalScope.globalScope.Promise(resolve => resolve(resolveValue)));
|
|
70
|
+
await expect(_globalScope.globalScope.Promise.all(customIterable)).resolves.toEqual([resolveValue]);
|
|
71
|
+
await expect(_globalScope.globalScope.Promise.all(arrayIterable)).resolves.toEqual([resolveValue]);
|
|
72
|
+
await expect(_globalScope.globalScope.Promise.all(setIterable)).resolves.toEqual([resolveValue]);
|
|
73
|
+
});
|
|
74
|
+
test.each([null, undefined])('should not try to iterate a non-iterable %s', async input => {
|
|
75
|
+
jest.spyOn(_globalScope.globalScope.Promise, 'resolve');
|
|
76
|
+
await expect(_globalScope.globalScope.Promise.all(input)).rejects.toThrow();
|
|
77
|
+
expect(_globalScope.globalScope.Promise.resolve).not.toHaveBeenCalled();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('race', () => {
|
|
81
|
+
test('should work with acceptable iterables', async () => {
|
|
82
|
+
jest.spyOn(_globalScope.globalScope.Promise, 'resolve');
|
|
83
|
+
const resolveValue = _faker.faker.datatype.uuid();
|
|
84
|
+
const customIterable = new CustomIterable([new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))]);
|
|
85
|
+
const arrayIterable = [new _globalScope.globalScope.Promise(resolve => resolve(resolveValue))];
|
|
86
|
+
const setIterable = new Set();
|
|
87
|
+
setIterable.add(new _globalScope.globalScope.Promise(resolve => resolve(resolveValue)));
|
|
88
|
+
await expect(_globalScope.globalScope.Promise.race(customIterable)).resolves.toEqual(resolveValue);
|
|
89
|
+
await expect(_globalScope.globalScope.Promise.race(arrayIterable)).resolves.toEqual(resolveValue);
|
|
90
|
+
await expect(_globalScope.globalScope.Promise.race(setIterable)).resolves.toEqual(resolveValue);
|
|
91
|
+
expect(_globalScope.globalScope.Promise.resolve).toHaveBeenCalled();
|
|
92
|
+
});
|
|
93
|
+
test.each([null, undefined])('should not try to iterate a non-iterable %s', async input => {
|
|
94
|
+
jest.spyOn(_globalScope.globalScope.Promise, 'resolve');
|
|
95
|
+
await expect(_globalScope.globalScope.Promise.race(input)).rejects.toThrow();
|
|
96
|
+
expect(_globalScope.globalScope.Promise.resolve).not.toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
class CustomIterable {
|
|
100
|
+
#iterables = [];
|
|
101
|
+
constructor(iterables) {
|
|
102
|
+
this.#iterables = iterables;
|
|
103
|
+
}
|
|
104
|
+
[Symbol.iterator]() {
|
|
105
|
+
return {
|
|
106
|
+
index: 0,
|
|
107
|
+
iterables: this.#iterables,
|
|
108
|
+
next() {
|
|
109
|
+
return {
|
|
110
|
+
done: this.index >= this.iterables.length,
|
|
111
|
+
value: this.iterables[this.index++] || undefined
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
[Symbol.iterator]() {
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -28,12 +28,12 @@ const RAF_NAME = 'requestAnimationFrame';
|
|
|
28
28
|
*/
|
|
29
29
|
function wrapRaf(sharedEE) {
|
|
30
30
|
const ee = scopedEE(sharedEE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
|
|
32
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
33
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
34
|
+
if (!_globalScope.isBrowserScope || wrapped[ee.debugId]++) return ee;
|
|
35
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap RAF
|
|
36
|
+
|
|
37
37
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
38
38
|
wrapFn.inPlace(window, [RAF_NAME], 'raf-');
|
|
39
39
|
ee.on('raf-start', function (args) {
|
|
@@ -35,12 +35,12 @@ const TIMER_FNS = [SET_TIMEOUT, 'setImmediate', SET_INTERVAL, CLEAR_TIMEOUT, 'cl
|
|
|
35
35
|
//eslint-disable-next-line
|
|
36
36
|
function wrapTimer(sharedEE) {
|
|
37
37
|
const ee = scopedEE(sharedEE);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
|
|
39
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
40
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
41
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
42
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap timer
|
|
43
|
+
|
|
44
44
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
45
45
|
wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(0, 2), SET_TIMEOUT + DASH);
|
|
46
46
|
wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(2, 3), SET_INTERVAL + DASH);
|
|
@@ -34,12 +34,11 @@ const XHR_PROPS = ['open', 'send']; // these are the specific funcs being wrappe
|
|
|
34
34
|
function wrapXhr(sharedEE) {
|
|
35
35
|
var baseEE = sharedEE || _contextualEe.ee;
|
|
36
36
|
const ee = scopedEE(baseEE);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
wrapped[ee.debugId] = 1; // <- otherwise, first feature to wrap XHR
|
|
37
|
+
|
|
38
|
+
// Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
|
|
39
|
+
// then we increment the count to track # of feats using this at runtime.
|
|
40
|
+
if (wrapped[ee.debugId]++) return ee;
|
|
41
|
+
wrapped[ee.debugId] = 1; // otherwise, first feature to wrap XHR
|
|
43
42
|
|
|
44
43
|
(0, _wrapEvents.wrapEvents)(baseEE); // wrap-events patches XMLHttpRequest.prototype.addEventListener for us
|
|
45
44
|
var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
|
|
@@ -62,7 +62,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
62
62
|
onFinished: onEventsHarvestFinished,
|
|
63
63
|
getPayload: prepareHarvest
|
|
64
64
|
}, this);
|
|
65
|
-
ee.on(
|
|
65
|
+
ee.on("drain-".concat(this.featureName), () => {
|
|
66
66
|
scheduler.startTimer(harvestTimeSeconds);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -30,7 +30,8 @@ var origRequest = _config.originals.REQ;
|
|
|
30
30
|
var origXHR = _globalScope.globalScope.XMLHttpRequest;
|
|
31
31
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
32
32
|
static featureName = _constants.FEATURE_NAME;
|
|
33
|
-
constructor(agentIdentifier, aggregator
|
|
33
|
+
constructor(agentIdentifier, aggregator) {
|
|
34
|
+
let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
34
35
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
|
|
35
36
|
|
|
36
37
|
// Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
|
|
@@ -21,10 +21,11 @@ test.each([{
|
|
|
21
21
|
input: '<anonymous>',
|
|
22
22
|
expected: undefined,
|
|
23
23
|
title: 'Return undefined ending is non-alphanumeric'
|
|
24
|
-
}])('$title',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
}])('$title', _ref => {
|
|
25
|
+
let {
|
|
26
|
+
input,
|
|
27
|
+
expected
|
|
28
|
+
} = _ref;
|
|
28
29
|
const result = (0, _canonicalFunctionName.canonicalFunctionName)(input);
|
|
29
30
|
expect(result).toEqual(expected);
|
|
30
31
|
});
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.computeStackTrace = computeStackTrace;
|
|
7
|
-
var _reduce = require("../../../common/util/reduce");
|
|
8
7
|
var _formatStackTrace = require("./format-stack-trace");
|
|
9
8
|
/*
|
|
10
9
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -120,7 +119,7 @@ function computeStackTraceFromStackProp(ex) {
|
|
|
120
119
|
if (!ex.stack) {
|
|
121
120
|
return null;
|
|
122
121
|
}
|
|
123
|
-
var errorInfo =
|
|
122
|
+
var errorInfo = ex.stack.split('\n').reduce(parseStackProp, {
|
|
124
123
|
frames: [],
|
|
125
124
|
stackLines: [],
|
|
126
125
|
wrapperSeen: false
|
|
@@ -146,7 +146,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
146
146
|
mode: 'sourceline',
|
|
147
147
|
name: mockError.name,
|
|
148
148
|
message: mockError.message,
|
|
149
|
-
stackString:
|
|
149
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line)
|
|
150
150
|
}));
|
|
151
151
|
expect(result.frames.length).toEqual(1);
|
|
152
152
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -172,7 +172,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
172
172
|
mode: 'sourceline',
|
|
173
173
|
name: mockError.name,
|
|
174
174
|
message: mockError.message,
|
|
175
|
-
stackString:
|
|
175
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message, "\n at ").concat(sourceURL, ":").concat(mockError.line, ":").concat(mockError.column)
|
|
176
176
|
}));
|
|
177
177
|
expect(result.frames.length).toEqual(1);
|
|
178
178
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -193,7 +193,7 @@ describe('errors without stack property and with line property', () => {
|
|
|
193
193
|
mode: 'sourceline',
|
|
194
194
|
name: mockError.name,
|
|
195
195
|
message: mockError.message,
|
|
196
|
-
stackString:
|
|
196
|
+
stackString: "RangeError: ".concat(mockError.message, "\n in evaluated code")
|
|
197
197
|
}));
|
|
198
198
|
expect(result.frames.length).toEqual(1);
|
|
199
199
|
expect(result.frames).toContainEqual(expect.objectContaining({
|
|
@@ -232,7 +232,7 @@ describe('errors that are messages only or primitives', () => {
|
|
|
232
232
|
expect(result).toEqual(expect.objectContaining({
|
|
233
233
|
mode: 'nameonly',
|
|
234
234
|
name: mockError.name,
|
|
235
|
-
stackString:
|
|
235
|
+
stackString: "".concat(mockError.name, ": undefined"),
|
|
236
236
|
frames: []
|
|
237
237
|
}));
|
|
238
238
|
});
|
|
@@ -248,7 +248,7 @@ describe('errors that are messages only or primitives', () => {
|
|
|
248
248
|
mode: 'nameonly',
|
|
249
249
|
name: mockError.name,
|
|
250
250
|
message: mockError.message,
|
|
251
|
-
stackString:
|
|
251
|
+
stackString: "".concat(mockError.name, ": ").concat(mockError.message),
|
|
252
252
|
frames: []
|
|
253
253
|
}));
|
|
254
254
|
});
|