@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
|
@@ -10,7 +10,7 @@ import { getRules, validateRules } from '../../../common/util/obfuscate';
|
|
|
10
10
|
import { VERSION } from "../../../common/constants/env.npm";
|
|
11
11
|
import { onDOMContentLoaded } from '../../../common/window/load';
|
|
12
12
|
import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts';
|
|
13
|
-
import { isBrowserScope } from '../../../common/
|
|
13
|
+
import { isBrowserScope } from '../../../common/constants/runtime';
|
|
14
14
|
import { AggregateBase } from '../../utils/aggregate-base';
|
|
15
15
|
import { stringify } from '../../../common/util/stringify';
|
|
16
16
|
import { endpointMap } from './endpoint-map';
|
|
@@ -11,7 +11,7 @@ import { cleanURL } from '../../../common/url/clean-url';
|
|
|
11
11
|
import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config';
|
|
12
12
|
import { FEATURE_NAME } from '../constants';
|
|
13
13
|
import { drain } from '../../../common/drain/drain';
|
|
14
|
-
import { isBrowserScope } from '../../../common/
|
|
14
|
+
import { isBrowserScope } from '../../../common/constants/runtime';
|
|
15
15
|
import { AggregateBase } from '../../utils/aggregate-base';
|
|
16
16
|
export class Aggregate extends AggregateBase {
|
|
17
17
|
static featureName = FEATURE_NAME;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { handle } from '../../../common/event-emitter/handle';
|
|
2
2
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
3
|
-
import { isiOS } from '../../../common/
|
|
3
|
+
import { isiOS, globalScope, isBrowserScope } from '../../../common/constants/runtime';
|
|
4
4
|
import { onTTFB } from 'web-vitals';
|
|
5
5
|
import { addPT, addPN } from '../../../common/timing/nav-timing';
|
|
6
6
|
import { stringify } from '../../../common/util/stringify';
|
|
@@ -9,7 +9,6 @@ import { getConfigurationValue, getInfo, getRuntime } from '../../../common/conf
|
|
|
9
9
|
import { Harvest } from '../../../common/harvest/harvest';
|
|
10
10
|
import * as CONSTANTS from '../constants';
|
|
11
11
|
import { getActivatedFeaturesFlags } from './initialized-features';
|
|
12
|
-
import { globalScope, isBrowserScope } from '../../../common/util/global-scope';
|
|
13
12
|
import { drain } from '../../../common/drain/drain';
|
|
14
13
|
import { activateFeatures } from '../../../common/util/feature-flags';
|
|
15
14
|
import { warn } from '../../../common/util/console';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { handle } from '../../../common/event-emitter/handle';
|
|
2
|
-
import { isiOS } from '../../../common/
|
|
2
|
+
import { isiOS } from '../../../common/constants/runtime';
|
|
3
3
|
import { InstrumentBase } from '../../utils/instrument-base';
|
|
4
4
|
import * as CONSTANTS from '../constants';
|
|
5
5
|
import { FEATURE_NAMES } from '../../../loaders/features/features';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { onFCP, onFID, onLCP, onCLS, onINP } from 'web-vitals';
|
|
7
7
|
import { onFirstPaint } from '../first-paint';
|
|
8
8
|
import { onLongTask } from '../long-tasks';
|
|
9
|
-
import { iOS_below16 } from '../../../common/
|
|
9
|
+
import { iOS_below16 } from '../../../common/constants/runtime';
|
|
10
10
|
import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
|
|
11
11
|
import { mapOwn } from '../../../common/util/map-own';
|
|
12
12
|
import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
@@ -232,9 +232,7 @@ export class Aggregate extends AggregateBase {
|
|
|
232
232
|
}
|
|
233
233
|
onHarvestFinished(result) {
|
|
234
234
|
if (result.retry && this.timingsSent.length > 0) {
|
|
235
|
-
|
|
236
|
-
this.timings.push(this.timingsSent[i]);
|
|
237
|
-
}
|
|
235
|
+
this.timings.unshift(...this.timingsSent);
|
|
238
236
|
this.timingsSent = [];
|
|
239
237
|
}
|
|
240
238
|
}
|
|
@@ -9,7 +9,7 @@ import { windowAddEventListener } from '../../../common/event-listener/event-lis
|
|
|
9
9
|
import { now } from '../../../common/timing/now';
|
|
10
10
|
import { InstrumentBase } from '../../utils/instrument-base';
|
|
11
11
|
import { FEATURE_NAME } from '../constants';
|
|
12
|
-
import { isBrowserScope } from '../../../common/
|
|
12
|
+
import { isBrowserScope } from '../../../common/constants/runtime';
|
|
13
13
|
export class Instrument extends InstrumentBase {
|
|
14
14
|
static featureName = FEATURE_NAME;
|
|
15
15
|
constructor(agentIdentifier, aggregator) {
|
|
@@ -16,42 +16,41 @@ import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
|
|
|
16
16
|
import { FEATURE_NAME } from '../constants';
|
|
17
17
|
import { stringify } from '../../../common/util/stringify';
|
|
18
18
|
import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config';
|
|
19
|
-
import { SESSION_EVENTS } from '../../../common/session/session-entity';
|
|
19
|
+
import { SESSION_EVENTS, MODE } from '../../../common/session/session-entity';
|
|
20
20
|
import { AggregateBase } from '../../utils/aggregate-base';
|
|
21
|
+
import { sharedChannel } from '../../../common/constants/shared-channel';
|
|
21
22
|
|
|
22
23
|
// would be better to get this dynamically in some way
|
|
23
24
|
export const RRWEB_VERSION = '2.0.0-alpha.8';
|
|
25
|
+
export const AVG_COMPRESSION = 0.12;
|
|
24
26
|
let recorder, gzipper, u8;
|
|
25
27
|
|
|
26
|
-
/** The "mode" with which the session replay is recording */
|
|
27
|
-
const MODE = {
|
|
28
|
-
OFF: 0,
|
|
29
|
-
FULL: 1,
|
|
30
|
-
ERROR: 2
|
|
31
|
-
};
|
|
32
28
|
/** Vortex caps payload sizes at 1MB */
|
|
33
|
-
const MAX_PAYLOAD_SIZE = 1000000;
|
|
29
|
+
export const MAX_PAYLOAD_SIZE = 1000000;
|
|
34
30
|
/** Unloading caps around 64kb */
|
|
35
|
-
const IDEAL_PAYLOAD_SIZE = 64000;
|
|
31
|
+
export const IDEAL_PAYLOAD_SIZE = 64000;
|
|
36
32
|
/** Interval between forcing new full snapshots in "error" mode */
|
|
37
33
|
const CHECKOUT_MS = 30000;
|
|
38
34
|
export class Aggregate extends AggregateBase {
|
|
39
35
|
static featureName = FEATURE_NAME;
|
|
40
36
|
constructor(agentIdentifier, aggregator) {
|
|
41
37
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
42
|
-
|
|
43
38
|
/** Each page mutation or event will be stored (raw) in this array. This array will be cleared on each harvest */
|
|
44
39
|
this.events = [];
|
|
45
40
|
/** The interval to harvest at. This gets overridden if the size of the payload exceeds certain thresholds */
|
|
46
41
|
this.harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'session_replay.harvestTimeSeconds') || 60;
|
|
47
42
|
/** Set once the recorder has fully initialized after flag checks and sampling */
|
|
48
43
|
this.initialized = false;
|
|
49
|
-
/** Set once an error has been detected on the page. */
|
|
44
|
+
/** Set once an error has been detected on the page. Never unset */
|
|
50
45
|
this.errorNoticed = false;
|
|
51
46
|
/** The "mode" to record in. Defaults to "OFF" until flags and sampling are checked. See "MODE" constant. */
|
|
52
47
|
this.mode = MODE.OFF;
|
|
53
48
|
/** Set once the feature has been "aborted" to prevent other side-effects from continuing */
|
|
54
49
|
this.blocked = false;
|
|
50
|
+
/** True when actively recording, false when paused or stopped */
|
|
51
|
+
this.recording = false;
|
|
52
|
+
/** can shut off efforts to compress the data */
|
|
53
|
+
this.shouldCompress = true;
|
|
55
54
|
|
|
56
55
|
/** Payload metadata -- Should indicate that the payload being sent is the first of a session */
|
|
57
56
|
this.isFirstChunk = false;
|
|
@@ -65,62 +64,61 @@ export class Aggregate extends AggregateBase {
|
|
|
65
64
|
|
|
66
65
|
/** A value which increments with every new mutation node reported. Resets after a harvest is sent */
|
|
67
66
|
this.payloadBytesEstimation = 0;
|
|
67
|
+
const shouldSetup = getConfigurationValue(agentIdentifier, 'privacy.cookies_enabled') === true && getConfigurationValue(agentIdentifier, 'session_trace.enabled') === true;
|
|
68
68
|
|
|
69
69
|
/** The method to stop recording. This defaults to a noop, but is overwritten once the recording library is imported and initialized */
|
|
70
70
|
this.stopRecording = () => {/* no-op until set by rrweb initializer */};
|
|
71
|
+
if (shouldSetup) {
|
|
72
|
+
// The SessionEntity class can emit a message indicating the session was cleared and reset (expiry, inactivity). This feature must abort and never resume if that occurs.
|
|
73
|
+
this.ee.on(SESSION_EVENTS.RESET, () => {
|
|
74
|
+
this.abort();
|
|
75
|
+
});
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// The SessionEntity class can emit a message indicating the session was resumed (visibility change). This feature must start running again (if already running) if that occurs.
|
|
82
|
-
this.ee.on(SESSION_EVENTS.RESUME, () => {
|
|
83
|
-
if (!this.initialized || this.mode === MODE.OFF) return;
|
|
84
|
-
this.startRecording();
|
|
85
|
-
this.takeFullSnapshot();
|
|
86
|
-
});
|
|
77
|
+
// The SessionEntity class can emit a message indicating the session was paused (visibility change). This feature must stop recording if that occurs.
|
|
78
|
+
this.ee.on(SESSION_EVENTS.PAUSE, () => {
|
|
79
|
+
this.stopRecording();
|
|
80
|
+
});
|
|
81
|
+
// The SessionEntity class can emit a message indicating the session was resumed (visibility change). This feature must start running again (if already running) if that occurs.
|
|
82
|
+
this.ee.on(SESSION_EVENTS.RESUME, () => {
|
|
83
|
+
if (!this.initialized || this.mode === MODE.OFF) return;
|
|
84
|
+
this.startRecording();
|
|
85
|
+
});
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
// Bespoke logic for new endpoint. This will change as downstream dependencies become solidified.
|
|
88
|
+
this.scheduler = new HarvestScheduler('blob', {
|
|
89
|
+
onFinished: this.onHarvestFinished.bind(this),
|
|
90
|
+
retryDelay: this.harvestTimeSeconds,
|
|
91
|
+
getPayload: this.prepareHarvest.bind(this),
|
|
92
|
+
raw: true
|
|
93
|
+
}, this);
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.mode
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
// Wait for an error to be reported. This currently is wrapped around the "Error" feature. This is a feature-feature dependency.
|
|
96
|
+
// This was to ensure that all errors, including those on the page before load and those handled with "noticeError" are accounted for. Needs evalulation
|
|
97
|
+
registerHandler('errorAgg', e => {
|
|
98
|
+
this.hasError = true;
|
|
99
|
+
this.errorNoticed = true;
|
|
100
|
+
// run once
|
|
101
|
+
if (this.mode === MODE.ERROR) {
|
|
102
|
+
this.mode = MODE.FULL;
|
|
103
|
+
// if the error was noticed AFTER the recorder was already imported....
|
|
104
|
+
if (recorder && this.initialized) {
|
|
105
|
+
this.stopRecording();
|
|
106
|
+
this.startRecording();
|
|
107
|
+
this.scheduler.startTimer(this.harvestTimeSeconds);
|
|
108
|
+
const {
|
|
109
|
+
session
|
|
110
|
+
} = getRuntime(this.agentIdentifier);
|
|
111
|
+
session.state.sessionReplay = this.mode;
|
|
112
|
+
}
|
|
112
113
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
114
|
+
}, this.featureName, this.ee);
|
|
115
|
+
this.waitForFlags(['sr']).then(_ref => {
|
|
116
|
+
let [flagOn] = _ref;
|
|
117
|
+
return this.initializeRecording(flagOn, Math.random() < getConfigurationValue(this.agentIdentifier, 'session_replay.errorSampleRate'), Math.random() < getConfigurationValue(this.agentIdentifier, 'session_replay.sampleRate'));
|
|
118
|
+
}).then(() => sharedChannel.onReplayReady(this.mode)); // notify watchers that replay started with the mode
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let [{
|
|
119
|
-
value
|
|
120
|
-
}] = _ref;
|
|
121
|
-
this.initializeRecording(value, Math.random() < getConfigurationValue(this.agentIdentifier, 'session_replay.errorSampleRate'), Math.random() < getConfigurationValue(this.agentIdentifier, 'session_replay.sampleRate'));
|
|
122
|
-
});
|
|
123
|
-
drain(this.agentIdentifier, this.featureName);
|
|
120
|
+
drain(this.agentIdentifier, this.featureName);
|
|
121
|
+
}
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
/**
|
|
@@ -153,6 +151,11 @@ export class Aggregate extends AggregateBase {
|
|
|
153
151
|
else return;
|
|
154
152
|
}
|
|
155
153
|
|
|
154
|
+
// If an error was noticed before the mode could be set (like in the early lifecycle of the page), immediately set to FULL mode
|
|
155
|
+
if (this.mode === MODE.ERROR && this.errorNoticed) {
|
|
156
|
+
this.mode = MODE.FULL;
|
|
157
|
+
}
|
|
158
|
+
|
|
156
159
|
// FULL mode records AND reports from the beginning, while ERROR mode only records (but does not report).
|
|
157
160
|
// ERROR mode will do this until an error is thrown, and then switch into FULL mode.
|
|
158
161
|
// If an error happened in ERROR mode before we've gotten to this stage, it will have already set the mode to FULL
|
|
@@ -160,33 +163,35 @@ export class Aggregate extends AggregateBase {
|
|
|
160
163
|
// We only report (harvest) in FULL mode
|
|
161
164
|
this.scheduler.startTimer(this.harvestTimeSeconds);
|
|
162
165
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.
|
|
166
|
+
try {
|
|
167
|
+
recorder = (await import( /* webpackChunkName: "recorder" */'rrweb')).record;
|
|
168
|
+
} catch (err) {
|
|
169
|
+
return this.abort();
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const {
|
|
173
|
+
gzipSync,
|
|
174
|
+
strToU8
|
|
175
|
+
} = await import( /* webpackChunkName: "compressor" */'fflate');
|
|
176
|
+
gzipper = gzipSync;
|
|
177
|
+
u8 = strToU8;
|
|
178
|
+
} catch (err) {
|
|
179
|
+
// compressor failed to load, but we can still record without compression as a last ditch effort
|
|
180
|
+
this.shouldCompress = false;
|
|
167
181
|
}
|
|
168
|
-
// We record in FULL or ERROR mode
|
|
169
|
-
|
|
170
|
-
recorder = (await import( /* webpackChunkName: "recorder" */'rrweb')).record;
|
|
171
182
|
this.startRecording();
|
|
172
|
-
const {
|
|
173
|
-
gzipSync,
|
|
174
|
-
strToU8
|
|
175
|
-
} = await import( /* webpackChunkName: "compressor" */'fflate');
|
|
176
|
-
gzipper = gzipSync;
|
|
177
|
-
u8 = strToU8;
|
|
178
183
|
this.isFirstChunk = !!session.isNew;
|
|
179
184
|
session.state.sessionReplay = this.mode;
|
|
180
185
|
}
|
|
181
|
-
prepareHarvest(
|
|
186
|
+
prepareHarvest() {
|
|
182
187
|
if (this.events.length === 0) return;
|
|
183
188
|
const payload = this.getHarvestContents();
|
|
184
|
-
|
|
189
|
+
if (this.shouldCompress) {
|
|
185
190
|
payload.body = gzipper(u8(stringify(payload.body)));
|
|
186
191
|
this.scheduler.opts.gzip = true;
|
|
187
|
-
}
|
|
188
|
-
// failed to gzip
|
|
192
|
+
} else {
|
|
189
193
|
this.scheduler.opts.gzip = false;
|
|
194
|
+
delete payload.qs.content_encoding;
|
|
190
195
|
}
|
|
191
196
|
// TODO -- Gracefully handle the buffer for retries.
|
|
192
197
|
this.clearBuffer();
|
|
@@ -253,7 +258,7 @@ export class Aggregate extends AggregateBase {
|
|
|
253
258
|
this.hasSnapshot = true;
|
|
254
259
|
// set up rrweb configurations for maximum privacy --
|
|
255
260
|
// https://newrelic.atlassian.net/wiki/spaces/O11Y/pages/2792293280/2023+02+28+Browser+-+Session+Replay#Configuration-options
|
|
256
|
-
|
|
261
|
+
const stop = recorder({
|
|
257
262
|
emit: this.store.bind(this),
|
|
258
263
|
blockClass,
|
|
259
264
|
ignoreClass,
|
|
@@ -266,6 +271,11 @@ export class Aggregate extends AggregateBase {
|
|
|
266
271
|
checkoutEveryNms: CHECKOUT_MS
|
|
267
272
|
})
|
|
268
273
|
});
|
|
274
|
+
this.recording = true;
|
|
275
|
+
this.stopRecording = () => {
|
|
276
|
+
this.recording = false;
|
|
277
|
+
stop();
|
|
278
|
+
};
|
|
269
279
|
}
|
|
270
280
|
|
|
271
281
|
/** Store a payload in the buffer (this.events). This should be the callback to the recording lib noticing a mutation */
|
|
@@ -276,6 +286,7 @@ export class Aggregate extends AggregateBase {
|
|
|
276
286
|
const payloadSize = this.getPayloadSize(eventBytes);
|
|
277
287
|
// Vortex will block payloads at a certain size, we might as well not send.
|
|
278
288
|
if (payloadSize > MAX_PAYLOAD_SIZE) {
|
|
289
|
+
this.clearBuffer();
|
|
279
290
|
return this.abort();
|
|
280
291
|
}
|
|
281
292
|
// Checkout events are flags by the recording lib that indicate a fullsnapshot was taken every n ms. These are important
|
|
@@ -313,7 +324,9 @@ export class Aggregate extends AggregateBase {
|
|
|
313
324
|
/** Abort the feature, once aborted it will not resume */
|
|
314
325
|
abort() {
|
|
315
326
|
this.blocked = true;
|
|
327
|
+
this.mode = MODE.OFF;
|
|
316
328
|
this.stopRecording();
|
|
329
|
+
this.ee.emit('REPLAY_ABORTED');
|
|
317
330
|
const {
|
|
318
331
|
session
|
|
319
332
|
} = getRuntime(this.agentIdentifier);
|
|
@@ -325,6 +338,7 @@ export class Aggregate extends AggregateBase {
|
|
|
325
338
|
* https://staging.onenr.io/037jbJWxbjy
|
|
326
339
|
* */
|
|
327
340
|
estimateCompression(data) {
|
|
328
|
-
return data *
|
|
341
|
+
if (this.shouldCompress) return data * AVG_COMPRESSION;
|
|
342
|
+
return data;
|
|
329
343
|
}
|
|
330
344
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getConfigurationValue } from '../../common/config/config';
|
|
2
|
+
import { MODE } from '../../common/session/session-entity';
|
|
3
|
+
import { gosNREUM } from '../../common/window/nreum';
|
|
4
|
+
import { sharedChannel } from '../../common/constants/shared-channel';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Figure out if the Replay feature is running (what mode it's in).
|
|
8
|
+
* IMPORTANT: Session tracking is assumed to be ON; if applicable, check init's privacy.cookies_enabled setting before using this fn!
|
|
9
|
+
* CRITICAL: This fn must be called prior to ALL features aggregate draining. If not, it will never resolve.
|
|
10
|
+
* @param {String} agentId
|
|
11
|
+
* @returns Promise that resolves to one of the values in MODE enum
|
|
12
|
+
*/
|
|
13
|
+
export async function getSessionReplayMode(agentId) {
|
|
14
|
+
try {
|
|
15
|
+
const newrelic = gosNREUM();
|
|
16
|
+
// Should be enabled by configuration and using an agent build that includes it (via checking that the instrument class was initialized).
|
|
17
|
+
if (getConfigurationValue(agentId, 'session_replay.enabled') && typeof newrelic.initializedAgents[agentId].features.session_replay === 'object') {
|
|
18
|
+
const srInitialized = await newrelic.initializedAgents[agentId].features.session_replay.onAggregateImported;
|
|
19
|
+
if (srInitialized) return await sharedChannel.sessionReplayInitialized; // wait for replay to determine which mode it's after running its sampling logic
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {/* exception ==> off */}
|
|
22
|
+
return MODE.OFF; // at any step of the way s.t. SR cannot be on by implication or is explicitly off
|
|
23
|
+
}
|