@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
|
@@ -3,216 +3,237 @@
|
|
|
3
3
|
* @jest-environment-options {"html": "<html><head><script></script></head><body></body></html>", "url": "https://example.com/"}
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { faker } from '@faker-js/faker'
|
|
7
|
+
import * as runtimeModule from '../constants/runtime'
|
|
8
|
+
import * as submitData from './submit-data'
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
jest.
|
|
10
|
-
__esModule: true,
|
|
11
|
-
get isWorkerScope () {
|
|
12
|
-
return mockWorkerScope()
|
|
13
|
-
}
|
|
14
|
-
}))
|
|
10
|
+
jest.enableAutomock()
|
|
11
|
+
jest.unmock('./submit-data')
|
|
15
12
|
|
|
16
13
|
const url = 'https://example.com/api'
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
jest.
|
|
20
|
-
mockWorkerScope.mockReturnValue(false)
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
jest.clearAllMocks()
|
|
21
17
|
})
|
|
22
18
|
|
|
23
|
-
describe('
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
describe('getSubmitMethod', () => {
|
|
20
|
+
test('should use xhr for final harvest when isBrowserScope is false', () => {
|
|
21
|
+
jest.replaceProperty(runtimeModule, 'isBrowserScope', false)
|
|
22
|
+
jest.replaceProperty(runtimeModule, 'supportsSendBeacon', true)
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const result = submitData.jsonp({ url, jsonp })
|
|
31
|
-
|
|
32
|
-
expect(result).toBeInstanceOf(HTMLScriptElement)
|
|
33
|
-
expect(result.type).toBe('text/javascript')
|
|
34
|
-
expect(result.src).toBe(url + '&jsonp=' + jsonp)
|
|
24
|
+
expect(submitData.getSubmitMethod({ isFinalHarvest: true })).toEqual(submitData.xhr)
|
|
35
25
|
})
|
|
36
26
|
|
|
37
|
-
test('should
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const jsonp = 'callback'
|
|
41
|
-
|
|
42
|
-
global.importScripts = jest.fn()
|
|
43
|
-
|
|
44
|
-
submitData.jsonp({ url, jsonp })
|
|
45
|
-
|
|
46
|
-
expect(importScripts).toHaveBeenCalledWith(url + '&jsonp=' + jsonp)
|
|
27
|
+
test('should use xhr for final harvest when supportsSendBeacon is false', () => {
|
|
28
|
+
jest.replaceProperty(runtimeModule, 'isBrowserScope', true)
|
|
29
|
+
jest.replaceProperty(runtimeModule, 'supportsSendBeacon', false)
|
|
47
30
|
|
|
48
|
-
|
|
31
|
+
expect(submitData.getSubmitMethod({ isFinalHarvest: true })).toEqual(submitData.xhr)
|
|
49
32
|
})
|
|
50
33
|
|
|
51
|
-
test('should
|
|
52
|
-
|
|
34
|
+
test('should use beacon for final harvest when isBrowserScope and supportsSendBeacon is true', () => {
|
|
35
|
+
jest.replaceProperty(runtimeModule, 'isBrowserScope', true)
|
|
36
|
+
jest.replaceProperty(runtimeModule, 'supportsSendBeacon', true)
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
jest.spyOn(submitData, 'xhrGet').mockImplementation(jest.fn())
|
|
38
|
+
expect(submitData.getSubmitMethod({ isFinalHarvest: true })).toEqual(submitData.beacon)
|
|
39
|
+
})
|
|
57
40
|
|
|
58
|
-
|
|
41
|
+
test.each([
|
|
42
|
+
null, undefined, false
|
|
43
|
+
])('should use xhr when final harvest is %s', (isFinalHarvest) => {
|
|
44
|
+
jest.replaceProperty(runtimeModule, 'isBrowserScope', true)
|
|
45
|
+
jest.replaceProperty(runtimeModule, 'supportsSendBeacon', true)
|
|
59
46
|
|
|
60
|
-
expect(
|
|
61
|
-
expect(submitData.xhrGet).toHaveBeenCalledTimes(1)
|
|
47
|
+
expect(submitData.getSubmitMethod({ isFinalHarvest })).toEqual(submitData.xhr)
|
|
62
48
|
})
|
|
63
49
|
|
|
64
|
-
test('should
|
|
65
|
-
jest.
|
|
50
|
+
test('should use xhr when opts is undefined', () => {
|
|
51
|
+
jest.replaceProperty(runtimeModule, 'isBrowserScope', true)
|
|
52
|
+
jest.replaceProperty(runtimeModule, 'supportsSendBeacon', true)
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
expect(() => {
|
|
70
|
-
submitData.jsonp({ url, jsonp })
|
|
71
|
-
}).not.toThrow()
|
|
54
|
+
expect(submitData.getSubmitMethod()).toEqual(submitData.xhr)
|
|
72
55
|
})
|
|
73
56
|
})
|
|
74
57
|
|
|
75
|
-
describe('
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
58
|
+
describe('xhr', () => {
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
jest.spyOn(global, 'XMLHttpRequest').mockImplementation(function () {
|
|
61
|
+
this.prototype = XMLHttpRequest.prototype
|
|
62
|
+
this.open = jest.fn()
|
|
63
|
+
this.send = jest.fn()
|
|
64
|
+
this.setRequestHeader = jest.fn()
|
|
65
|
+
|
|
66
|
+
this._withCredentials = false
|
|
67
|
+
Object.defineProperty(this, 'withCredentials', {
|
|
68
|
+
get: jest.fn(() => this._withCredentials),
|
|
69
|
+
set: jest.fn((val) => this._withCredentials = val)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
85
72
|
})
|
|
86
73
|
|
|
87
|
-
test('should
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}).not.toThrow()
|
|
91
|
-
})
|
|
92
|
-
})
|
|
74
|
+
test('should make and send an xhr with default values', () => {
|
|
75
|
+
const result = submitData.xhr({ url })
|
|
76
|
+
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0]
|
|
93
77
|
|
|
94
|
-
describe('submitData.xhr', () => {
|
|
95
|
-
test('should return an XMLHttpRequest object', () => {
|
|
96
|
-
const result = submitData.xhrGet({ url })
|
|
97
78
|
expect(result).toBeInstanceOf(XMLHttpRequest)
|
|
79
|
+
expect(result.withCredentials).toBe(true)
|
|
80
|
+
expect(xhr.open).toHaveBeenCalledWith('POST', url, true)
|
|
81
|
+
expect(xhr.setRequestHeader).toHaveBeenCalledWith('content-type', 'text/plain')
|
|
82
|
+
expect(xhr.send).toHaveBeenCalledWith(null)
|
|
98
83
|
})
|
|
99
84
|
|
|
100
|
-
test('should
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
85
|
+
test('should send the body when provided', () => {
|
|
86
|
+
const body = faker.lorem.paragraph()
|
|
87
|
+
submitData.xhr({ url, body })
|
|
88
|
+
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0]
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
expect(() => {
|
|
108
|
-
submitData.xhr({ url: 'invalid url' })
|
|
109
|
-
}).not.toThrow()
|
|
90
|
+
expect(xhr.send).toHaveBeenCalledWith(body)
|
|
110
91
|
})
|
|
111
92
|
|
|
112
|
-
test('should
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
submitData.xhr({ url })
|
|
93
|
+
test('should set async to false', () => {
|
|
94
|
+
submitData.xhr({ url, sync: true })
|
|
95
|
+
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0]
|
|
116
96
|
|
|
117
|
-
expect(
|
|
97
|
+
expect(xhr.open).toHaveBeenCalledWith('POST', url, false)
|
|
118
98
|
})
|
|
119
99
|
|
|
120
|
-
test('should
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
submitData.xhr({ url, method: 'GET' })
|
|
100
|
+
test('should use the provided method', () => {
|
|
101
|
+
submitData.xhr({ url, method: 'HEAD' })
|
|
102
|
+
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0]
|
|
124
103
|
|
|
125
|
-
expect(
|
|
104
|
+
expect(xhr.open).toHaveBeenCalledWith('HEAD', url, true)
|
|
126
105
|
})
|
|
127
106
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
submitData.xhr({ url, sync: true })
|
|
107
|
+
test('should use the provided headers', () => {
|
|
108
|
+
const headers = [{ key: faker.lorem.word(), value: faker.datatype.uuid() }]
|
|
109
|
+
submitData.xhr({ url, headers })
|
|
110
|
+
const xhr = jest.mocked(global.XMLHttpRequest).mock.instances[0]
|
|
133
111
|
|
|
134
|
-
expect(
|
|
112
|
+
expect(xhr.setRequestHeader).not.toHaveBeenCalledWith('content-type', 'text/plain')
|
|
113
|
+
expect(xhr.setRequestHeader).toHaveBeenCalledWith(headers[0].key, headers[0].value)
|
|
135
114
|
})
|
|
136
115
|
|
|
137
|
-
test('should
|
|
138
|
-
|
|
116
|
+
test('should not throw an error if withCredentials is not supported', () => {
|
|
117
|
+
jest.spyOn(global, 'XMLHttpRequest').mockImplementation(function () {
|
|
118
|
+
this.prototype = XMLHttpRequest.prototype
|
|
119
|
+
this.open = jest.fn()
|
|
120
|
+
this.send = jest.fn()
|
|
121
|
+
this.setRequestHeader = jest.fn()
|
|
122
|
+
})
|
|
139
123
|
|
|
140
|
-
|
|
124
|
+
expect(() => submitData.xhr({ url })).not.toThrow()
|
|
125
|
+
})
|
|
141
126
|
|
|
142
|
-
|
|
127
|
+
test('should not throw an error if setRequestHeader throws an error', () => {
|
|
128
|
+
jest.spyOn(global, 'XMLHttpRequest').mockImplementation(function () {
|
|
129
|
+
this.prototype = XMLHttpRequest.prototype
|
|
130
|
+
this.open = jest.fn()
|
|
131
|
+
this.send = jest.fn()
|
|
132
|
+
this.setRequestHeader = jest.fn()
|
|
143
133
|
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
Object.defineProperty(this, 'withCredentials', {
|
|
135
|
+
get: jest.fn().mockImplementation(() => { throw new Error(faker.lorem.sentence()) }),
|
|
136
|
+
set: jest.fn().mockImplementation(() => { throw new Error(faker.lorem.sentence()) })
|
|
137
|
+
})
|
|
146
138
|
})
|
|
139
|
+
|
|
140
|
+
expect(() => submitData.xhr({ url })).not.toThrow()
|
|
147
141
|
})
|
|
142
|
+
})
|
|
148
143
|
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
describe('fetchKeepAlive', () => {
|
|
145
|
+
beforeEach(() => {
|
|
146
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve())
|
|
147
|
+
})
|
|
151
148
|
|
|
152
|
-
|
|
149
|
+
afterEach(() => {
|
|
150
|
+
delete global.fetch
|
|
151
|
+
})
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
test('should make a fetch with default values', () => {
|
|
154
|
+
submitData.fetchKeepAlive({ url })
|
|
155
155
|
|
|
156
|
-
expect(
|
|
156
|
+
expect(global.fetch).toHaveBeenCalledWith(url, {
|
|
157
|
+
method: 'POST',
|
|
158
|
+
body: null,
|
|
159
|
+
keepalive: true,
|
|
160
|
+
headers: [['content-type', 'text/plain']]
|
|
161
|
+
})
|
|
157
162
|
})
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
describe('submitData.img', () => {
|
|
161
|
-
test('should return an HTMLImageElement', () => {
|
|
162
|
-
const imageUrl = 'https://example.com/image.png'
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
test('should send the body when provided', () => {
|
|
165
|
+
const body = faker.lorem.paragraph()
|
|
166
|
+
submitData.fetchKeepAlive({ url, body })
|
|
165
167
|
|
|
166
|
-
expect(
|
|
168
|
+
expect(global.fetch).toHaveBeenCalledWith(url, {
|
|
169
|
+
method: 'POST',
|
|
170
|
+
body,
|
|
171
|
+
keepalive: true,
|
|
172
|
+
headers: [['content-type', 'text/plain']]
|
|
173
|
+
})
|
|
167
174
|
})
|
|
168
175
|
|
|
169
|
-
test('should
|
|
170
|
-
|
|
171
|
-
submitData.img({})
|
|
172
|
-
}).not.toThrow()
|
|
173
|
-
})
|
|
176
|
+
test('should use the provided method', () => {
|
|
177
|
+
submitData.fetchKeepAlive({ url, method: 'HEAD' })
|
|
174
178
|
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
expect(global.fetch).toHaveBeenCalledWith(url, {
|
|
180
|
+
method: 'HEAD',
|
|
181
|
+
body: null,
|
|
182
|
+
keepalive: true,
|
|
183
|
+
headers: [['content-type', 'text/plain']]
|
|
184
|
+
})
|
|
185
|
+
})
|
|
177
186
|
|
|
178
|
-
|
|
187
|
+
test('should use the provided headers', () => {
|
|
188
|
+
const headers = [{ key: faker.lorem.word(), value: faker.datatype.uuid() }]
|
|
189
|
+
submitData.fetchKeepAlive({ url, headers })
|
|
179
190
|
|
|
180
|
-
expect(
|
|
191
|
+
expect(global.fetch).toHaveBeenCalledWith(url, {
|
|
192
|
+
method: 'POST',
|
|
193
|
+
body: null,
|
|
194
|
+
keepalive: true,
|
|
195
|
+
headers: [[headers[0].key, headers[0].value]]
|
|
196
|
+
})
|
|
181
197
|
})
|
|
182
198
|
})
|
|
183
199
|
|
|
184
|
-
describe('
|
|
185
|
-
|
|
186
|
-
|
|
200
|
+
describe('beacon', () => {
|
|
201
|
+
afterEach(() => {
|
|
202
|
+
delete window.navigator.sendBeacon
|
|
203
|
+
})
|
|
187
204
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
205
|
+
test('should return true when beacon request succeeds', () => {
|
|
206
|
+
window.navigator.sendBeacon = jest.fn().mockReturnValue(true)
|
|
191
207
|
|
|
208
|
+
const body = faker.lorem.paragraph()
|
|
192
209
|
const result = submitData.beacon({ url, body })
|
|
193
210
|
|
|
194
211
|
expect(result).toBe(true)
|
|
212
|
+
expect(window.navigator.sendBeacon).toHaveBeenCalledWith(url, body)
|
|
195
213
|
})
|
|
196
214
|
|
|
197
|
-
test('should return false when beacon request
|
|
198
|
-
|
|
215
|
+
test('should return false when beacon request returns false', () => {
|
|
216
|
+
window.navigator.sendBeacon = jest.fn().mockReturnValue(false)
|
|
199
217
|
|
|
200
|
-
|
|
201
|
-
bind: jest.fn(() => () => { throw new Error('message') })
|
|
202
|
-
}
|
|
218
|
+
const result = submitData.beacon({ url })
|
|
203
219
|
|
|
204
|
-
|
|
220
|
+
expect(result).toBe(false)
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
test('should return false when beacon request throws an error', () => {
|
|
224
|
+
window.navigator.sendBeacon = jest.fn(() => { throw new Error(faker.lorem.sentence()) })
|
|
225
|
+
|
|
226
|
+
const result = submitData.beacon({ url })
|
|
205
227
|
|
|
206
228
|
expect(result).toBe(false)
|
|
207
229
|
})
|
|
208
230
|
|
|
209
|
-
test('should
|
|
210
|
-
|
|
231
|
+
test('should always bind window.navigator to the sendBeacon function', () => {
|
|
232
|
+
window.navigator.sendBeacon = jest.fn().mockReturnValue(true)
|
|
233
|
+
window.navigator.sendBeacon.bind = jest.fn(() => {})
|
|
211
234
|
|
|
212
|
-
|
|
235
|
+
submitData.beacon({ url })
|
|
213
236
|
|
|
214
|
-
expect(()
|
|
215
|
-
submitData.beacon({ url, body })
|
|
216
|
-
}).toThrow()
|
|
237
|
+
expect(window.navigator.sendBeacon.bind).toHaveBeenCalledWith(window.navigator)
|
|
217
238
|
})
|
|
218
239
|
})
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { ee as baseEE } from '../event-emitter/contextual-ee'
|
|
11
11
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
12
12
|
import { getOrSet } from '../util/get-or-set'
|
|
13
|
-
import { globalScope, isBrowserScope } from '../
|
|
13
|
+
import { globalScope, isBrowserScope } from '../constants/runtime'
|
|
14
14
|
|
|
15
15
|
const wrapped = {}
|
|
16
16
|
const XHR = XMLHttpRequest
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This module is used by: ajax, spa.
|
|
8
8
|
*/
|
|
9
9
|
import { ee as baseEE } from '../event-emitter/contextual-ee'
|
|
10
|
-
import { globalScope } from '../
|
|
10
|
+
import { globalScope } from '../constants/runtime'
|
|
11
11
|
import { flag } from './wrap-function'
|
|
12
12
|
|
|
13
13
|
var prefix = 'fetch-'
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { ee as globalEE } from '../event-emitter/contextual-ee'
|
|
10
10
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
11
|
-
import { isBrowserScope } from '../
|
|
11
|
+
import { isBrowserScope } from '../constants/runtime'
|
|
12
12
|
|
|
13
13
|
const wrapped = {}
|
|
14
14
|
const HISTORY_FNS = ['pushState', 'replaceState']
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { eventListenerOpts } from '../event-listener/event-listener-opts'
|
|
11
11
|
import { ee as baseEE } from '../event-emitter/contextual-ee'
|
|
12
12
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
13
|
-
import { isBrowserScope } from '../
|
|
13
|
+
import { isBrowserScope } from '../constants/runtime'
|
|
14
14
|
|
|
15
15
|
const wrapped = {}
|
|
16
16
|
const domInsertMethods = ['appendChild', 'insertBefore', 'replaceChild']
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { ee as baseEE } from '../event-emitter/contextual-ee'
|
|
11
11
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
12
12
|
import { originals } from '../config/config'
|
|
13
|
-
import { isBrowserScope } from '../
|
|
13
|
+
import { isBrowserScope } from '../constants/runtime'
|
|
14
14
|
|
|
15
15
|
const wrapped = {}
|
|
16
16
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { createWrapperWithEmitter as wrapFn, flag } from './wrap-function'
|
|
11
11
|
import { ee as baseEE, getOrSetContext } from '../event-emitter/contextual-ee'
|
|
12
12
|
import { originals } from '../config/config'
|
|
13
|
-
import { globalScope } from '../
|
|
13
|
+
import { globalScope } from '../constants/runtime'
|
|
14
14
|
|
|
15
15
|
const wrapped = {}
|
|
16
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker'
|
|
2
|
-
import { globalScope } from '../
|
|
2
|
+
import { globalScope } from '../constants/runtime'
|
|
3
3
|
import { originals } from '../config/config'
|
|
4
4
|
|
|
5
5
|
jest.mock('./wrap-function', () => ({
|
|
@@ -24,7 +24,7 @@ jest.mock('../config/config', () => ({
|
|
|
24
24
|
__esModule: true,
|
|
25
25
|
originals: {}
|
|
26
26
|
}))
|
|
27
|
-
jest.mock('../
|
|
27
|
+
jest.mock('../constants/runtime', () => ({
|
|
28
28
|
__esModule: true,
|
|
29
29
|
globalScope: {
|
|
30
30
|
NREUM: {}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @file Wraps `window.requestAnimationFrame` for instrumentation.
|
|
7
|
-
* This module is used by: jserror
|
|
7
|
+
* This module is used by: jserror.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { ee as baseEE } from '../event-emitter/contextual-ee'
|
|
11
11
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
12
|
-
import { isBrowserScope } from '../
|
|
12
|
+
import { isBrowserScope } from '../constants/runtime'
|
|
13
13
|
|
|
14
14
|
const wrapped = {}
|
|
15
15
|
const RAF_NAME = 'requestAnimationFrame'
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @file Wraps native timeout and interval methods for instrumentation.
|
|
7
|
-
* This module is used by: jserrors,
|
|
7
|
+
* This module is used by: jserrors, spa.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { ee as baseEE } from '../event-emitter/contextual-ee'
|
|
11
11
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
12
|
-
import { globalScope } from '../
|
|
12
|
+
import { globalScope } from '../constants/runtime'
|
|
13
13
|
|
|
14
14
|
const wrapped = {}
|
|
15
15
|
const SET_TIMEOUT = 'setTimeout'
|
|
@@ -12,7 +12,7 @@ import { ee as contextualEE } from '../event-emitter/contextual-ee'
|
|
|
12
12
|
import { eventListenerOpts } from '../event-listener/event-listener-opts'
|
|
13
13
|
import { createWrapperWithEmitter as wfn } from './wrap-function'
|
|
14
14
|
import { originals } from '../config/config'
|
|
15
|
-
import { globalScope } from '../
|
|
15
|
+
import { globalScope } from '../constants/runtime'
|
|
16
16
|
import { warn } from '../util/console'
|
|
17
17
|
|
|
18
18
|
const wrapped = {}
|
|
@@ -173,7 +173,7 @@ export class Aggregate extends AggregateBase {
|
|
|
173
173
|
|
|
174
174
|
function onEventsHarvestFinished (result) {
|
|
175
175
|
if (result.retry && sentAjaxEvents.length > 0 && allAjaxIsEnabled()) {
|
|
176
|
-
ajaxEvents
|
|
176
|
+
ajaxEvents.unshift(...sentAjaxEvents)
|
|
177
177
|
sentAjaxEvents = []
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { getConfiguration, getConfigurationValue, getLoaderConfig } from '../../../common/config/config'
|
|
6
6
|
import { generateSpanId, generateTraceId } from '../../../common/ids/unique-id'
|
|
7
7
|
import { parseUrl } from '../../../common/url/parse-url'
|
|
8
|
-
import { globalScope } from '../../../common/
|
|
8
|
+
import { globalScope } from '../../../common/constants/runtime'
|
|
9
9
|
import { stringify } from '../../../common/util/stringify'
|
|
10
10
|
|
|
11
11
|
export class DT {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { originals, getLoaderConfig, getRuntime } from '../../../common/config/config'
|
|
6
6
|
import { handle } from '../../../common/event-emitter/handle'
|
|
7
7
|
import { id } from '../../../common/ids/id'
|
|
8
|
-
import { ffVersion } from '../../../common/
|
|
8
|
+
import { ffVersion, globalScope } from '../../../common/constants/runtime'
|
|
9
9
|
import { dataSize } from '../../../common/util/data-size'
|
|
10
10
|
import { eventListenerOpts } from '../../../common/event-listener/event-listener-opts'
|
|
11
11
|
import { now } from '../../../common/timing/now'
|
|
@@ -16,7 +16,6 @@ import { responseSizeFromXhr } from './response-size'
|
|
|
16
16
|
import { InstrumentBase } from '../../utils/instrument-base'
|
|
17
17
|
import { FEATURE_NAME } from '../constants'
|
|
18
18
|
import { FEATURE_NAMES } from '../../../loaders/features/features'
|
|
19
|
-
import { globalScope } from '../../../common/util/global-scope'
|
|
20
19
|
|
|
21
20
|
var handlers = ['load', 'error', 'abort', 'timeout']
|
|
22
21
|
var handlersLen = handlers.length
|
|
@@ -4,7 +4,7 @@ import { browserErrorUtils } from '../../../../tools/testing-utils'
|
|
|
4
4
|
const globalScopeLocation = 'https://example.com/'
|
|
5
5
|
|
|
6
6
|
const mockGlobalScopeLocation = (url) => {
|
|
7
|
-
jest.doMock('../../../common/
|
|
7
|
+
jest.doMock('../../../common/constants/runtime', () => ({
|
|
8
8
|
initialLocation: url || globalScopeLocation
|
|
9
9
|
}))
|
|
10
10
|
}
|
|
@@ -15,7 +15,7 @@ import { handle } from '../../../common/event-emitter/handle'
|
|
|
15
15
|
import { mapOwn } from '../../../common/util/map-own'
|
|
16
16
|
import { getInfo, getConfigurationValue, getRuntime } from '../../../common/config/config'
|
|
17
17
|
import { now } from '../../../common/timing/now'
|
|
18
|
-
import { globalScope } from '../../../common/
|
|
18
|
+
import { globalScope } from '../../../common/constants/runtime'
|
|
19
19
|
|
|
20
20
|
import { FEATURE_NAME } from '../constants'
|
|
21
21
|
import { drain } from '../../../common/drain/drain'
|
|
@@ -32,6 +32,7 @@ export class Aggregate extends AggregateBase {
|
|
|
32
32
|
super(agentIdentifier, aggregator, FEATURE_NAME)
|
|
33
33
|
|
|
34
34
|
this.stackReported = {}
|
|
35
|
+
this.observedAt = {}
|
|
35
36
|
this.pageviewReported = {}
|
|
36
37
|
this.errorCache = {}
|
|
37
38
|
this.currentBody
|
|
@@ -92,7 +93,7 @@ export class Aggregate extends AggregateBase {
|
|
|
92
93
|
mapOwn(this.currentBody, (key, value) => {
|
|
93
94
|
for (var i = 0; i < value.length; i++) {
|
|
94
95
|
var bucket = value[i]
|
|
95
|
-
var name = this.getBucketName(bucket.params, bucket.custom)
|
|
96
|
+
var name = this.getBucketName(key, bucket.params, bucket.custom)
|
|
96
97
|
this.aggregator.merge(key, name, bucket.metrics, bucket.params, bucket.custom)
|
|
97
98
|
}
|
|
98
99
|
})
|
|
@@ -104,7 +105,11 @@ export class Aggregate extends AggregateBase {
|
|
|
104
105
|
return stringHashCode(`${params.exceptionClass}_${params.message}_${params.stack_trace || params.browser_stack_hash}`)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
getBucketName (params, customParams) {
|
|
108
|
+
getBucketName (objType, params, customParams) {
|
|
109
|
+
if (objType === 'xhr') {
|
|
110
|
+
return stringHashCode(stringify(params)) + ':' + stringHashCode(stringify(customParams))
|
|
111
|
+
}
|
|
112
|
+
|
|
108
113
|
return this.nameHash(params) + ':' + stringHashCode(stringify(customParams))
|
|
109
114
|
}
|
|
110
115
|
|
|
@@ -171,6 +176,7 @@ export class Aggregate extends AggregateBase {
|
|
|
171
176
|
if (!this.stackReported[bucketHash]) {
|
|
172
177
|
this.stackReported[bucketHash] = true
|
|
173
178
|
params.stack_trace = truncateSize(stackInfo.stackString)
|
|
179
|
+
this.observedAt[bucketHash] = agentRuntime.offset + time
|
|
174
180
|
} else {
|
|
175
181
|
params.browser_stack_hash = stringHashCode(stackInfo.stackString)
|
|
176
182
|
}
|
|
@@ -186,6 +192,9 @@ export class Aggregate extends AggregateBase {
|
|
|
186
192
|
this.pageviewReported[bucketHash] = true
|
|
187
193
|
}
|
|
188
194
|
|
|
195
|
+
if (agentRuntime?.session?.state?.sessionReplay) params.hasReplay = true
|
|
196
|
+
params.firstOccurrenceTimestamp = this.observedAt[bucketHash]
|
|
197
|
+
|
|
189
198
|
var type = internal ? 'ierr' : 'err'
|
|
190
199
|
var newMetrics = { time: time }
|
|
191
200
|
|