@newrelic/browser-agent 0.1.231 → 1.232.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/common/config/state/configurable.js +27 -21
- package/dist/cjs/common/config/state/init.js +8 -0
- package/dist/cjs/common/config/state/runtime.js +24 -26
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/context/shared-context.js +2 -1
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +2 -2
- package/dist/cjs/common/event-emitter/register-handler.test.js +1 -1
- package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
- package/dist/cjs/common/harvest/harvest-scheduler.js +14 -11
- package/dist/cjs/common/harvest/harvest.js +3 -1
- package/dist/cjs/common/session/constants.js +12 -0
- package/dist/cjs/common/session/session-entity.js +278 -0
- package/dist/cjs/common/session/session-entity.test.js +436 -0
- package/dist/cjs/common/storage/first-party-cookies.js +35 -0
- package/dist/cjs/common/storage/local-memory.js +35 -0
- package/dist/cjs/common/storage/local-memory.test.js +20 -0
- package/dist/cjs/common/storage/local-storage.js +33 -0
- package/dist/cjs/common/storage/local-storage.test.js +14 -0
- package/dist/cjs/common/timer/interaction-timer.js +78 -0
- package/dist/cjs/common/timer/interaction-timer.test.js +216 -0
- package/dist/cjs/common/timer/timer.js +32 -0
- package/dist/cjs/common/timer/timer.test.js +105 -0
- package/dist/cjs/common/unload/eol.js +2 -2
- package/dist/cjs/common/util/data-size.js +6 -0
- package/dist/cjs/common/util/data-size.test.js +47 -0
- package/dist/cjs/common/util/invoke.js +73 -0
- package/dist/cjs/common/util/invoke.test.js +49 -0
- package/dist/cjs/common/util/obfuscate.js +0 -4
- package/dist/cjs/common/window/page-visibility.js +3 -1
- package/dist/cjs/common/wrap/wrap-timer.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +2 -2
- package/dist/cjs/features/jserrors/aggregate/index.js +3 -3
- package/dist/cjs/features/metrics/aggregate/index.js +13 -2
- 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 +6 -6
- package/dist/cjs/features/session_trace/aggregate/index.js +2 -2
- package/dist/cjs/features/spa/aggregate/index.js +6 -5
- package/dist/cjs/features/utils/agent-session.js +73 -0
- package/dist/cjs/features/utils/feature-base.js +1 -1
- package/dist/cjs/features/utils/instrument-base.js +7 -2
- package/dist/cjs/features/utils/lazy-loader.js +1 -1
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/api.js +1 -4
- package/dist/cjs/loaders/api/apiAsync.js +3 -2
- package/dist/cjs/loaders/configure/configure.js +0 -6
- package/dist/esm/common/config/state/configurable.js +26 -20
- package/dist/esm/common/config/state/init.js +8 -0
- package/dist/esm/common/config/state/runtime.js +24 -26
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/context/shared-context.js +2 -1
- package/dist/esm/common/event-emitter/contextual-ee.test.js +2 -2
- package/dist/esm/common/event-emitter/register-handler.test.js +1 -1
- package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
- package/dist/esm/common/harvest/harvest-scheduler.js +14 -11
- package/dist/esm/common/harvest/harvest.js +3 -1
- package/dist/esm/common/session/constants.js +3 -0
- package/dist/esm/common/session/session-entity.js +271 -0
- package/dist/esm/common/session/session-entity.test.js +434 -0
- package/dist/esm/common/storage/first-party-cookies.js +28 -0
- package/dist/esm/common/storage/local-memory.js +28 -0
- package/dist/esm/common/storage/local-memory.test.js +18 -0
- package/dist/esm/common/storage/local-storage.js +26 -0
- package/dist/esm/common/storage/local-storage.test.js +12 -0
- package/dist/esm/common/timer/interaction-timer.js +71 -0
- package/dist/esm/common/timer/interaction-timer.test.js +214 -0
- package/dist/esm/common/timer/timer.js +25 -0
- package/dist/esm/common/timer/timer.test.js +103 -0
- package/dist/esm/common/unload/eol.js +1 -1
- package/dist/esm/common/util/data-size.js +7 -0
- package/dist/esm/common/util/data-size.test.js +45 -0
- package/dist/esm/common/util/invoke.js +66 -0
- package/dist/esm/common/util/invoke.test.js +47 -0
- package/dist/esm/common/util/obfuscate.js +0 -4
- package/dist/esm/common/window/page-visibility.js +3 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +2 -2
- package/dist/esm/features/jserrors/aggregate/index.js +3 -3
- package/dist/esm/features/metrics/aggregate/index.js +14 -3
- 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 +6 -6
- package/dist/esm/features/session_trace/aggregate/index.js +2 -2
- package/dist/esm/features/spa/aggregate/index.js +6 -5
- package/dist/esm/features/utils/agent-session.js +67 -0
- package/dist/esm/features/utils/feature-base.js +1 -1
- package/dist/esm/features/utils/instrument-base.js +7 -2
- package/dist/esm/features/utils/lazy-loader.js +1 -1
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/api.js +2 -5
- package/dist/esm/loaders/api/apiAsync.js +2 -1
- package/dist/esm/loaders/configure/configure.js +2 -8
- 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/context/shared-context.d.ts.map +1 -1
- package/dist/types/common/event-listener/event-listener-opts.d.ts +2 -2
- package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -0
- 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/session/constants.d.ts +4 -0
- package/dist/types/common/session/constants.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +72 -0
- package/dist/types/common/session/session-entity.d.ts.map +1 -0
- package/dist/types/common/storage/first-party-cookies.d.ts +8 -0
- package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -0
- package/dist/types/common/storage/local-memory.d.ts +8 -0
- package/dist/types/common/storage/local-memory.d.ts.map +1 -0
- package/dist/types/common/storage/local-storage.d.ts +6 -0
- package/dist/types/common/storage/local-storage.d.ts.map +1 -0
- package/dist/types/common/timer/interaction-timer.d.ts +11 -0
- package/dist/types/common/timer/interaction-timer.d.ts.map +1 -0
- package/dist/types/common/timer/timer.d.ts +12 -0
- package/dist/types/common/timer/timer.d.ts.map +1 -0
- package/dist/types/common/util/data-size.d.ts +7 -1
- package/dist/types/common/util/data-size.d.ts.map +1 -1
- package/dist/types/common/util/invoke.d.ts +35 -0
- package/dist/types/common/util/invoke.d.ts.map +1 -0
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/window/page-visibility.d.ts +1 -1
- package/dist/types/common/window/page-visibility.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/index.d.ts +2 -2
- package/dist/types/features/metrics/aggregate/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 +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_trace/aggregate/index.d.ts +2 -2
- package/dist/types/features/session_trace/aggregate/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 +2 -0
- package/dist/types/features/utils/agent-session.d.ts.map +1 -0
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/features/utils/lazy-loader.d.ts +2 -2
- package/dist/types/features/utils/lazy-loader.d.ts.map +1 -1
- 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/configure/configure.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/common/config/state/configurable.js +26 -19
- package/src/common/config/state/init.js +7 -0
- package/src/common/config/state/runtime.js +22 -27
- package/src/common/context/shared-context.js +2 -1
- package/src/common/event-emitter/contextual-ee.test.js +2 -2
- package/src/common/event-emitter/register-handler.test.js +1 -1
- package/src/common/event-listener/event-listener-opts.js +4 -4
- package/src/common/harvest/harvest-scheduler.js +12 -8
- package/src/common/harvest/harvest.js +3 -1
- package/src/common/session/constants.js +3 -0
- package/src/common/session/session-entity.js +271 -0
- package/src/common/session/session-entity.test.js +317 -0
- package/src/common/storage/first-party-cookies.js +31 -0
- package/src/common/storage/local-memory.js +30 -0
- package/src/common/storage/local-memory.test.js +19 -0
- package/src/common/storage/local-storage.js +28 -0
- package/src/common/storage/local-storage.test.js +17 -0
- package/src/common/timer/interaction-timer.js +75 -0
- package/src/common/timer/interaction-timer.test.js +167 -0
- package/src/common/timer/timer.js +31 -0
- package/src/common/timer/timer.test.js +100 -0
- package/src/common/unload/eol.js +1 -1
- package/src/common/util/data-size.js +6 -0
- package/src/common/util/data-size.test.js +50 -0
- package/src/common/util/invoke.js +55 -0
- package/src/common/util/invoke.test.js +65 -0
- package/src/common/util/obfuscate.js +0 -4
- package/src/common/window/page-visibility.js +2 -2
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/features/ajax/aggregate/index.js +2 -2
- package/src/features/jserrors/aggregate/index.js +3 -3
- package/src/features/metrics/aggregate/index.js +18 -3
- package/src/features/page_action/aggregate/index.js +2 -2
- package/src/features/page_view_event/aggregate/index.js +6 -3
- package/src/features/page_view_timing/aggregate/index.js +6 -6
- package/src/features/session_trace/aggregate/index.js +2 -2
- package/src/features/spa/aggregate/index.js +5 -5
- package/src/features/utils/agent-session.js +68 -0
- package/src/features/utils/feature-base.js +1 -1
- package/src/features/utils/instrument-base.js +5 -2
- package/src/features/utils/lazy-loader.js +1 -1
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/api.js +2 -5
- package/src/loaders/api/apiAsync.js +2 -1
- package/src/loaders/configure/configure.js +2 -7
- package/dist/cjs/common/util/single.js +0 -23
- package/dist/cjs/common/window/session-storage.js +0 -87
- package/dist/cjs/features/utils/aggregate-base.js +0 -13
- package/dist/esm/common/util/single.js +0 -16
- package/dist/esm/common/window/session-storage.js +0 -77
- package/dist/esm/features/utils/aggregate-base.js +0 -6
- package/dist/types/common/util/single.d.ts +0 -2
- package/dist/types/common/util/single.d.ts.map +0 -1
- package/dist/types/common/window/session-storage.d.ts +0 -18
- package/dist/types/common/window/session-storage.d.ts.map +0 -1
- package/dist/types/features/utils/aggregate-base.d.ts +0 -4
- package/dist/types/features/utils/aggregate-base.d.ts.map +0 -1
- package/src/common/util/single.js +0 -18
- package/src/common/window/session-storage.js +0 -75
- package/src/features/utils/aggregate-base.js +0 -7
|
@@ -7,7 +7,6 @@ exports.Aggregate = void 0;
|
|
|
7
7
|
var _config = require("../../../common/config/config");
|
|
8
8
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
9
9
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
10
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
11
10
|
var _constants = require("../constants");
|
|
12
11
|
var _drain = require("../../../common/drain/drain");
|
|
13
12
|
var _frameworkDetection = require("../../../common/metrics/framework-detection");
|
|
@@ -17,7 +16,9 @@ var _env = require("../../../common/constants/env.npm");
|
|
|
17
16
|
var _load = require("../../../common/window/load");
|
|
18
17
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
19
18
|
var _globalScope = require("../../../common/util/global-scope");
|
|
20
|
-
|
|
19
|
+
var _featureBase = require("../../utils/feature-base");
|
|
20
|
+
var _stringify = require("../../../common/util/stringify");
|
|
21
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
21
22
|
static featureName = _constants.FEATURE_NAME;
|
|
22
23
|
constructor(agentIdentifier, aggregator) {
|
|
23
24
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
@@ -109,6 +110,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
109
110
|
try {
|
|
110
111
|
if (this.resourcesSent) return;
|
|
111
112
|
const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
|
|
113
|
+
const info = (0, _config.getInfo)(this.agentIdentifier);
|
|
112
114
|
// make sure this only gets sent once
|
|
113
115
|
this.resourcesSent = true;
|
|
114
116
|
// differentiate between internal+external and ajax+non-ajax
|
|
@@ -134,10 +136,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
134
136
|
this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/BytesSent"), agentRuntime.bytesSent[endpoint]);
|
|
135
137
|
});
|
|
136
138
|
|
|
139
|
+
// Capture per-agent query bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
|
|
140
|
+
Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
|
|
141
|
+
this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/QueryBytesSent"), agentRuntime.queryBytesSent[endpoint]);
|
|
142
|
+
});
|
|
143
|
+
|
|
137
144
|
// Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
|
|
138
145
|
if (agentRuntime.ptid) {
|
|
139
146
|
this.storeSupportabilityMetrics('PageSession/Feature/SessionTrace/DurationMs', Math.round(performance.now()));
|
|
140
147
|
}
|
|
148
|
+
|
|
149
|
+
// Capture metrics for size of custom attributes
|
|
150
|
+
const jsAttributes = (0, _stringify.stringify)(info.jsAttributes);
|
|
151
|
+
this.storeSupportabilityMetrics('PageSession/Feature/CustomData/Bytes', jsAttributes === '{}' ? 0 : jsAttributes.length);
|
|
141
152
|
} catch (e) {
|
|
142
153
|
// do nothing
|
|
143
154
|
}
|
|
@@ -10,16 +10,16 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
|
|
|
10
10
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
11
11
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
12
12
|
var _config = require("../../../common/config/config");
|
|
13
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
14
13
|
var _constants = require("../constants");
|
|
15
14
|
var _drain = require("../../../common/drain/drain");
|
|
16
15
|
var _globalScope = require("../../../common/util/global-scope");
|
|
16
|
+
var _featureBase = require("../../utils/feature-base");
|
|
17
17
|
/*
|
|
18
18
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
19
19
|
* SPDX-License-Identifier: Apache-2.0
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
class Aggregate extends
|
|
22
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
23
23
|
static featureName = _constants.FEATURE_NAME;
|
|
24
24
|
constructor(agentIdentifier, aggregator) {
|
|
25
25
|
var _this;
|
|
@@ -16,15 +16,15 @@ var _paintMetrics = require("../../../common/metrics/paint-metrics");
|
|
|
16
16
|
var _submitData = require("../../../common/util/submit-data");
|
|
17
17
|
var _config = require("../../../common/config/config");
|
|
18
18
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
19
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
20
19
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
21
20
|
var _initializedFeatures = require("./initialized-features");
|
|
22
21
|
var _globalScope = require("../../../common/util/global-scope");
|
|
23
22
|
var _drain = require("../../../common/drain/drain");
|
|
23
|
+
var _featureBase = require("../../utils/feature-base");
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
26
26
|
const jsonp = 'NREUM.setToken';
|
|
27
|
-
class Aggregate extends
|
|
27
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
28
28
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
29
29
|
constructor(agentIdentifier, aggregator) {
|
|
30
30
|
super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
|
|
@@ -138,7 +138,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
138
138
|
var queryString = (0, _encode.fromArray)(chunksForQueryString, agentRuntime.maxBytes);
|
|
139
139
|
|
|
140
140
|
// Capture bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
|
|
141
|
-
agentRuntime.bytesSent[protocol] =
|
|
141
|
+
agentRuntime.bytesSent[protocol] = 0; // Set to zero for now until RUM is moved to POST
|
|
142
|
+
|
|
143
|
+
// Capture query bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
|
|
144
|
+
agentRuntime.queryBytesSent[protocol] = (agentRuntime.queryBytesSent[protocol] || 0) + queryString?.length || 0;
|
|
142
145
|
const isValidJsonp = _submitData.submitData.jsonp(this.getScheme() + '://' + info.beacon + '/' + protocol + '/' + info.licenseKey + queryString, jsonp);
|
|
143
146
|
// Usually `drain` is invoked automatically after processing feature flags contained in the JSONP callback from
|
|
144
147
|
// ingest (see `activateFeatures`), so when JSONP cannot execute (as with module workers), we drain manually.
|
|
@@ -15,16 +15,16 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
|
|
|
15
15
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
16
16
|
var _handle = require("../../../common/event-emitter/handle");
|
|
17
17
|
var _config = require("../../../common/config/config");
|
|
18
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
19
18
|
var _constants = require("../constants");
|
|
20
19
|
var _drain = require("../../../common/drain/drain");
|
|
21
20
|
var _features = require("../../../loaders/features/features");
|
|
21
|
+
var _featureBase = require("../../utils/feature-base");
|
|
22
22
|
/*
|
|
23
23
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
24
24
|
* SPDX-License-Identifier: Apache-2.0
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
class Aggregate extends
|
|
27
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
28
28
|
static featureName = _constants.FEATURE_NAME;
|
|
29
29
|
constructor(agentIdentifier, aggregator) {
|
|
30
30
|
var _this;
|
|
@@ -35,7 +35,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
35
35
|
this.curSessEndRecorded = false;
|
|
36
36
|
this.cls = null; // this should be null unless set to a numeric value by web-vitals so that we differentiate if CLS is supported
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
/* ! This is the section that used to be in the loader portion: ! */
|
|
39
39
|
/* ------------------------------------------------------------ */
|
|
40
40
|
const pageStartedHidden = (0, _config.getRuntime)(agentIdentifier).initHidden; // our attempt at recapturing initial vis state since this code runs post-load time
|
|
41
41
|
this.alreadySent = new Set(); // since we don't support timings on BFCache restores, this tracks and helps cap metrics that web-vitals report more than once
|
|
@@ -111,10 +111,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
111
111
|
attributes.size = lcpEntry.size;
|
|
112
112
|
attributes.eid = lcpEntry.id;
|
|
113
113
|
if (lcpEntry.url) {
|
|
114
|
-
attributes
|
|
114
|
+
attributes.elUrl = (0, _cleanUrl.cleanURL)(lcpEntry.url);
|
|
115
115
|
}
|
|
116
116
|
if (lcpEntry.element?.tagName) {
|
|
117
|
-
attributes
|
|
117
|
+
attributes.elTag = lcpEntry.element.tagName;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
this.addConnectionAttributes(attributes);
|
|
@@ -227,7 +227,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
227
227
|
Future: onCLS value changes should be reported directly & CLS separated into its own timing node so it's not beholden to 'pageHide' firing. It'd also be possible to report the real final CLS.
|
|
228
228
|
*/
|
|
229
229
|
if (this.cls !== null) {
|
|
230
|
-
attrs
|
|
230
|
+
attrs.cls = this.cls;
|
|
231
231
|
}
|
|
232
232
|
this.timings.push({
|
|
233
233
|
name: name,
|
|
@@ -13,17 +13,17 @@ var _supportsPerformanceObserver = require("../../../common/window/supports-perf
|
|
|
13
13
|
var _lodash = _interopRequireDefault(require("lodash._slice"));
|
|
14
14
|
var _config = require("../../../common/config/config");
|
|
15
15
|
var _now = require("../../../common/timing/now");
|
|
16
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
17
16
|
var _constants = require("../constants");
|
|
18
17
|
var _drain = require("../../../common/drain/drain");
|
|
19
18
|
var _handlerCache = require("../../utils/handler-cache");
|
|
19
|
+
var _featureBase = require("../../utils/feature-base");
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
/*
|
|
22
22
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
23
23
|
* SPDX-License-Identifier: Apache-2.0
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
class Aggregate extends
|
|
26
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
27
27
|
static featureName = _constants.FEATURE_NAME;
|
|
28
28
|
constructor(agentIdentifier, aggregator) {
|
|
29
29
|
var _this;
|
|
@@ -14,20 +14,20 @@ var _paintMetrics = require("../../../common/metrics/paint-metrics");
|
|
|
14
14
|
var _interaction = require("./interaction");
|
|
15
15
|
var _config = require("../../../common/config/config");
|
|
16
16
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
17
|
-
var _aggregateBase = require("../../utils/aggregate-base");
|
|
18
17
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
19
18
|
var _serializer = require("./serializer");
|
|
20
19
|
var _contextualEe = require("../../../common/event-emitter/contextual-ee");
|
|
21
20
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
22
21
|
var _drain = require("../../../common/drain/drain");
|
|
23
22
|
var _features = require("../../../loaders/features/features");
|
|
23
|
+
var _featureBase = require("../../utils/feature-base");
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
26
26
|
/*
|
|
27
27
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
28
28
|
* SPDX-License-Identifier: Apache-2.0
|
|
29
29
|
*/
|
|
30
|
-
/*eslint no-undef: "error"*/
|
|
30
|
+
/* eslint no-undef: "error" */
|
|
31
31
|
|
|
32
32
|
const {
|
|
33
33
|
FEATURE_NAME,
|
|
@@ -47,7 +47,7 @@ const {
|
|
|
47
47
|
JSONP_END,
|
|
48
48
|
originalSetTimeout
|
|
49
49
|
} = CONSTANTS;
|
|
50
|
-
class Aggregate extends
|
|
50
|
+
class Aggregate extends _featureBase.FeatureBase {
|
|
51
51
|
static featureName = FEATURE_NAME;
|
|
52
52
|
constructor(agentIdentifier, aggregator) {
|
|
53
53
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
@@ -90,7 +90,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
90
90
|
onFinished: onHarvestFinished,
|
|
91
91
|
retryDelay: state.harvestTimeSeconds
|
|
92
92
|
}, {
|
|
93
|
-
agentIdentifier
|
|
93
|
+
agentIdentifier,
|
|
94
|
+
ee: baseEE
|
|
94
95
|
});
|
|
95
96
|
scheduler.harvest.on('events', onHarvestStarted);
|
|
96
97
|
|
|
@@ -222,7 +223,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
222
223
|
if (evName === 'click') {
|
|
223
224
|
var value = getActionText(ev.target);
|
|
224
225
|
if (value) {
|
|
225
|
-
state.currentNode.attrs.custom
|
|
226
|
+
state.currentNode.attrs.custom.actionText = value;
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setupAgentSession = setupAgentSession;
|
|
7
|
+
var _config = require("../../common/config/config");
|
|
8
|
+
var _drain = require("../../common/drain/drain");
|
|
9
|
+
var _contextualEe = require("../../common/event-emitter/contextual-ee");
|
|
10
|
+
var _registerHandler = require("../../common/event-emitter/register-handler");
|
|
11
|
+
var _globalScope = require("../../common/util/global-scope");
|
|
12
|
+
var _sessionEntity = require("../../common/session/session-entity");
|
|
13
|
+
var _localStorage = require("../../common/storage/local-storage.js");
|
|
14
|
+
var _firstPartyCookies = require("../../common/storage/first-party-cookies");
|
|
15
|
+
var _localMemory = require("../../common/storage/local-memory");
|
|
16
|
+
let ranOnce = 0;
|
|
17
|
+
function setupAgentSession(agentIdentifier) {
|
|
18
|
+
const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
19
|
+
if (ranOnce++) return agentRuntime.session;
|
|
20
|
+
const sharedEE = _contextualEe.ee.get(agentIdentifier);
|
|
21
|
+
|
|
22
|
+
// domain is a string that can be specified by customer.
|
|
23
|
+
// only way to keep the session object across subdomains is using first party cookies
|
|
24
|
+
// This determines which storage wrapper the session manager will use to keep state
|
|
25
|
+
let storageAPI;
|
|
26
|
+
const cookiesEnabled = (0, _config.getConfigurationValue)(agentIdentifier, 'privacy.cookies_enabled') === true;
|
|
27
|
+
if (cookiesEnabled && _globalScope.isBrowserScope) {
|
|
28
|
+
storageAPI = (0, _config.getConfigurationValue)(agentIdentifier, 'session.domain') ? new _firstPartyCookies.FirstPartyCookies((0, _config.getConfigurationValue)(agentIdentifier, 'session.domain')) : new _localStorage.LocalStorage();
|
|
29
|
+
}
|
|
30
|
+
if (cookiesEnabled) {
|
|
31
|
+
// defaults to "LocalMemory" if storageAPI is undefined, such as in Worker build
|
|
32
|
+
agentRuntime.session = new _sessionEntity.SessionEntity({
|
|
33
|
+
agentIdentifier,
|
|
34
|
+
key: 'SESSION',
|
|
35
|
+
storageAPI,
|
|
36
|
+
expiresMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.expiresMs'),
|
|
37
|
+
inactiveMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.inactiveMs')
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The first time the agent runs on a page, it should put everything
|
|
42
|
+
// that's currently stored in the storage API into the local info.jsAttributes object
|
|
43
|
+
if (_globalScope.isBrowserScope) {
|
|
44
|
+
// retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
|
|
45
|
+
const customSessionData = agentRuntime.session?.read?.()?.custom;
|
|
46
|
+
const agentInfo = (0, _config.getInfo)(agentIdentifier);
|
|
47
|
+
if (customSessionData) {
|
|
48
|
+
(0, _config.setInfo)(agentIdentifier, {
|
|
49
|
+
...agentInfo,
|
|
50
|
+
jsAttributes: {
|
|
51
|
+
...agentInfo.jsAttributes,
|
|
52
|
+
...customSessionData
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// any calls to newrelic.setCustomAttribute(<persisted>) will need to be added to:
|
|
59
|
+
// local info.jsAttributes {}
|
|
60
|
+
// the session's storage API
|
|
61
|
+
(0, _registerHandler.registerHandler)('api-setCustomAttribute', (time, key, value) => {
|
|
62
|
+
agentRuntime.session.syncCustomAttribute(key, value);
|
|
63
|
+
}, 'session', sharedEE);
|
|
64
|
+
|
|
65
|
+
// any calls to newrelic.setUserId(...) will need to be added to:
|
|
66
|
+
// local info.jsAttributes {}
|
|
67
|
+
// the session's storage API
|
|
68
|
+
(0, _registerHandler.registerHandler)('api-setUserId', (time, key, value) => {
|
|
69
|
+
agentRuntime.session.syncCustomAttribute(key, value);
|
|
70
|
+
}, 'session', sharedEE);
|
|
71
|
+
(0, _drain.drain)(agentIdentifier, 'session');
|
|
72
|
+
return agentRuntime.session;
|
|
73
|
+
}
|
|
@@ -32,7 +32,7 @@ class FeatureBase {
|
|
|
32
32
|
* loader configurations may appear after the loader code is executed.
|
|
33
33
|
*/
|
|
34
34
|
checkConfiguration() {
|
|
35
|
-
// NOTE: This check has to happen at aggregator load time
|
|
35
|
+
// NOTE: This check has to happen at aggregator load time
|
|
36
36
|
if (!(0, _config.isConfigured)(this.agentIdentifier)) {
|
|
37
37
|
let jsAttributes = {
|
|
38
38
|
...(0, _nreum.gosCDN)().info?.jsAttributes
|
|
@@ -53,6 +53,12 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
53
53
|
* it's only responsible for aborting its one specific feature, rather than all.
|
|
54
54
|
*/
|
|
55
55
|
try {
|
|
56
|
+
// The session entity needs to be attached to the config internals before the aggregator chunk runs
|
|
57
|
+
const {
|
|
58
|
+
setupAgentSession
|
|
59
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "session-manager" */'./agent-session')));
|
|
60
|
+
setupAgentSession(this.agentIdentifier);
|
|
61
|
+
// import and instantiate the aggregator chunk
|
|
56
62
|
const {
|
|
57
63
|
lazyLoader
|
|
58
64
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-loader" */'./lazy-loader')));
|
|
@@ -61,9 +67,8 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
61
67
|
} = await lazyLoader(this.featureName, 'aggregate');
|
|
62
68
|
new Aggregate(this.agentIdentifier, this.aggregator);
|
|
63
69
|
} catch (e) {
|
|
64
|
-
(0, _console.warn)("Downloading ".concat(this.featureName, " failed..."));
|
|
70
|
+
(0, _console.warn)("Downloading ".concat(this.featureName, " failed..."), e);
|
|
65
71
|
this.abortHandler?.(); // undo any important alterations made to the page
|
|
66
|
-
|
|
67
72
|
// not supported yet but nice to do: "abort" this agent's EE for this feature specifically
|
|
68
73
|
}
|
|
69
74
|
};
|
|
@@ -16,7 +16,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
16
|
* should be.
|
|
17
17
|
* @param featureName Name of the feature to import such as ajax or session_trace
|
|
18
18
|
* @param featurePart Name of the feature part to load; should be either instrument or aggregate
|
|
19
|
-
* @returns {Promise<InstrumentBase|
|
|
19
|
+
* @returns {Promise<InstrumentBase|FeatureBase|null>}
|
|
20
20
|
*/
|
|
21
21
|
function lazyLoader(featureName, featurePart) {
|
|
22
22
|
if (featurePart === 'aggregate') {
|
|
@@ -74,7 +74,7 @@ class Agent {
|
|
|
74
74
|
this.features[featName].abortHandler?.();
|
|
75
75
|
}
|
|
76
76
|
const newrelic = (0, _nreum.gosNREUM)();
|
|
77
|
-
delete newrelic.initializedAgents[this.agentIdentifier]?.
|
|
77
|
+
delete newrelic.initializedAgents[this.agentIdentifier]?.api; // prevent further calls to agent-specific APIs (see "configure.js")
|
|
78
78
|
delete newrelic.initializedAgents[this.agentIdentifier]?.[NR_FEATURES_REF_NAME]; // GC mem used internally by features
|
|
79
79
|
delete this.sharedAggregator;
|
|
80
80
|
// Keep the initialized agent object with its configs for troubleshooting purposes.
|
|
@@ -17,7 +17,6 @@ var _globalScope = require("../../common/util/global-scope");
|
|
|
17
17
|
var _console = require("../../common/util/console");
|
|
18
18
|
var _constants = require("../../features/metrics/constants");
|
|
19
19
|
var _nreum = require("../../common/window/nreum");
|
|
20
|
-
var _sessionStorage = require("../../common/window/session-storage");
|
|
21
20
|
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); }
|
|
22
21
|
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; } /*
|
|
23
22
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -81,7 +80,6 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
81
80
|
const currentInfo = (0, _config.getInfo)(agentIdentifier);
|
|
82
81
|
if (value === null) {
|
|
83
82
|
delete currentInfo.jsAttributes[key];
|
|
84
|
-
if (_globalScope.isBrowserScope) (0, _sessionStorage.removeFromBrowserStorage)(key, CUSTOM_ATTR_GROUP); // addToBrowserStorage flag isn't needed to unset keys from storage
|
|
85
83
|
} else {
|
|
86
84
|
(0, _config.setInfo)(agentIdentifier, {
|
|
87
85
|
...currentInfo,
|
|
@@ -90,9 +88,8 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
90
88
|
[key]: value
|
|
91
89
|
}
|
|
92
90
|
});
|
|
93
|
-
if (_globalScope.isBrowserScope && addToBrowserStorage) (0, _sessionStorage.putInBrowserStorage)(key, value, CUSTOM_ATTR_GROUP);
|
|
94
91
|
}
|
|
95
|
-
return apiCall(prefix, apiName, true)();
|
|
92
|
+
return apiCall(prefix, apiName, true, !!addToBrowserStorage || value === null ? 'session' : undefined)(key, value);
|
|
96
93
|
}
|
|
97
94
|
apiInterface.setCustomAttribute = function (name, value) {
|
|
98
95
|
let persistAttribute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -9,7 +9,7 @@ var _config = require("../../common/config/config");
|
|
|
9
9
|
var _contextualEe = require("../../common/event-emitter/contextual-ee");
|
|
10
10
|
var _handle = require("../../common/event-emitter/handle");
|
|
11
11
|
var _registerHandler = require("../../common/event-emitter/register-handler");
|
|
12
|
-
var
|
|
12
|
+
var _invoke = require("../../common/util/invoke");
|
|
13
13
|
var _submitData = require("../../common/util/submit-data");
|
|
14
14
|
var _globalScope = require("../../common/util/global-scope");
|
|
15
15
|
var _constants = require("../../features/metrics/constants");
|
|
@@ -18,7 +18,7 @@ function setAPI(agentIdentifier) {
|
|
|
18
18
|
var cycle = 0;
|
|
19
19
|
var scheme = (0, _config.getConfigurationValue)(agentIdentifier, 'ssl') === false ? 'http' : 'https';
|
|
20
20
|
var api = {
|
|
21
|
-
finished: (0,
|
|
21
|
+
finished: (0, _invoke.single)(finished),
|
|
22
22
|
setErrorHandler: setErrorHandler,
|
|
23
23
|
addToTrace: addToTrace,
|
|
24
24
|
inlineHit: inlineHit,
|
|
@@ -71,6 +71,7 @@ function setAPI(agentIdentifier) {
|
|
|
71
71
|
request_name = window.encodeURIComponent(request_name);
|
|
72
72
|
cycle += 1;
|
|
73
73
|
const agentInfo = (0, _config.getInfo)(agentIdentifier);
|
|
74
|
+
const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
74
75
|
if (!agentInfo.beacon) return;
|
|
75
76
|
var url = scheme + '://' + agentInfo.beacon + '/1/' + agentInfo.licenseKey;
|
|
76
77
|
url += '?a=' + agentInfo.applicationID + '&';
|
|
@@ -9,7 +9,6 @@ var _nreum = require("../../common/window/nreum");
|
|
|
9
9
|
var _config = require("../../common/config/config");
|
|
10
10
|
var _featureFlags = require("../../common/util/feature-flags");
|
|
11
11
|
var _globalScope = require("../../common/util/global-scope");
|
|
12
|
-
var _sessionStorage = require("../../common/window/session-storage");
|
|
13
12
|
function configure(agentIdentifier) {
|
|
14
13
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15
14
|
let loaderType = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -34,11 +33,6 @@ function configure(agentIdentifier) {
|
|
|
34
33
|
// add a default attr to all worker payloads
|
|
35
34
|
info.jsAttributes.isWorker = true;
|
|
36
35
|
}
|
|
37
|
-
if (_globalScope.isBrowserScope) {
|
|
38
|
-
// retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
|
|
39
|
-
let prevPageSessionJsAttrs = (0, _sessionStorage.getAllStorageItemsOfGroup)(_api.CUSTOM_ATTR_GROUP);
|
|
40
|
-
Object.assign(info.jsAttributes, prevPageSessionJsAttrs);
|
|
41
|
-
}
|
|
42
36
|
(0, _config.setInfo)(agentIdentifier, info);
|
|
43
37
|
(0, _config.setConfiguration)(agentIdentifier, init || {});
|
|
44
38
|
(0, _config.setLoaderConfig)(agentIdentifier, loader_config || {});
|
|
@@ -2,25 +2,31 @@ import { getFrozenAttributes } from '../../../loaders/features/featureDependenci
|
|
|
2
2
|
import { warn } from '../../util/console';
|
|
3
3
|
export class Configurable {
|
|
4
4
|
constructor(obj, model) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
Object.assign(this, setValues(obj, model));
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function setValues(obj, model) {
|
|
9
|
+
const state = {};
|
|
10
|
+
try {
|
|
11
|
+
if (!obj || typeof obj !== 'object') return warn('New setting a Configurable requires an object as input');
|
|
12
|
+
if (!model || typeof model !== 'object') return warn('Setting a Configurable requires a model to set its initial properties');
|
|
13
|
+
Object.assign(state, model);
|
|
14
|
+
Object.entries(obj).forEach(_ref => {
|
|
15
|
+
let [key, value] = _ref;
|
|
16
|
+
if (!Object.keys(model).includes(key)) return;
|
|
17
|
+
const frozenAttrs = getFrozenAttributes(key);
|
|
18
|
+
if (frozenAttrs.length && value && typeof value === 'object') {
|
|
19
|
+
frozenAttrs.forEach(attr => {
|
|
20
|
+
if (attr in value) {
|
|
21
|
+
warn("\"".concat(attr, "\" is a protected attribute and can not be changed in feature ").concat(key, ". It will have no effect."));
|
|
22
|
+
delete value[attr];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
state[key] = value;
|
|
27
|
+
});
|
|
28
|
+
return state;
|
|
29
|
+
} catch (err) {
|
|
30
|
+
warn('An error occured while setting a Configurable', err);
|
|
25
31
|
}
|
|
26
32
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS } from '../../session/constants';
|
|
2
|
+
import { globalScope } from '../../util/global-scope';
|
|
1
3
|
import { gosNREUMInitializedAgents } from '../../window/nreum';
|
|
2
4
|
import { Configurable } from './configurable';
|
|
3
5
|
const model = {
|
|
@@ -19,6 +21,12 @@ const model = {
|
|
|
19
21
|
cors_use_tracecontext_headers: undefined,
|
|
20
22
|
allowed_origins: undefined
|
|
21
23
|
},
|
|
24
|
+
session: {
|
|
25
|
+
domain: undefined,
|
|
26
|
+
// used by first party cookies to set the top-level domain
|
|
27
|
+
expiresMs: DEFAULT_EXPIRES_MS,
|
|
28
|
+
inactiveMs: DEFAULT_INACTIVE_MS
|
|
29
|
+
},
|
|
22
30
|
ssl: undefined,
|
|
23
31
|
obfuscate: undefined,
|
|
24
32
|
jserrors: {
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
import * as userAgent from '../../util/user-agent';
|
|
2
2
|
import { Configurable } from './configurable';
|
|
3
3
|
import { gosNREUMInitializedAgents } from '../../window/nreum';
|
|
4
|
-
import { getCurrentSessionIdOrMakeNew } from '../../window/session-storage';
|
|
5
|
-
import { getConfigurationValue } from '../config';
|
|
6
4
|
import { globalScope } from '../../util/global-scope';
|
|
7
5
|
import { BUILD_ENV, DIST_METHOD, VERSION } from "../../constants/env.npm";
|
|
8
|
-
const model =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
6
|
+
const model = {
|
|
7
|
+
buildEnv: BUILD_ENV,
|
|
8
|
+
bytesSent: {},
|
|
9
|
+
// Used for SM to capture body bytes sent per endpoint
|
|
10
|
+
queryBytesSent: {},
|
|
11
|
+
// Used for SM to capture query parameter bytes sent per endpoint
|
|
12
|
+
customTransaction: undefined,
|
|
13
|
+
disabled: false,
|
|
14
|
+
distMethod: DIST_METHOD,
|
|
15
|
+
isolatedBacklog: false,
|
|
16
|
+
loaderType: undefined,
|
|
17
|
+
maxBytes: 30000,
|
|
18
|
+
// The "timeOrigin" property is the new standard timestamp property shared across main frame and workers, but is not supported in some early Safari browsers (safari<15) + IE
|
|
19
|
+
// ingest expects an integer value, and timeOrigin can return a float.
|
|
20
|
+
offset: Math.floor(globalScope?.performance?.timeOrigin || globalScope?.performance?.timing?.navigationStart || Date.now()),
|
|
21
|
+
onerror: undefined,
|
|
22
|
+
origin: '' + globalScope.location,
|
|
23
|
+
ptid: undefined,
|
|
24
|
+
releaseIds: {},
|
|
25
|
+
session: undefined,
|
|
26
|
+
xhrWrappable: typeof globalScope.XMLHttpRequest?.prototype?.addEventListener === 'function',
|
|
27
|
+
userAgent,
|
|
28
|
+
version: VERSION
|
|
31
29
|
};
|
|
32
30
|
const _cache = {};
|
|
33
31
|
export function getRuntime(id) {
|
|
@@ -37,6 +35,6 @@ export function getRuntime(id) {
|
|
|
37
35
|
}
|
|
38
36
|
export function setRuntime(id, obj) {
|
|
39
37
|
if (!id) throw new Error('All runtime objects require an agent identifier!');
|
|
40
|
-
_cache[id] = new Configurable(obj, model
|
|
38
|
+
_cache[id] = new Configurable(obj, model);
|
|
41
39
|
gosNREUMInitializedAgents(id, _cache[id], 'runtime');
|
|
42
40
|
}
|
|
@@ -253,8 +253,8 @@ describe('event-emitter emit', () => {
|
|
|
253
253
|
scopeEE.emit(eventType, eventArgs, {}, false, false);
|
|
254
254
|
expect(mockScopeListener).toHaveBeenCalledTimes(1);
|
|
255
255
|
expect(mockListener).not.toHaveBeenCalled();
|
|
256
|
-
expect(scopeEE.backlog
|
|
257
|
-
expect(ee.backlog
|
|
256
|
+
expect(scopeEE.backlog.feature).toEqual(expect.arrayContaining([expect.arrayContaining([scopeEE, eventType, eventArgs, {}])]));
|
|
257
|
+
expect(ee.backlog.feature).toEqual(scopeEE.backlog.feature);
|
|
258
258
|
});
|
|
259
259
|
});
|
|
260
260
|
describe('getOrSetContext', () => {
|
|
@@ -17,7 +17,7 @@ test('should default group to "feature"', async () => {
|
|
|
17
17
|
const eventType = faker.datatype.uuid();
|
|
18
18
|
const eventHandler = jest.fn();
|
|
19
19
|
registerHandler(eventType, eventHandler);
|
|
20
|
-
expect(registerHandler.handlers
|
|
20
|
+
expect(registerHandler.handlers.feature).toEqual(expect.objectContaining({
|
|
21
21
|
[eventType]: [expect.arrayContaining([handleEE, eventHandler])]
|
|
22
22
|
}));
|
|
23
23
|
});
|