@newrelic/browser-agent 1.234.0 → 1.236.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 +42 -2
- package/dist/cjs/common/config/state/init.js +3 -0
- package/dist/cjs/common/config/state/runtime.js +4 -4
- 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/constants/shared-channel.js +19 -0
- package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +35 -16
- package/dist/cjs/common/harvest/harvest.js +163 -144
- 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 +21 -13
- package/dist/cjs/common/timer/interaction-timer.js +3 -3
- 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/feature-flags.js +23 -12
- package/dist/cjs/common/util/obfuscate.js +2 -2
- package/dist/cjs/common/util/submit-data.js +61 -79
- 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 +2 -2
- 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 +3 -3
- package/dist/cjs/common/wrap/wrap-timer.js +5 -5
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +1 -1
- 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/index.js +11 -4
- package/dist/cjs/features/jserrors/instrument/index.js +6 -19
- 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/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 +99 -82
- package/dist/cjs/features/session_replay/replay-mode.js +28 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +222 -99
- package/dist/cjs/features/session_trace/constants.js +1 -3
- package/dist/cjs/features/session_trace/instrument/index.js +2 -18
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/constants.js +0 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/agent-session.js +20 -36
- package/dist/cjs/features/utils/aggregate-base.js +7 -12
- package/dist/cjs/features/utils/handler-cache.js +28 -23
- package/dist/cjs/features/utils/instrument-base.js +58 -40
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent.js +7 -1
- package/dist/cjs/loaders/api/api.js +2 -2
- package/dist/cjs/loaders/api/apiAsync.js +6 -4
- package/dist/cjs/loaders/configure/configure.js +2 -2
- package/dist/cjs/loaders/features/featureDependencies.js +2 -0
- package/dist/cjs/loaders/micro-agent.js +29 -38
- package/dist/esm/common/config/state/init.js +3 -0
- package/dist/esm/common/config/state/runtime.js +1 -1
- 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/constants/shared-channel.js +12 -0
- package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +34 -17
- package/dist/esm/common/harvest/harvest.js +160 -142
- 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 +18 -12
- package/dist/esm/common/timer/interaction-timer.js +2 -2
- 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/feature-flags.js +23 -12
- package/dist/esm/common/util/obfuscate.js +2 -2
- package/dist/esm/common/util/submit-data.js +58 -76
- 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 +1 -1
- 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 +2 -2
- package/dist/esm/common/wrap/wrap-timer.js +2 -2
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +1 -1
- 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/index.js +10 -3
- package/dist/esm/features/jserrors/instrument/index.js +3 -16
- 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/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 +92 -78
- package/dist/esm/features/session_replay/replay-mode.js +23 -0
- package/dist/esm/features/session_trace/aggregate/index.js +223 -100
- package/dist/esm/features/session_trace/constants.js +0 -1
- package/dist/esm/features/session_trace/instrument/index.js +2 -18
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/constants.js +0 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/agent-session.js +21 -37
- package/dist/esm/features/utils/aggregate-base.js +7 -12
- package/dist/esm/features/utils/handler-cache.js +28 -23
- package/dist/esm/features/utils/instrument-base.js +57 -39
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent.js +7 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/configure/configure.js +1 -1
- package/dist/esm/loaders/features/featureDependencies.js +2 -0
- package/dist/esm/loaders/micro-agent.js +29 -38
- package/dist/types/common/config/state/init.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/constants/shared-channel.d.ts +5 -0
- package/dist/types/common/constants/shared-channel.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts +5 -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 +9 -5
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts +1 -0
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +62 -64
- package/dist/types/common/util/submit-data.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 +2 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.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 +14 -5
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/replay-mode.d.ts +9 -0
- package/dist/types/features/session_replay/replay-mode.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +21 -3
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +0 -1
- package/dist/types/features/session_trace/constants.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +0 -2
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +6 -1
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts +12 -11
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +17 -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.d.ts +4 -4
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +3 -4
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +14 -7
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +1 -0
- package/src/common/config/state/runtime.js +1 -1
- 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/constants/shared-channel.js +13 -0
- package/src/common/context/__mocks__/shared-context.js +8 -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 +31 -19
- package/src/common/harvest/harvest-scheduler.test.js +491 -20
- package/src/common/harvest/harvest.js +147 -130
- package/src/common/harvest/harvest.test.js +788 -139
- 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.test.js → session-entity.component-test.js} +71 -48
- package/src/common/session/session-entity.js +16 -13
- package/src/common/timer/interaction-timer.js +2 -2
- 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 +32 -21
- 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 +6 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/data-size.test.js +27 -20
- package/src/common/util/feature-flags.js +24 -12
- package/src/common/util/feature-flags.test.js +98 -0
- package/src/common/util/obfuscate.component-test.js +173 -0
- package/src/common/util/obfuscate.js +2 -2
- package/src/common/util/submit-data.js +42 -56
- package/src/common/util/submit-data.test.js +158 -137
- 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 +1 -1
- 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 +2 -2
- package/src/common/wrap/wrap-timer.js +2 -2
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +1 -1
- 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.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +12 -3
- package/src/features/jserrors/instrument/index.js +3 -16
- 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/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 +368 -0
- package/src/features/session_replay/aggregate/index.js +96 -71
- package/src/features/session_replay/instrument/index.js +0 -1
- package/src/features/session_replay/replay-mode.js +23 -0
- package/src/features/session_trace/aggregate/index.js +198 -79
- package/src/features/session_trace/constants.js +0 -1
- package/src/features/session_trace/instrument/index.js +3 -20
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/constants.js +0 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.js +22 -34
- package/src/features/utils/agent-session.test.js +194 -0
- package/src/features/utils/aggregate-base.js +12 -9
- package/src/features/utils/aggregate-base.test.js +122 -0
- package/src/features/utils/feature-base.test.js +45 -0
- package/src/features/utils/handler-cache.js +29 -23
- package/src/features/utils/handler-cache.test.js +72 -0
- package/src/features/utils/instrument-base.js +45 -29
- package/src/features/utils/instrument-base.test.js +209 -0
- package/src/features/utils/lazy-feature-loader.test.js +37 -0
- package/src/index.js +1 -3
- package/src/loaders/agent.js +8 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/configure/configure.js +1 -1
- package/src/loaders/features/featureDependencies.js +2 -0
- package/src/loaders/micro-agent.js +26 -30
- 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.test.js +0 -39
- package/dist/cjs/common/harvest/harvest.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.test.js +0 -460
- package/dist/cjs/common/storage/local-memory.js +0 -35
- package/dist/cjs/common/storage/local-memory.test.js +0 -20
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.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 -42
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.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.test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -47
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -58
- 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/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -221
- 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/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/spa/aggregate/interaction-node.test.js +0 -16
- 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.test.js +0 -37
- package/dist/esm/common/harvest/harvest.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.test.js +0 -458
- package/dist/esm/common/storage/local-memory.js +0 -28
- package/dist/esm/common/storage/local-memory.test.js +0 -18
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.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 -38
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.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.test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -45
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -45
- 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/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -219
- 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/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/spa/aggregate/interaction-node.test.js +0 -14
- 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/storage/local-memory.d.ts +0 -8
- package/dist/types/common/storage/local-memory.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -14
- package/dist/types/common/util/global-scope.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/storage/local-memory.js +0 -30
- package/src/common/storage/local-memory.test.js +0 -19
- package/src/common/util/global-scope.js +0 -49
- /package/src/common/timer/{interaction-timer.test.js → interaction-timer.component-test.js} +0 -0
- /package/src/common/url/{encode.test.js → encode.component-test.js} +0 -0
- /package/src/common/url/{protocol.test.js → protocol.component-test.js} +0 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker'
|
|
2
|
+
import { InstrumentBase } from './instrument-base'
|
|
3
|
+
import { FeatureBase } from './feature-base'
|
|
4
|
+
import { drain, registerDrain } from '../../common/drain/drain'
|
|
5
|
+
import { onWindowLoad } from '../../common/window/load'
|
|
6
|
+
import { lazyFeatureLoader } from './lazy-feature-loader'
|
|
7
|
+
import { getConfigurationValue } from '../../common/config/config'
|
|
8
|
+
import { setupAgentSession } from './agent-session'
|
|
9
|
+
import { warn } from '../../common/util/console'
|
|
10
|
+
import * as globalScopeModule from '../../common/constants/runtime'
|
|
11
|
+
import { FEATURE_NAMES } from '../../loaders/features/features'
|
|
12
|
+
|
|
13
|
+
jest.enableAutomock()
|
|
14
|
+
jest.unmock('./instrument-base')
|
|
15
|
+
jest.unmock('../../loaders/features/features')
|
|
16
|
+
jest.mock('../../common/drain/drain', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
drain: jest.fn(),
|
|
19
|
+
registerDrain: jest.fn()
|
|
20
|
+
}))
|
|
21
|
+
jest.mock('../../common/window/load', () => ({
|
|
22
|
+
__esModule: true,
|
|
23
|
+
onWindowLoad: jest.fn()
|
|
24
|
+
}))
|
|
25
|
+
jest.mock('../../common/constants/runtime', () => ({
|
|
26
|
+
__esModule: true,
|
|
27
|
+
isBrowserScope: undefined,
|
|
28
|
+
isWorkerScope: undefined
|
|
29
|
+
}))
|
|
30
|
+
jest.mock('../../common/config/config', () => ({
|
|
31
|
+
__esModule: true,
|
|
32
|
+
getConfigurationValue: jest.fn()
|
|
33
|
+
}))
|
|
34
|
+
jest.mock('./feature-base', () => ({
|
|
35
|
+
__esModule: true,
|
|
36
|
+
FeatureBase: jest.fn(function (...args) {
|
|
37
|
+
this.agentIdentifier = args[0]
|
|
38
|
+
this.aggregator = args[1]
|
|
39
|
+
this.featureName = args[2]
|
|
40
|
+
})
|
|
41
|
+
}))
|
|
42
|
+
jest.mock('./agent-session', () => ({
|
|
43
|
+
__esModule: true,
|
|
44
|
+
setupAgentSession: jest.fn()
|
|
45
|
+
}))
|
|
46
|
+
|
|
47
|
+
let agentIdentifier
|
|
48
|
+
let aggregator
|
|
49
|
+
let featureName
|
|
50
|
+
let mockAggregate
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
jest.replaceProperty(globalScopeModule, 'isBrowserScope', true)
|
|
54
|
+
jest.replaceProperty(globalScopeModule, 'isWorkerScope', false)
|
|
55
|
+
|
|
56
|
+
agentIdentifier = faker.datatype.uuid()
|
|
57
|
+
aggregator = {}
|
|
58
|
+
featureName = faker.datatype.uuid()
|
|
59
|
+
|
|
60
|
+
mockAggregate = jest.fn()
|
|
61
|
+
jest.mocked(lazyFeatureLoader).mockResolvedValue({ Aggregate: mockAggregate })
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('should construct a new instrument', () => {
|
|
65
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, featureName)
|
|
66
|
+
|
|
67
|
+
expect(FeatureBase).toHaveBeenCalledWith(agentIdentifier, aggregator, featureName)
|
|
68
|
+
expect(instrument.featAggregate).toBeUndefined()
|
|
69
|
+
expect(instrument.auto).toEqual(true)
|
|
70
|
+
expect(instrument.abortHandler).toBeUndefined()
|
|
71
|
+
expect(registerDrain).toHaveBeenCalledWith(agentIdentifier, featureName)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test('should not immediately drain', () => {
|
|
75
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, featureName, false)
|
|
76
|
+
|
|
77
|
+
expect(registerDrain).not.toHaveBeenCalled()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('should import aggregator on window load', async () => {
|
|
81
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, featureName)
|
|
82
|
+
const aggregateArgs = { [faker.datatype.uuid()]: faker.lorem.sentence() }
|
|
83
|
+
instrument.importAggregator(aggregateArgs)
|
|
84
|
+
|
|
85
|
+
const windowLoadCallback = jest.mocked(onWindowLoad).mock.calls[0][0]
|
|
86
|
+
await windowLoadCallback()
|
|
87
|
+
|
|
88
|
+
expect(onWindowLoad).toHaveBeenCalledWith(expect.any(Function), true)
|
|
89
|
+
expect(lazyFeatureLoader).toHaveBeenCalledWith(featureName, 'aggregate')
|
|
90
|
+
expect(mockAggregate).toHaveBeenCalledWith(agentIdentifier, aggregator, aggregateArgs)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('should immediately import aggregator in worker scope', async () => {
|
|
94
|
+
jest.replaceProperty(globalScopeModule, 'isBrowserScope', false)
|
|
95
|
+
jest.replaceProperty(globalScopeModule, 'isWorkerScope', true)
|
|
96
|
+
|
|
97
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, featureName)
|
|
98
|
+
const aggregateArgs = { [faker.datatype.uuid()]: faker.lorem.sentence() }
|
|
99
|
+
instrument.importAggregator(aggregateArgs)
|
|
100
|
+
|
|
101
|
+
// In worker scope, we cannot wait on importLater method
|
|
102
|
+
await new Promise(process.nextTick)
|
|
103
|
+
|
|
104
|
+
expect(onWindowLoad).not.toHaveBeenCalled()
|
|
105
|
+
expect(lazyFeatureLoader).toHaveBeenCalledWith(featureName, 'aggregate')
|
|
106
|
+
expect(mockAggregate).toHaveBeenCalledWith(agentIdentifier, aggregator, aggregateArgs)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('should import the session manager and replay aggregate for new session', async () => {
|
|
110
|
+
jest.mocked(getConfigurationValue).mockReturnValue(true)
|
|
111
|
+
jest.mocked(setupAgentSession).mockReturnValue({
|
|
112
|
+
isNew: true
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, FEATURE_NAMES.sessionReplay)
|
|
116
|
+
const aggregateArgs = { [faker.datatype.uuid()]: faker.lorem.sentence() }
|
|
117
|
+
instrument.importAggregator(aggregateArgs)
|
|
118
|
+
|
|
119
|
+
const windowLoadCallback = jest.mocked(onWindowLoad).mock.calls[0][0]
|
|
120
|
+
await windowLoadCallback()
|
|
121
|
+
|
|
122
|
+
expect(getConfigurationValue).toHaveBeenCalledWith(agentIdentifier, 'privacy.cookies_enabled')
|
|
123
|
+
expect(setupAgentSession).toHaveBeenCalledWith(agentIdentifier)
|
|
124
|
+
expect(lazyFeatureLoader).toHaveBeenCalledWith(FEATURE_NAMES.sessionReplay, 'aggregate')
|
|
125
|
+
expect(mockAggregate).toHaveBeenCalledWith(agentIdentifier, aggregator, aggregateArgs)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
test('should import the session manager and replay aggregate when a recording is active', async () => {
|
|
129
|
+
jest.mocked(getConfigurationValue).mockReturnValue(true)
|
|
130
|
+
jest.mocked(setupAgentSession).mockReturnValue({
|
|
131
|
+
isNew: false,
|
|
132
|
+
state: {
|
|
133
|
+
sessionReplay: 1
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, FEATURE_NAMES.sessionReplay)
|
|
138
|
+
const aggregateArgs = { [faker.datatype.uuid()]: faker.lorem.sentence() }
|
|
139
|
+
instrument.importAggregator(aggregateArgs)
|
|
140
|
+
|
|
141
|
+
const windowLoadCallback = jest.mocked(onWindowLoad).mock.calls[0][0]
|
|
142
|
+
await windowLoadCallback()
|
|
143
|
+
|
|
144
|
+
expect(getConfigurationValue).toHaveBeenCalledWith(agentIdentifier, 'privacy.cookies_enabled')
|
|
145
|
+
expect(setupAgentSession).toHaveBeenCalledWith(agentIdentifier)
|
|
146
|
+
expect(lazyFeatureLoader).toHaveBeenCalledWith(FEATURE_NAMES.sessionReplay, 'aggregate')
|
|
147
|
+
expect(mockAggregate).toHaveBeenCalledWith(agentIdentifier, aggregator, aggregateArgs)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('should not import session aggregate when session is not new and a recording is not active', async () => {
|
|
151
|
+
jest.mocked(getConfigurationValue).mockReturnValue(true)
|
|
152
|
+
jest.mocked(setupAgentSession).mockReturnValue({
|
|
153
|
+
isNew: false,
|
|
154
|
+
state: {
|
|
155
|
+
sessionReplay: 0
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, FEATURE_NAMES.sessionReplay)
|
|
160
|
+
const aggregateArgs = { [faker.datatype.uuid()]: faker.lorem.sentence() }
|
|
161
|
+
instrument.importAggregator(aggregateArgs)
|
|
162
|
+
|
|
163
|
+
const windowLoadCallback = jest.mocked(onWindowLoad).mock.calls[0][0]
|
|
164
|
+
await windowLoadCallback()
|
|
165
|
+
|
|
166
|
+
expect(getConfigurationValue).toHaveBeenCalledWith(agentIdentifier, 'privacy.cookies_enabled')
|
|
167
|
+
expect(setupAgentSession).toHaveBeenCalledWith(agentIdentifier)
|
|
168
|
+
expect(drain).toHaveBeenCalledWith(agentIdentifier, FEATURE_NAMES.sessionReplay)
|
|
169
|
+
expect(lazyFeatureLoader).not.toHaveBeenCalled()
|
|
170
|
+
expect(mockAggregate).not.toHaveBeenCalled()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
test('feature still imports by default even when setupAgentSession throws an error', async () => {
|
|
174
|
+
jest.mocked(getConfigurationValue).mockReturnValue(true)
|
|
175
|
+
jest.mocked(setupAgentSession).mockImplementation(() => { throw new Error(faker.lorem.sentence()) })
|
|
176
|
+
|
|
177
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, featureName)
|
|
178
|
+
const aggregateArgs = { [faker.datatype.uuid()]: faker.lorem.sentence() }
|
|
179
|
+
instrument.abortHandler = jest.fn()
|
|
180
|
+
instrument.importAggregator(aggregateArgs)
|
|
181
|
+
|
|
182
|
+
const windowLoadCallback = jest.mocked(onWindowLoad).mock.calls[0][0]
|
|
183
|
+
await windowLoadCallback()
|
|
184
|
+
|
|
185
|
+
expect(onWindowLoad).toHaveBeenCalledWith(expect.any(Function), true)
|
|
186
|
+
expect(instrument.abortHandler).not.toHaveBeenCalled()
|
|
187
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('A problem occurred when starting up session manager'), expect.any(Error))
|
|
188
|
+
expect(lazyFeatureLoader).toHaveBeenCalled()
|
|
189
|
+
expect(mockAggregate).toHaveBeenCalled()
|
|
190
|
+
await expect(instrument.onAggregateImported).resolves.toBe(true)
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
test('no uncaught async exception is thrown when an import fails', async () => {
|
|
194
|
+
jest.mocked(lazyFeatureLoader).mockRejectedValue(new Error('ChunkLoadError')) // () => { throw new Error('ChunkLoadError: loading chunk xxx failed.') })
|
|
195
|
+
const mockOnError = jest.fn()
|
|
196
|
+
global.onerror = mockOnError
|
|
197
|
+
|
|
198
|
+
const instrument = new InstrumentBase(agentIdentifier, aggregator, featureName)
|
|
199
|
+
instrument.abortHandler = jest.fn()
|
|
200
|
+
instrument.importAggregator()
|
|
201
|
+
|
|
202
|
+
const windowLoadCallback = jest.mocked(onWindowLoad).mock.calls[0][0]
|
|
203
|
+
await windowLoadCallback()
|
|
204
|
+
|
|
205
|
+
expect(warn).toHaveBeenNthCalledWith(2, expect.stringContaining(`Downloading and initializing ${featureName} failed`), expect.any(Error))
|
|
206
|
+
expect(instrument.abortHandler).toHaveBeenCalled()
|
|
207
|
+
await expect(instrument.onAggregateImported).resolves.toBe(false)
|
|
208
|
+
expect(mockOnError).not.toHaveBeenCalled()
|
|
209
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker'
|
|
2
|
+
import { FEATURE_NAMES } from '../../loaders/features/features'
|
|
3
|
+
import { lazyFeatureLoader } from './lazy-feature-loader'
|
|
4
|
+
|
|
5
|
+
// Use enableAutomock to make it easier to mock all the things that get imported by the aggregators
|
|
6
|
+
jest.enableAutomock()
|
|
7
|
+
// Unmock the file under test and the constants file
|
|
8
|
+
jest.unmock('../../loaders/features/features')
|
|
9
|
+
jest.unmock('./lazy-feature-loader')
|
|
10
|
+
|
|
11
|
+
test.each(Object.keys(FEATURE_NAMES))('should import the aggregate for feature %s', async (key) => {
|
|
12
|
+
const featureName = FEATURE_NAMES[key]
|
|
13
|
+
const randomId = faker.datatype.uuid()
|
|
14
|
+
|
|
15
|
+
jest.setMock(`../${featureName}/aggregate`, {
|
|
16
|
+
id: randomId,
|
|
17
|
+
featureName
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const result = await lazyFeatureLoader(featureName, 'aggregate')
|
|
21
|
+
|
|
22
|
+
expect(result.id).toEqual(randomId)
|
|
23
|
+
expect(result.featureName).toEqual(featureName)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('should throw an error when the featureName is not supported', async () => {
|
|
27
|
+
const featureName = faker.datatype.uuid()
|
|
28
|
+
|
|
29
|
+
expect(() => lazyFeatureLoader(featureName, 'aggregate')).toThrow()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('should return undefined when the featurePart is not supported', async () => {
|
|
33
|
+
const featureName = faker.datatype.uuid()
|
|
34
|
+
const featurePart = faker.datatype.uuid()
|
|
35
|
+
|
|
36
|
+
expect(lazyFeatureLoader(featureName, featurePart)).toBeUndefined()
|
|
37
|
+
})
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export { Agent } from './loaders/agent'
|
|
2
2
|
export { BrowserAgent } from './loaders/browser-agent'
|
|
3
3
|
export { WorkerAgent } from './loaders/worker-agent'
|
|
4
|
-
|
|
5
|
-
/** IN-PROGRESS -- DOES NOT CURRENTLY WORK CORRECTLY */
|
|
6
|
-
// export { MicroAgent } from './loaders/micro-agent'
|
|
4
|
+
export { MicroAgent } from './loaders/micro-agent'
|
|
7
5
|
|
|
8
6
|
export { Ajax } from './features/ajax'
|
|
9
7
|
export { JSErrors } from './features/jserrors'
|
package/src/loaders/agent.js
CHANGED
|
@@ -12,6 +12,7 @@ import { generateRandomHexString } from '../common/ids/unique-id'
|
|
|
12
12
|
import { getConfiguration, getInfo, getLoaderConfig, getRuntime } from '../common/config/config'
|
|
13
13
|
import { warn } from '../common/util/console'
|
|
14
14
|
import { stringify } from '../common/util/stringify'
|
|
15
|
+
import { globalScope } from '../common/constants/runtime'
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* A flexible class that may be used to compose an agent from a select subset of feature modules. In applications
|
|
@@ -19,12 +20,18 @@ import { stringify } from '../common/util/stringify'
|
|
|
19
20
|
*/
|
|
20
21
|
export class Agent {
|
|
21
22
|
constructor (options, agentIdentifier = generateRandomHexString(16)) {
|
|
23
|
+
if (!globalScope) {
|
|
24
|
+
// We could not determine the runtime environment. Short-circuite the agent here
|
|
25
|
+
// to avoid possible exceptions later that may cause issues with customer's application.
|
|
26
|
+
warn('Failed to initial the agent. Could not determine the runtime environment.')
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
this.agentIdentifier = agentIdentifier
|
|
23
31
|
this.sharedAggregator = new Aggregator({ agentIdentifier: this.agentIdentifier })
|
|
24
32
|
this.features = {}
|
|
25
33
|
|
|
26
34
|
this.desiredFeatures = new Set(options.features || []) // expected to be a list of static Instrument/InstrumentBase classes, see "spa.js" for example
|
|
27
|
-
|
|
28
35
|
// For Now... ALL agents must make the rum call whether the page_view_event feature was enabled or not.
|
|
29
36
|
// NR1 creates an index on the rum call, and if not seen for a few days, will remove the browser app!
|
|
30
37
|
// Future work is being planned to evaluate removing this behavior from the backend, but for now we must ensure this call is made
|
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 {
|
|
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'
|
|
@@ -157,7 +157,7 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// theres no window.load event on non-browser scopes, lazy load immediately
|
|
160
|
-
if (
|
|
160
|
+
if (!isBrowserScope) lazyLoad()
|
|
161
161
|
// try to stay out of the way of the window.load event, lazy load once that has finished.
|
|
162
162
|
else onWindowLoad(() => lazyLoad(), true)
|
|
163
163
|
|
|
@@ -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) {
|
|
@@ -2,7 +2,7 @@ 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
4
|
import { activateFeatures, activatedFeatures } from '../../common/util/feature-flags'
|
|
5
|
-
import { isWorkerScope } from '../../common/
|
|
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
|
|
@@ -6,6 +6,8 @@ export function getFeatureDependencyNames (feature) {
|
|
|
6
6
|
return [FEATURE_NAMES.jserrors]
|
|
7
7
|
case FEATURE_NAMES.sessionTrace:
|
|
8
8
|
return [FEATURE_NAMES.ajax, FEATURE_NAMES.pageViewEvent]
|
|
9
|
+
case FEATURE_NAMES.sessionReplay:
|
|
10
|
+
return [FEATURE_NAMES.sessionTrace]
|
|
9
11
|
case FEATURE_NAMES.pageViewTiming:
|
|
10
12
|
return [FEATURE_NAMES.pageViewEvent] // this could change if we disconnect window load timings
|
|
11
13
|
default:
|
|
@@ -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,21 +9,18 @@ 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'
|
|
11
13
|
|
|
12
14
|
const nonAutoFeatures = [
|
|
13
15
|
FEATURE_NAMES.jserrors,
|
|
14
|
-
FEATURE_NAMES.pageAction
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
const autoFeatures = [
|
|
16
|
+
FEATURE_NAMES.pageAction,
|
|
18
17
|
FEATURE_NAMES.metrics
|
|
19
18
|
]
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
* A minimal agent class designed to
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* instrumentations at runtime, and to report desired data, events, and errors programatically.
|
|
21
|
+
* A minimal agent class designed to only respond to manual user input. As such, this class does not
|
|
22
|
+
* automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
|
|
23
|
+
* Out of the box, it can manually handle and report Page View, Page Action, and Error events.
|
|
26
24
|
*/
|
|
27
25
|
export class MicroAgent {
|
|
28
26
|
/**
|
|
@@ -51,28 +49,26 @@ export class MicroAgent {
|
|
|
51
49
|
start () {
|
|
52
50
|
try {
|
|
53
51
|
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
|
-
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
|
|
55
|
+
this.features.page_view_event = new PVE(this.agentIdentifier, this.sharedAggregator)
|
|
56
|
+
} catch (err) {
|
|
57
|
+
warn('Something prevented the agent from instrumenting.', err)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onWindowLoad(() => {
|
|
61
|
+
// these features do not import an "instrument" file, meaning they are only hooked up to the API.
|
|
62
|
+
nonAutoFeatures.forEach(f => {
|
|
63
|
+
if (enabledFeatures[f]) {
|
|
64
|
+
import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
|
|
65
|
+
return lazyFeatureLoader(f, 'aggregate')
|
|
66
|
+
}).then(({ Aggregate }) => {
|
|
67
|
+
this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator)
|
|
68
|
+
}).catch(err =>
|
|
69
|
+
warn('Something prevented the agent from being downloaded.', err))
|
|
70
|
+
}
|
|
71
|
+
})
|
|
76
72
|
})
|
|
77
73
|
gosNREUMInitializedAgents(this.agentIdentifier, this.features, 'features')
|
|
78
74
|
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;
|