@newrelic/browser-agent 1.235.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 +41 -1
- 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/event-listener/event-listener-opts.js +3 -3
- package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
- package/dist/cjs/common/harvest/harvest.js +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 +2 -2
- package/dist/cjs/common/timer/interaction-timer.js +2 -2
- package/dist/cjs/common/unload/eol.js +10 -11
- package/dist/cjs/common/url/canonicalize-url.js +2 -2
- package/dist/cjs/common/url/parse-url.js +3 -3
- package/dist/cjs/common/url/protocol.js +2 -2
- package/dist/cjs/common/util/submit-data.js +58 -76
- 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 +2 -2
- package/dist/cjs/common/wrap/wrap-timer.js +4 -4
- package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
- package/dist/cjs/features/ajax/aggregate/index.js +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 +7 -4
- package/dist/cjs/features/jserrors/instrument/index.js +4 -4
- 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/replay-mode.js +2 -2
- package/dist/cjs/features/session_trace/instrument/index.js +2 -2
- package/dist/cjs/features/spa/aggregate/index.js +1 -1
- package/dist/cjs/features/spa/instrument/index.js +2 -2
- package/dist/cjs/features/utils/instrument-base.js +6 -7
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/loaders/agent.js +7 -0
- 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/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/event-listener/event-listener-opts.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
- package/dist/esm/common/harvest/harvest.js +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 +1 -1
- package/dist/esm/common/timer/interaction-timer.js +1 -1
- package/dist/esm/common/unload/eol.js +1 -2
- package/dist/esm/common/url/canonicalize-url.js +1 -1
- package/dist/esm/common/url/parse-url.js +1 -1
- package/dist/esm/common/url/protocol.js +1 -1
- package/dist/esm/common/util/submit-data.js +55 -73
- 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 +1 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +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 +6 -3
- package/dist/esm/features/jserrors/instrument/index.js +1 -1
- 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/replay-mode.js +2 -2
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +1 -1
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +4 -5
- package/dist/esm/index.js +1 -4
- package/dist/esm/loaders/agent.js +7 -0
- package/dist/esm/loaders/api/api.js +1 -1
- package/dist/esm/loaders/api/apiAsync.js +3 -3
- package/dist/esm/loaders/configure/configure.js +1 -1
- 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/harvest/harvest-scheduler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +49 -38
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/harvest/types.d.ts +100 -0
- package/dist/types/common/harvest/types.d.ts.map +1 -0
- package/dist/types/common/unload/eol.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 +1 -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/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/micro-agent.d.ts +3 -4
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/common/config/__mocks__/config.js +11 -0
- package/src/common/config/state/init.js +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/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 +21 -20
- package/src/common/harvest/harvest-scheduler.test.js +496 -0
- package/src/common/harvest/harvest.js +147 -130
- package/src/common/harvest/harvest.test.js +818 -0
- package/src/common/harvest/types.js +47 -0
- package/src/common/ids/id.js +1 -1
- package/src/common/ids/unique-id.js +1 -1
- package/src/common/session/__mocks__/session-entity.js +25 -0
- package/src/common/session/session-entity.component-test.js +1 -1
- package/src/common/session/session-entity.js +1 -1
- package/src/common/timer/interaction-timer.js +1 -1
- package/src/common/timing/__mocks__/now.js +1 -0
- package/src/common/unload/__mocks__/eol.js +1 -0
- package/src/common/unload/eol.js +1 -2
- package/src/common/url/__mocks__/clean-url.js +1 -0
- package/src/common/url/__mocks__/encode.js +7 -0
- package/src/common/url/__mocks__/location.js +1 -0
- package/src/common/url/canonicalize-url.js +1 -1
- package/src/common/url/canonicalize-url.test.js +2 -2
- package/src/common/url/parse-url.js +1 -1
- package/src/common/url/parse-url.test.js +3 -3
- package/src/common/url/protocol.js +1 -1
- package/src/common/util/__mocks__/obfuscate.js +10 -0
- package/src/common/util/__mocks__/stringify.js +1 -0
- package/src/common/util/__mocks__/submit-data.js +6 -0
- package/src/common/util/__mocks__/traverse.js +1 -0
- package/src/common/util/submit-data.js +39 -53
- package/src/common/util/submit-data.test.js +81 -68
- 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 +1 -1
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/index.js +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 +7 -3
- package/src/features/jserrors/instrument/index.js +1 -1
- 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/replay-mode.js +2 -2
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +1 -1
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/agent-session.test.js +2 -2
- package/src/features/utils/instrument-base.js +5 -5
- package/src/features/utils/instrument-base.test.js +22 -3
- package/src/index.js +1 -3
- package/src/loaders/agent.js +8 -0
- package/src/loaders/api/api.js +1 -1
- package/src/loaders/api/apiAsync.js +3 -3
- package/src/loaders/configure/configure.js +1 -1
- 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.component-test.js +0 -39
- package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
- package/dist/cjs/common/ids/id.test.js +0 -85
- package/dist/cjs/common/ids/unique-id.test.js +0 -49
- package/dist/cjs/common/session/session-entity.component-test.js +0 -497
- package/dist/cjs/common/storage/local-storage.test.js +0 -14
- package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
- package/dist/cjs/common/timer/timer.test.js +0 -105
- package/dist/cjs/common/timing/nav-timing.test.js +0 -192
- package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
- package/dist/cjs/common/url/clean-url.test.js +0 -9
- package/dist/cjs/common/url/encode.component-test.js +0 -74
- package/dist/cjs/common/url/location.test.js +0 -13
- package/dist/cjs/common/url/parse-url.test.js +0 -111
- package/dist/cjs/common/url/protocol.component-test.js +0 -15
- package/dist/cjs/common/util/console.test.js +0 -30
- package/dist/cjs/common/util/data-size.test.js +0 -64
- package/dist/cjs/common/util/feature-flags.test.js +0 -84
- package/dist/cjs/common/util/get-or-set.test.js +0 -47
- package/dist/cjs/common/util/global-scope.js +0 -27
- package/dist/cjs/common/util/global-scope.test.js +0 -72
- package/dist/cjs/common/util/invoke.test.js +0 -49
- package/dist/cjs/common/util/map-own.test.js +0 -49
- package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
- package/dist/cjs/common/util/stringify.test.js +0 -48
- package/dist/cjs/common/util/submit-data.test.js +0 -245
- package/dist/cjs/common/util/traverse.test.js +0 -44
- package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
- package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
- package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
- package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
- package/dist/cjs/features/utils/agent-session.test.js +0 -211
- package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
- package/dist/cjs/features/utils/feature-base.test.js +0 -42
- package/dist/cjs/features/utils/handler-cache.test.js +0 -53
- package/dist/cjs/features/utils/instrument-base.test.js +0 -179
- package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
- package/dist/esm/common/browser-version/firefox-version.js +0 -10
- package/dist/esm/common/browser-version/ios-version.js +0 -11
- package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
- package/dist/esm/common/event-emitter/handle.test.js +0 -54
- package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
- package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
- package/dist/esm/common/harvest/harvest.component-test.js +0 -222
- package/dist/esm/common/ids/id.test.js +0 -81
- package/dist/esm/common/ids/unique-id.test.js +0 -44
- package/dist/esm/common/session/session-entity.component-test.js +0 -495
- package/dist/esm/common/storage/local-storage.test.js +0 -12
- package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
- package/dist/esm/common/timer/timer.test.js +0 -103
- package/dist/esm/common/timing/nav-timing.test.js +0 -190
- package/dist/esm/common/url/canonicalize-url.test.js +0 -34
- package/dist/esm/common/url/clean-url.test.js +0 -7
- package/dist/esm/common/url/encode.component-test.js +0 -70
- package/dist/esm/common/url/location.test.js +0 -11
- package/dist/esm/common/url/parse-url.test.js +0 -107
- package/dist/esm/common/url/protocol.component-test.js +0 -13
- package/dist/esm/common/util/console.test.js +0 -28
- package/dist/esm/common/util/data-size.test.js +0 -60
- package/dist/esm/common/util/feature-flags.test.js +0 -80
- package/dist/esm/common/util/get-or-set.test.js +0 -45
- package/dist/esm/common/util/global-scope.js +0 -17
- package/dist/esm/common/util/global-scope.test.js +0 -70
- package/dist/esm/common/util/invoke.test.js +0 -47
- package/dist/esm/common/util/map-own.test.js +0 -47
- package/dist/esm/common/util/obfuscate.component-test.js +0 -125
- package/dist/esm/common/util/stringify.test.js +0 -46
- package/dist/esm/common/util/submit-data.test.js +0 -241
- package/dist/esm/common/util/traverse.test.js +0 -42
- package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
- package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
- package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
- package/dist/esm/features/utils/agent-session.test.js +0 -207
- package/dist/esm/features/utils/aggregate-base.test.js +0 -108
- package/dist/esm/features/utils/feature-base.test.js +0 -40
- package/dist/esm/features/utils/handler-cache.test.js +0 -51
- package/dist/esm/features/utils/instrument-base.test.js +0 -175
- package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
- package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
- package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
- package/dist/types/common/browser-version/ios-version.d.ts +0 -3
- package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
- package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
- package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
- package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
- package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
- package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
- package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
- package/dist/types/common/url/encode.component-test.d.ts +0 -2
- package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
- package/dist/types/common/url/protocol.component-test.d.ts +0 -2
- package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
- package/dist/types/common/util/global-scope.d.ts +0 -5
- package/dist/types/common/util/global-scope.d.ts.map +0 -1
- package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
- package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
- package/src/common/browser-version/firefox-version.js +0 -10
- package/src/common/browser-version/ios-version.js +0 -11
- package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
- package/src/common/harvest/harvest.component-test.js +0 -169
- package/src/common/util/global-scope.js +0 -23
- package/src/common/util/global-scope.test.js +0 -87
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/browser-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.236.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
|
|
6
6
|
"description": "Tests for the New Relic JavaScript agent",
|
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
"require": "./dist/cjs/loaders/browser-agent.js",
|
|
38
38
|
"default": "./dist/esm/loaders/browser-agent.js"
|
|
39
39
|
},
|
|
40
|
+
"./loaders/micro-agent": {
|
|
41
|
+
"types": "./dist/types/loaders/micro-agent.d.ts",
|
|
42
|
+
"require": "./dist/cjs/loaders/micro-agent.js",
|
|
43
|
+
"default": "./dist/esm/loaders/micro-agent.js"
|
|
44
|
+
},
|
|
40
45
|
"./loaders/worker-agent": {
|
|
41
46
|
"types": "./dist/types/loaders/worker-agent.d.ts",
|
|
42
47
|
"require": "./dist/cjs/loaders/worker-agent.js",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const isConfigured = jest.fn()
|
|
2
|
+
export const getInfo = jest.fn()
|
|
3
|
+
export const setInfo = jest.fn()
|
|
4
|
+
export const getConfiguration = jest.fn()
|
|
5
|
+
export const getConfigurationValue = jest.fn()
|
|
6
|
+
export const setConfiguration = jest.fn()
|
|
7
|
+
export const getLoaderConfig = jest.fn()
|
|
8
|
+
export const setLoaderConfig = jest.fn()
|
|
9
|
+
export const originals = {}
|
|
10
|
+
export const getRuntime = jest.fn()
|
|
11
|
+
export const setRuntime = jest.fn()
|
|
@@ -31,6 +31,7 @@ const model = () => {
|
|
|
31
31
|
page_view_event: { enabled: true },
|
|
32
32
|
page_view_timing: { enabled: true, harvestTimeSeconds: 30, long_task: false },
|
|
33
33
|
session_trace: { enabled: true, harvestTimeSeconds: 10 },
|
|
34
|
+
harvest: { tooManyRequestsDelay: 60 },
|
|
34
35
|
session_replay: {
|
|
35
36
|
// feature settings
|
|
36
37
|
enabled: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getModeledObject } from './configurable'
|
|
2
2
|
import { gosNREUMInitializedAgents } from '../../window/nreum'
|
|
3
|
-
import { globalScope } from '../../
|
|
3
|
+
import { globalScope } from '../../constants/runtime'
|
|
4
4
|
import { BUILD_ENV, DIST_METHOD, VERSION } from '../../constants/env'
|
|
5
5
|
|
|
6
6
|
const model = {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const isBrowserScope = true
|
|
2
|
+
export const isWorkerScope = false
|
|
3
|
+
export const globalScope = window
|
|
4
|
+
export const initialLocation = '' + globalScope?.location
|
|
5
|
+
export const isiOS = false
|
|
6
|
+
export const iOS_below16 = false
|
|
7
|
+
export const ffVersion = 0
|
|
8
|
+
export const supportsSendBeacon = true
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Contains constants about the environment the agent is running
|
|
3
|
+
* within. These values are derived at the time the agent is first loaded.
|
|
4
|
+
* @copyright 2023 New Relic Corporation. All rights reserved.
|
|
5
|
+
* @license Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Indicates if the agent is running within a normal browser window context.
|
|
10
|
+
*/
|
|
11
|
+
export const isBrowserScope =
|
|
12
|
+
typeof window !== 'undefined' &&
|
|
13
|
+
!!window.document
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Indicates if the agent is running within a worker context.
|
|
17
|
+
*/
|
|
18
|
+
export const isWorkerScope =
|
|
19
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
20
|
+
(
|
|
21
|
+
(
|
|
22
|
+
typeof self !== 'undefined' &&
|
|
23
|
+
self instanceof WorkerGlobalScope &&
|
|
24
|
+
self.navigator instanceof WorkerNavigator
|
|
25
|
+
) ||
|
|
26
|
+
(
|
|
27
|
+
(
|
|
28
|
+
typeof globalThis !== 'undefined' &&
|
|
29
|
+
globalThis instanceof WorkerGlobalScope &&
|
|
30
|
+
globalThis.navigator instanceof WorkerNavigator
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export const globalScope = isBrowserScope
|
|
36
|
+
? window
|
|
37
|
+
: typeof WorkerGlobalScope !== 'undefined' && ((
|
|
38
|
+
typeof self !== 'undefined' &&
|
|
39
|
+
self instanceof WorkerGlobalScope &&
|
|
40
|
+
self
|
|
41
|
+
) || (
|
|
42
|
+
typeof globalThis !== 'undefined' &&
|
|
43
|
+
globalThis instanceof WorkerGlobalScope &&
|
|
44
|
+
globalThis
|
|
45
|
+
))
|
|
46
|
+
|
|
47
|
+
export const initialLocation = '' + globalScope?.location
|
|
48
|
+
|
|
49
|
+
export const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent)
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Shared Web Workers introduced in iOS 16.0+ and n/a in 15.6-
|
|
53
|
+
*
|
|
54
|
+
* It was discovered in Safari 14 (https://bugs.webkit.org/show_bug.cgi?id=225305) that the buffered flag in PerformanceObserver
|
|
55
|
+
* did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
|
|
56
|
+
* This was fixed in v16+.
|
|
57
|
+
*/
|
|
58
|
+
export const iOS_below16 = (isiOS && typeof SharedWorker === 'undefined')
|
|
59
|
+
|
|
60
|
+
export const ffVersion = (() => {
|
|
61
|
+
const match = navigator.userAgent.match(/Firefox[/\s](\d+\.\d+)/)
|
|
62
|
+
if (Array.isArray(match) && match.length >= 2) {
|
|
63
|
+
return +match[1]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return 0
|
|
67
|
+
})()
|
|
68
|
+
|
|
69
|
+
export const isIE = Boolean(isBrowserScope && window.document.documentMode) // deprecated property that only works in IE
|
|
70
|
+
|
|
71
|
+
export const supportsSendBeacon = !!navigator.sendBeacon
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime module exports variables whose values are set at the time of import and
|
|
3
|
+
* can depend on the environment the agent is running within. To make testing this module
|
|
4
|
+
* easier, use async import to import the module and only use the node jest environment so
|
|
5
|
+
* we can more easily define environment variables.
|
|
6
|
+
* @jest-environment node
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { faker } from '@faker-js/faker'
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// We assume every runtime has a global navigator variable
|
|
13
|
+
global.navigator = {
|
|
14
|
+
userAgent: faker.lorem.sentence()
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
delete global.navigator
|
|
20
|
+
jest.resetModules()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('should indicate agent is running in a browser scope', async () => {
|
|
24
|
+
const mockedWindow = global.window = {
|
|
25
|
+
[faker.datatype.uuid()]: faker.lorem.sentence,
|
|
26
|
+
document: {
|
|
27
|
+
[faker.datatype.uuid()]: faker.lorem.sentence
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const runtime = await import('./runtime')
|
|
32
|
+
|
|
33
|
+
delete global.window
|
|
34
|
+
|
|
35
|
+
expect(runtime.isBrowserScope).toEqual(true)
|
|
36
|
+
expect(runtime.isWorkerScope).toEqual(false)
|
|
37
|
+
expect(runtime.globalScope).toEqual(mockedWindow)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('should indicate agent is running in a worker scope using global self variable', async () => {
|
|
41
|
+
global.WorkerGlobalScope = class WorkerGlobalScope {}
|
|
42
|
+
global.WorkerNavigator = class WorkerNavigator {}
|
|
43
|
+
const mockedGlobalSelf = global.self = new global.WorkerGlobalScope()
|
|
44
|
+
mockedGlobalSelf.navigator = new global.WorkerNavigator()
|
|
45
|
+
|
|
46
|
+
const runtime = await import('./runtime')
|
|
47
|
+
|
|
48
|
+
delete global.WorkerGlobalScope
|
|
49
|
+
delete global.WorkerNavigator
|
|
50
|
+
delete global.self
|
|
51
|
+
|
|
52
|
+
expect(runtime.isBrowserScope).toEqual(false)
|
|
53
|
+
expect(runtime.isWorkerScope).toEqual(true)
|
|
54
|
+
expect(runtime.globalScope).toEqual(mockedGlobalSelf)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('should indicate agent is running in a worker scope using global self variable', async () => {
|
|
58
|
+
global.WorkerGlobalScope = class WorkerGlobalScope {}
|
|
59
|
+
global.WorkerNavigator = class WorkerNavigator {}
|
|
60
|
+
const cachedGlobalThis = global.globalThis
|
|
61
|
+
const mockedGlobalThis = global.globalThis = new WorkerGlobalScope()
|
|
62
|
+
Object.defineProperties(global.globalThis, Object.getOwnPropertyDescriptors(cachedGlobalThis))
|
|
63
|
+
global.globalThis.navigator = new WorkerNavigator()
|
|
64
|
+
|
|
65
|
+
const runtime = await import('./runtime')
|
|
66
|
+
|
|
67
|
+
delete global.WorkerGlobalScope
|
|
68
|
+
delete global.WorkerNavigator
|
|
69
|
+
global.globalThis = cachedGlobalThis
|
|
70
|
+
|
|
71
|
+
expect(runtime.isBrowserScope).toEqual(false)
|
|
72
|
+
expect(runtime.isWorkerScope).toEqual(true)
|
|
73
|
+
expect(runtime.globalScope).toEqual(mockedGlobalThis)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test('should store the initial page location', async () => {
|
|
77
|
+
const initialLocation = faker.internet.url()
|
|
78
|
+
const mockedWindow = global.window = {
|
|
79
|
+
[faker.datatype.uuid()]: faker.lorem.sentence,
|
|
80
|
+
document: {
|
|
81
|
+
[faker.datatype.uuid()]: faker.lorem.sentence
|
|
82
|
+
},
|
|
83
|
+
location: {
|
|
84
|
+
href: initialLocation,
|
|
85
|
+
toString () {
|
|
86
|
+
return this.href
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const runtime = await import('./runtime')
|
|
92
|
+
mockedWindow.location.href = faker.internet.url()
|
|
93
|
+
|
|
94
|
+
delete global.window
|
|
95
|
+
|
|
96
|
+
expect(runtime.initialLocation).toEqual(initialLocation)
|
|
97
|
+
expect(runtime.initialLocation).not.toEqual(mockedWindow.location.href)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test.each([
|
|
101
|
+
{ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: true },
|
|
102
|
+
{ userAgent: 'Mozilla/5.0 (iPad; CPU OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: true },
|
|
103
|
+
{ userAgent: 'Mozilla/5.0 (iPod touch; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: true },
|
|
104
|
+
{ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15', expected: false },
|
|
105
|
+
{ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0', expected: false },
|
|
106
|
+
{ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.4; rv:109.0) Gecko/20100101 Firefox/114.0', expected: false }
|
|
107
|
+
])('should set isiOS to $expected for $userAgent', async ({ userAgent, expected }) => {
|
|
108
|
+
global.navigator.userAgent = userAgent
|
|
109
|
+
|
|
110
|
+
const runtime = await import('./runtime')
|
|
111
|
+
|
|
112
|
+
expect(runtime.isiOS).toEqual(expected)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test.each([
|
|
116
|
+
{ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: false },
|
|
117
|
+
{ userAgent: 'Mozilla/5.0 (iPad; CPU OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: false },
|
|
118
|
+
{ userAgent: 'Mozilla/5.0 (iPod touch; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: false },
|
|
119
|
+
{ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1', expected: true },
|
|
120
|
+
{ userAgent: 'Mozilla/5.0 (iPad; CPU OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1', expected: true },
|
|
121
|
+
{ userAgent: 'Mozilla/5.0 (iPod touch; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1', expected: true },
|
|
122
|
+
{ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15', expected: false },
|
|
123
|
+
{ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0', expected: false },
|
|
124
|
+
{ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.4; rv:109.0) Gecko/20100101 Firefox/114.0', expected: false }
|
|
125
|
+
])('should set iOS_below16 to $expected for $userAgent', async ({ userAgent, expected }) => {
|
|
126
|
+
if (!expected) {
|
|
127
|
+
global.SharedWorker = class SharedWorker {}
|
|
128
|
+
}
|
|
129
|
+
global.navigator.userAgent = userAgent
|
|
130
|
+
|
|
131
|
+
const runtime = await import('./runtime')
|
|
132
|
+
|
|
133
|
+
delete global.SharedWorker
|
|
134
|
+
|
|
135
|
+
expect(runtime.iOS_below16).toEqual(expected)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test.each([
|
|
139
|
+
{ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: 0 },
|
|
140
|
+
{ userAgent: 'Mozilla/5.0 (iPad; CPU OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: 0 },
|
|
141
|
+
{ userAgent: 'Mozilla/5.0 (iPod touch; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1', expected: 0 },
|
|
142
|
+
{ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15', expected: 0 },
|
|
143
|
+
{ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0', expected: 114 },
|
|
144
|
+
{ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.4; rv:109.0) Gecko/20100101 Firefox/114.0', expected: 114 }
|
|
145
|
+
])('should set ffVersion to $expected for $userAgent', async ({ userAgent, expected }) => {
|
|
146
|
+
global.navigator.userAgent = userAgent
|
|
147
|
+
|
|
148
|
+
const runtime = await import('./runtime')
|
|
149
|
+
|
|
150
|
+
expect(runtime.ffVersion).toEqual(expected)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
test('should set supportsSendBeacon to false', async () => {
|
|
154
|
+
// Ensure we don't have a sendBeacon function
|
|
155
|
+
delete global.navigator.sendBeacon
|
|
156
|
+
|
|
157
|
+
const runtime = await import('./runtime')
|
|
158
|
+
|
|
159
|
+
expect(runtime.supportsSendBeacon).toEqual(false)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('should set supportsSendBeacon to true', async () => {
|
|
163
|
+
global.navigator.sendBeacon = jest.fn()
|
|
164
|
+
|
|
165
|
+
const runtime = await import('./runtime')
|
|
166
|
+
|
|
167
|
+
expect(runtime.supportsSendBeacon).toEqual(true)
|
|
168
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const Harvest = jest.fn(function () {
|
|
2
|
+
this.sharedContext = {
|
|
3
|
+
agentIdentifier: 'abcd'
|
|
4
|
+
}
|
|
5
|
+
this.sendX = jest.fn()
|
|
6
|
+
this.send = jest.fn()
|
|
7
|
+
this.obfuscateAndSend = jest.fn()
|
|
8
|
+
this._send = jest.fn()
|
|
9
|
+
this.baseQueryString = jest.fn()
|
|
10
|
+
this.createPayload = jest.fn()
|
|
11
|
+
this.cleanPayload = jest.fn()
|
|
12
|
+
this.on = jest.fn()
|
|
13
|
+
})
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import * as submitData from '../util/submit-data'
|
|
7
7
|
import { SharedContext } from '../context/shared-context'
|
|
8
|
-
import { Harvest
|
|
8
|
+
import { Harvest } from './harvest'
|
|
9
9
|
import { subscribeToEOL } from '../unload/eol'
|
|
10
10
|
import { getConfigurationValue } from '../config/config'
|
|
11
11
|
import { SESSION_EVENTS } from '../session/session-entity'
|
|
@@ -71,30 +71,39 @@ export class HarvestScheduler extends SharedContext {
|
|
|
71
71
|
|
|
72
72
|
scheduleHarvest (delay, opts) {
|
|
73
73
|
if (this.timeoutHandle) return
|
|
74
|
-
var timer = this
|
|
75
74
|
|
|
76
75
|
if (delay == null) {
|
|
77
76
|
delay = this.interval
|
|
78
77
|
}
|
|
79
78
|
this.timeoutHandle = setTimeout(() => {
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
this.timeoutHandle = null
|
|
80
|
+
this.runHarvest(opts)
|
|
82
81
|
}, delay * 1000)
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
runHarvest (opts) {
|
|
86
85
|
if (this.aborted) return
|
|
87
|
-
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This is executed immediately after harvest sends the data via XHR, or if there's nothing to send. Note that this excludes on unloading / sendBeacon.
|
|
89
|
+
* @param {Object} result
|
|
90
|
+
*/
|
|
91
|
+
const cbRanAfterSend = (result) => {
|
|
92
|
+
if (opts?.forceNoRetry) result.retry = false // discard unsent data rather than re-queuing for next harvest attempt
|
|
93
|
+
this.onHarvestFinished(opts, result)
|
|
94
|
+
}
|
|
88
95
|
|
|
89
96
|
let harvests = []
|
|
90
97
|
let submitMethod
|
|
98
|
+
let payload
|
|
91
99
|
|
|
92
|
-
if (this.opts.getPayload) {
|
|
93
|
-
|
|
100
|
+
if (this.opts.getPayload) {
|
|
101
|
+
// Ajax & PVT & SR features provide a callback function to get data for harvesting
|
|
102
|
+
submitMethod = submitData.getSubmitMethod({ isFinalHarvest: opts?.unload })
|
|
94
103
|
if (!submitMethod) return false
|
|
95
104
|
|
|
96
|
-
const retry = submitMethod
|
|
97
|
-
|
|
105
|
+
const retry = !opts?.unload && submitMethod === submitData.xhr
|
|
106
|
+
payload = this.opts.getPayload({ retry: retry })
|
|
98
107
|
|
|
99
108
|
if (!payload) {
|
|
100
109
|
if (this.started) {
|
|
@@ -134,16 +143,8 @@ export class HarvestScheduler extends SharedContext {
|
|
|
134
143
|
if (this.started) {
|
|
135
144
|
this.scheduleHarvest()
|
|
136
145
|
}
|
|
137
|
-
return
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
* This is executed immediately after harvest sends the data via XHR, or if there's nothing to send. Note that this excludes on unloading / sendBeacon.
|
|
141
|
-
* @param {Object} result
|
|
142
|
-
*/
|
|
143
|
-
function cbRanAfterSend (result) {
|
|
144
|
-
if (opts?.forceNoRetry) result.retry = false // discard unsent data rather than re-queuing for next harvest attempt
|
|
145
|
-
scheduler.onHarvestFinished(opts, result)
|
|
146
|
-
}
|
|
147
|
+
return
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
onHarvestFinished (opts, result) {
|
|
@@ -152,7 +153,7 @@ export class HarvestScheduler extends SharedContext {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
if (result.sent && result.retry) {
|
|
155
|
-
|
|
156
|
+
const delay = result.delay || this.opts.retryDelay
|
|
156
157
|
// reschedule next harvest if should be delayed longer
|
|
157
158
|
if (this.started && delay) {
|
|
158
159
|
clearTimeout(this.timeoutHandle)
|