@newrelic/browser-agent 1.235.0 → 1.237.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/cjs/common/config/state/init.js +4 -0
- package/dist/cjs/common/config/state/runtime.js +6 -5
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +52 -0
- package/dist/cjs/common/deny-list/deny-list.js +14 -10
- package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
- package/dist/cjs/common/harvest/harvest.js +154 -148
- package/dist/cjs/common/harvest/types.js +54 -0
- package/dist/cjs/common/ids/id.js +2 -2
- package/dist/cjs/common/ids/unique-id.js +3 -3
- package/dist/cjs/common/session/session-entity.js +2 -2
- package/dist/cjs/common/timer/interaction-timer.js +2 -2
- package/dist/cjs/common/unload/eol.js +10 -11
- package/dist/cjs/common/url/canonicalize-url.js +2 -2
- package/dist/cjs/common/url/parse-url.js +3 -3
- package/dist/cjs/common/url/protocol.js +2 -2
- package/dist/cjs/common/util/submit-data.js +31 -81
- package/dist/cjs/common/window/nreum.js +14 -14
- package/dist/cjs/common/wrap/wrap-events.js +3 -3
- package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
- package/dist/cjs/common/wrap/wrap-history.js +2 -2
- package/dist/cjs/common/wrap/wrap-jsonp.js +14 -8
- package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -2
- package/dist/cjs/common/wrap/wrap-raf.js +2 -2
- package/dist/cjs/common/wrap/wrap-timer.js +4 -4
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +25 -28
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
- package/dist/cjs/features/ajax/instrument/index.js +6 -7
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
- package/dist/cjs/features/jserrors/constants.js +2 -4
- package/dist/cjs/features/jserrors/instrument/index.js +80 -89
- package/dist/cjs/features/jserrors/instrument/uncaught-error.js +22 -0
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
- package/dist/cjs/features/metrics/aggregate/index.js +3 -3
- package/dist/cjs/features/page_action/aggregate/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
- package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
- package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +65 -34
- package/dist/cjs/features/session_replay/replay-mode.js +2 -2
- package/dist/cjs/features/session_trace/aggregate/index.js +3 -4
- package/dist/cjs/features/session_trace/instrument/index.js +2 -2
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +12 -15
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent-base.js +87 -0
- package/dist/cjs/loaders/agent.js +48 -1
- package/dist/cjs/loaders/api/api.js +3 -3
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/api/interaction-types.js +87 -0
- package/dist/cjs/loaders/configure/configure.js +4 -3
- package/dist/cjs/loaders/micro-agent.js +32 -39
- package/dist/esm/common/config/state/init.js +4 -0
- package/dist/esm/common/config/state/runtime.js +3 -2
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +38 -0
- package/dist/esm/common/deny-list/deny-list.js +14 -10
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
- package/dist/esm/common/harvest/harvest.js +150 -146
- package/dist/esm/common/harvest/types.js +47 -0
- package/dist/esm/common/ids/id.js +1 -1
- package/dist/esm/common/ids/unique-id.js +1 -1
- package/dist/esm/common/session/session-entity.js +1 -1
- package/dist/esm/common/timer/interaction-timer.js +1 -1
- package/dist/esm/common/unload/eol.js +1 -2
- package/dist/esm/common/url/canonicalize-url.js +1 -1
- package/dist/esm/common/url/parse-url.js +1 -1
- package/dist/esm/common/url/protocol.js +1 -1
- package/dist/esm/common/util/submit-data.js +29 -78
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/common/wrap/wrap-events.js +1 -1
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-history.js +1 -1
- package/dist/esm/common/wrap/wrap-jsonp.js +13 -7
- package/dist/esm/common/wrap/wrap-mutation.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -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 +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +26 -29
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
- package/dist/esm/features/ajax/instrument/index.js +1 -2
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +6 -3
- package/dist/esm/features/jserrors/constants.js +1 -2
- package/dist/esm/features/jserrors/instrument/index.js +79 -88
- package/dist/esm/features/jserrors/instrument/uncaught-error.js +15 -0
- package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
- package/dist/esm/features/metrics/aggregate/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +1 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/aggregate/initialized-features.js +23 -19
- package/dist/esm/features/page_view_event/instrument/index.js +1 -1
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +65 -34
- package/dist/esm/features/session_replay/replay-mode.js +2 -2
- package/dist/esm/features/session_trace/aggregate/index.js +3 -4
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +11 -14
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent-base.js +80 -0
- package/dist/esm/loaders/agent.js +48 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/api/interaction-types.js +80 -0
- package/dist/esm/loaders/configure/configure.js +4 -3
- package/dist/esm/loaders/micro-agent.js +32 -39
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +29 -0
- package/dist/types/common/constants/runtime.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +49 -38
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/harvest/types.d.ts +100 -0
- package/dist/types/common/harvest/types.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +6 -6
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +44 -64
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/constants.d.ts +0 -1
- package/dist/types/features/jserrors/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +0 -13
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts +15 -0
- package/dist/types/features/jserrors/instrument/uncaught-error.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +5 -5
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +16 -30
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/loaders/agent-base.d.ts +59 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -0
- package/dist/types/loaders/agent.d.ts +39 -5
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +122 -0
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +6 -6
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +2 -1
- package/src/common/config/state/runtime.js +3 -2
- package/src/common/constants/__mocks__/env.js +3 -0
- package/src/common/constants/__mocks__/runtime.js +8 -0
- package/src/common/constants/env.cdn.test.js +7 -0
- package/src/common/constants/env.npm.test.js +7 -0
- package/src/common/constants/env.test.js +7 -0
- package/src/common/constants/runtime.js +71 -0
- package/src/common/constants/runtime.test.js +168 -0
- package/src/common/context/__mocks__/shared-context.js +8 -0
- package/src/common/deny-list/deny-list.js +11 -11
- package/src/common/deny-list/deny-list.test.js +31 -0
- package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
- package/src/common/event-listener/event-listener-opts.js +1 -1
- package/src/common/harvest/__mocks__/harvest.js +13 -0
- package/src/common/harvest/harvest-scheduler.js +21 -20
- package/src/common/harvest/harvest-scheduler.test.js +496 -0
- package/src/common/harvest/harvest.js +142 -134
- package/src/common/harvest/harvest.test.js +798 -0
- package/src/common/harvest/types.js +47 -0
- package/src/common/ids/id.js +1 -1
- package/src/common/ids/unique-id.js +1 -1
- package/src/common/session/__mocks__/session-entity.js +25 -0
- package/src/common/session/session-entity.component-test.js +1 -1
- package/src/common/session/session-entity.js +1 -1
- package/src/common/timer/interaction-timer.js +1 -1
- package/src/common/timing/__mocks__/now.js +1 -0
- package/src/common/unload/__mocks__/eol.js +1 -0
- package/src/common/unload/eol.js +1 -2
- package/src/common/url/__mocks__/clean-url.js +1 -0
- package/src/common/url/__mocks__/encode.js +7 -0
- package/src/common/url/__mocks__/location.js +1 -0
- package/src/common/url/canonicalize-url.js +1 -1
- package/src/common/url/canonicalize-url.test.js +2 -2
- package/src/common/url/parse-url.js +1 -1
- package/src/common/url/parse-url.test.js +3 -3
- package/src/common/url/protocol.js +1 -1
- package/src/common/util/__mocks__/obfuscate.js +10 -0
- package/src/common/util/__mocks__/stringify.js +1 -0
- package/src/common/util/__mocks__/submit-data.js +5 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +22 -58
- package/src/common/util/submit-data.test.js +30 -73
- package/src/common/window/nreum.js +1 -1
- package/src/common/wrap/wrap-events.js +1 -1
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-history.js +1 -1
- package/src/common/wrap/wrap-jsonp.js +12 -7
- package/src/common/wrap/wrap-mutation.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/common/wrap/wrap-promise.test.js +2 -2
- package/src/common/wrap/wrap-raf.js +1 -1
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +26 -32
- package/src/features/ajax/instrument/distributed-tracing.js +1 -1
- package/src/features/ajax/instrument/index.js +1 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.js +1 -1
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +7 -3
- package/src/features/jserrors/constants.js +0 -1
- package/src/features/jserrors/instrument/index.js +92 -88
- package/src/features/jserrors/instrument/uncaught-error.js +15 -0
- package/src/features/metrics/aggregate/framework-detection.js +1 -1
- package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
- package/src/features/metrics/aggregate/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +1 -1
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/aggregate/initialized-features.js +18 -14
- package/src/features/page_view_event/instrument/index.js +1 -1
- package/src/features/page_view_timing/aggregate/index.js +2 -4
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/aggregate/index.component-test.js +17 -56
- package/src/features/session_replay/aggregate/index.js +47 -28
- package/src/features/session_replay/replay-mode.js +2 -2
- package/src/features/session_trace/aggregate/index.js +3 -4
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.test.js +2 -2
- package/src/features/utils/instrument-base.js +11 -14
- package/src/features/utils/instrument-base.test.js +29 -3
- package/src/index.js +1 -3
- package/src/loaders/agent-base.js +81 -0
- package/src/loaders/agent.js +50 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/api/interaction-types.js +80 -0
- package/src/loaders/configure/configure.js +5 -4
- package/src/loaders/micro-agent.js +30 -31
- package/dist/cjs/common/browser-version/firefox-version.js +0 -17
- package/dist/cjs/common/browser-version/ios-version.js +0 -19
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
- package/dist/cjs/common/event-emitter/handle.test.js +0 -58
- package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
- package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
- package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
- package/dist/cjs/common/ids/id.test.js +0 -85
- package/dist/cjs/common/ids/unique-id.test.js +0 -49
- package/dist/cjs/common/session/session-entity.component-test.js +0 -497
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
- package/dist/cjs/common/timer/timer.test.js +0 -105
- package/dist/cjs/common/timing/nav-timing.test.js +0 -192
- package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.component-test.js +0 -74
- package/dist/cjs/common/url/location.test.js +0 -13
- package/dist/cjs/common/url/parse-url.test.js +0 -111
- package/dist/cjs/common/url/protocol.component-test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -64
- package/dist/cjs/common/util/feature-flags.test.js +0 -84
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -27
- package/dist/cjs/common/util/global-scope.test.js +0 -72
- package/dist/cjs/common/util/invoke.test.js +0 -49
- package/dist/cjs/common/util/map-own.test.js +0 -49
- package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
- package/dist/cjs/common/util/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -245
- package/dist/cjs/common/util/traverse.test.js +0 -44
- package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
- package/dist/cjs/features/jserrors/instrument/debug.js +0 -40
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
- package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
- package/dist/cjs/features/utils/agent-session.test.js +0 -211
- package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
- package/dist/cjs/features/utils/feature-base.test.js +0 -42
- package/dist/cjs/features/utils/handler-cache.test.js +0 -53
- package/dist/cjs/features/utils/instrument-base.test.js +0 -179
- package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
- package/dist/esm/common/browser-version/firefox-version.js +0 -10
- package/dist/esm/common/browser-version/ios-version.js +0 -11
- package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
- package/dist/esm/common/event-emitter/handle.test.js +0 -54
- package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
- package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
- package/dist/esm/common/harvest/harvest.component-test.js +0 -222
- package/dist/esm/common/ids/id.test.js +0 -81
- package/dist/esm/common/ids/unique-id.test.js +0 -44
- package/dist/esm/common/session/session-entity.component-test.js +0 -495
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
- package/dist/esm/common/timer/timer.test.js +0 -103
- package/dist/esm/common/timing/nav-timing.test.js +0 -190
- package/dist/esm/common/url/canonicalize-url.test.js +0 -34
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.component-test.js +0 -70
- package/dist/esm/common/url/location.test.js +0 -11
- package/dist/esm/common/url/parse-url.test.js +0 -107
- package/dist/esm/common/url/protocol.component-test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -60
- package/dist/esm/common/util/feature-flags.test.js +0 -80
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -17
- package/dist/esm/common/util/global-scope.test.js +0 -70
- package/dist/esm/common/util/invoke.test.js +0 -47
- package/dist/esm/common/util/map-own.test.js +0 -47
- package/dist/esm/common/util/obfuscate.component-test.js +0 -125
- package/dist/esm/common/util/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -241
- package/dist/esm/common/util/traverse.test.js +0 -42
- package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
- package/dist/esm/features/jserrors/instrument/debug.js +0 -38
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
- package/dist/esm/features/utils/agent-session.test.js +0 -207
- package/dist/esm/features/utils/aggregate-base.test.js +0 -108
- package/dist/esm/features/utils/feature-base.test.js +0 -40
- package/dist/esm/features/utils/handler-cache.test.js +0 -51
- package/dist/esm/features/utils/instrument-base.test.js +0 -175
- package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
- package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
- package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
- package/dist/types/common/browser-version/ios-version.d.ts +0 -3
- package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
- package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
- package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
- package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
- package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
- package/dist/types/common/url/encode.component-test.d.ts +0 -2
- package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
- package/dist/types/common/url/protocol.component-test.d.ts +0 -2
- package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -5
- package/dist/types/common/util/global-scope.d.ts.map +0 -1
- package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
- package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
- package/dist/types/features/jserrors/instrument/debug.d.ts +0 -2
- package/dist/types/features/jserrors/instrument/debug.d.ts.map +0 -1
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
- package/src/common/browser-version/firefox-version.js +0 -10
- package/src/common/browser-version/ios-version.js +0 -11
- package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
- package/src/common/harvest/harvest.component-test.js +0 -169
- package/src/common/util/global-scope.js +0 -23
- package/src/common/util/global-scope.test.js +0 -87
- package/src/features/jserrors/instrument/debug.js +0 -36
package/src/loaders/agent.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// loader files
|
|
2
|
+
import { AgentBase } from './agent-base'
|
|
2
3
|
import { getEnabledFeatures } from './features/enabled-features'
|
|
3
4
|
import { configure } from './configure/configure'
|
|
4
5
|
import { getFeatureDependencyNames } from './features/featureDependencies'
|
|
@@ -12,13 +13,27 @@ import { generateRandomHexString } from '../common/ids/unique-id'
|
|
|
12
13
|
import { getConfiguration, getInfo, getLoaderConfig, getRuntime } from '../common/config/config'
|
|
13
14
|
import { warn } from '../common/util/console'
|
|
14
15
|
import { stringify } from '../common/util/stringify'
|
|
16
|
+
import { globalScope } from '../common/constants/runtime'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {import('./api/interaction-types').InteractionInstance} InteractionInstance
|
|
20
|
+
*/
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* A flexible class that may be used to compose an agent from a select subset of feature modules. In applications
|
|
18
24
|
* sensitive to network load, this may result in smaller builds with slightly lower performance impact.
|
|
19
25
|
*/
|
|
20
|
-
export class Agent {
|
|
26
|
+
export class Agent extends AgentBase {
|
|
21
27
|
constructor (options, agentIdentifier = generateRandomHexString(16)) {
|
|
28
|
+
super()
|
|
29
|
+
|
|
30
|
+
if (!globalScope) {
|
|
31
|
+
// We could not determine the runtime environment. Short-circuite the agent here
|
|
32
|
+
// to avoid possible exceptions later that may cause issues with customer's application.
|
|
33
|
+
warn('Failed to initial the agent. Could not determine the runtime environment.')
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
this.agentIdentifier = agentIdentifier
|
|
23
38
|
this.sharedAggregator = new Aggregator({ agentIdentifier: this.agentIdentifier })
|
|
24
39
|
this.features = {}
|
|
@@ -76,4 +91,38 @@ export class Agent {
|
|
|
76
91
|
return false
|
|
77
92
|
}
|
|
78
93
|
}
|
|
94
|
+
|
|
95
|
+
/* Below API methods are only available on a standard agent and not the micro agent */
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Adds a JavaScript object with a custom name, start time, etc. to an in-progress session trace.
|
|
99
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/addtotrace/}
|
|
100
|
+
* @param {{name: string, start: number, end?: number, origin?: string, type?: string}} customAttributes Supply a JavaScript object with these required and optional name/value pairs:
|
|
101
|
+
*
|
|
102
|
+
* - Required name/value pairs: name, start
|
|
103
|
+
* - Optional name/value pairs: end, origin, type
|
|
104
|
+
*
|
|
105
|
+
* If you are sending the same event object to New Relic as a PageAction, omit the TYPE attribute. (type is a string to describe what type of event you are marking inside of a session trace.) If included, it will override the event type and cause the PageAction event to be sent incorrectly. Instead, use the name attribute for event information.
|
|
106
|
+
*/
|
|
107
|
+
addToTrace (customAttributes) {
|
|
108
|
+
warn('Call to agent api addToTrace failed. The page action feature is not currently initialized.')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Gives SPA routes more accurate names than default names. Monitors specific routes rather than by default grouping.
|
|
113
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcurrentroutename/}
|
|
114
|
+
* @param {string} name Current route name for the page.
|
|
115
|
+
*/
|
|
116
|
+
setCurrentRouteName (name) {
|
|
117
|
+
warn('Call to agent api setCurrentRouteName failed. The spa feature is not currently initialized.')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns a new API object that is bound to the current SPA interaction.
|
|
122
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/interaction/}
|
|
123
|
+
* @returns {InteractionInstance} An API object that is bound to a specific BrowserInteraction event. Each time this method is called for the same BrowserInteraction, a new object is created, but it still references the same interaction.
|
|
124
|
+
*/
|
|
125
|
+
interaction () {
|
|
126
|
+
warn('Call to agent api interaction failed. The spa feature is not currently initialized.')
|
|
127
|
+
}
|
|
79
128
|
}
|
package/src/loaders/api/api.js
CHANGED
|
@@ -9,7 +9,7 @@ import { ee } from '../../common/event-emitter/contextual-ee'
|
|
|
9
9
|
import { now } from '../../common/timing/now'
|
|
10
10
|
import { drain, registerDrain } from '../../common/drain/drain'
|
|
11
11
|
import { onWindowLoad } from '../../common/window/load'
|
|
12
|
-
import { isBrowserScope } from '../../common/
|
|
12
|
+
import { isBrowserScope } from '../../common/constants/runtime'
|
|
13
13
|
import { warn } from '../../common/util/console'
|
|
14
14
|
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../features/metrics/constants'
|
|
15
15
|
import { gosCDN } from '../../common/window/nreum'
|
|
@@ -127,7 +127,7 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
127
127
|
try {
|
|
128
128
|
return cb.apply(this, arguments)
|
|
129
129
|
} catch (err) {
|
|
130
|
-
tracerEE.emit('fn-err', [arguments, this,
|
|
130
|
+
tracerEE.emit('fn-err', [arguments, this, err], contextStore)
|
|
131
131
|
// the error came from outside the agent, so don't swallow
|
|
132
132
|
throw err
|
|
133
133
|
} finally {
|
|
@@ -4,8 +4,8 @@ import { ee } from '../../common/event-emitter/contextual-ee'
|
|
|
4
4
|
import { handle } from '../../common/event-emitter/handle'
|
|
5
5
|
import { registerHandler } from '../../common/event-emitter/register-handler'
|
|
6
6
|
import { single } from '../../common/util/invoke'
|
|
7
|
-
import
|
|
8
|
-
import { isBrowserScope } from '../../common/
|
|
7
|
+
import * as submitData from '../../common/util/submit-data'
|
|
8
|
+
import { isBrowserScope } from '../../common/constants/runtime'
|
|
9
9
|
import { CUSTOM_METRIC_CHANNEL } from '../../features/metrics/constants'
|
|
10
10
|
|
|
11
11
|
export function setAPI (agentIdentifier) {
|
|
@@ -78,7 +78,7 @@ export function setAPI (agentIdentifier) {
|
|
|
78
78
|
url += 'fe=' + ~~fe_time + '&'
|
|
79
79
|
url += 'c=' + cycle
|
|
80
80
|
|
|
81
|
-
submitData.
|
|
81
|
+
submitData.xhr({ url })
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function setErrorHandler (t, handler) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef InteractionInstance
|
|
3
|
+
* @property {actionText} actionText
|
|
4
|
+
* @property {createTracer} createTracer
|
|
5
|
+
* @property {end} end
|
|
6
|
+
* @property {getContext} getContext
|
|
7
|
+
* @property {ignore} ignore
|
|
8
|
+
* @property {onEnd} onEnd
|
|
9
|
+
* @property {onEnd} save
|
|
10
|
+
* @property {setAttribute} setAttribute
|
|
11
|
+
* @property {setName} setName
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sets the text value of the HTML element that was clicked to start a browser interaction.
|
|
16
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/actiontext/}
|
|
17
|
+
* @callback actionText
|
|
18
|
+
* @param {string} value The text value of the HTML element that represents the action that started the interaction.
|
|
19
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Times sub-components of a SPA interaction separately, including wait time and JS execution time.
|
|
24
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/createtracer/}
|
|
25
|
+
* @callback createTracer
|
|
26
|
+
* @param {string} name This will be used as the name of the tracer.
|
|
27
|
+
* @param {string} [callback] A callback that contains the synchronous work to run at the end of the async work. To execute this callback, call the wrapper function returned using createTracer().
|
|
28
|
+
* @returns {Function} Returns a method that wraps the original callback. When this method is invoked, it calls the original callback and ends the async timing.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Ends the SPA interaction at the current time.
|
|
33
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/end/}
|
|
34
|
+
* @callback end
|
|
35
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stores values for the current SPA interaction asynchronously in browser.
|
|
40
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/getcontext/}
|
|
41
|
+
* @callback getContext
|
|
42
|
+
* @param {(ctx: object) => void} callback This function is called when the interaction ends. It is called with one parameter, which is the interaction context.
|
|
43
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Change the values associated with a SPA interaction before the interaction is saved.
|
|
48
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/onend/}
|
|
49
|
+
* @callback onEnd
|
|
50
|
+
* @param {(ctx: object) => void} callback This function is called when the interaction ends. It is called with one parameter, which is the interaction context.
|
|
51
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Ensures a SPA browser interaction will be saved when it ends.
|
|
56
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/save/}
|
|
57
|
+
* @callback save
|
|
58
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Adds a custom SPA attribute only to the current interaction in browser.
|
|
63
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setattribute/}
|
|
64
|
+
* @callback setAttribute
|
|
65
|
+
* @param {string} key Used as the attribute name on the BrowserInteraction event.
|
|
66
|
+
* @param {any} key Used as the attribute value on the BrowserInteraction event. This can be a string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string.
|
|
67
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sets the name and trigger of a SPA's browser interaction that is not a route change or URL change.
|
|
72
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setname/}
|
|
73
|
+
* @callback setName
|
|
74
|
+
* @param {string} name If null, the name will be set using the targetGroupedUrl attribute. If not null, this will set the browserInteractionName attribute in the BrowserInteraction event.
|
|
75
|
+
* @param {string} [trigger] If not null, this will set the TRIGGER attribute on the BrowserInteraction event.
|
|
76
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/* istanbul ignore next */
|
|
80
|
+
export const unused = {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { setAPI, setTopLevelCallers } from '../api/api'
|
|
2
2
|
import { addToNREUM, gosCDN, gosNREUMInitializedAgents } from '../../common/window/nreum'
|
|
3
3
|
import { setConfiguration, setInfo, setLoaderConfig, setRuntime } from '../../common/config/config'
|
|
4
|
-
import {
|
|
5
|
-
import { isWorkerScope } from '../../common/
|
|
4
|
+
import { activatedFeatures } from '../../common/util/feature-flags'
|
|
5
|
+
import { isWorkerScope } from '../../common/constants/runtime'
|
|
6
6
|
|
|
7
7
|
export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
|
|
8
8
|
let { init, info, loader_config, runtime = { loaderType }, exposed = true } = opts
|
|
@@ -15,15 +15,16 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
|
|
|
15
15
|
|
|
16
16
|
setConfiguration(agentIdentifier, init || {})
|
|
17
17
|
setLoaderConfig(agentIdentifier, loader_config || {})
|
|
18
|
-
setRuntime(agentIdentifier, runtime)
|
|
19
18
|
|
|
20
19
|
info.jsAttributes ??= {}
|
|
21
20
|
if (isWorkerScope) { // add a default attr to all worker payloads
|
|
22
21
|
info.jsAttributes.isWorker = true
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
setInfo(agentIdentifier, info)
|
|
26
24
|
|
|
25
|
+
runtime.denyList = init.ajax?.block_internal ? (init.ajax.deny_list || []).concat(info.beacon, info.errorBeacon) : init.ajax?.deny_list
|
|
26
|
+
setRuntime(agentIdentifier, runtime)
|
|
27
|
+
|
|
27
28
|
setTopLevelCallers()
|
|
28
29
|
const api = setAPI(agentIdentifier, forceDrain)
|
|
29
30
|
gosNREUMInitializedAgents(agentIdentifier, api, 'api')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// loader files
|
|
2
|
+
import { Instrument as PVE } from '../features/page_view_event/instrument'
|
|
2
3
|
import { getEnabledFeatures } from './features/enabled-features'
|
|
3
4
|
import { configure } from './configure/configure'
|
|
4
5
|
// core files
|
|
@@ -8,28 +9,28 @@ import { generateRandomHexString } from '../common/ids/unique-id'
|
|
|
8
9
|
import { getConfiguration, getInfo, getLoaderConfig, getRuntime } from '../common/config/config'
|
|
9
10
|
import { FEATURE_NAMES } from './features/features'
|
|
10
11
|
import { warn } from '../common/util/console'
|
|
12
|
+
import { onWindowLoad } from '../common/window/load'
|
|
13
|
+
import { AgentBase } from './agent-base'
|
|
11
14
|
|
|
12
15
|
const nonAutoFeatures = [
|
|
13
16
|
FEATURE_NAMES.jserrors,
|
|
14
|
-
FEATURE_NAMES.pageAction
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
const autoFeatures = [
|
|
17
|
+
FEATURE_NAMES.pageAction,
|
|
18
18
|
FEATURE_NAMES.metrics
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* A minimal agent class designed to
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* instrumentations at runtime, and to report desired data, events, and errors programatically.
|
|
22
|
+
* A minimal agent class designed to only respond to manual user input. As such, this class does not
|
|
23
|
+
* automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
|
|
24
|
+
* Out of the box, it can manually handle and report Page View, Page Action, and Error events.
|
|
26
25
|
*/
|
|
27
|
-
export class MicroAgent {
|
|
26
|
+
export class MicroAgent extends AgentBase {
|
|
28
27
|
/**
|
|
29
28
|
* @param {Object} options - Specifies features and runtime configuration,
|
|
30
29
|
* @param {string=} agentIdentifier - The optional unique ID of the agent.
|
|
31
30
|
*/
|
|
32
31
|
constructor (options, agentIdentifier = generateRandomHexString(16)) {
|
|
32
|
+
super()
|
|
33
|
+
|
|
33
34
|
this.agentIdentifier = agentIdentifier
|
|
34
35
|
this.sharedAggregator = new Aggregator({ agentIdentifier: this.agentIdentifier })
|
|
35
36
|
this.features = {}
|
|
@@ -51,28 +52,26 @@ export class MicroAgent {
|
|
|
51
52
|
start () {
|
|
52
53
|
try {
|
|
53
54
|
const enabledFeatures = getEnabledFeatures(this.agentIdentifier)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
warn('Something prevented the agent from being downloaded.'))
|
|
75
|
-
}
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
// a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
|
|
58
|
+
this.features.page_view_event = new PVE(this.agentIdentifier, this.sharedAggregator)
|
|
59
|
+
} catch (err) {
|
|
60
|
+
warn('Something prevented the agent from instrumenting.', err)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
onWindowLoad(() => {
|
|
64
|
+
// these features do not import an "instrument" file, meaning they are only hooked up to the API.
|
|
65
|
+
nonAutoFeatures.forEach(f => {
|
|
66
|
+
if (enabledFeatures[f]) {
|
|
67
|
+
import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
|
|
68
|
+
return lazyFeatureLoader(f, 'aggregate')
|
|
69
|
+
}).then(({ Aggregate }) => {
|
|
70
|
+
this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator)
|
|
71
|
+
}).catch(err =>
|
|
72
|
+
warn('Something prevented the agent from being downloaded.', err))
|
|
73
|
+
}
|
|
74
|
+
})
|
|
76
75
|
})
|
|
77
76
|
gosNREUMInitializedAgents(this.agentIdentifier, this.features, 'features')
|
|
78
77
|
return this
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ffVersion = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
9
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/* eslint-disable no-useless-escape */
|
|
13
|
-
|
|
14
|
-
var ffVersion = 0;
|
|
15
|
-
exports.ffVersion = ffVersion;
|
|
16
|
-
var match = navigator.userAgent.match(/Firefox[\/\s](\d+\.\d+)/);
|
|
17
|
-
if (match) exports.ffVersion = ffVersion = +match[1];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isiOS = exports.iOS_below16 = void 0;
|
|
7
|
-
const isiOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
|
|
8
|
-
|
|
9
|
-
/* Feature detection to get our version(s). */
|
|
10
|
-
|
|
11
|
-
// Shared Web Workers introduced in iOS 16.0+ and n/a in 15.6-
|
|
12
|
-
exports.isiOS = isiOS;
|
|
13
|
-
const iOS_below16 = isiOS && Boolean(typeof SharedWorker === 'undefined');
|
|
14
|
-
/*
|
|
15
|
-
^ It was discovered in Safari 14 (https://bugs.webkit.org/show_bug.cgi?id=225305) that the buffered flag in PerformanceObserver
|
|
16
|
-
did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
|
|
17
|
-
This was fixed in v16+.
|
|
18
|
-
*/
|
|
19
|
-
exports.iOS_below16 = iOS_below16;
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _faker = require("@faker-js/faker");
|
|
4
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
5
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
6
|
-
let mockNREUM;
|
|
7
|
-
let runtime;
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
mockNREUM = {};
|
|
10
|
-
runtime = {};
|
|
11
|
-
jest.doMock('../window/nreum', () => ({
|
|
12
|
-
__esModule: true,
|
|
13
|
-
gosNREUM: jest.fn(() => mockNREUM)
|
|
14
|
-
}));
|
|
15
|
-
jest.doMock('../config/config', () => ({
|
|
16
|
-
__esModule: true,
|
|
17
|
-
getRuntime: jest.fn(() => runtime)
|
|
18
|
-
}));
|
|
19
|
-
});
|
|
20
|
-
afterEach(() => {
|
|
21
|
-
jest.resetModules();
|
|
22
|
-
jest.resetAllMocks();
|
|
23
|
-
});
|
|
24
|
-
describe('global event-emitter', () => {
|
|
25
|
-
test('it returns the event-emitter defined on window.NREUM', async () => {
|
|
26
|
-
const mockEE = {};
|
|
27
|
-
mockNREUM.ee = mockEE;
|
|
28
|
-
const {
|
|
29
|
-
ee
|
|
30
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
31
|
-
expect(ee).toEqual(mockEE);
|
|
32
|
-
});
|
|
33
|
-
test('it sets the global event-emitter on window.NREUM', async () => {
|
|
34
|
-
const {
|
|
35
|
-
ee
|
|
36
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
37
|
-
expect(ee).toEqual(mockNREUM.ee);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('scoping event-emitter', () => {
|
|
41
|
-
test('it creates a new child event-emitter', async () => {
|
|
42
|
-
const {
|
|
43
|
-
ee
|
|
44
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
45
|
-
const childName = _faker.faker.datatype.uuid();
|
|
46
|
-
const result = ee.get(childName);
|
|
47
|
-
expect(result).not.toEqual(mockNREUM.ee);
|
|
48
|
-
expect(result).toEqual(ee.get(childName)); // Should always return the same event-emitter
|
|
49
|
-
expect(result.debugId).toEqual(childName);
|
|
50
|
-
});
|
|
51
|
-
test('it creates a child event-emitter with an isolated backlog', async () => {
|
|
52
|
-
const childName = _faker.faker.random.alphaNumeric(16);
|
|
53
|
-
jest.doMock('../config/config', () => ({
|
|
54
|
-
__esModule: true,
|
|
55
|
-
getRuntime: jest.fn(id => {
|
|
56
|
-
if (id === childName) {
|
|
57
|
-
return {
|
|
58
|
-
isolatedBacklog: true
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return runtime;
|
|
62
|
-
})
|
|
63
|
-
}));
|
|
64
|
-
const {
|
|
65
|
-
ee
|
|
66
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
67
|
-
const result = ee.get(childName);
|
|
68
|
-
expect(ee.backlog).not.toBe(result.backlog);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe('event-emitter context', () => {
|
|
72
|
-
test('it returns a new context', async () => {
|
|
73
|
-
const {
|
|
74
|
-
ee
|
|
75
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
76
|
-
const result = ee.context();
|
|
77
|
-
expect(result).toEqual({});
|
|
78
|
-
});
|
|
79
|
-
test('it returns the same context', async () => {
|
|
80
|
-
const {
|
|
81
|
-
ee
|
|
82
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
83
|
-
const result = ee.context();
|
|
84
|
-
expect(result).toEqual(ee.context(result));
|
|
85
|
-
});
|
|
86
|
-
test('it adds the context to the provided object', async () => {
|
|
87
|
-
const {
|
|
88
|
-
ee
|
|
89
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
90
|
-
const obj = {};
|
|
91
|
-
const result = ee.context(obj);
|
|
92
|
-
expect(result).toEqual(obj['nr@context']);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('event-emitter buffer', () => {
|
|
96
|
-
test('it should create a new buffer for the given group', async () => {
|
|
97
|
-
const {
|
|
98
|
-
ee
|
|
99
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
100
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
101
|
-
const group = _faker.faker.datatype.uuid();
|
|
102
|
-
ee.buffer([eventType], group);
|
|
103
|
-
expect(ee.backlog).toEqual(expect.objectContaining({
|
|
104
|
-
[group]: []
|
|
105
|
-
}));
|
|
106
|
-
expect(ee.isBuffering(eventType)).toEqual(true);
|
|
107
|
-
});
|
|
108
|
-
test('it should default group to "feature"', async () => {
|
|
109
|
-
const {
|
|
110
|
-
ee
|
|
111
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
112
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
113
|
-
ee.buffer([eventType]);
|
|
114
|
-
expect(ee.backlog).toEqual(expect.objectContaining({
|
|
115
|
-
feature: []
|
|
116
|
-
}));
|
|
117
|
-
expect(ee.isBuffering(eventType)).toEqual(true);
|
|
118
|
-
});
|
|
119
|
-
test('it should not create buffer if event-emitter is aborted', async () => {
|
|
120
|
-
const {
|
|
121
|
-
ee
|
|
122
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
123
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
124
|
-
const group = _faker.faker.datatype.uuid();
|
|
125
|
-
ee.backlog = {
|
|
126
|
-
api: ['foo', 'bar', 'baz']
|
|
127
|
-
};
|
|
128
|
-
ee.abort();
|
|
129
|
-
ee.buffer([eventType], group);
|
|
130
|
-
expect(ee.backlog).toEqual({});
|
|
131
|
-
expect(ee.isBuffering(eventType)).toEqual(false);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
describe('event-emitter abort', () => {
|
|
135
|
-
test('it aborts if there is an API backlog', async () => {
|
|
136
|
-
const {
|
|
137
|
-
ee
|
|
138
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
139
|
-
ee.backlog = {
|
|
140
|
-
api: ['foo', 'bar', 'baz']
|
|
141
|
-
};
|
|
142
|
-
ee.abort();
|
|
143
|
-
expect(ee.aborted).toEqual(true);
|
|
144
|
-
expect(ee.backlog).toEqual({});
|
|
145
|
-
});
|
|
146
|
-
test('it aborts if there is a feature backlog', async () => {
|
|
147
|
-
const {
|
|
148
|
-
ee
|
|
149
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
150
|
-
ee.backlog = {
|
|
151
|
-
feature: ['foo', 'bar', 'baz']
|
|
152
|
-
};
|
|
153
|
-
ee.abort();
|
|
154
|
-
expect(ee.aborted).toEqual(true);
|
|
155
|
-
expect(ee.backlog).toEqual({});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
describe('event-emitter emit', () => {
|
|
159
|
-
test('should execute the listener', async () => {
|
|
160
|
-
const {
|
|
161
|
-
ee
|
|
162
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
163
|
-
const mockListener = jest.fn();
|
|
164
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
165
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
166
|
-
ee.on(eventType, mockListener);
|
|
167
|
-
ee.emit(eventType, eventArgs);
|
|
168
|
-
expect(mockListener).toHaveBeenCalledWith(eventArgs[0], eventArgs[1], eventArgs[2]);
|
|
169
|
-
});
|
|
170
|
-
test('should not execute the listener after removal', async () => {
|
|
171
|
-
const {
|
|
172
|
-
ee
|
|
173
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
174
|
-
const mockListener = jest.fn();
|
|
175
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
176
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
177
|
-
ee.on(eventType, mockListener);
|
|
178
|
-
ee.emit(eventType, eventArgs);
|
|
179
|
-
ee.removeEventListener(eventType, mockListener);
|
|
180
|
-
ee.emit(eventType, eventArgs);
|
|
181
|
-
expect(mockListener).toHaveBeenCalledTimes(1);
|
|
182
|
-
});
|
|
183
|
-
test('should return early if global event-emitter is aborted', async () => {
|
|
184
|
-
const {
|
|
185
|
-
ee
|
|
186
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
187
|
-
const mockListener = jest.fn();
|
|
188
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
189
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
190
|
-
ee.backlog = {
|
|
191
|
-
api: ['foo', 'bar', 'baz']
|
|
192
|
-
};
|
|
193
|
-
ee.abort();
|
|
194
|
-
ee.on(eventType, mockListener);
|
|
195
|
-
ee.emit(eventType, eventArgs);
|
|
196
|
-
expect(mockListener).toHaveBeenCalledTimes(0);
|
|
197
|
-
});
|
|
198
|
-
test('should still emit if global event-emitter is aborted but force flag is true', async () => {
|
|
199
|
-
const {
|
|
200
|
-
ee
|
|
201
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
202
|
-
const scopeEE = ee.get(_faker.faker.datatype.uuid());
|
|
203
|
-
const mockScopeListener = jest.fn();
|
|
204
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
205
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
206
|
-
ee.backlog = {
|
|
207
|
-
api: ['foo', 'bar', 'baz']
|
|
208
|
-
};
|
|
209
|
-
ee.abort();
|
|
210
|
-
scopeEE.on(eventType, mockScopeListener);
|
|
211
|
-
scopeEE.emit(eventType, eventArgs, {}, true);
|
|
212
|
-
expect(mockScopeListener).toHaveBeenCalledTimes(1);
|
|
213
|
-
});
|
|
214
|
-
test('should bubble the event if bubble flag is true', async () => {
|
|
215
|
-
const {
|
|
216
|
-
ee
|
|
217
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
218
|
-
const scopeEE = ee.get(_faker.faker.datatype.uuid());
|
|
219
|
-
const mockListener = jest.fn();
|
|
220
|
-
const mockScopeListener = jest.fn();
|
|
221
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
222
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
223
|
-
ee.on(eventType, mockListener);
|
|
224
|
-
scopeEE.on(eventType, mockScopeListener);
|
|
225
|
-
scopeEE.emit(eventType, eventArgs, {}, false, true);
|
|
226
|
-
expect(mockScopeListener).toHaveBeenCalledTimes(1);
|
|
227
|
-
expect(mockListener).toHaveBeenCalledTimes(1);
|
|
228
|
-
});
|
|
229
|
-
test('should not bubble the event if bubble flag is false', async () => {
|
|
230
|
-
const {
|
|
231
|
-
ee
|
|
232
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
233
|
-
const scopeEE = ee.get(_faker.faker.datatype.uuid());
|
|
234
|
-
const mockListener = jest.fn();
|
|
235
|
-
const mockScopeListener = jest.fn();
|
|
236
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
237
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
238
|
-
ee.on(eventType, mockListener);
|
|
239
|
-
scopeEE.on(eventType, mockScopeListener);
|
|
240
|
-
scopeEE.emit(eventType, eventArgs, {}, false, false);
|
|
241
|
-
expect(mockScopeListener).toHaveBeenCalledTimes(1);
|
|
242
|
-
expect(mockListener).not.toHaveBeenCalled();
|
|
243
|
-
});
|
|
244
|
-
test('should buffer the event on the scoped event-emitter', async () => {
|
|
245
|
-
const {
|
|
246
|
-
ee
|
|
247
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
248
|
-
const scopeEE = ee.get(_faker.faker.datatype.uuid());
|
|
249
|
-
const mockListener = jest.fn();
|
|
250
|
-
const mockScopeListener = jest.fn();
|
|
251
|
-
const eventType = _faker.faker.datatype.uuid();
|
|
252
|
-
const eventArgs = ['a', 'b', 'c'];
|
|
253
|
-
ee.on(eventType, mockListener);
|
|
254
|
-
ee.buffer([eventType]);
|
|
255
|
-
scopeEE.on(eventType, mockScopeListener);
|
|
256
|
-
scopeEE.buffer([eventType]);
|
|
257
|
-
scopeEE.emit(eventType, eventArgs, {}, false, false);
|
|
258
|
-
expect(mockScopeListener).toHaveBeenCalledTimes(1);
|
|
259
|
-
expect(mockListener).not.toHaveBeenCalled();
|
|
260
|
-
expect(scopeEE.backlog.feature).toEqual(expect.arrayContaining([expect.arrayContaining([scopeEE, eventType, eventArgs, {}])]));
|
|
261
|
-
expect(ee.backlog.feature).toEqual(scopeEE.backlog.feature);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
describe('getOrSetContext', () => {
|
|
265
|
-
test('it returns a new context', async () => {
|
|
266
|
-
const {
|
|
267
|
-
getOrSetContext
|
|
268
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
269
|
-
const obj = {};
|
|
270
|
-
const result = getOrSetContext(obj);
|
|
271
|
-
expect(result).toEqual({});
|
|
272
|
-
expect(result).toEqual(obj['nr@context']);
|
|
273
|
-
});
|
|
274
|
-
test('it returns the same context', async () => {
|
|
275
|
-
const {
|
|
276
|
-
getOrSetContext
|
|
277
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./contextual-ee')));
|
|
278
|
-
const obj = {};
|
|
279
|
-
const result = getOrSetContext(obj);
|
|
280
|
-
expect(getOrSetContext(obj)).toEqual(result);
|
|
281
|
-
});
|
|
282
|
-
});
|