@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable n/handle-callback-err */
|
|
2
|
+
|
|
1
3
|
import { warn } from '../common/util/console'
|
|
2
4
|
|
|
3
5
|
export class AgentBase {
|
|
@@ -51,6 +53,18 @@ export class AgentBase {
|
|
|
51
53
|
warn('Call to agent api setUserId failed. The js errors feature is not currently initialized.')
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Adds a user-defined application version string to subsequent events on the page.
|
|
58
|
+
* This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
|
|
59
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
|
|
60
|
+
* @param {string|null} value A string identifier for the application version, useful for
|
|
61
|
+
* tying all browser events to a specific release tag. The value parameter does not
|
|
62
|
+
* have to be unique. Passing a null value unsets any existing value.
|
|
63
|
+
*/
|
|
64
|
+
setApplicationVersion (value) {
|
|
65
|
+
warn('Call to agent api setApplicationVersion failed. The agent is not currently initialized.')
|
|
66
|
+
}
|
|
67
|
+
|
|
54
68
|
/**
|
|
55
69
|
* Allows selective ignoring and grouping of known errors that the browser agent captures.
|
|
56
70
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
|
|
@@ -78,4 +92,13 @@ export class AgentBase {
|
|
|
78
92
|
addRelease (name, id) {
|
|
79
93
|
warn('Call to agent api addRelease failed. The agent is not currently initialized.')
|
|
80
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Starts a set of agent features if not running in "autoStart" mode
|
|
98
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
|
|
99
|
+
* @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
|
|
100
|
+
*/
|
|
101
|
+
start (featureNames) {
|
|
102
|
+
warn('Call to agent api addRelease failed. The agent is not currently initialized.')
|
|
103
|
+
}
|
|
81
104
|
}
|
package/src/loaders/agent.js
CHANGED
|
@@ -46,7 +46,7 @@ export class Agent extends AgentBase {
|
|
|
46
46
|
|
|
47
47
|
Object.assign(this, configure(this.agentIdentifier, options, options.loaderType || 'agent'))
|
|
48
48
|
|
|
49
|
-
this.
|
|
49
|
+
this.run()
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
get config () {
|
|
@@ -58,20 +58,20 @@ export class Agent extends AgentBase {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
run () {
|
|
62
62
|
const NR_FEATURES_REF_NAME = 'features'
|
|
63
63
|
// Attempt to initialize all the requested features (sequentially in prio order & synchronously), with any failure aborting the whole process.
|
|
64
64
|
try {
|
|
65
65
|
const enabledFeatures = getEnabledFeatures(this.agentIdentifier)
|
|
66
66
|
const featuresToStart = [...this.desiredFeatures]
|
|
67
67
|
featuresToStart.sort((a, b) => featurePriority[a.featureName] - featurePriority[b.featureName])
|
|
68
|
-
featuresToStart.forEach(
|
|
68
|
+
featuresToStart.forEach(InstrumentCtor => {
|
|
69
69
|
// pageViewEvent must be enabled because RUM calls are not optional. See comment in constructor and PR 428.
|
|
70
|
-
if (enabledFeatures[
|
|
71
|
-
const dependencies = getFeatureDependencyNames(
|
|
70
|
+
if (enabledFeatures[InstrumentCtor.featureName] || InstrumentCtor.featureName === FEATURE_NAMES.pageViewEvent) {
|
|
71
|
+
const dependencies = getFeatureDependencyNames(InstrumentCtor.featureName)
|
|
72
72
|
const hasAllDeps = dependencies.every(x => enabledFeatures[x])
|
|
73
|
-
if (!hasAllDeps) warn(`${
|
|
74
|
-
this.features[
|
|
73
|
+
if (!hasAllDeps) warn(`${InstrumentCtor.featureName} is enabled but one or more dependent features has been disabled (${stringify(dependencies)}). This may cause unintended consequences or missing data...`)
|
|
74
|
+
this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator)
|
|
75
75
|
}
|
|
76
76
|
})
|
|
77
77
|
gosNREUMInitializedAgents(this.agentIdentifier, this.features, NR_FEATURES_REF_NAME)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { setAPI } from './api'
|
|
2
|
+
import { setInfo, getInfo, setConfiguration } from '../../common/config/config'
|
|
3
|
+
|
|
4
|
+
setInfo('abcd', { licenseKey: '1234', applicationID: '1234' })
|
|
5
|
+
setConfiguration('abcd', {})
|
|
6
|
+
let apiInterface
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
console.warn = jest.fn()
|
|
9
|
+
apiInterface = setAPI('abcd', true)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
jest.restoreAllMocks()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('api', () => {
|
|
17
|
+
describe('setApplicationVersion', () => {
|
|
18
|
+
test('setApplicationVersion sets and unsets ja with valid values', () => {
|
|
19
|
+
apiInterface.setApplicationVersion('1.2.3')
|
|
20
|
+
expect(getInfo('abcd').jsAttributes).toMatchObject({ 'application.version': '1.2.3' })
|
|
21
|
+
|
|
22
|
+
apiInterface.setApplicationVersion(null)
|
|
23
|
+
expect(getInfo('abcd').jsAttributes).toMatchObject({ })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('setApplicationVersion warns if invalid data is supplied', () => {
|
|
27
|
+
apiInterface.setApplicationVersion(1)
|
|
28
|
+
expect(console.warn).toHaveBeenCalledWith('New Relic: Failed to execute setApplicationVersion. Expected <String | null>, but got <number>.')
|
|
29
|
+
|
|
30
|
+
apiInterface.setApplicationVersion(false)
|
|
31
|
+
expect(console.warn).toHaveBeenCalledWith('New Relic: Failed to execute setApplicationVersion. Expected <String | null>, but got <boolean>.')
|
|
32
|
+
|
|
33
|
+
apiInterface.setApplicationVersion({ version: '1.2.3' })
|
|
34
|
+
expect(console.warn).toHaveBeenCalledWith('New Relic: Failed to execute setApplicationVersion. Expected <String | null>, but got <object>.')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('setApplicationVersion replaces existing data if called twice', () => {
|
|
38
|
+
apiInterface.setApplicationVersion('1.2.3')
|
|
39
|
+
expect(getInfo('abcd').jsAttributes).toMatchObject({ 'application.version': '1.2.3' })
|
|
40
|
+
|
|
41
|
+
apiInterface.setApplicationVersion('4.5.6')
|
|
42
|
+
expect(getInfo('abcd').jsAttributes).toMatchObject({ 'application.version': '4.5.6' })
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
})
|
package/src/loaders/api/api.js
CHANGED
|
@@ -21,7 +21,7 @@ export function setTopLevelCallers () {
|
|
|
21
21
|
const funcs = [
|
|
22
22
|
'setErrorHandler', 'finished', 'addToTrace', 'inlineHit', 'addRelease',
|
|
23
23
|
'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute',
|
|
24
|
-
'interaction', 'noticeError', 'setUserId'
|
|
24
|
+
'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start'
|
|
25
25
|
]
|
|
26
26
|
funcs.forEach(f => {
|
|
27
27
|
nr[f] = (...args) => caller(f, ...args)
|
|
@@ -56,7 +56,7 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
56
56
|
var spaPrefix = prefix + 'ixn-'
|
|
57
57
|
|
|
58
58
|
// Setup stub functions that queue calls for later processing.
|
|
59
|
-
asyncApiFns.forEach(fnName => apiInterface[fnName] = apiCall(prefix, fnName, true, 'api'))
|
|
59
|
+
asyncApiFns.forEach(fnName => { apiInterface[fnName] = apiCall(prefix, fnName, true, 'api') })
|
|
60
60
|
|
|
61
61
|
apiInterface.addPageAction = apiCall(prefix, 'addPageAction', true, FEATURE_NAMES.pageAction)
|
|
62
62
|
apiInterface.setCurrentRouteName = apiCall(prefix, 'routeName', true, FEATURE_NAMES.spa)
|
|
@@ -109,6 +109,36 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
109
109
|
return appendJsAttribute('enduser.id', value, 'setUserId', true)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Attach the 'applcation.version' attribute onto agent payloads. This may be used in NR queries to group all browser events by a specific customer-defined release.
|
|
114
|
+
* @param {string|null} value - Application version -- if null, will "unset" the value
|
|
115
|
+
* @returns @see apiCall
|
|
116
|
+
*/
|
|
117
|
+
apiInterface.setApplicationVersion = function (value) {
|
|
118
|
+
if (!(typeof value === 'string' || value === null)) {
|
|
119
|
+
warn(`Failed to execute setApplicationVersion. Expected <String | null>, but got <${typeof value}>.`)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
return appendJsAttribute('application.version', value, 'setApplicationVersion', false)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
apiInterface.start = (features) => {
|
|
126
|
+
try {
|
|
127
|
+
const featNames = Object.values(FEATURE_NAMES)
|
|
128
|
+
if (features === undefined) features = featNames
|
|
129
|
+
else {
|
|
130
|
+
features = Array.isArray(features) && features.length ? features : [features]
|
|
131
|
+
if (features.some(f => !featNames.includes(f))) return warn(`Invalid feature name supplied. Acceptable feature names are: ${featNames}`)
|
|
132
|
+
if (!features.includes(FEATURE_NAMES.pageViewEvent)) features.push(FEATURE_NAMES.pageViewEvent)
|
|
133
|
+
}
|
|
134
|
+
features.forEach(feature => {
|
|
135
|
+
instanceEE.emit(`${feature}-opt-in`)
|
|
136
|
+
})
|
|
137
|
+
} catch (err) {
|
|
138
|
+
warn('An unexpected issue occurred', err)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
112
142
|
apiInterface.interaction = function () {
|
|
113
143
|
return new InteractionHandle().get()
|
|
114
144
|
}
|
|
@@ -138,7 +168,7 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
138
168
|
}
|
|
139
169
|
}
|
|
140
170
|
|
|
141
|
-
|
|
171
|
+
;['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
|
|
142
172
|
InteractionApiProto[name] = apiCall(spaPrefix, name, undefined, FEATURE_NAMES.spa)
|
|
143
173
|
})
|
|
144
174
|
|
|
@@ -146,7 +176,7 @@ export function setAPI (agentIdentifier, forceDrain) {
|
|
|
146
176
|
return function () {
|
|
147
177
|
handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/' + name + '/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
|
|
148
178
|
if (bufferGroup) handle(prefix + name, [now(), ...arguments], notSpa ? null : this, bufferGroup, instanceEE) // no bufferGroup means only the SM is emitted
|
|
149
|
-
return notSpa ?
|
|
179
|
+
return notSpa ? undefined : this
|
|
150
180
|
}
|
|
151
181
|
}
|
|
152
182
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { setTopLevelCallers, setAPI } from './api'
|
|
2
|
+
import { gosCDN } from '../../common/window/nreum'
|
|
3
|
+
|
|
4
|
+
jest.enableAutomock()
|
|
5
|
+
jest.unmock('./api')
|
|
6
|
+
|
|
7
|
+
describe('setTopLevelCallers', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
delete gosCDN().initializedAgents
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('adds all api methods', () => {
|
|
13
|
+
setTopLevelCallers()
|
|
14
|
+
|
|
15
|
+
expect(Object.keys(gosCDN()).length).toEqual(14)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('and runs the corresponding fn under every exposed agent', () => {
|
|
19
|
+
let newrelic = gosCDN()
|
|
20
|
+
newrelic.initializedAgents = {
|
|
21
|
+
abcd: { exposed: true, api: { noticeError: jest.fn() } },
|
|
22
|
+
efgh: { exposed: false, api: { noticeError: jest.fn() } },
|
|
23
|
+
ijkl: { exposed: true, api: { noticeError: jest.fn() } }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const someArgs = ['wtfish', { bop: 'it' }]
|
|
27
|
+
newrelic.noticeError(...someArgs)
|
|
28
|
+
expect(newrelic.initializedAgents.abcd.api.noticeError).toHaveBeenCalledWith(...someArgs)
|
|
29
|
+
expect(newrelic.initializedAgents.efgh.api.noticeError).not.toHaveBeenCalled()
|
|
30
|
+
expect(newrelic.initializedAgents.ijkl.api.noticeError).toHaveBeenCalledWith(...someArgs)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('fn call returns right number of results based on running agent(s)', () => {
|
|
34
|
+
let newrelic = gosCDN()
|
|
35
|
+
newrelic.initializedAgents = {
|
|
36
|
+
abcd: { exposed: true, api: { interaction: jest.fn(() => 'duck') } }
|
|
37
|
+
}
|
|
38
|
+
let ret = newrelic.interaction()
|
|
39
|
+
expect(ret).toEqual('duck')
|
|
40
|
+
|
|
41
|
+
newrelic.initializedAgents.efgh = { exposed: true, api: { interaction: jest.fn(() => 'truck') } }
|
|
42
|
+
ret = newrelic.interaction()
|
|
43
|
+
expect(ret).toEqual(['duck', 'truck'])
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
jest.unmock('../../common/event-emitter/contextual-ee')
|
|
48
|
+
jest.mock('../../common/constants/runtime', () => {
|
|
49
|
+
return {
|
|
50
|
+
__esModule: true,
|
|
51
|
+
isBrowserScope: false
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('setAPI', () => {
|
|
56
|
+
test('also adds all api methods', () => {
|
|
57
|
+
let apiI = setAPI('abcd', true)
|
|
58
|
+
|
|
59
|
+
expect(Object.keys(apiI).length).toEqual(14)
|
|
60
|
+
for (const k of Object.keys(apiI)) { expect(apiI[k]).toBeInstanceOf(Function) }
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('sets up spa interaction api prototype/handle', () => {
|
|
64
|
+
let apiI = setAPI('abcd', true)
|
|
65
|
+
let interactionProto = Object.getPrototypeOf(apiI.interaction())
|
|
66
|
+
|
|
67
|
+
expect(Object.keys(interactionProto).length).toEqual(10)
|
|
68
|
+
for (const k of Object.keys(interactionProto)) { expect(interactionProto[k]).toBeInstanceOf(Function) }
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('calls asyncApi setAPI as well', async () => {
|
|
72
|
+
jest.resetModules()
|
|
73
|
+
let setApiCalled
|
|
74
|
+
let asyncSetApi = new Promise(resolve => { setApiCalled = resolve })
|
|
75
|
+
jest.doMock('./apiAsync', () => {
|
|
76
|
+
return {
|
|
77
|
+
__esModule: true,
|
|
78
|
+
setAPI: jest.fn(id => setApiCalled(id))
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
setAPI('abcd', true)
|
|
83
|
+
await expect(asyncSetApi).resolves.toBe('abcd')
|
|
84
|
+
})
|
|
85
|
+
})
|
|
@@ -16,10 +16,10 @@ export function setAPI (agentIdentifier) {
|
|
|
16
16
|
|
|
17
17
|
var api = {
|
|
18
18
|
finished: single(finished),
|
|
19
|
-
setErrorHandler
|
|
20
|
-
addToTrace
|
|
21
|
-
inlineHit
|
|
22
|
-
addRelease
|
|
19
|
+
setErrorHandler,
|
|
20
|
+
addToTrace,
|
|
21
|
+
inlineHit,
|
|
22
|
+
addRelease
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Hook all of the api functions up to the queues/stubs created in loader/api.js
|
|
@@ -49,33 +49,32 @@ export function setAPI (agentIdentifier) {
|
|
|
49
49
|
handle('bstApi', [report], undefined, FEATURE_NAMES.sessionTrace, instanceEE)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// NREUM.inlineHit(
|
|
52
|
+
// NREUM.inlineHit(requestName, queueTime, appTime, totalBackEndTime, domTime, frontEndTime)
|
|
53
53
|
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
function inlineHit (t,
|
|
54
|
+
// requestName - the 'web page' name or service name
|
|
55
|
+
// queueTime - the amount of time spent in the app tier queue
|
|
56
|
+
// appTime - the amount of time spent in the application code
|
|
57
|
+
// totalBackEndTime - the total roundtrip time of the remote service call
|
|
58
|
+
// domTime - the time spent processing the result of the service call (or user defined)
|
|
59
|
+
// frontEndTime - the time spent rendering the result of the service call (or user defined)
|
|
60
|
+
function inlineHit (t, requestName, queueTime, appTime, totalBackEndTime, domTime, frontEndTime) {
|
|
61
61
|
if (!isBrowserScope) return
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
requestName = window.encodeURIComponent(requestName)
|
|
64
64
|
cycle += 1
|
|
65
65
|
|
|
66
66
|
const agentInfo = getInfo(agentIdentifier)
|
|
67
|
-
const agentRuntime = getRuntime(agentIdentifier)
|
|
68
67
|
if (!agentInfo.beacon) return
|
|
69
68
|
|
|
70
69
|
var url = scheme + '://' + agentInfo.beacon + '/1/' + agentInfo.licenseKey
|
|
71
70
|
|
|
72
71
|
url += '?a=' + agentInfo.applicationID + '&'
|
|
73
|
-
url += 't=' +
|
|
74
|
-
url += 'qt=' + ~~
|
|
75
|
-
url += 'ap=' + ~~
|
|
76
|
-
url += 'be=' + ~~
|
|
77
|
-
url += 'dc=' + ~~
|
|
78
|
-
url += 'fe=' + ~~
|
|
72
|
+
url += 't=' + requestName + '&'
|
|
73
|
+
url += 'qt=' + ~~queueTime + '&'
|
|
74
|
+
url += 'ap=' + ~~appTime + '&'
|
|
75
|
+
url += 'be=' + ~~totalBackEndTime + '&'
|
|
76
|
+
url += 'dc=' + ~~domTime + '&'
|
|
77
|
+
url += 'fe=' + ~~frontEndTime + '&'
|
|
79
78
|
url += 'c=' + cycle
|
|
80
79
|
|
|
81
80
|
submitData.xhr({ url })
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { setAPI } from './apiAsync'
|
|
2
|
+
import * as register from '../../common/event-emitter/register-handler'
|
|
3
|
+
|
|
4
|
+
jest.enableAutomock()
|
|
5
|
+
jest.unmock('./apiAsync')
|
|
6
|
+
jest.unmock('../../common/event-emitter/contextual-ee')
|
|
7
|
+
|
|
8
|
+
test('setAPI registers all async methods', () => {
|
|
9
|
+
let callSpy = jest.spyOn(register, 'registerHandler')
|
|
10
|
+
setAPI('abcd')
|
|
11
|
+
|
|
12
|
+
expect(callSpy).toHaveBeenCalledTimes(5)
|
|
13
|
+
for (let i = 0; i < 5; i++) {
|
|
14
|
+
expect(callSpy.mock.calls[i][0].startsWith('api-')).toBeTruthy()
|
|
15
|
+
expect(callSpy.mock.calls[i][1]).toBeInstanceOf(Function)
|
|
16
|
+
}
|
|
17
|
+
})
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @property {getContext} getContext
|
|
7
7
|
* @property {ignore} ignore
|
|
8
8
|
* @property {onEnd} onEnd
|
|
9
|
-
* @property {
|
|
9
|
+
* @property {save} save
|
|
10
10
|
* @property {setAttribute} setAttribute
|
|
11
11
|
* @property {setName} setName
|
|
12
12
|
*/
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/createtracer/}
|
|
25
25
|
* @callback createTracer
|
|
26
26
|
* @param {string} name This will be used as the name of the tracer.
|
|
27
|
-
* @param {
|
|
28
|
-
* @returns {
|
|
27
|
+
* @param {(...args: any[]) => any} [callback] A callback that contains the synchronous work to run at the end of the async work. To execute this callback, call the wrapper function returned using createTracer().
|
|
28
|
+
* @returns {(...args: any[]) => any} Returns a method that wraps the original callback. When this method is invoked, it calls the original callback and ends the async timing.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -43,6 +43,13 @@
|
|
|
43
43
|
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Overrides other SPA save() calls; ignores an interaction so it is not saved or sent to New Relic.
|
|
48
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/ignore/}
|
|
49
|
+
* @callback ignore
|
|
50
|
+
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
51
|
+
*/
|
|
52
|
+
|
|
46
53
|
/**
|
|
47
54
|
* Change the values associated with a SPA interaction before the interaction is saved.
|
|
48
55
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/onend/}
|
|
@@ -63,7 +70,7 @@
|
|
|
63
70
|
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setattribute/}
|
|
64
71
|
* @callback setAttribute
|
|
65
72
|
* @param {string} key Used as the attribute name on the BrowserInteraction event.
|
|
66
|
-
* @param {any}
|
|
73
|
+
* @param {any} value Used as the attribute value on the BrowserInteraction event. This can be a string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string.
|
|
67
74
|
* @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
|
|
68
75
|
*/
|
|
69
76
|
|
|
@@ -5,15 +5,18 @@ import { activatedFeatures } from '../../common/util/feature-flags'
|
|
|
5
5
|
import { isWorkerScope } from '../../common/constants/runtime'
|
|
6
6
|
|
|
7
7
|
export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
|
|
8
|
+
// eslint-disable-next-line camelcase
|
|
8
9
|
let { init, info, loader_config, runtime = { loaderType }, exposed = true } = opts
|
|
9
10
|
const nr = gosCDN()
|
|
10
11
|
if (!info) {
|
|
11
12
|
init = nr.init
|
|
12
13
|
info = nr.info
|
|
14
|
+
// eslint-disable-next-line camelcase
|
|
13
15
|
loader_config = nr.loader_config
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
setConfiguration(agentIdentifier, init || {})
|
|
19
|
+
// eslint-disable-next-line camelcase
|
|
17
20
|
setLoaderConfig(agentIdentifier, loader_config || {})
|
|
18
21
|
|
|
19
22
|
info.jsAttributes ??= {}
|
|
@@ -6,7 +6,7 @@ import { configure } from './configure/configure'
|
|
|
6
6
|
import { Aggregator } from '../common/aggregate/aggregator'
|
|
7
7
|
import { gosNREUMInitializedAgents } from '../common/window/nreum'
|
|
8
8
|
import { generateRandomHexString } from '../common/ids/unique-id'
|
|
9
|
-
import { getConfiguration, getInfo, getLoaderConfig, getRuntime } from '../common/config/config'
|
|
9
|
+
import { getConfiguration, getConfigurationValue, getInfo, getLoaderConfig, getRuntime } from '../common/config/config'
|
|
10
10
|
import { FEATURE_NAMES } from './features/features'
|
|
11
11
|
import { warn } from '../common/util/console'
|
|
12
12
|
import { onWindowLoad } from '../common/window/load'
|
|
@@ -37,7 +37,13 @@ export class MicroAgent extends AgentBase {
|
|
|
37
37
|
|
|
38
38
|
Object.assign(this, configure(this.agentIdentifier, { ...options, runtime: { isolatedBacklog: true } }, options.loaderType || 'micro-agent'))
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Starts a set of agent features if not running in "autoStart" mode
|
|
42
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
|
|
43
|
+
* @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
|
|
44
|
+
*/
|
|
45
|
+
this.start = features => this.run(features)
|
|
46
|
+
this.run(nonAutoFeatures.filter(featureName => getConfigurationValue(agentIdentifier, `${featureName}.autoStart`)))
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
get config () {
|
|
@@ -49,7 +55,19 @@ export class MicroAgent extends AgentBase {
|
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
run (features) {
|
|
59
|
+
try {
|
|
60
|
+
const featNames = nonAutoFeatures
|
|
61
|
+
if (features === undefined) features = featNames
|
|
62
|
+
else {
|
|
63
|
+
features = Array.isArray(features) && features.length ? features : [features]
|
|
64
|
+
if (features.some(f => !featNames.includes(f))) return warn(`Invalid feature name supplied. Acceptable feature names are: ${featNames}`)
|
|
65
|
+
if (!features.includes(FEATURE_NAMES.pageViewEvent)) features.push(FEATURE_NAMES.pageViewEvent)
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
warn('An unexpected issue occurred', err)
|
|
69
|
+
}
|
|
70
|
+
|
|
53
71
|
try {
|
|
54
72
|
const enabledFeatures = getEnabledFeatures(this.agentIdentifier)
|
|
55
73
|
|
|
@@ -63,7 +81,7 @@ export class MicroAgent extends AgentBase {
|
|
|
63
81
|
onWindowLoad(() => {
|
|
64
82
|
// these features do not import an "instrument" file, meaning they are only hooked up to the API.
|
|
65
83
|
nonAutoFeatures.forEach(f => {
|
|
66
|
-
if (enabledFeatures[f]) {
|
|
84
|
+
if (enabledFeatures[f] && features.includes(f)) {
|
|
67
85
|
import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
|
|
68
86
|
return lazyFeatureLoader(f, 'aggregate')
|
|
69
87
|
}).then(({ Aggregate }) => {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.endpointMap = void 0;
|
|
7
|
-
const endpointMap = {
|
|
8
|
-
rum: '1',
|
|
9
|
-
events: 'Events',
|
|
10
|
-
ins: 'Ins',
|
|
11
|
-
jserrors: 'Jserrors',
|
|
12
|
-
resources: 'Resources'
|
|
13
|
-
};
|
|
14
|
-
exports.endpointMap = endpointMap;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getPolyfills = getPolyfills;
|
|
7
|
-
/**
|
|
8
|
-
* This file is used as a replacement for the polyfill-detection.es5.js
|
|
9
|
-
* file when running the polyfills webpack build.
|
|
10
|
-
* @returns {string[]} an empty array
|
|
11
|
-
*/
|
|
12
|
-
function getPolyfills() {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getPolyfills = getPolyfills;
|
|
7
|
-
const detectionRegex = /\{ \[native code\] \}/;
|
|
8
|
-
const POLYFILLS = {
|
|
9
|
-
FUNCTION_BIND: 'Function.bind',
|
|
10
|
-
FUNCTION_APPLY: 'Function.apply',
|
|
11
|
-
FUNCTION_CALL: 'Function.call',
|
|
12
|
-
ARRAY_INCLUDES: 'Array.includes',
|
|
13
|
-
ARRAY_FROM: 'Array.from',
|
|
14
|
-
ARRAY_FIND: 'Array.find',
|
|
15
|
-
ARRAY_FLAT: 'Array.flat',
|
|
16
|
-
ARRAY_FLATMAP: 'Array.flatMap',
|
|
17
|
-
OBJECT_ASSIGN: 'Object.assign',
|
|
18
|
-
OBJECT_ENTRIES: 'Object.entries',
|
|
19
|
-
OBJECT_VALUES: 'Object.values',
|
|
20
|
-
MAP: 'Map',
|
|
21
|
-
SET: 'Set',
|
|
22
|
-
WEAK_MAP: 'WeakMap',
|
|
23
|
-
WEAK_SET: 'WeakSet'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Checks for native globals to see if they have been polyfilled by customer code.
|
|
28
|
-
* @returns {string[]} Array of methods that were detected to have been polyfilled
|
|
29
|
-
*/
|
|
30
|
-
function getPolyfills() {
|
|
31
|
-
const polyfills = [];
|
|
32
|
-
const mockFunction = function () {/* noop */};
|
|
33
|
-
try {
|
|
34
|
-
if (typeof mockFunction.bind === 'function' && !detectionRegex.test(mockFunction.bind.toString())) polyfills.push(POLYFILLS.FUNCTION_BIND);
|
|
35
|
-
if (typeof mockFunction.apply === 'function' && !detectionRegex.test(mockFunction.apply.toString())) polyfills.push(POLYFILLS.FUNCTION_APPLY);
|
|
36
|
-
if (typeof mockFunction.call === 'function' && !detectionRegex.test(mockFunction.call.toString())) polyfills.push(POLYFILLS.FUNCTION_CALL);
|
|
37
|
-
if (typeof [].includes === 'function' && !detectionRegex.test([].includes.toString())) polyfills.push(POLYFILLS.ARRAY_INCLUDES);
|
|
38
|
-
if (typeof Array.from === 'function' && !detectionRegex.test(Array.from.toString())) polyfills.push(POLYFILLS.ARRAY_FROM);
|
|
39
|
-
if (typeof [].find === 'function' && !detectionRegex.test([].find.toString())) polyfills.push(POLYFILLS.ARRAY_FIND);
|
|
40
|
-
if (typeof [].flat === 'function' && !detectionRegex.test([].flat.toString())) polyfills.push(POLYFILLS.ARRAY_FLAT);
|
|
41
|
-
if (typeof [].flatMap === 'function' && !detectionRegex.test([].flatMap.toString())) polyfills.push(POLYFILLS.ARRAY_FLATMAP);
|
|
42
|
-
if (typeof Object.assign === 'function' && !detectionRegex.test(Object.assign.toString())) polyfills.push(POLYFILLS.OBJECT_ASSIGN);
|
|
43
|
-
if (typeof Object.entries === 'function' && !detectionRegex.test(Object.entries.toString())) polyfills.push(POLYFILLS.OBJECT_ENTRIES);
|
|
44
|
-
if (typeof Object.values === 'function' && !detectionRegex.test(Object.values.toString())) polyfills.push(POLYFILLS.OBJECT_VALUES);
|
|
45
|
-
if (typeof Map === 'function' && !detectionRegex.test(Map.toString())) polyfills.push(POLYFILLS.MAP);
|
|
46
|
-
if (typeof Set === 'function' && !detectionRegex.test(Set.toString())) polyfills.push(POLYFILLS.SET);
|
|
47
|
-
if (typeof WeakMap === 'function' && !detectionRegex.test(WeakMap.toString())) polyfills.push(POLYFILLS.WEAK_MAP);
|
|
48
|
-
if (typeof WeakSet === 'function' && !detectionRegex.test(WeakSet.toString())) polyfills.push(POLYFILLS.WEAK_SET);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
// Possibly not supported
|
|
51
|
-
}
|
|
52
|
-
return polyfills;
|
|
53
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const detectionRegex = /\{ \[native code\] \}/;
|
|
2
|
-
const POLYFILLS = {
|
|
3
|
-
FUNCTION_BIND: 'Function.bind',
|
|
4
|
-
FUNCTION_APPLY: 'Function.apply',
|
|
5
|
-
FUNCTION_CALL: 'Function.call',
|
|
6
|
-
ARRAY_INCLUDES: 'Array.includes',
|
|
7
|
-
ARRAY_FROM: 'Array.from',
|
|
8
|
-
ARRAY_FIND: 'Array.find',
|
|
9
|
-
ARRAY_FLAT: 'Array.flat',
|
|
10
|
-
ARRAY_FLATMAP: 'Array.flatMap',
|
|
11
|
-
OBJECT_ASSIGN: 'Object.assign',
|
|
12
|
-
OBJECT_ENTRIES: 'Object.entries',
|
|
13
|
-
OBJECT_VALUES: 'Object.values',
|
|
14
|
-
MAP: 'Map',
|
|
15
|
-
SET: 'Set',
|
|
16
|
-
WEAK_MAP: 'WeakMap',
|
|
17
|
-
WEAK_SET: 'WeakSet'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Checks for native globals to see if they have been polyfilled by customer code.
|
|
22
|
-
* @returns {string[]} Array of methods that were detected to have been polyfilled
|
|
23
|
-
*/
|
|
24
|
-
export function getPolyfills() {
|
|
25
|
-
const polyfills = [];
|
|
26
|
-
const mockFunction = function () {/* noop */};
|
|
27
|
-
try {
|
|
28
|
-
if (typeof mockFunction.bind === 'function' && !detectionRegex.test(mockFunction.bind.toString())) polyfills.push(POLYFILLS.FUNCTION_BIND);
|
|
29
|
-
if (typeof mockFunction.apply === 'function' && !detectionRegex.test(mockFunction.apply.toString())) polyfills.push(POLYFILLS.FUNCTION_APPLY);
|
|
30
|
-
if (typeof mockFunction.call === 'function' && !detectionRegex.test(mockFunction.call.toString())) polyfills.push(POLYFILLS.FUNCTION_CALL);
|
|
31
|
-
if (typeof [].includes === 'function' && !detectionRegex.test([].includes.toString())) polyfills.push(POLYFILLS.ARRAY_INCLUDES);
|
|
32
|
-
if (typeof Array.from === 'function' && !detectionRegex.test(Array.from.toString())) polyfills.push(POLYFILLS.ARRAY_FROM);
|
|
33
|
-
if (typeof [].find === 'function' && !detectionRegex.test([].find.toString())) polyfills.push(POLYFILLS.ARRAY_FIND);
|
|
34
|
-
if (typeof [].flat === 'function' && !detectionRegex.test([].flat.toString())) polyfills.push(POLYFILLS.ARRAY_FLAT);
|
|
35
|
-
if (typeof [].flatMap === 'function' && !detectionRegex.test([].flatMap.toString())) polyfills.push(POLYFILLS.ARRAY_FLATMAP);
|
|
36
|
-
if (typeof Object.assign === 'function' && !detectionRegex.test(Object.assign.toString())) polyfills.push(POLYFILLS.OBJECT_ASSIGN);
|
|
37
|
-
if (typeof Object.entries === 'function' && !detectionRegex.test(Object.entries.toString())) polyfills.push(POLYFILLS.OBJECT_ENTRIES);
|
|
38
|
-
if (typeof Object.values === 'function' && !detectionRegex.test(Object.values.toString())) polyfills.push(POLYFILLS.OBJECT_VALUES);
|
|
39
|
-
if (typeof Map === 'function' && !detectionRegex.test(Map.toString())) polyfills.push(POLYFILLS.MAP);
|
|
40
|
-
if (typeof Set === 'function' && !detectionRegex.test(Set.toString())) polyfills.push(POLYFILLS.SET);
|
|
41
|
-
if (typeof WeakMap === 'function' && !detectionRegex.test(WeakMap.toString())) polyfills.push(POLYFILLS.WEAK_MAP);
|
|
42
|
-
if (typeof WeakSet === 'function' && !detectionRegex.test(WeakSet.toString())) polyfills.push(POLYFILLS.WEAK_SET);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
// Possibly not supported
|
|
45
|
-
}
|
|
46
|
-
return polyfills;
|
|
47
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-map.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/endpoint-map.js"],"names":[],"mappings":""}
|