@newrelic/browser-agent 1.237.1 → 1.239.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/dist/cjs/common/config/state/init.js +21 -13
- package/dist/cjs/common/config/state/runtime.js +0 -4
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/constants/runtime.js +3 -3
- package/dist/cjs/common/constants/shared-channel.js +3 -1
- package/dist/cjs/common/deny-list/deny-list.js +3 -9
- package/dist/cjs/common/drain/drain.js +1 -1
- package/dist/cjs/common/event-emitter/contextual-ee.js +24 -32
- package/dist/cjs/common/event-emitter/event-context.js +12 -0
- package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
- package/dist/cjs/common/harvest/harvest.js +4 -7
- package/dist/cjs/common/ids/bundle-id.js +19 -0
- package/dist/cjs/common/serialize/bel-serializer.js +1 -1
- package/dist/cjs/common/session/session-entity.js +16 -12
- package/dist/cjs/common/storage/first-party-cookies.js +5 -4
- package/dist/cjs/common/storage/local-storage.js +3 -2
- package/dist/cjs/common/timer/interaction-timer.js +14 -6
- package/dist/cjs/common/timing/nav-timing.js +1 -1
- package/dist/cjs/common/unload/eol.js +4 -30
- package/dist/cjs/common/util/feature-flags.js +14 -15
- package/dist/cjs/common/util/invoke.js +3 -1
- package/dist/cjs/common/util/obfuscate.js +3 -5
- package/dist/cjs/common/util/traverse.js +1 -0
- package/dist/cjs/common/window/page-visibility.js +1 -2
- package/dist/cjs/common/wrap/wrap-events.js +3 -2
- package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
- package/dist/cjs/common/wrap/wrap-function.js +15 -46
- package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
- package/dist/cjs/common/wrap/wrap-mutation.js +1 -2
- package/dist/cjs/common/wrap/wrap-promise.js +2 -3
- package/dist/cjs/common/wrap/wrap-xhr.js +23 -27
- package/dist/cjs/features/ajax/aggregate/index.js +5 -7
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -12
- package/dist/cjs/features/ajax/instrument/index.js +66 -24
- package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
- package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
- package/dist/cjs/features/metrics/aggregate/index.js +20 -37
- package/dist/cjs/features/metrics/instrument/index.js +0 -2
- package/dist/cjs/features/page_action/aggregate/index.js +17 -19
- package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
- package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
- package/dist/cjs/features/session_replay/aggregate/index.js +5 -3
- package/dist/cjs/features/session_trace/aggregate/index.js +22 -16
- package/dist/cjs/features/spa/aggregate/index.js +14 -20
- package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
- package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
- package/dist/cjs/features/utils/aggregate-base.js +4 -0
- package/dist/cjs/features/utils/handler-cache.js +3 -1
- package/dist/cjs/features/utils/instrument-base.js +24 -6
- package/dist/cjs/loaders/agent-base.js +23 -0
- package/dist/cjs/loaders/agent.js +7 -7
- package/dist/cjs/loaders/api/api.js +34 -4
- package/dist/cjs/loaders/api/apiAsync.js +19 -20
- package/dist/cjs/loaders/api/interaction-types.js +11 -4
- package/dist/cjs/loaders/configure/configure.js +3 -0
- package/dist/cjs/loaders/micro-agent.js +20 -3
- package/dist/esm/common/config/state/init.js +21 -13
- package/dist/esm/common/config/state/runtime.js +0 -4
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/constants/runtime.js +1 -1
- package/dist/esm/common/constants/shared-channel.js +3 -1
- package/dist/esm/common/deny-list/deny-list.js +3 -9
- package/dist/esm/common/drain/drain.js +1 -1
- package/dist/esm/common/event-emitter/contextual-ee.js +22 -29
- package/dist/esm/common/event-emitter/event-context.js +5 -0
- package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
- package/dist/esm/common/harvest/harvest.js +4 -7
- package/dist/esm/common/ids/bundle-id.js +13 -0
- package/dist/esm/common/serialize/bel-serializer.js +1 -1
- package/dist/esm/common/session/session-entity.js +16 -12
- package/dist/esm/common/storage/first-party-cookies.js +5 -4
- package/dist/esm/common/storage/local-storage.js +3 -2
- package/dist/esm/common/timer/interaction-timer.js +14 -6
- package/dist/esm/common/timing/nav-timing.js +1 -1
- package/dist/esm/common/unload/eol.js +5 -31
- package/dist/esm/common/util/feature-flags.js +14 -15
- package/dist/esm/common/util/invoke.js +3 -1
- package/dist/esm/common/util/obfuscate.js +3 -5
- package/dist/esm/common/util/traverse.js +1 -0
- package/dist/esm/common/window/page-visibility.js +1 -2
- package/dist/esm/common/wrap/wrap-events.js +4 -3
- package/dist/esm/common/wrap/wrap-fetch.js +2 -4
- package/dist/esm/common/wrap/wrap-function.js +15 -44
- package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
- package/dist/esm/common/wrap/wrap-mutation.js +2 -3
- package/dist/esm/common/wrap/wrap-promise.js +3 -4
- package/dist/esm/common/wrap/wrap-xhr.js +23 -27
- package/dist/esm/features/ajax/aggregate/index.js +5 -7
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -12
- package/dist/esm/features/ajax/instrument/index.js +67 -25
- package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
- package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/dist/esm/features/jserrors/aggregate/index.js +4 -5
- package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
- package/dist/esm/features/metrics/aggregate/index.js +22 -39
- package/dist/esm/features/metrics/instrument/index.js +1 -3
- package/dist/esm/features/page_action/aggregate/index.js +17 -19
- package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
- package/dist/esm/features/page_view_event/instrument/index.js +4 -2
- package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
- package/dist/esm/features/session_replay/aggregate/index.js +4 -2
- package/dist/esm/features/session_trace/aggregate/index.js +22 -16
- package/dist/esm/features/spa/aggregate/index.js +14 -20
- package/dist/esm/features/spa/aggregate/interaction.js +0 -2
- package/dist/esm/features/spa/aggregate/serializer.js +1 -1
- package/dist/esm/features/utils/aggregate-base.js +4 -0
- package/dist/esm/features/utils/handler-cache.js +3 -1
- package/dist/esm/features/utils/instrument-base.js +24 -6
- package/dist/esm/loaders/agent-base.js +23 -0
- package/dist/esm/loaders/agent.js +7 -7
- package/dist/esm/loaders/api/api.js +34 -4
- package/dist/esm/loaders/api/apiAsync.js +19 -20
- package/dist/esm/loaders/api/interaction-types.js +11 -4
- package/dist/esm/loaders/configure/configure.js +3 -0
- package/dist/esm/loaders/features/enabled-features.js +1 -1
- package/dist/esm/loaders/micro-agent.js +21 -4
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/constants/runtime.d.ts +1 -1
- package/dist/types/common/constants/runtime.d.ts.map +1 -1
- package/dist/types/common/event-emitter/contextual-ee.d.ts +22 -2
- package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
- package/dist/types/common/event-emitter/event-context.d.ts +5 -0
- package/dist/types/common/event-emitter/event-context.d.ts.map +1 -0
- package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/ids/bundle-id.d.ts +5 -0
- package/dist/types/common/ids/bundle-id.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +12 -15
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
- package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
- package/dist/types/common/storage/local-storage.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.d.ts +3 -0
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
- package/dist/types/common/unload/eol.d.ts +1 -2
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/util/traverse.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts +2 -2
- package/dist/types/common/window/page-visibility.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-events.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-function.d.ts +1 -19
- package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
- package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +1 -1
- package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/canonical-function-name.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/metrics/aggregate/framework-detection.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
- package/dist/types/features/page_action/aggregate/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.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +5 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +1 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +15 -0
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/api/api.d.ts +7 -0
- package/dist/types/loaders/api/api.d.ts.map +1 -1
- package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
- package/dist/types/loaders/api/interaction-types.d.ts +18 -7
- package/dist/types/loaders/api/interaction-types.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts +2 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +9 -9
- package/dist/types/loaders/micro-agent.d.ts +7 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +62 -38
- package/src/common/aggregate/aggregator.test.js +107 -0
- package/src/common/config/state/configurable.test.js +73 -0
- package/src/common/config/state/info.test.js +31 -0
- package/src/common/config/state/init.js +13 -12
- package/src/common/config/state/init.test.js +28 -0
- package/src/common/config/state/loader-config.test.js +21 -0
- package/src/common/config/state/runtime.js +0 -2
- package/src/common/config/state/runtime.test.js +21 -0
- package/src/common/constants/__mocks__/runtime.js +1 -1
- package/src/common/constants/runtime.js +1 -1
- package/src/common/constants/runtime.test.js +2 -2
- package/src/common/constants/shared-channel.js +1 -1
- package/src/common/deny-list/deny-list.js +3 -11
- package/src/common/deny-list/deny-list.test.js +103 -30
- package/src/common/drain/drain.js +1 -1
- package/src/common/drain/drain.test.js +74 -0
- package/src/common/event-emitter/{contextual-ee.test.js → contextual-ee.component-test.js} +15 -32
- package/src/common/event-emitter/contextual-ee.js +26 -37
- package/src/common/event-emitter/event-context.js +5 -0
- package/src/common/harvest/harvest-scheduler.js +2 -5
- package/src/common/harvest/harvest-scheduler.test.js +2 -6
- package/src/common/harvest/harvest.js +4 -7
- package/src/common/harvest/harvest.test.js +1 -3
- package/src/common/ids/__mocks__/bundle-id.js +2 -0
- package/src/common/ids/__mocks__/unique-id.js +17 -0
- package/src/common/ids/bundle-id.js +13 -0
- package/src/common/ids/id.test.js +6 -6
- package/src/common/serialize/bel-serializer.js +1 -1
- package/src/common/session/session-entity.component-test.js +3 -2
- package/src/common/session/session-entity.js +11 -9
- package/src/common/storage/first-party-cookies.js +5 -4
- package/src/common/storage/local-storage.js +3 -2
- package/src/common/timer/interaction-timer.component-test.js +52 -7
- package/src/common/timer/interaction-timer.js +15 -6
- package/src/common/timer/timer.test.js +0 -1
- package/src/common/timing/nav-timing.js +1 -1
- package/src/common/unload/eol.js +5 -31
- package/src/common/url/__mocks__/parse-url.js +15 -0
- package/src/common/url/{encode.component-test.js → encode.test.js} +1 -0
- package/src/common/util/__mocks__/get-or-set.js +5 -0
- package/src/common/util/__mocks__/invoke.js +1 -0
- package/src/common/util/data-size.test.js +0 -1
- package/src/common/util/feature-flags.js +15 -17
- package/src/common/util/feature-flags.test.js +4 -8
- package/src/common/util/invoke.js +1 -1
- package/src/common/util/obfuscate.js +3 -5
- package/src/common/util/submit-data.test.js +1 -1
- package/src/common/util/traverse.js +1 -0
- package/src/common/window/__mocks__/nreum.js +12 -0
- package/src/common/window/page-visibility.js +1 -2
- package/src/common/wrap/wrap-events.js +4 -3
- package/src/common/wrap/wrap-fetch.js +2 -4
- package/src/common/wrap/wrap-function.js +16 -44
- package/src/common/wrap/wrap-jsonp.js +1 -1
- package/src/common/wrap/wrap-mutation.js +2 -3
- package/src/common/wrap/{wrap-promise.test.js → wrap-promise.component-test.js} +2 -32
- package/src/common/wrap/wrap-promise.js +3 -4
- package/src/common/wrap/wrap-xhr.js +24 -28
- package/src/features/ajax/aggregate/index.js +5 -7
- package/src/features/ajax/instrument/distributed-tracing.js +8 -12
- package/src/features/ajax/instrument/distributed-tracing.test.js +375 -0
- package/src/features/ajax/instrument/index.js +62 -27
- package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
- package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
- package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
- package/src/features/jserrors/aggregate/index.js +4 -5
- package/src/features/metrics/aggregate/framework-detection.js +129 -8
- package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
- package/src/features/metrics/aggregate/index.js +22 -45
- package/src/features/metrics/instrument/index.js +1 -3
- package/src/features/page_action/aggregate/index.js +12 -13
- package/src/features/page_view_event/aggregate/index.js +1 -2
- package/src/features/page_view_event/instrument/index.js +2 -2
- package/src/features/page_view_timing/aggregate/index.js +7 -8
- package/src/features/session_replay/aggregate/index.component-test.js +3 -15
- package/src/features/session_replay/aggregate/index.js +4 -2
- package/src/features/session_trace/aggregate/index.js +22 -16
- package/src/features/spa/aggregate/index.js +14 -20
- package/src/features/spa/aggregate/interaction.js +0 -2
- package/src/features/spa/aggregate/serializer.js +1 -1
- package/src/features/utils/aggregate-base.js +5 -0
- package/src/features/utils/aggregate-base.test.js +2 -1
- package/src/features/utils/handler-cache.js +3 -2
- package/src/features/utils/instrument-base.js +25 -6
- package/src/features/utils/instrument-base.test.js +2 -2
- package/src/loaders/agent-base.js +23 -0
- package/src/loaders/agent.js +7 -7
- package/src/loaders/api/api.component-test.js +45 -0
- package/src/loaders/api/api.js +34 -4
- package/src/loaders/api/api.test.js +85 -0
- package/src/loaders/api/apiAsync.js +19 -20
- package/src/loaders/api/apiAsync.test.js +17 -0
- package/src/loaders/api/interaction-types.js +11 -4
- package/src/loaders/configure/configure.js +3 -0
- package/src/loaders/features/enabled-features.js +1 -1
- package/src/loaders/micro-agent.js +22 -4
- package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
- package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
- package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
- package/src/features/metrics/aggregate/endpoint-map.js +0 -7
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
- package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
- package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
- package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
- /package/src/common/url/{protocol.component-test.js → protocol.test.js} +0 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/browser-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.239.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "New Relic Browser Agent",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"homepage": "https://docs.newrelic.com/docs/browser/browser-monitoring",
|
|
9
9
|
"main": "./dist/cjs/index.js",
|
|
@@ -13,6 +13,45 @@
|
|
|
13
13
|
">=4.2": {
|
|
14
14
|
"*": [
|
|
15
15
|
"dist/types/*"
|
|
16
|
+
],
|
|
17
|
+
"src/*": [
|
|
18
|
+
"dist/types/*"
|
|
19
|
+
],
|
|
20
|
+
"loaders/agent": [
|
|
21
|
+
"dist/types/loaders/agent.d.ts"
|
|
22
|
+
],
|
|
23
|
+
"loaders/browser-agent": [
|
|
24
|
+
"dist/types/loaders/browser-agent.d.ts"
|
|
25
|
+
],
|
|
26
|
+
"loaders/micro-agent": [
|
|
27
|
+
"dist/types/loaders/micro-agent.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"loaders/worker-agent": [
|
|
30
|
+
"dist/types/loaders/worker-agent.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"features/ajax": [
|
|
33
|
+
"dist/types/features/ajax/index.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"features/jserrors": [
|
|
36
|
+
"dist/types/features/jserrors/index.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"features/metrics": [
|
|
39
|
+
"dist/types/features/metrics/index.d.ts"
|
|
40
|
+
],
|
|
41
|
+
"features/page_action": [
|
|
42
|
+
"dist/types/features/page_action/index.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"features/page_view_event": [
|
|
45
|
+
"dist/types/features/page_view_event/index.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"features/page_view_timing": [
|
|
48
|
+
"dist/types/features/page_view_timing/index.d.ts"
|
|
49
|
+
],
|
|
50
|
+
"features/session_trace": [
|
|
51
|
+
"dist/types/features/session_trace/index.d.ts"
|
|
52
|
+
],
|
|
53
|
+
"features/spa": [
|
|
54
|
+
"dist/types/features/spa/index.d.ts"
|
|
16
55
|
]
|
|
17
56
|
}
|
|
18
57
|
},
|
|
@@ -92,35 +131,30 @@
|
|
|
92
131
|
"node": ">=12.17.0 < 13.0.0 || >=13.7.0"
|
|
93
132
|
},
|
|
94
133
|
"scripts": {
|
|
95
|
-
"wdio": "node --max-old-space-size=8192 tools/wdio/bin/cli.js",
|
|
96
134
|
"start": "npm-run-all --parallel cdn:watch test-server",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
135
|
+
"lint": "eslint -c .eslintrc.js --ext .js,.cjs,.mjs .",
|
|
136
|
+
"lint:fix": "npm run lint -- --fix",
|
|
137
|
+
"test": "jest",
|
|
138
|
+
"test:unit": "jest --selectProjects unit",
|
|
139
|
+
"test:component": "jest --selectProjects component",
|
|
140
|
+
"test:types": "tsd -f ./tests/dts/**/*.ts",
|
|
141
|
+
"wdio": "node --max-old-space-size=8192 tools/wdio/bin/cli.js",
|
|
142
|
+
"jil": "tools/jil/bin/cli.js",
|
|
99
143
|
"build:all": "npm run cdn:build:local && npm run build:npm && npm run tools:test-builds",
|
|
100
144
|
"build:npm": "npm run npm:build:esm && npm run npm:build:cjs && npm run npm:build:types && npm run npm:pack",
|
|
101
145
|
"build:browser-tests": "npm --prefix ./tools/test-builds/browser-tests run build",
|
|
102
|
-
"
|
|
103
|
-
"lint:fix": "npm run lint -- --fix",
|
|
104
|
-
"test-jil": "tools/jil/bin/cli.js",
|
|
105
|
-
"ci-build": "npm ci --cache ./.npm",
|
|
106
|
-
"build-tar": "npm run ci-build && tar czf ./build/browser-agent.tar.gz --exclude=.git --exclude=.npm --exclude=build/browser-agent.tar.gz .",
|
|
107
|
-
"watch": "jung -D '\\.npm|.git|node_modules|build|tools|tests' --run -- npm run build:all",
|
|
146
|
+
"watch:browser-tests": "jung -r ./src -F '.*\\.test\\.js' --run -- npm run build:browser-tests",
|
|
108
147
|
"cdn:build": "npm run cdn:build:prod",
|
|
109
|
-
"cdn:build:
|
|
110
|
-
"cdn:build:
|
|
111
|
-
"
|
|
112
|
-
"cdn:build:dev": "npm run cdn:
|
|
113
|
-
"cdn:build:
|
|
114
|
-
"cdn:
|
|
115
|
-
"
|
|
116
|
-
"cdn:build:experiment": "npm run cdn:fresh-build && PUBLISH=EXPERIMENT npm run cdn:webpack && npm run cdn:cleanup",
|
|
117
|
-
"cdn:cleanup": "node ./tools/scripts/post-build-cleanup",
|
|
118
|
-
"cdn:clone": "node ./tools/scripts/clone",
|
|
119
|
-
"cdn:fresh-build": "rm -rf ./build",
|
|
148
|
+
"cdn:build:local": "npm run cdn:webpack",
|
|
149
|
+
"cdn:build:prod": "npm run cdn:webpack -- --env mode=prod",
|
|
150
|
+
"postcdn:build:prod": "npm run cdn:clone",
|
|
151
|
+
"cdn:build:dev": "npm run cdn:webpack -- --env mode=dev",
|
|
152
|
+
"cdn:build:experiment": "npm run cdn:webpack -- --env mode=experiment",
|
|
153
|
+
"cdn:webpack": "npx webpack --progress --config ./tools/webpack/index.mjs",
|
|
154
|
+
"postcdn:webpack": "npm run cdn:cleanup",
|
|
120
155
|
"cdn:watch": "jung -r ./src -F '.*\\.test\\.js' --run -- npm run cdn:build:local",
|
|
121
|
-
"cdn:
|
|
122
|
-
"cdn:
|
|
123
|
-
"packages:bundle": "webpack -c tools/jil/webpack.modular.js",
|
|
156
|
+
"cdn:cleanup": "node ./tools/webpack/scripts/cleanup.mjs",
|
|
157
|
+
"cdn:clone": "node ./tools/webpack/scripts/clone.mjs",
|
|
124
158
|
"test-server": "node ./tools/wdio/bin/server",
|
|
125
159
|
"sauce:connect": "node ./tools/saucelabs/bin.mjs",
|
|
126
160
|
"sauce:get-browsers": "node ./tools/browsers-lists/sauce-browsers.mjs",
|
|
@@ -130,8 +164,7 @@
|
|
|
130
164
|
"npm:build:esm": "npx babel --env-name npm-esm --out-dir dist/esm --out-file-extension .js ./src",
|
|
131
165
|
"npm:build:cjs": "npx babel --env-name npm-cjs --out-dir dist/cjs --out-file-extension .js ./src",
|
|
132
166
|
"npm:build:types": "npx tsc -b",
|
|
133
|
-
"npm:pack": "mkdir -p temp && export PKG_NAME=$(npm pack --pack-destination temp) && echo ./temp/$PKG_NAME"
|
|
134
|
-
"watch:browser-tests": "jung -r ./src -F '.*\\.test\\.js' --run -- npm run build:browser-tests"
|
|
167
|
+
"npm:pack": "mkdir -p temp && export PKG_NAME=$(npm pack --pack-destination temp) && echo ./temp/$PKG_NAME"
|
|
135
168
|
},
|
|
136
169
|
"config": {
|
|
137
170
|
"unsafe-perm": true
|
|
@@ -147,7 +180,6 @@
|
|
|
147
180
|
"web-vitals": "^3.1.0"
|
|
148
181
|
},
|
|
149
182
|
"devDependencies": {
|
|
150
|
-
"@actions/core": "^1.10.0",
|
|
151
183
|
"@babel/cli": "^7.20.7",
|
|
152
184
|
"@babel/core": "^7.20.12",
|
|
153
185
|
"@babel/eslint-parser": "^7.19.1",
|
|
@@ -166,20 +198,17 @@
|
|
|
166
198
|
"@fastify/static": "^6.10.1",
|
|
167
199
|
"@newrelic/newrelic-oss-cli": "^0.1.2",
|
|
168
200
|
"@newrelic/nr-querypack": "https://git@github.com/newrelic/nr-querypack",
|
|
169
|
-
"@octokit/rest": "^19.0.7",
|
|
170
201
|
"@wdio/cli": "^8.10.5",
|
|
171
202
|
"@wdio/local-runner": "^8.10.5",
|
|
172
203
|
"@wdio/mocha-framework": "^8.10.4",
|
|
173
204
|
"@wdio/sauce-service": "^8.10.5",
|
|
174
205
|
"@wdio/selenium-standalone-service": "^8.10.4",
|
|
175
206
|
"@wdio/spec-reporter": "^8.10.5",
|
|
176
|
-
"aws-sdk": "^2.894.0",
|
|
177
207
|
"babel-jest": "^29.4.1",
|
|
178
208
|
"babel-loader": "^8.2.5",
|
|
179
209
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
180
210
|
"babelify": "^10.0.0",
|
|
181
211
|
"browserify": "^13.3.0",
|
|
182
|
-
"chalk": "^5.1.2",
|
|
183
212
|
"charm": "^1.0.1",
|
|
184
213
|
"concat-stream": "^1.5.1",
|
|
185
214
|
"deepmerge-ts": "^5.1.0",
|
|
@@ -193,11 +222,9 @@
|
|
|
193
222
|
"eslint-plugin-sonarjs": "^0.19.0",
|
|
194
223
|
"fastify": "^4.17.0",
|
|
195
224
|
"fastify-plugin": "^4.5.0",
|
|
196
|
-
"filesize": "^10.0.7",
|
|
197
225
|
"fs-extra": "^11.1.0",
|
|
198
226
|
"function-bind": "^1.1.1",
|
|
199
227
|
"glob": "^10.2.5",
|
|
200
|
-
"gzip-size": "^7.0.0",
|
|
201
228
|
"html-webpack-plugin": "^5.5.0",
|
|
202
229
|
"husky": "^8.0.0",
|
|
203
230
|
"istanbul-lib-coverage": "^3.2.0",
|
|
@@ -209,26 +236,23 @@
|
|
|
209
236
|
"jest-extended": "^3.2.4",
|
|
210
237
|
"jung": "^2.1.0",
|
|
211
238
|
"just-debounce": "^1.0.0",
|
|
212
|
-
"mime-types": "^2.1.11",
|
|
213
239
|
"newrelic": "^9.7.5",
|
|
214
240
|
"node-fetch": "^3.3.0",
|
|
215
241
|
"npm-run-all": "^4.1.5",
|
|
216
242
|
"object-inspect": "^1.5.0",
|
|
217
|
-
"octokit": "^2.0.14",
|
|
218
243
|
"path-browserify": "^1.0.1",
|
|
219
244
|
"preprocessify": "0.0.6",
|
|
220
245
|
"process": "^0.11.10",
|
|
221
|
-
"request": "2.74.0",
|
|
222
246
|
"saucelabs": "^7.2.1",
|
|
223
247
|
"semver": "^5.3.0",
|
|
224
248
|
"serialize-anything": "^1.2.3",
|
|
225
|
-
"sinon": "^2.4.1",
|
|
226
249
|
"stream-browserify": "^3.0.0",
|
|
227
250
|
"tap-parser": "^1.2.2",
|
|
228
251
|
"tape": "^4.8.0",
|
|
229
252
|
"through": "^2.3.8",
|
|
230
|
-
"
|
|
253
|
+
"tsd": "^0.28.1",
|
|
231
254
|
"typescript": "^5.0.3",
|
|
255
|
+
"util": "^0.12.5",
|
|
232
256
|
"uuid": "^9.0.0",
|
|
233
257
|
"wait-on": "^7.0.1",
|
|
234
258
|
"wd": "^1.11.2",
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Aggregator } from './aggregator.js'
|
|
2
|
+
|
|
3
|
+
let aggregator
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
aggregator = new Aggregator({ agentIdentifier: 'blah' })
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
test('storing and getting buckets', () => {
|
|
9
|
+
let bucket = aggregator.store('abc', '123')
|
|
10
|
+
const expectedBucketPattern = { params: {}, metrics: { count: 1 } }
|
|
11
|
+
expect(bucket).toEqual(expectedBucketPattern)
|
|
12
|
+
expect(aggregator.get('abc', '123')).toEqual(expectedBucketPattern)
|
|
13
|
+
|
|
14
|
+
aggregator.store('abc', '456')
|
|
15
|
+
// check we can get all buckets under the same type
|
|
16
|
+
expect(aggregator.get('abc')).toEqual({ 123: expectedBucketPattern, 456: expectedBucketPattern })
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('storing the same bucket again', () => {
|
|
20
|
+
test('increments the count', () => {
|
|
21
|
+
aggregator.store('abc', '123')
|
|
22
|
+
aggregator.store('abc', '123')
|
|
23
|
+
expect(aggregator.get('abc', '123')).toEqual({ params: {}, metrics: { count: 2 } })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('does not overwrite params', () => {
|
|
27
|
+
aggregator.store('def', '123', { someParam: true })
|
|
28
|
+
aggregator.store('def', '123', { anotherParam: true })
|
|
29
|
+
expect(aggregator.get('def', '123')).toEqual({ params: { someParam: true }, metrics: { count: 2 } })
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('does not overwrite custom params either', () => {
|
|
33
|
+
aggregator.store('ghi', '123', undefined, undefined, { someCustomParam: true })
|
|
34
|
+
aggregator.store('ghi', '123', undefined, undefined, { someCustomParam: false })
|
|
35
|
+
expect(aggregator.get('ghi', '123')).toEqual({ params: {}, custom: { someCustomParam: true }, metrics: { count: 2 } })
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('metrics are properly updated', () => {
|
|
40
|
+
test('when using store fn', () => {
|
|
41
|
+
const expectedBucketPattern = {
|
|
42
|
+
params: {},
|
|
43
|
+
metrics: {
|
|
44
|
+
count: 2,
|
|
45
|
+
met1: { t: 3, min: 1, max: 2, sos: 5, c: 2 },
|
|
46
|
+
met2: { t: 7, min: 3, max: 4, sos: 25, c: 2 }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
aggregator.store('abc', '123', undefined, { met1: 1, met2: 3 })
|
|
50
|
+
aggregator.store('abc', '123', undefined, { met1: 2, met2: 4 })
|
|
51
|
+
expect(aggregator.get('abc', '123')).toEqual(expectedBucketPattern)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('when using storeMetric fn', () => {
|
|
55
|
+
const expectedBucketPattern = {
|
|
56
|
+
params: {},
|
|
57
|
+
stats: { t: 6, min: 1, max: 3, sos: 14, c: 3 }
|
|
58
|
+
}
|
|
59
|
+
aggregator.storeMetric('abc', 'metric', undefined, 2)
|
|
60
|
+
aggregator.storeMetric('abc', 'metric', undefined, 1)
|
|
61
|
+
aggregator.storeMetric('abc', 'metric', undefined, 3)
|
|
62
|
+
expect(aggregator.get('abc', 'metric')).toEqual(expectedBucketPattern)
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test('take fn gets and deletes correctly', () => {
|
|
67
|
+
aggregator.store('type1', 'a')
|
|
68
|
+
aggregator.store('type1', 'b')
|
|
69
|
+
aggregator.store('type2', 'a')
|
|
70
|
+
aggregator.store('type3', 'a')
|
|
71
|
+
|
|
72
|
+
expect(aggregator.take(['type0'])).toBeNull() // when type dne in aggregator
|
|
73
|
+
let obj = aggregator.take(['type1', 'type2'])
|
|
74
|
+
expect(obj.type1.length).toEqual(2)
|
|
75
|
+
expect(obj.type2.length).toEqual(1)
|
|
76
|
+
expect(aggregator.get('type1', 'a')).toBeUndefined() // should be gone now
|
|
77
|
+
expect(aggregator.get('type3', 'a')).toEqual(expect.any(Object))
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('merge fn combines metrics correctly', () => {
|
|
81
|
+
aggregator.store('abc', '123', undefined, { met1: 1, met2: 3 })
|
|
82
|
+
let bucket = aggregator.store('abc', '123', undefined, { met1: 2 })
|
|
83
|
+
const expectedMetrics = {
|
|
84
|
+
count: 2,
|
|
85
|
+
met1: { t: 3, min: 1, max: 2, sos: 5, c: 2 },
|
|
86
|
+
met2: { t: 3 }
|
|
87
|
+
}
|
|
88
|
+
expect(bucket.metrics).toEqual(expectedMetrics)
|
|
89
|
+
|
|
90
|
+
aggregator.merge('abc', '456', bucket.metrics)
|
|
91
|
+
expect(aggregator.get('abc', '456').metrics).toEqual(expectedMetrics)
|
|
92
|
+
|
|
93
|
+
aggregator.merge('abc', '123', {
|
|
94
|
+
count: 4,
|
|
95
|
+
met1: { t: 4, min: 0, max: 4, sos: 16, c: 2 },
|
|
96
|
+
met2: { t: 5 },
|
|
97
|
+
met3: { t: 6 },
|
|
98
|
+
met4: { t: 7, min: 3, max: 4, sos: 25, c: 2 }
|
|
99
|
+
})
|
|
100
|
+
expect(aggregator.get('abc', '123').metrics).toEqual({
|
|
101
|
+
count: 6,
|
|
102
|
+
met1: { t: 7, min: 0, max: 4, sos: 21, c: 4 },
|
|
103
|
+
met2: { t: 8, min: 3, max: 5, sos: 34, c: 2 },
|
|
104
|
+
met3: { t: 6 },
|
|
105
|
+
met4: { t: 7, min: 3, max: 4, sos: 25, c: 2 }
|
|
106
|
+
})
|
|
107
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getModeledObject } from './configurable'
|
|
2
|
+
|
|
3
|
+
test('if either params are not objects, function fails', () => {
|
|
4
|
+
let result = getModeledObject(123, {})
|
|
5
|
+
expect(result).toEqual(undefined)
|
|
6
|
+
|
|
7
|
+
result = getModeledObject({}, () => 'whatever')
|
|
8
|
+
expect(result).toEqual(undefined)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('models are not mutated by function', () => {
|
|
12
|
+
const template = { dontchangethis: true }
|
|
13
|
+
getModeledObject({ dontchangethis: false, addthis: true }, template)
|
|
14
|
+
expect(template).toEqual({ dontchangethis: true })
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const model = {
|
|
18
|
+
eat: true,
|
|
19
|
+
sleep: true,
|
|
20
|
+
rave: true,
|
|
21
|
+
repeat: {
|
|
22
|
+
eat: true,
|
|
23
|
+
sleep: true,
|
|
24
|
+
rave: true,
|
|
25
|
+
repeat: false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
test('empty object does not change model output', () => {
|
|
30
|
+
expect(getModeledObject({}, model)).toEqual(model)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('existing keys get their values changed', () => {
|
|
34
|
+
let obj = {
|
|
35
|
+
sleep: false,
|
|
36
|
+
repeat: {
|
|
37
|
+
eat: false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
expect(getModeledObject(obj, model)).toEqual({
|
|
41
|
+
eat: true,
|
|
42
|
+
sleep: false,
|
|
43
|
+
rave: true,
|
|
44
|
+
repeat: {
|
|
45
|
+
eat: false, // should recurse
|
|
46
|
+
sleep: true,
|
|
47
|
+
rave: true,
|
|
48
|
+
repeat: false
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('existing keys can change types too, to/from object', () => {
|
|
54
|
+
// in other words, if replacement is not an object, it has no effect
|
|
55
|
+
let obj = {
|
|
56
|
+
rave: {},
|
|
57
|
+
repeat: 'just a sad lonely string now'
|
|
58
|
+
}
|
|
59
|
+
expect(getModeledObject(obj, model)).toEqual({
|
|
60
|
+
eat: true,
|
|
61
|
+
sleep: true,
|
|
62
|
+
rave: {},
|
|
63
|
+
repeat: 'just a sad lonely string now'
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('keys not in model are ignored', () => {
|
|
68
|
+
expect(getModeledObject({ game: 'allnight' }, model)).toEqual(model)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('but if model is empty, then keys are not ignored', () => {
|
|
72
|
+
expect(getModeledObject({ game: 'allnight' }, {})).toEqual({ game: 'allnight' })
|
|
73
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
let isValid, getInfo, setInfo
|
|
2
|
+
beforeEach(async () => {
|
|
3
|
+
jest.resetModules()
|
|
4
|
+
;({ isValid, getInfo, setInfo } = await import('./info.js'))
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
test('set/getInfo should throw on an invalid agent id', () => {
|
|
8
|
+
// currently only checks if it's a truthy value
|
|
9
|
+
expect(() => setInfo(undefined, {})).toThrow('require an agent id')
|
|
10
|
+
expect(() => getInfo(undefined)).toThrow('require an agent id')
|
|
11
|
+
expect(() => setInfo('', {})).toThrow('require an agent id')
|
|
12
|
+
expect(() => getInfo('')).toThrow('require an agent id')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('set/getInfo works correctly', () => {
|
|
16
|
+
expect(() => setInfo(123, { beacon: 'im here' })).not.toThrow() // notice setInfo accepts numbers
|
|
17
|
+
let cachedObj = getInfo('123')
|
|
18
|
+
expect(Object.keys(cachedObj).length).toBeGreaterThan(1)
|
|
19
|
+
expect(cachedObj.beacon).toEqual('im here')
|
|
20
|
+
expect(cachedObj.licenseKey).toEqual(undefined) // this should mirror default in info.js
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('isValid is correct', () => {
|
|
24
|
+
setInfo('ab', { errorBeacon: 'some value' })
|
|
25
|
+
setInfo('cd', { errorBeacon: 'some value', licenseKey: 'cereal box' })
|
|
26
|
+
expect(isValid('ab')).toBeFalsy()
|
|
27
|
+
expect(isValid('cd')).toBeFalsy()
|
|
28
|
+
|
|
29
|
+
setInfo('ef', { errorBeacon: 'some value', licenseKey: 'cereal box', applicationID: '25' })
|
|
30
|
+
expect(isValid('ef')).toBeTruthy()
|
|
31
|
+
})
|
|
@@ -8,9 +8,8 @@ const model = () => {
|
|
|
8
8
|
maskInputOptions: { password: true }
|
|
9
9
|
}
|
|
10
10
|
return {
|
|
11
|
-
allow_bfcache: true, // *cli - temporary feature flag for BFCache work
|
|
12
11
|
privacy: { cookies_enabled: true }, // *cli - per discussion, default should be true
|
|
13
|
-
ajax: { deny_list: undefined, block_internal: true, enabled: true, harvestTimeSeconds: 10 },
|
|
12
|
+
ajax: { deny_list: undefined, block_internal: true, enabled: true, harvestTimeSeconds: 10, autoStart: true },
|
|
14
13
|
distributed_tracing: {
|
|
15
14
|
enabled: undefined,
|
|
16
15
|
exclude_newrelic_header: undefined,
|
|
@@ -25,15 +24,16 @@ const model = () => {
|
|
|
25
24
|
},
|
|
26
25
|
ssl: undefined,
|
|
27
26
|
obfuscate: undefined,
|
|
28
|
-
jserrors: { enabled: true, harvestTimeSeconds: 10 },
|
|
29
|
-
metrics: { enabled: true },
|
|
30
|
-
page_action: { enabled: true, harvestTimeSeconds: 30 },
|
|
31
|
-
page_view_event: { enabled: true },
|
|
32
|
-
page_view_timing: { enabled: true, harvestTimeSeconds: 30, long_task: false },
|
|
33
|
-
session_trace: { enabled: true, harvestTimeSeconds: 10 },
|
|
27
|
+
jserrors: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
|
|
28
|
+
metrics: { enabled: true, autoStart: true },
|
|
29
|
+
page_action: { enabled: true, harvestTimeSeconds: 30, autoStart: true },
|
|
30
|
+
page_view_event: { enabled: true, autoStart: true },
|
|
31
|
+
page_view_timing: { enabled: true, harvestTimeSeconds: 30, long_task: false, autoStart: true },
|
|
32
|
+
session_trace: { enabled: true, harvestTimeSeconds: 10, autoStart: true },
|
|
34
33
|
harvest: { tooManyRequestsDelay: 60 },
|
|
35
34
|
session_replay: {
|
|
36
35
|
// feature settings
|
|
36
|
+
autoStart: true,
|
|
37
37
|
enabled: false,
|
|
38
38
|
harvestTimeSeconds: 60,
|
|
39
39
|
sampleRate: 0.1,
|
|
@@ -61,26 +61,27 @@ const model = () => {
|
|
|
61
61
|
hiddenState.maskInputOptions = { ...val, password: true }
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
spa: { enabled: true, harvestTimeSeconds: 10 }
|
|
64
|
+
spa: { enabled: true, harvestTimeSeconds: 10, autoStart: true }
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const _cache = {}
|
|
69
|
+
const missingAgentIdError = 'All configuration objects require an agent identifier!'
|
|
69
70
|
|
|
70
71
|
export function getConfiguration (id) {
|
|
71
|
-
if (!id) throw new Error(
|
|
72
|
+
if (!id) throw new Error(missingAgentIdError)
|
|
72
73
|
if (!_cache[id]) throw new Error(`Configuration for ${id} was never set`)
|
|
73
74
|
return _cache[id]
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
export function setConfiguration (id, obj) {
|
|
77
|
-
if (!id) throw new Error(
|
|
78
|
+
if (!id) throw new Error(missingAgentIdError)
|
|
78
79
|
_cache[id] = getModeledObject(obj, model())
|
|
79
80
|
gosNREUMInitializedAgents(id, _cache[id], 'config')
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export function getConfigurationValue (id, path) {
|
|
83
|
-
if (!id) throw new Error(
|
|
84
|
+
if (!id) throw new Error(missingAgentIdError)
|
|
84
85
|
var val = getConfiguration(id)
|
|
85
86
|
if (val) {
|
|
86
87
|
var parts = path.split('.')
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
let getConfiguration, setConfiguration, getConfigurationValue
|
|
2
|
+
beforeEach(async () => {
|
|
3
|
+
jest.resetModules()
|
|
4
|
+
;({ getConfiguration, setConfiguration, getConfigurationValue } = await import('./init.js'))
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
test('set/getConfiguration should throw on an invalid agent id', () => {
|
|
8
|
+
// currently only checks if it's a truthy value
|
|
9
|
+
expect(() => setConfiguration(undefined, {})).toThrow('require an agent id')
|
|
10
|
+
expect(() => getConfiguration(undefined)).toThrow('require an agent id')
|
|
11
|
+
expect(() => setConfiguration('', {})).toThrow('require an agent id')
|
|
12
|
+
expect(() => getConfiguration('')).toThrow('require an agent id')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('set/getConfiguration works correctly', () => {
|
|
16
|
+
expect(() => setConfiguration(123, { jserrors: { enabled: false } })).not.toThrow() // notice setConfiguration accepts numbers
|
|
17
|
+
let cachedObj = getConfiguration('123')
|
|
18
|
+
expect(Object.keys(cachedObj).length).toBeGreaterThan(1)
|
|
19
|
+
expect(cachedObj.jserrors.enabled).toEqual(false)
|
|
20
|
+
expect(cachedObj.page_action.enabled).toEqual(true) // this should mirror default in init.js
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('getConfigurationValue parses path correctly', () => {
|
|
24
|
+
setConfiguration('ab', { page_action: { harvestTimeSeconds: 1000 } })
|
|
25
|
+
expect(getConfigurationValue('ab', '')).toBeUndefined()
|
|
26
|
+
expect(getConfigurationValue('ab', 'page_action')).toEqual({ enabled: true, harvestTimeSeconds: 1000, autoStart: true })
|
|
27
|
+
expect(getConfigurationValue('ab', 'page_action.harvestTimeSeconds')).toEqual(1000)
|
|
28
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
let getLoaderConfig, setLoaderConfig
|
|
2
|
+
beforeEach(async () => {
|
|
3
|
+
jest.resetModules()
|
|
4
|
+
;({ getLoaderConfig, setLoaderConfig } = await import('./loader-config.js'))
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
test('set/getLoaderConfig should throw on an invalid agent id', () => {
|
|
8
|
+
// currently only checks if it's a truthy value
|
|
9
|
+
expect(() => setLoaderConfig(undefined, {})).toThrow('require an agent id')
|
|
10
|
+
expect(() => getLoaderConfig(undefined)).toThrow('require an agent id')
|
|
11
|
+
expect(() => setLoaderConfig('', {})).toThrow('require an agent id')
|
|
12
|
+
expect(() => getLoaderConfig('')).toThrow('require an agent id')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('set/getLoaderConfig works correctly', () => {
|
|
16
|
+
expect(() => setLoaderConfig(123, { trustKey: 1 })).not.toThrow() // notice setLoaderConfig accepts numbers
|
|
17
|
+
let cachedObj = getLoaderConfig('123')
|
|
18
|
+
expect(Object.keys(cachedObj).length).toBeGreaterThan(1)
|
|
19
|
+
expect(cachedObj.trustKey).toEqual(1)
|
|
20
|
+
expect(cachedObj.xpid).toBeUndefined() // this should mirror default in loader-config.js
|
|
21
|
+
})
|
|
@@ -5,8 +5,6 @@ import { BUILD_ENV, DIST_METHOD, VERSION } from '../../constants/env'
|
|
|
5
5
|
|
|
6
6
|
const model = {
|
|
7
7
|
buildEnv: BUILD_ENV,
|
|
8
|
-
bytesSent: {}, // Used for SM to capture body bytes sent per endpoint
|
|
9
|
-
queryBytesSent: {}, // Used for SM to capture query parameter bytes sent per endpoint
|
|
10
8
|
customTransaction: undefined,
|
|
11
9
|
disabled: false,
|
|
12
10
|
distMethod: DIST_METHOD,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
let getRuntime, setRuntime
|
|
2
|
+
beforeEach(async () => {
|
|
3
|
+
jest.resetModules()
|
|
4
|
+
;({ getRuntime, setRuntime } = await import('./runtime.js'))
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
test('set/getRuntime should throw on an invalid agent id', () => {
|
|
8
|
+
// currently only checks if it's a truthy value
|
|
9
|
+
expect(() => setRuntime(undefined, {})).toThrow('require an agent id')
|
|
10
|
+
expect(() => getRuntime(undefined)).toThrow('require an agent id')
|
|
11
|
+
expect(() => setRuntime('', {})).toThrow('require an agent id')
|
|
12
|
+
expect(() => getRuntime('')).toThrow('require an agent id')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('set/getRuntime works correctly', () => {
|
|
16
|
+
expect(() => setRuntime(123, { session: 1 })).not.toThrow() // notice setRuntime accepts numbers
|
|
17
|
+
let cachedObj = getRuntime('123')
|
|
18
|
+
expect(Object.keys(cachedObj).length).toBeGreaterThan(1)
|
|
19
|
+
expect(cachedObj.session).toEqual(1)
|
|
20
|
+
expect(cachedObj.maxBytes).toEqual(30000) // this should mirror default in runtime.js
|
|
21
|
+
})
|
|
@@ -3,6 +3,6 @@ export const isWorkerScope = false
|
|
|
3
3
|
export const globalScope = window
|
|
4
4
|
export const initialLocation = '' + globalScope?.location
|
|
5
5
|
export const isiOS = false
|
|
6
|
-
export const
|
|
6
|
+
export const iOSBelow16 = false
|
|
7
7
|
export const ffVersion = 0
|
|
8
8
|
export const supportsSendBeacon = true
|
|
@@ -55,7 +55,7 @@ export const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent)
|
|
|
55
55
|
* did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
|
|
56
56
|
* This was fixed in v16+.
|
|
57
57
|
*/
|
|
58
|
-
export const
|
|
58
|
+
export const iOSBelow16 = (isiOS && typeof SharedWorker === 'undefined')
|
|
59
59
|
|
|
60
60
|
export const ffVersion = (() => {
|
|
61
61
|
const match = navigator.userAgent.match(/Firefox[/\s](\d+\.\d+)/)
|
|
@@ -122,7 +122,7 @@ test.each([
|
|
|
122
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
123
|
{ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0', expected: false },
|
|
124
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
|
|
125
|
+
])('should set iOSBelow16 to $expected for $userAgent', async ({ userAgent, expected }) => {
|
|
126
126
|
if (!expected) {
|
|
127
127
|
global.SharedWorker = class SharedWorker {}
|
|
128
128
|
}
|
|
@@ -132,7 +132,7 @@ test.each([
|
|
|
132
132
|
|
|
133
133
|
delete global.SharedWorker
|
|
134
134
|
|
|
135
|
-
expect(runtime.
|
|
135
|
+
expect(runtime.iOSBelow16).toEqual(expected)
|
|
136
136
|
})
|
|
137
137
|
|
|
138
138
|
test.each([
|
|
@@ -65,7 +65,7 @@ export function setDenyList (denyListConfig) {
|
|
|
65
65
|
host = url
|
|
66
66
|
pathname = ''
|
|
67
67
|
}
|
|
68
|
-
let [hostname
|
|
68
|
+
let [hostname] = host.split(':')
|
|
69
69
|
|
|
70
70
|
denyList.push({ hostname, pathname })
|
|
71
71
|
}
|
|
@@ -81,11 +81,7 @@ function domainMatchesPattern (pattern, domain) {
|
|
|
81
81
|
return false
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
return true
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return false
|
|
84
|
+
return domain.indexOf(pattern) === (domain.length - pattern.length)
|
|
89
85
|
}
|
|
90
86
|
|
|
91
87
|
/**
|
|
@@ -108,9 +104,5 @@ function comparePath (pattern, path) {
|
|
|
108
104
|
return true
|
|
109
105
|
}
|
|
110
106
|
|
|
111
|
-
|
|
112
|
-
return true
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return false
|
|
107
|
+
return pattern === path
|
|
116
108
|
}
|