@newrelic/browser-agent 1.232.1 → 1.233.1
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/cdn/experimental.js +27 -0
- package/dist/cjs/cdn/polyfills.js +5 -2
- package/dist/cjs/common/config/state/configurable.js +15 -26
- package/dist/cjs/common/config/state/info.js +1 -1
- package/dist/cjs/common/config/state/init.js +101 -56
- package/dist/cjs/common/config/state/loader-config.js +1 -1
- package/dist/cjs/common/config/state/runtime.js +1 -5
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/drain/drain.js +1 -1
- package/dist/cjs/common/harvest/harvest-scheduler.js +43 -8
- package/dist/cjs/common/harvest/harvest-scheduler.test.js +39 -0
- package/dist/cjs/common/harvest/harvest.js +106 -55
- package/dist/cjs/common/session/session-entity.js +35 -22
- package/dist/cjs/common/session/session-entity.test.js +73 -49
- package/dist/cjs/common/timer/interaction-timer.js +9 -12
- package/dist/cjs/common/url/protocol.test.js +0 -1
- package/dist/cjs/common/util/feature-flags.js +2 -1
- package/dist/cjs/common/util/submit-data.js +57 -18
- package/dist/cjs/common/wrap/wrap-fetch.js +1 -1
- package/dist/cjs/common/wrap/wrap-function.js +1 -1
- package/dist/cjs/common/wrap/wrap-promise.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +2 -2
- package/dist/cjs/features/jserrors/aggregate/index.js +7 -5
- package/dist/cjs/features/metrics/aggregate/framework-detection.js +67 -0
- package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +137 -0
- package/dist/cjs/features/metrics/aggregate/index.js +7 -3
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +14 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +17 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +53 -0
- package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +165 -0
- package/dist/cjs/features/page_action/aggregate/index.js +2 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
- package/dist/cjs/features/page_view_timing/aggregate/index.js +2 -2
- package/dist/cjs/features/session_replay/aggregate/index.js +336 -0
- package/dist/cjs/features/session_replay/constants.js +9 -0
- package/dist/cjs/features/session_replay/index.js +12 -0
- package/dist/cjs/features/session_replay/instrument/index.js +29 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +163 -162
- package/dist/cjs/features/session_trace/constants.js +2 -9
- package/dist/cjs/features/session_trace/instrument/index.js +24 -66
- package/dist/cjs/features/spa/aggregate/index.js +2 -2
- package/dist/cjs/features/utils/agent-session.js +1 -2
- package/dist/cjs/features/utils/aggregate-base.js +64 -0
- package/dist/cjs/features/utils/feature-base.js +0 -31
- package/dist/cjs/features/utils/handler-cache.js +3 -4
- package/dist/cjs/features/utils/instrument-base.js +42 -10
- package/dist/cjs/features/utils/{lazy-loader.js → lazy-feature-loader.js} +4 -2
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/apiAsync.js +3 -1
- package/dist/cjs/loaders/configure/configure.js +3 -3
- package/dist/cjs/loaders/features/featureDependencies.js +0 -12
- package/dist/cjs/loaders/features/features.js +3 -1
- package/dist/cjs/loaders/micro-agent.js +6 -6
- package/dist/esm/cdn/experimental.js +24 -0
- package/dist/esm/cdn/polyfills.js +5 -2
- package/dist/esm/common/config/state/configurable.js +14 -24
- package/dist/esm/common/config/state/info.js +2 -2
- package/dist/esm/common/config/state/init.js +102 -57
- package/dist/esm/common/config/state/loader-config.js +2 -2
- package/dist/esm/common/config/state/runtime.js +2 -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/drain/drain.js +1 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +43 -8
- package/dist/esm/common/harvest/harvest-scheduler.test.js +37 -0
- package/dist/esm/common/harvest/harvest.js +108 -56
- package/dist/esm/common/session/session-entity.js +35 -22
- package/dist/esm/common/session/session-entity.test.js +73 -49
- package/dist/esm/common/timer/interaction-timer.js +9 -12
- package/dist/esm/common/url/protocol.test.js +0 -1
- package/dist/esm/common/util/feature-flags.js +2 -1
- package/dist/esm/common/util/submit-data.js +57 -18
- package/dist/esm/common/wrap/wrap-fetch.js +1 -1
- package/dist/esm/common/wrap/wrap-function.js +1 -1
- package/dist/esm/common/wrap/wrap-promise.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +2 -2
- package/dist/esm/features/jserrors/aggregate/index.js +7 -5
- package/dist/esm/features/metrics/aggregate/framework-detection.js +61 -0
- package/dist/esm/features/metrics/aggregate/framework-detection.test.js +133 -0
- package/dist/esm/features/metrics/aggregate/index.js +7 -3
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +8 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +15 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.js +47 -0
- package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +163 -0
- package/dist/esm/features/page_action/aggregate/index.js +2 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +2 -2
- package/dist/esm/features/session_replay/aggregate/index.js +330 -0
- package/dist/esm/features/session_replay/constants.js +2 -0
- package/dist/esm/features/session_replay/index.js +12 -0
- package/dist/esm/features/session_replay/instrument/index.js +21 -0
- package/dist/esm/features/session_trace/aggregate/index.js +163 -162
- package/dist/esm/features/session_trace/constants.js +1 -5
- package/dist/esm/features/session_trace/instrument/index.js +24 -66
- package/dist/esm/features/spa/aggregate/index.js +2 -2
- package/dist/esm/features/utils/agent-session.js +1 -2
- package/dist/esm/features/utils/aggregate-base.js +57 -0
- package/dist/esm/features/utils/feature-base.js +1 -32
- package/dist/esm/features/utils/handler-cache.js +3 -4
- package/dist/esm/features/utils/instrument-base.js +42 -10
- package/dist/esm/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/apiAsync.js +3 -1
- package/dist/esm/loaders/configure/configure.js +3 -3
- package/dist/esm/loaders/features/featureDependencies.js +0 -11
- package/dist/esm/loaders/features/features.js +3 -1
- package/dist/esm/loaders/micro-agent.js +6 -6
- package/dist/types/cdn/experimental.d.ts +2 -0
- package/dist/types/cdn/experimental.d.ts.map +1 -0
- package/dist/types/common/config/state/configurable.d.ts +1 -3
- package/dist/types/common/config/state/configurable.d.ts.map +1 -1
- 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/harvest/harvest-scheduler.d.ts +26 -3
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts +37 -34
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts +6 -3
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.d.ts +2 -1
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/submit-data.d.ts +40 -14
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +6 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +7 -0
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -0
- 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 +2 -2
- 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 +2 -2
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +100 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -0
- package/dist/types/features/session_replay/constants.d.ts +2 -0
- package/dist/types/features/session_replay/constants.d.ts.map +1 -0
- package/dist/types/features/session_replay/index.d.ts +2 -0
- package/dist/types/features/session_replay/index.d.ts.map +1 -0
- package/dist/types/features/session_replay/instrument/index.d.ts +6 -0
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +8 -57
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +0 -3
- package/dist/types/features/session_trace/constants.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -3
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +2 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +11 -0
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
- package/dist/types/features/utils/feature-base.d.ts +0 -5
- package/dist/types/features/utils/feature-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 +3 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/features/utils/{lazy-loader.d.ts → lazy-feature-loader.d.ts} +2 -2
- package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/featureDependencies.d.ts +0 -1
- package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
- package/dist/types/loaders/features/features.d.ts +1 -0
- package/dist/types/loaders/features/features.d.ts.map +1 -1
- package/package.json +30 -20
- package/src/cdn/experimental.js +36 -0
- package/src/cdn/polyfills.js +4 -1
- package/src/common/config/state/configurable.js +18 -24
- package/src/common/config/state/info.js +2 -2
- package/src/common/config/state/init.js +62 -28
- package/src/common/config/state/loader-config.js +2 -2
- package/src/common/config/state/runtime.js +2 -4
- package/src/common/drain/drain.js +1 -1
- package/src/common/harvest/harvest-scheduler.js +48 -8
- package/src/common/harvest/harvest-scheduler.test.js +25 -0
- package/src/common/harvest/harvest.js +72 -50
- package/src/common/session/session-entity.js +34 -23
- package/src/common/session/session-entity.test.js +57 -51
- package/src/common/timer/interaction-timer.js +9 -12
- package/src/common/url/protocol.test.js +0 -1
- package/src/common/util/feature-flags.js +2 -2
- package/src/common/util/submit-data.js +28 -17
- package/src/common/wrap/wrap-fetch.js +1 -1
- package/src/common/wrap/wrap-function.js +1 -1
- package/src/common/wrap/wrap-promise.js +1 -1
- package/src/features/ajax/aggregate/index.js +2 -2
- package/src/features/jserrors/aggregate/index.js +7 -5
- package/src/features/metrics/aggregate/framework-detection.js +73 -0
- package/src/features/metrics/aggregate/framework-detection.test.js +201 -0
- package/src/features/metrics/aggregate/index.js +8 -3
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +9 -0
- package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +16 -0
- package/src/features/metrics/aggregate/polyfill-detection.js +48 -0
- package/src/features/metrics/aggregate/polyfill-detection.test.js +163 -0
- package/src/features/page_action/aggregate/index.js +2 -2
- package/src/features/page_view_event/aggregate/index.js +5 -5
- package/src/features/page_view_timing/aggregate/index.js +2 -2
- package/src/features/session_replay/aggregate/index.js +319 -0
- package/src/features/session_replay/constants.js +3 -0
- package/src/features/session_replay/index.js +12 -0
- package/src/features/session_replay/instrument/index.js +22 -0
- package/src/features/session_trace/aggregate/index.js +148 -187
- package/src/features/session_trace/constants.js +0 -4
- package/src/features/session_trace/instrument/index.js +17 -69
- package/src/features/spa/aggregate/index.js +2 -2
- package/src/features/utils/agent-session.js +1 -2
- package/src/features/utils/aggregate-base.js +51 -0
- package/src/features/utils/feature-base.js +1 -31
- package/src/features/utils/handler-cache.js +3 -4
- package/src/features/utils/instrument-base.js +40 -8
- package/src/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/apiAsync.js +1 -1
- package/src/loaders/configure/configure.js +4 -3
- package/src/loaders/features/featureDependencies.js +0 -12
- package/src/loaders/features/features.js +3 -1
- package/src/loaders/micro-agent.js +4 -4
- package/dist/cjs/common/metrics/framework-detection.js +0 -72
- package/dist/cjs/common/util/user-agent.js +0 -57
- package/dist/cjs/common/window/supports-performance-observer.js +0 -15
- package/dist/esm/common/metrics/framework-detection.js +0 -66
- package/dist/esm/common/util/user-agent.js +0 -48
- package/dist/esm/common/window/supports-performance-observer.js +0 -9
- package/dist/types/common/metrics/framework-detection.d.ts.map +0 -1
- package/dist/types/common/util/user-agent.d.ts +0 -5
- package/dist/types/common/util/user-agent.d.ts.map +0 -1
- package/dist/types/common/window/supports-performance-observer.d.ts +0 -2
- package/dist/types/common/window/supports-performance-observer.d.ts.map +0 -1
- package/dist/types/features/utils/lazy-loader.d.ts.map +0 -1
- package/src/common/metrics/framework-detection.js +0 -71
- package/src/common/util/user-agent.js +0 -56
- package/src/common/window/supports-performance-observer.js +0 -10
- /package/dist/types/{common/metrics → features/metrics/aggregate}/framework-detection.d.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _agent = require("../loaders/agent");
|
|
4
|
+
var _instrument = require("../features/page_view_event/instrument");
|
|
5
|
+
var _instrument2 = require("../features/page_view_timing/instrument");
|
|
6
|
+
var _instrument3 = require("../features/metrics/instrument");
|
|
7
|
+
var _instrument4 = require("../features/jserrors/instrument");
|
|
8
|
+
var _instrument5 = require("../features/ajax/instrument");
|
|
9
|
+
var _instrument6 = require("../features/session_trace/instrument");
|
|
10
|
+
var _instrument7 = require("../features/session_replay/instrument");
|
|
11
|
+
var _instrument8 = require("../features/spa/instrument");
|
|
12
|
+
var _instrument9 = require("../features/page_action/instrument");
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
15
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @file Creates an "EXPERIMENTAL" agent loader bundle composed of the core agent and all available feature modules, including experimental features.
|
|
19
|
+
*
|
|
20
|
+
* NOTE: This loader is ONLY used for internal testing. The code contained within is likely under development and dormant. It will not download to instrumented pages or record any data.
|
|
21
|
+
* It is not production ready, and is not intended to be imported or implemented in any build of the browser agent
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
new _agent.Agent({
|
|
25
|
+
features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument7.Instrument, _instrument3.Instrument, _instrument9.Instrument, _instrument4.Instrument, _instrument8.Instrument],
|
|
26
|
+
loaderType: 'experimental'
|
|
27
|
+
});
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
require("core-js/stable/promise");
|
|
4
4
|
require("core-js/stable/array/includes");
|
|
5
|
-
require("core-js/stable/array/from");
|
|
6
5
|
require("core-js/stable/array/find");
|
|
6
|
+
require("core-js/stable/array/flat");
|
|
7
|
+
require("core-js/stable/array/flat-map");
|
|
8
|
+
require("core-js/stable/array/from");
|
|
7
9
|
require("core-js/stable/array/some");
|
|
8
10
|
require("core-js/stable/object/assign");
|
|
9
11
|
require("core-js/stable/object/entries");
|
|
@@ -11,4 +13,5 @@ require("core-js/stable/object/values");
|
|
|
11
13
|
require("core-js/stable/map");
|
|
12
14
|
require("core-js/stable/reflect");
|
|
13
15
|
require("core-js/stable/set");
|
|
14
|
-
require("core-js/stable/weak-set");
|
|
16
|
+
require("core-js/stable/weak-set");
|
|
17
|
+
require("core-js/stable/object/get-own-property-descriptors");
|
|
@@ -3,36 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _featureDependencies = require("../../../loaders/features/featureDependencies");
|
|
6
|
+
exports.getModeledObject = getModeledObject;
|
|
8
7
|
var _console = require("../../util/console");
|
|
9
|
-
|
|
10
|
-
constructor(obj, model) {
|
|
11
|
-
Object.assign(this, setValues(obj, model));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.Configurable = Configurable;
|
|
15
|
-
function setValues(obj, model) {
|
|
16
|
-
const state = {};
|
|
8
|
+
function getModeledObject(obj, model) {
|
|
17
9
|
try {
|
|
18
|
-
if (!obj || typeof obj !== 'object') return (0, _console.warn)('
|
|
10
|
+
if (!obj || typeof obj !== 'object') return (0, _console.warn)('Setting a Configurable requires an object as input');
|
|
19
11
|
if (!model || typeof model !== 'object') return (0, _console.warn)('Setting a Configurable requires a model to set its initial properties');
|
|
20
|
-
|
|
21
|
-
Object.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
});
|
|
12
|
+
// allow getters and setters to pass from model to target
|
|
13
|
+
const output = Object.create(Object.getPrototypeOf(model), Object.getOwnPropertyDescriptors(model));
|
|
14
|
+
const target = Object.keys(output).length === 0 ? obj : output;
|
|
15
|
+
for (let key in target) {
|
|
16
|
+
if (obj[key] !== undefined) {
|
|
17
|
+
try {
|
|
18
|
+
if (typeof obj[key] === 'object' && typeof model[key] === 'object') output[key] = getModeledObject(obj[key], model[key]);else output[key] = obj[key];
|
|
19
|
+
} catch (e) {
|
|
20
|
+
(0, _console.warn)('An error occurred while setting a property of a Configurable', e);
|
|
21
|
+
}
|
|
32
22
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return state;
|
|
23
|
+
}
|
|
24
|
+
return output;
|
|
36
25
|
} catch (err) {
|
|
37
26
|
(0, _console.warn)('An error occured while setting a Configurable', err);
|
|
38
27
|
}
|
|
@@ -45,6 +45,6 @@ function getInfo(id) {
|
|
|
45
45
|
}
|
|
46
46
|
function setInfo(id, obj) {
|
|
47
47
|
if (!id) throw new Error('All info objects require an agent identifier!');
|
|
48
|
-
_cache[id] =
|
|
48
|
+
_cache[id] = (0, _configurable.getModeledObject)(obj, model);
|
|
49
49
|
(0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'info');
|
|
50
50
|
}
|
|
@@ -7,63 +7,108 @@ exports.getConfiguration = getConfiguration;
|
|
|
7
7
|
exports.getConfigurationValue = getConfigurationValue;
|
|
8
8
|
exports.setConfiguration = setConfiguration;
|
|
9
9
|
var _constants = require("../../session/constants");
|
|
10
|
-
var _globalScope = require("../../util/global-scope");
|
|
11
10
|
var _nreum = require("../../window/nreum");
|
|
12
11
|
var _configurable = require("./configurable");
|
|
13
|
-
const model = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
12
|
+
const model = () => {
|
|
13
|
+
const hiddenState = {
|
|
14
|
+
blockSelector: '[data-nr-block]',
|
|
15
|
+
maskInputOptions: {
|
|
16
|
+
password: true
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
allow_bfcache: true,
|
|
21
|
+
// *cli - temporary feature flag for BFCache work
|
|
22
|
+
privacy: {
|
|
23
|
+
cookies_enabled: true
|
|
24
|
+
},
|
|
25
|
+
// *cli - per discussion, default should be true
|
|
26
|
+
ajax: {
|
|
27
|
+
deny_list: undefined,
|
|
28
|
+
enabled: true,
|
|
29
|
+
harvestTimeSeconds: 10
|
|
30
|
+
},
|
|
31
|
+
distributed_tracing: {
|
|
32
|
+
enabled: undefined,
|
|
33
|
+
exclude_newrelic_header: undefined,
|
|
34
|
+
cors_use_newrelic_header: undefined,
|
|
35
|
+
cors_use_tracecontext_headers: undefined,
|
|
36
|
+
allowed_origins: undefined
|
|
37
|
+
},
|
|
38
|
+
session: {
|
|
39
|
+
domain: undefined,
|
|
40
|
+
// used by first party cookies to set the top-level domain
|
|
41
|
+
expiresMs: _constants.DEFAULT_EXPIRES_MS,
|
|
42
|
+
inactiveMs: _constants.DEFAULT_INACTIVE_MS
|
|
43
|
+
},
|
|
44
|
+
ssl: undefined,
|
|
45
|
+
obfuscate: undefined,
|
|
46
|
+
jserrors: {
|
|
47
|
+
enabled: true,
|
|
48
|
+
harvestTimeSeconds: 10
|
|
49
|
+
},
|
|
50
|
+
metrics: {
|
|
51
|
+
enabled: true
|
|
52
|
+
},
|
|
53
|
+
page_action: {
|
|
54
|
+
enabled: true,
|
|
55
|
+
harvestTimeSeconds: 30
|
|
56
|
+
},
|
|
57
|
+
page_view_event: {
|
|
58
|
+
enabled: true
|
|
59
|
+
},
|
|
60
|
+
page_view_timing: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
harvestTimeSeconds: 30,
|
|
63
|
+
long_task: false
|
|
64
|
+
},
|
|
65
|
+
session_trace: {
|
|
66
|
+
enabled: true,
|
|
67
|
+
harvestTimeSeconds: 10
|
|
68
|
+
},
|
|
69
|
+
session_replay: {
|
|
70
|
+
// feature settings
|
|
71
|
+
enabled: false,
|
|
72
|
+
harvestTimeSeconds: 60,
|
|
73
|
+
sampleRate: 0.1,
|
|
74
|
+
errorSampleRate: 0.1,
|
|
75
|
+
// recording config settings
|
|
76
|
+
maskTextSelector: '*',
|
|
77
|
+
maskAllInputs: true,
|
|
78
|
+
// these properties only have getters because they are enforcable constants and should error if someone tries to override them
|
|
79
|
+
get blockClass() {
|
|
80
|
+
return 'nr-block';
|
|
81
|
+
},
|
|
82
|
+
get ignoreClass() {
|
|
83
|
+
return 'nr-ignore';
|
|
84
|
+
},
|
|
85
|
+
get maskTextClass() {
|
|
86
|
+
return 'nr-mask';
|
|
87
|
+
},
|
|
88
|
+
// props with a getter and setter are used to extend enforcable constants with customer input
|
|
89
|
+
// we must preserve data-nr-block no matter what else the customer sets
|
|
90
|
+
get blockSelector() {
|
|
91
|
+
return hiddenState.blockSelector;
|
|
92
|
+
},
|
|
93
|
+
set blockSelector(val) {
|
|
94
|
+
hiddenState.blockSelector += ",".concat(val);
|
|
95
|
+
},
|
|
96
|
+
// password: must always be present and true no matter what customer sets
|
|
97
|
+
get maskInputOptions() {
|
|
98
|
+
return hiddenState.maskInputOptions;
|
|
99
|
+
},
|
|
100
|
+
set maskInputOptions(val) {
|
|
101
|
+
hiddenState.maskInputOptions = {
|
|
102
|
+
...val,
|
|
103
|
+
password: true
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
spa: {
|
|
108
|
+
enabled: true,
|
|
109
|
+
harvestTimeSeconds: 10
|
|
110
|
+
}
|
|
111
|
+
};
|
|
67
112
|
};
|
|
68
113
|
const _cache = {};
|
|
69
114
|
function getConfiguration(id) {
|
|
@@ -73,7 +118,7 @@ function getConfiguration(id) {
|
|
|
73
118
|
}
|
|
74
119
|
function setConfiguration(id, obj) {
|
|
75
120
|
if (!id) throw new Error('All configuration objects require an agent identifier!');
|
|
76
|
-
_cache[id] =
|
|
121
|
+
_cache[id] = (0, _configurable.getModeledObject)(obj, model());
|
|
77
122
|
(0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'config');
|
|
78
123
|
}
|
|
79
124
|
function getConfigurationValue(id, path) {
|
|
@@ -23,6 +23,6 @@ function getLoaderConfig(id) {
|
|
|
23
23
|
}
|
|
24
24
|
function setLoaderConfig(id, obj) {
|
|
25
25
|
if (!id) throw new Error('All loader-config objects require an agent identifier!');
|
|
26
|
-
_cache[id] =
|
|
26
|
+
_cache[id] = (0, _configurable.getModeledObject)(obj, model);
|
|
27
27
|
(0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'loader_config');
|
|
28
28
|
}
|
|
@@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getRuntime = getRuntime;
|
|
7
7
|
exports.setRuntime = setRuntime;
|
|
8
|
-
var userAgent = _interopRequireWildcard(require("../../util/user-agent"));
|
|
9
8
|
var _configurable = require("./configurable");
|
|
10
9
|
var _nreum = require("../../window/nreum");
|
|
11
10
|
var _globalScope = require("../../util/global-scope");
|
|
12
11
|
var _env = require("../../constants/env.npm");
|
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
12
|
const model = {
|
|
16
13
|
buildEnv: _env.BUILD_ENV,
|
|
17
14
|
bytesSent: {},
|
|
@@ -33,7 +30,6 @@ const model = {
|
|
|
33
30
|
releaseIds: {},
|
|
34
31
|
session: undefined,
|
|
35
32
|
xhrWrappable: typeof _globalScope.globalScope.XMLHttpRequest?.prototype?.addEventListener === 'function',
|
|
36
|
-
userAgent,
|
|
37
33
|
version: _env.VERSION
|
|
38
34
|
};
|
|
39
35
|
const _cache = {};
|
|
@@ -44,6 +40,6 @@ function getRuntime(id) {
|
|
|
44
40
|
}
|
|
45
41
|
function setRuntime(id, obj) {
|
|
46
42
|
if (!id) throw new Error('All runtime objects require an agent identifier!');
|
|
47
|
-
_cache[id] =
|
|
43
|
+
_cache[id] = (0, _configurable.getModeledObject)(obj, model);
|
|
48
44
|
(0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'runtime');
|
|
49
45
|
}
|
|
@@ -66,7 +66,7 @@ function drain() {
|
|
|
66
66
|
|
|
67
67
|
// Only when the event-groups for all features are ready to drain (staged) do we execute the drain. This has the effect
|
|
68
68
|
// that the last feature to call drain triggers drain for all features.
|
|
69
|
-
const items =
|
|
69
|
+
const items = [...registry[agentIdentifier]];
|
|
70
70
|
if (items.every(_ref => {
|
|
71
71
|
let [key, values] = _ref;
|
|
72
72
|
return values.staged;
|
|
@@ -18,6 +18,17 @@ var _config = require("../config/config");
|
|
|
18
18
|
* Periodically invokes harvest calls and handles retries
|
|
19
19
|
*/
|
|
20
20
|
class HarvestScheduler extends _sharedContext.SharedContext {
|
|
21
|
+
/**
|
|
22
|
+
* Create a HarvestScheduler
|
|
23
|
+
* @param {string} endpoint - The base BAM endpoint name -- ex. 'events'
|
|
24
|
+
* @param {object} opts - The options used to configure the HarvestScheduler
|
|
25
|
+
* @param {Function} opts.onFinished - The callback to be fired when a harvest has finished
|
|
26
|
+
* @param {Function} opts.getPayload - A callback which can be triggered to return a payload for harvesting
|
|
27
|
+
* @param {number} opts.retryDelay - The number of seconds to wait before retrying after a network failure
|
|
28
|
+
* @param {boolean} opts.raw - Use a prefabricated payload shape as the harvest payload without the need for formatting
|
|
29
|
+
* @param {string} opts.customUrl - A custom url that falls outside of the shape of the standard BAM harvester url pattern. Will use directly instead of concatenating various pieces
|
|
30
|
+
* @param {*} parent - The parent object, whose state can be passed into SharedContext
|
|
31
|
+
*/
|
|
21
32
|
constructor(endpoint, opts, parent) {
|
|
22
33
|
super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
|
|
23
34
|
this.endpoint = endpoint;
|
|
@@ -69,23 +80,47 @@ class HarvestScheduler extends _sharedContext.SharedContext {
|
|
|
69
80
|
runHarvest(opts) {
|
|
70
81
|
if (this.aborted) return;
|
|
71
82
|
var scheduler = this;
|
|
83
|
+
let harvests = [];
|
|
84
|
+
let submitMethod;
|
|
72
85
|
if (this.opts.getPayload) {
|
|
73
|
-
// Ajax & PVT
|
|
74
|
-
|
|
86
|
+
// Ajax & PVT & SR
|
|
87
|
+
submitMethod = (0, _harvest.getSubmitMethod)(this.endpoint, opts);
|
|
75
88
|
if (!submitMethod) return false;
|
|
76
|
-
|
|
89
|
+
const retry = submitMethod.method === _submitData.submitData.xhr;
|
|
77
90
|
var payload = this.opts.getPayload({
|
|
78
91
|
retry: retry
|
|
79
92
|
});
|
|
80
|
-
if (payload) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.harvest.send(this.endpoint, payload[i], opts, submitMethod, onHarvestFinished);
|
|
93
|
+
if (!payload) {
|
|
94
|
+
if (this.started) {
|
|
95
|
+
this.scheduleHarvest();
|
|
84
96
|
}
|
|
97
|
+
return;
|
|
85
98
|
}
|
|
99
|
+
payload = Object.prototype.toString.call(payload) === '[object Array]' ? payload : [payload];
|
|
100
|
+
harvests.push(...payload);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** sendX is used for features that do not supply a preformatted payload via "getPayload" */
|
|
104
|
+
let send = args => this.harvest.sendX(args);
|
|
105
|
+
if (harvests.length) {
|
|
106
|
+
/** _send is the underlying method for sending in the harvest, if sending raw we can bypass the other helpers completely which format the payloads */
|
|
107
|
+
if (this.opts.raw) send = args => this.harvest._send(args);
|
|
108
|
+
/** send is used to formated the payloads from "getPayload" and obfuscate before sending */else send = args => this.harvest.send(args);
|
|
86
109
|
} else {
|
|
87
|
-
|
|
110
|
+
// force it to run at least once in sendX mode
|
|
111
|
+
harvests.push(undefined);
|
|
88
112
|
}
|
|
113
|
+
harvests.forEach(payload => {
|
|
114
|
+
send({
|
|
115
|
+
endpoint: this.endpoint,
|
|
116
|
+
payload,
|
|
117
|
+
opts,
|
|
118
|
+
submitMethod,
|
|
119
|
+
cbFinished: onHarvestFinished,
|
|
120
|
+
customUrl: this.opts.customUrl,
|
|
121
|
+
raw: this.opts.raw
|
|
122
|
+
});
|
|
123
|
+
});
|
|
89
124
|
if (this.started) {
|
|
90
125
|
this.scheduleHarvest();
|
|
91
126
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _init = require("../config/state/init");
|
|
4
|
+
var _harvestScheduler = require("./harvest-scheduler");
|
|
5
|
+
describe('runHarvest', () => {
|
|
6
|
+
it('should re-schedule harvest even if there is no accumulated data', () => {
|
|
7
|
+
(0, _init.setConfiguration)('asdf', {});
|
|
8
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
9
|
+
getPayload: jest.fn()
|
|
10
|
+
}, {
|
|
11
|
+
agentIdentifier: 'asdf',
|
|
12
|
+
ee: {
|
|
13
|
+
on: jest.fn()
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
scheduler.started = true;
|
|
17
|
+
jest.spyOn(scheduler, 'scheduleHarvest');
|
|
18
|
+
scheduler.runHarvest();
|
|
19
|
+
expect(scheduler.opts.getPayload()).toBeFalsy();
|
|
20
|
+
expect(scheduler.scheduleHarvest).toHaveBeenCalledTimes(1);
|
|
21
|
+
});
|
|
22
|
+
it('should also re-schedule harvest if there is accumulated data', () => {
|
|
23
|
+
(0, _init.setConfiguration)('asdf', {});
|
|
24
|
+
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
25
|
+
getPayload: jest.fn().mockImplementation(() => 'payload')
|
|
26
|
+
}, {
|
|
27
|
+
agentIdentifier: 'asdf',
|
|
28
|
+
ee: {
|
|
29
|
+
on: jest.fn()
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
scheduler.started = true;
|
|
33
|
+
scheduler.harvest._send = () => {};
|
|
34
|
+
jest.spyOn(scheduler, 'scheduleHarvest');
|
|
35
|
+
scheduler.runHarvest();
|
|
36
|
+
expect(scheduler.opts.getPayload()).toBeTruthy();
|
|
37
|
+
expect(scheduler.scheduleHarvest).toHaveBeenCalledTimes(1);
|
|
38
|
+
});
|
|
39
|
+
});
|