@newrelic/browser-agent 1.238.0 → 1.239.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/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 +2 -8
- package/dist/cjs/common/drain/drain.js +1 -1
- package/dist/cjs/common/event-emitter/contextual-ee.js +6 -6
- package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
- package/dist/cjs/common/harvest/harvest.js +2 -6
- 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-jsonp.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +5 -7
- package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -8
- package/dist/cjs/features/ajax/instrument/index.js +47 -15
- 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 +3 -3
- package/dist/cjs/features/session_trace/aggregate/index.js +8 -8
- 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 +11 -0
- package/dist/cjs/loaders/agent.js +7 -7
- package/dist/cjs/loaders/api/api.js +21 -4
- package/dist/cjs/loaders/api/apiAsync.js +19 -20
- 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 +2 -8
- package/dist/esm/common/drain/drain.js +1 -1
- package/dist/esm/common/event-emitter/contextual-ee.js +6 -6
- package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
- package/dist/esm/common/harvest/harvest.js +2 -6
- 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-jsonp.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +5 -7
- package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -8
- package/dist/esm/features/ajax/instrument/index.js +47 -15
- 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 +2 -2
- package/dist/esm/features/session_trace/aggregate/index.js +8 -8
- 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 +11 -0
- package/dist/esm/loaders/agent.js +7 -7
- package/dist/esm/loaders/api/api.js +21 -4
- package/dist/esm/loaders/api/apiAsync.js +19 -20
- 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/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts +6 -9
- 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/page-visibility.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.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.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 +6 -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 +1 -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/configure/configure.d.ts +1 -0
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +7 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +41 -12
- 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 +2 -10
- package/src/common/drain/drain.js +1 -1
- package/src/common/drain/drain.test.js +74 -0
- package/src/common/event-emitter/contextual-ee.js +6 -6
- 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 +2 -6
- package/src/common/harvest/harvest.test.js +0 -2
- 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/encode.test.js +1 -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 +3 -1
- package/src/common/window/page-visibility.js +1 -2
- package/src/common/wrap/wrap-jsonp.js +1 -1
- package/src/features/ajax/aggregate/index.js +5 -7
- package/src/features/ajax/instrument/distributed-tracing.js +8 -8
- package/src/features/ajax/instrument/index.js +40 -17
- 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 +2 -2
- package/src/features/session_trace/aggregate/index.js +6 -9
- 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 +11 -0
- package/src/loaders/agent.js +7 -7
- package/src/loaders/api/api.js +21 -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/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
|
@@ -16,7 +16,6 @@ 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
18
|
var _constants = require("../constants");
|
|
19
|
-
var _drain = require("../../../common/drain/drain");
|
|
20
19
|
var _features = require("../../../loaders/features/features");
|
|
21
20
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
22
21
|
/*
|
|
@@ -51,7 +50,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
/* First Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
|
|
54
|
-
if (_runtime.
|
|
53
|
+
if (_runtime.iOSBelow16) {
|
|
55
54
|
try {
|
|
56
55
|
if (!pageStartedHidden) {
|
|
57
56
|
// see ios-version.js for detail on this following bug case; tldr: buffered flag doesn't work but getEntriesByType does
|
|
@@ -127,7 +126,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
127
126
|
let {
|
|
128
127
|
value
|
|
129
128
|
} = _ref5;
|
|
130
|
-
|
|
129
|
+
this.cls = value;
|
|
131
130
|
}, {
|
|
132
131
|
reportAllChanges: true
|
|
133
132
|
});
|
|
@@ -176,7 +175,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
176
175
|
this.ee.on("drain-".concat(this.featureName), () => {
|
|
177
176
|
this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
|
|
178
177
|
});
|
|
179
|
-
|
|
178
|
+
this.drain();
|
|
180
179
|
}
|
|
181
180
|
|
|
182
181
|
// takes an attributes object and appends connection attributes if available
|
|
@@ -230,9 +229,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
230
229
|
attrs.cls = this.cls;
|
|
231
230
|
}
|
|
232
231
|
this.timings.push({
|
|
233
|
-
name
|
|
234
|
-
value
|
|
235
|
-
attrs
|
|
232
|
+
name,
|
|
233
|
+
value,
|
|
234
|
+
attrs
|
|
236
235
|
});
|
|
237
236
|
(0, _handle.handle)('pvtAdded', [name, value, attrs], undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
|
|
238
237
|
}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RRWEB_VERSION = exports.MAX_PAYLOAD_SIZE = exports.IDEAL_PAYLOAD_SIZE = exports.Aggregate = exports.AVG_COMPRESSION = void 0;
|
|
7
|
-
var _drain = require("../../../common/drain/drain");
|
|
8
7
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
9
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
10
9
|
var _constants = require("../constants");
|
|
@@ -14,6 +13,7 @@ var _sessionEntity = require("../../../common/session/session-entity");
|
|
|
14
13
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
15
14
|
var _sharedChannel = require("../../../common/constants/shared-channel");
|
|
16
15
|
var _encode = require("../../../common/url/encode");
|
|
16
|
+
var _console = require("../../../common/util/console");
|
|
17
17
|
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); }
|
|
18
18
|
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; } /*
|
|
19
19
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
@@ -135,7 +135,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
135
135
|
return this.initializeRecording(flagOn, Math.random() < (0, _config.getConfigurationValue)(this.agentIdentifier, 'session_replay.errorSampleRate'), Math.random() < (0, _config.getConfigurationValue)(this.agentIdentifier, 'session_replay.sampleRate'));
|
|
136
136
|
}).then(() => _sharedChannel.sharedChannel.onReplayReady(this.mode)); // notify watchers that replay started with the mode
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
this.drain();
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -268,7 +268,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
268
268
|
/** Begin recording using configured recording lib */
|
|
269
269
|
startRecording() {
|
|
270
270
|
if (!recorder) {
|
|
271
|
-
warn('Recording library was never imported');
|
|
271
|
+
(0, _console.warn)('Recording library was never imported');
|
|
272
272
|
return this.abort();
|
|
273
273
|
}
|
|
274
274
|
this.recording = true;
|
|
@@ -10,7 +10,6 @@ var _parseUrl = require("../../../common/url/parse-url");
|
|
|
10
10
|
var _config = require("../../../common/config/config");
|
|
11
11
|
var _now = require("../../../common/timing/now");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
-
var _drain = require("../../../common/drain/drain");
|
|
14
13
|
var _handlerCache = require("../../utils/handler-cache");
|
|
15
14
|
var _sessionEntity = require("../../../common/session/session-entity");
|
|
16
15
|
var _replayMode = require("../../session_replay/replay-mode");
|
|
@@ -144,7 +143,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
144
143
|
});
|
|
145
144
|
mostRecentModeKnown = updatedTraceMode;
|
|
146
145
|
});
|
|
147
|
-
this.ee.on(_sessionEntity.SESSION_EVENTS.PAUSE, () =>
|
|
146
|
+
this.ee.on(_sessionEntity.SESSION_EVENTS.PAUSE, () => {
|
|
147
|
+
mostRecentModeKnown = sessionEntity.state.sessionTraceMode;
|
|
148
|
+
});
|
|
148
149
|
if (!sessionEntity.isNew) {
|
|
149
150
|
// inherit the same mode as existing session's Trace
|
|
150
151
|
if (sessionEntity.state.sessionReplay === _sessionEntity.MODE.OFF) this.isStandalone = true;
|
|
@@ -216,7 +217,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
216
217
|
}
|
|
217
218
|
return operationalGate.settle(() => _this.processPVT(...args));
|
|
218
219
|
}, this.featureName, this.ee);
|
|
219
|
-
|
|
220
|
+
this.drain();
|
|
220
221
|
}
|
|
221
222
|
startTracing(startupBuffer) {
|
|
222
223
|
let dontStartHarvestYet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -340,8 +341,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
340
341
|
const origin = this.evtOrigin(event.target, target);
|
|
341
342
|
if (event.type in ignoredEvents.global) return true;
|
|
342
343
|
if (!!ignoredEvents[origin] && ignoredEvents[origin].ignoreAll) return true;
|
|
343
|
-
|
|
344
|
-
return false;
|
|
344
|
+
return !!(!!ignoredEvents[origin] && event.type in ignoredEvents[origin]);
|
|
345
345
|
}
|
|
346
346
|
evtName(type) {
|
|
347
347
|
switch (type) {
|
|
@@ -451,7 +451,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
451
451
|
// limit the amount of pending data awaiting next harvest
|
|
452
452
|
if (this.isStandalone || this.agentRuntime.session.state.sessionTraceMode !== _sessionEntity.MODE.ERROR) return;
|
|
453
453
|
const openedSpace = this.trimSTNs(ERROR_MODE_SECONDS_WINDOW); // but maybe we could make some space by discarding irrelevant nodes if we're in sessioned Error mode
|
|
454
|
-
if (openedSpace
|
|
454
|
+
if (openedSpace === 0) return;
|
|
455
455
|
}
|
|
456
456
|
if (this.isStandalone && (0, _now.now)() >= MAX_TRACE_DURATION) {
|
|
457
457
|
return;
|
|
@@ -474,7 +474,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
474
474
|
* This isn't exact since nodes go through some processing & EE handlers chain, but it's close enough as we still capture nodes whose duration overlaps the lookback window.
|
|
475
475
|
* ASSUMPTION: all 'end' timings stored are relative to timeOrigin (DOMHighResTimeStamp) and not Unix epoch based. */
|
|
476
476
|
let cutoffIdx = nodeList.findIndex(node => cutoffHighResTime <= node.e);
|
|
477
|
-
if (cutoffIdx
|
|
477
|
+
if (cutoffIdx === 0) return;else if (cutoffIdx < 0) {
|
|
478
478
|
// whole list falls outside lookback window and is irrelevant
|
|
479
479
|
cutoffIdx = nodeList.length;
|
|
480
480
|
delete this.trace[nameCategory];
|
|
@@ -538,7 +538,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
538
538
|
};
|
|
539
539
|
function trivial(node) {
|
|
540
540
|
const limit = 4;
|
|
541
|
-
|
|
541
|
+
return !!(node && typeof node.e === 'number' && typeof node.s === 'number' && node.e - node.s < limit);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
}
|
|
@@ -18,7 +18,6 @@ var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
|
18
18
|
var _serializer = require("./serializer");
|
|
19
19
|
var _contextualEe = require("../../../common/event-emitter/contextual-ee");
|
|
20
20
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
21
|
-
var _drain = require("../../../common/drain/drain");
|
|
22
21
|
var _features = require("../../../loaders/features/features");
|
|
23
22
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
24
23
|
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); }
|
|
@@ -144,8 +143,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
144
143
|
|
|
145
144
|
// register plugins
|
|
146
145
|
var pluginApi = {
|
|
147
|
-
getCurrentNode
|
|
148
|
-
setCurrentNode
|
|
146
|
+
getCurrentNode,
|
|
147
|
+
setCurrentNode
|
|
149
148
|
};
|
|
150
149
|
(0, _registerHandler.registerHandler)('spa-register', function (init) {
|
|
151
150
|
if (typeof init === 'function') {
|
|
@@ -210,21 +209,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
210
209
|
// If this event was emitted by an XHR, restore the node ID associated with
|
|
211
210
|
// that XHR.
|
|
212
211
|
setCurrentNode(baseEE.context(eventSource).spaNode);
|
|
213
|
-
} else if (!state.currentNode) {
|
|
212
|
+
} else if (!state.currentNode && INTERACTION_EVENTS.indexOf(evName) !== -1) {
|
|
214
213
|
// Otherwise, if no interaction is currently active, create a new node ID,
|
|
215
214
|
// and let the aggregator know that we entered a new event handler callback
|
|
216
215
|
// so that it has a chance to possibly start an interaction.
|
|
217
|
-
|
|
218
|
-
var ixn = new _interaction.Interaction(evName, this[FN_START], state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
|
|
216
|
+
var ixn = new _interaction.Interaction(evName, this[FN_START], state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
|
|
219
217
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
218
|
+
// Store the interaction as prevInteraction in case it is prematurely discarded
|
|
219
|
+
state.prevInteraction = ixn;
|
|
220
|
+
setCurrentNode(ixn.root);
|
|
221
|
+
if (evName === 'click') {
|
|
222
|
+
var value = getActionText(ev.target);
|
|
223
|
+
if (value) {
|
|
224
|
+
state.currentNode.attrs.custom.actionText = value;
|
|
228
225
|
}
|
|
229
226
|
}
|
|
230
227
|
}
|
|
@@ -506,7 +503,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
506
503
|
}, this.featureName, promiseEE);
|
|
507
504
|
(0, _registerHandler.registerHandler)(INTERACTION_API + 'get', function (t) {
|
|
508
505
|
var interaction;
|
|
509
|
-
if (state?.currentNode?.[INTERACTION]) interaction = this.ixn = state.currentNode[INTERACTION];else if (state?.prevNode?.end === null && state?.prevNode?.[INTERACTION]?.root?.[INTERACTION]?.eventName
|
|
506
|
+
if (state?.currentNode?.[INTERACTION]) interaction = this.ixn = state.currentNode[INTERACTION];else if (state?.prevNode?.end === null && state?.prevNode?.[INTERACTION]?.root?.[INTERACTION]?.eventName !== 'initialPageLoad') interaction = this.ixn = state.prevNode[INTERACTION];else interaction = this.ixn = new _interaction.Interaction('api', t, state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
|
|
510
507
|
if (!state.currentNode) {
|
|
511
508
|
interaction.checkFinish();
|
|
512
509
|
if (state.depth) setCurrentNode(interaction.root);
|
|
@@ -674,12 +671,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
674
671
|
}
|
|
675
672
|
function isEnabled() {
|
|
676
673
|
var enabled = (0, _config.getConfigurationValue)(agentIdentifier, 'spa.enabled');
|
|
677
|
-
|
|
678
|
-
return false;
|
|
679
|
-
}
|
|
680
|
-
return true;
|
|
674
|
+
return enabled !== false;
|
|
681
675
|
}
|
|
682
|
-
|
|
676
|
+
this.drain();
|
|
683
677
|
}
|
|
684
678
|
}
|
|
685
679
|
exports.Aggregate = Aggregate;
|
|
@@ -8,7 +8,6 @@ var _config = require("../../../common/config/config");
|
|
|
8
8
|
var _mapOwn = require("../../../common/util/map-own");
|
|
9
9
|
var _contextualEe = require("../../../common/event-emitter/contextual-ee");
|
|
10
10
|
var _interactionNode = require("./interaction-node");
|
|
11
|
-
var _now = require("../../../common/timing/now");
|
|
12
11
|
/*
|
|
13
12
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
14
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -84,7 +83,6 @@ InteractionPrototype.finish = function finishInteraction() {
|
|
|
84
83
|
var root = interaction.root;
|
|
85
84
|
if (root.end !== null) return;
|
|
86
85
|
var endTimestamp = Math.max(interaction.lastCb, interaction.lastFinish);
|
|
87
|
-
var delta = (0, _now.now)() - endTimestamp;
|
|
88
86
|
var attrs = root.attrs;
|
|
89
87
|
var customAttrs = attrs.custom;
|
|
90
88
|
if (this.onFinished) {
|
|
@@ -126,7 +126,7 @@ class Serializer extends _sharedContext.SharedContext {
|
|
|
126
126
|
// (since its the same as interaction.start)
|
|
127
127
|
// and limit to just the first 20 values we know about
|
|
128
128
|
(0, _mapOwn.mapOwn)(navTiming.slice(1, 21), function (i, v) {
|
|
129
|
-
if (v !==
|
|
129
|
+
if (v !== undefined) {
|
|
130
130
|
navTimingNode += seperator + (0, _belSerializer.numeric)(v - prev);
|
|
131
131
|
seperator = ',';
|
|
132
132
|
prev = v;
|
|
@@ -9,6 +9,7 @@ var _featureBase = require("./feature-base");
|
|
|
9
9
|
var _config = require("../../common/config/config");
|
|
10
10
|
var _configure = require("../../loaders/configure/configure");
|
|
11
11
|
var _nreum = require("../../common/window/nreum");
|
|
12
|
+
var _drain = require("../../common/drain/drain");
|
|
12
13
|
class AggregateBase extends _featureBase.FeatureBase {
|
|
13
14
|
constructor() {
|
|
14
15
|
super(...arguments);
|
|
@@ -26,6 +27,9 @@ class AggregateBase extends _featureBase.FeatureBase {
|
|
|
26
27
|
(0, _registerHandler.registerHandler)("rumresp-".concat(fName), isOn => resolve(isOn), this.featureName, this.ee);
|
|
27
28
|
})));
|
|
28
29
|
}
|
|
30
|
+
drain() {
|
|
31
|
+
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
32
|
+
}
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* Checks for additional `jsAttributes` items to support backward compatibility with implementations of the agent where
|
|
@@ -42,7 +42,9 @@ class HandlerCache {
|
|
|
42
42
|
* @returns {void}
|
|
43
43
|
*/
|
|
44
44
|
settle(handler) {
|
|
45
|
-
if (this.#decision === false)
|
|
45
|
+
if (this.#decision === false) {
|
|
46
|
+
// Do nothing
|
|
47
|
+
} else if (this.#decision === undefined) this.#cache.push(handler);else handler();
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
/**
|
|
@@ -37,18 +37,24 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
37
37
|
this.auto = auto;
|
|
38
38
|
|
|
39
39
|
/** @type {Function | undefined} This should be set by any derived Instrument class if it has things to do when feature fails or is killed. */
|
|
40
|
-
this.abortHandler;
|
|
40
|
+
this.abortHandler = undefined;
|
|
41
|
+
|
|
41
42
|
/**
|
|
42
43
|
* @type {Class} Holds the reference to the feature's aggregate module counterpart, if and after it has been initialized. This may not be assigned until after page loads!
|
|
43
44
|
* The only purpose of this for now is to expose it to the NREUM interface, as the feature's instrument instance is already exposed.
|
|
44
45
|
*/
|
|
45
|
-
this.featAggregate;
|
|
46
|
+
this.featAggregate = undefined;
|
|
47
|
+
|
|
46
48
|
/**
|
|
47
49
|
* @type {Promise} Assigned immediately after @see importAggregator runs. Serves as a signal for when the inner async fn finishes execution. Useful for features to await
|
|
48
50
|
* one another if there are inter-features dependencies.
|
|
49
51
|
*/
|
|
50
|
-
this.onAggregateImported;
|
|
51
|
-
|
|
52
|
+
this.onAggregateImported = undefined;
|
|
53
|
+
|
|
54
|
+
/** used in conjunction with newrelic.start() to defer harvesting in features */
|
|
55
|
+
if ((0, _config.getConfigurationValue)(this.agentIdentifier, "".concat(this.featureName, ".autoStart")) === false) this.auto = false;
|
|
56
|
+
/** if the feature requires opt-in (!auto-start), it will get registered once the api has been called */
|
|
57
|
+
if (this.auto) (0, _drain.registerDrain)(agentIdentifier, featureName);
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
@@ -59,7 +65,19 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
59
65
|
*/
|
|
60
66
|
importAggregator() {
|
|
61
67
|
let argsObjFromInstrument = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
62
|
-
if (this.featAggregate
|
|
68
|
+
if (this.featAggregate) return;
|
|
69
|
+
if (!this.auto) {
|
|
70
|
+
// this feature requires an opt in...
|
|
71
|
+
// wait for API to be called
|
|
72
|
+
this.ee.on("".concat(this.featureName, "-opt-in"), () => {
|
|
73
|
+
// register the feature to drain only once the API has been called, it will drain when importAggregator finishes for all the features
|
|
74
|
+
// called by the api in that cycle
|
|
75
|
+
(0, _drain.registerDrain)(this.agentIdentifier, this.featureName);
|
|
76
|
+
this.auto = true;
|
|
77
|
+
this.importAggregator();
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
63
81
|
const enableSessionTracking = _runtime.isBrowserScope && (0, _config.getConfigurationValue)(this.agentIdentifier, 'privacy.cookies_enabled') === true;
|
|
64
82
|
let loadedSuccessfully;
|
|
65
83
|
this.onAggregateImported = new Promise(resolve => {
|
|
@@ -80,7 +98,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
|
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
/**
|
|
83
|
-
* Note this try-catch differs from the one in Agent.
|
|
101
|
+
* Note this try-catch differs from the one in Agent.run() in that it's placed later in a page's lifecycle and
|
|
84
102
|
* it's only responsible for aborting its one specific feature, rather than all.
|
|
85
103
|
*/
|
|
86
104
|
try {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.AgentBase = void 0;
|
|
7
7
|
var _console = require("../common/util/console");
|
|
8
|
+
/* eslint-disable n/handle-callback-err */
|
|
9
|
+
|
|
8
10
|
class AgentBase {
|
|
9
11
|
/**
|
|
10
12
|
* Reports a browser PageAction event along with a name and optional attributes.
|
|
@@ -95,5 +97,14 @@ class AgentBase {
|
|
|
95
97
|
addRelease(name, id) {
|
|
96
98
|
(0, _console.warn)('Call to agent api addRelease failed. The agent is not currently initialized.');
|
|
97
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Starts a set of agent features if not running in "autoStart" mode
|
|
103
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
|
|
104
|
+
* @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
|
|
105
|
+
*/
|
|
106
|
+
start(featureNames) {
|
|
107
|
+
(0, _console.warn)('Call to agent api addRelease failed. The agent is not currently initialized.');
|
|
108
|
+
}
|
|
98
109
|
}
|
|
99
110
|
exports.AgentBase = AgentBase;
|
|
@@ -52,7 +52,7 @@ class Agent extends _agentBase.AgentBase {
|
|
|
52
52
|
// Future work is being planned to evaluate removing this behavior from the backend, but for now we must ensure this call is made
|
|
53
53
|
this.desiredFeatures.add(_instrument.Instrument);
|
|
54
54
|
Object.assign(this, (0, _configure.configure)(this.agentIdentifier, options, options.loaderType || 'agent'));
|
|
55
|
-
this.
|
|
55
|
+
this.run();
|
|
56
56
|
}
|
|
57
57
|
get config() {
|
|
58
58
|
return {
|
|
@@ -62,20 +62,20 @@ class Agent extends _agentBase.AgentBase {
|
|
|
62
62
|
runtime: (0, _config.getRuntime)(this.agentIdentifier)
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
run() {
|
|
66
66
|
const NR_FEATURES_REF_NAME = 'features';
|
|
67
67
|
// Attempt to initialize all the requested features (sequentially in prio order & synchronously), with any failure aborting the whole process.
|
|
68
68
|
try {
|
|
69
69
|
const enabledFeatures = (0, _enabledFeatures.getEnabledFeatures)(this.agentIdentifier);
|
|
70
70
|
const featuresToStart = [...this.desiredFeatures];
|
|
71
71
|
featuresToStart.sort((a, b) => _features.featurePriority[a.featureName] - _features.featurePriority[b.featureName]);
|
|
72
|
-
featuresToStart.forEach(
|
|
72
|
+
featuresToStart.forEach(InstrumentCtor => {
|
|
73
73
|
// pageViewEvent must be enabled because RUM calls are not optional. See comment in constructor and PR 428.
|
|
74
|
-
if (enabledFeatures[
|
|
75
|
-
const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(
|
|
74
|
+
if (enabledFeatures[InstrumentCtor.featureName] || InstrumentCtor.featureName === _features.FEATURE_NAMES.pageViewEvent) {
|
|
75
|
+
const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(InstrumentCtor.featureName);
|
|
76
76
|
const hasAllDeps = dependencies.every(x => enabledFeatures[x]);
|
|
77
|
-
if (!hasAllDeps) (0, _console.warn)("".concat(
|
|
78
|
-
this.features[
|
|
77
|
+
if (!hasAllDeps) (0, _console.warn)("".concat(InstrumentCtor.featureName, " is enabled but one or more dependent features has been disabled (").concat((0, _stringify.stringify)(dependencies), "). This may cause unintended consequences or missing data..."));
|
|
78
|
+
this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator);
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
(0, _nreum.gosNREUMInitializedAgents)(this.agentIdentifier, this.features, NR_FEATURES_REF_NAME);
|
|
@@ -26,7 +26,7 @@ const CUSTOM_ATTR_GROUP = 'CUSTOM/'; // the subgroup items should be stored unde
|
|
|
26
26
|
exports.CUSTOM_ATTR_GROUP = CUSTOM_ATTR_GROUP;
|
|
27
27
|
function setTopLevelCallers() {
|
|
28
28
|
const nr = (0, _nreum.gosCDN)();
|
|
29
|
-
const funcs = ['setErrorHandler', 'finished', 'addToTrace', 'inlineHit', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion'];
|
|
29
|
+
const funcs = ['setErrorHandler', 'finished', 'addToTrace', 'inlineHit', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start'];
|
|
30
30
|
funcs.forEach(f => {
|
|
31
31
|
nr[f] = function () {
|
|
32
32
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -58,7 +58,9 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
58
58
|
var spaPrefix = prefix + 'ixn-';
|
|
59
59
|
|
|
60
60
|
// Setup stub functions that queue calls for later processing.
|
|
61
|
-
asyncApiFns.forEach(fnName =>
|
|
61
|
+
asyncApiFns.forEach(fnName => {
|
|
62
|
+
apiInterface[fnName] = apiCall(prefix, fnName, true, 'api');
|
|
63
|
+
});
|
|
62
64
|
apiInterface.addPageAction = apiCall(prefix, 'addPageAction', true, _features.FEATURE_NAMES.pageAction);
|
|
63
65
|
apiInterface.setCurrentRouteName = apiCall(prefix, 'routeName', true, _features.FEATURE_NAMES.spa);
|
|
64
66
|
apiInterface.setPageViewName = function (name, host) {
|
|
@@ -128,6 +130,21 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
128
130
|
}
|
|
129
131
|
return appendJsAttribute('application.version', value, 'setApplicationVersion', false);
|
|
130
132
|
};
|
|
133
|
+
apiInterface.start = features => {
|
|
134
|
+
try {
|
|
135
|
+
const featNames = Object.values(_features.FEATURE_NAMES);
|
|
136
|
+
if (features === undefined) features = featNames;else {
|
|
137
|
+
features = Array.isArray(features) && features.length ? features : [features];
|
|
138
|
+
if (features.some(f => !featNames.includes(f))) return (0, _console.warn)("Invalid feature name supplied. Acceptable feature names are: ".concat(featNames));
|
|
139
|
+
if (!features.includes(_features.FEATURE_NAMES.pageViewEvent)) features.push(_features.FEATURE_NAMES.pageViewEvent);
|
|
140
|
+
}
|
|
141
|
+
features.forEach(feature => {
|
|
142
|
+
instanceEE.emit("".concat(feature, "-opt-in"));
|
|
143
|
+
});
|
|
144
|
+
} catch (err) {
|
|
145
|
+
(0, _console.warn)('An unexpected issue occurred', err);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
131
148
|
apiInterface.interaction = function () {
|
|
132
149
|
return new InteractionHandle().get();
|
|
133
150
|
};
|
|
@@ -154,14 +171,14 @@ function setAPI(agentIdentifier, forceDrain) {
|
|
|
154
171
|
};
|
|
155
172
|
}
|
|
156
173
|
};
|
|
157
|
-
|
|
174
|
+
['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
|
|
158
175
|
InteractionApiProto[name] = apiCall(spaPrefix, name, undefined, _features.FEATURE_NAMES.spa);
|
|
159
176
|
});
|
|
160
177
|
function apiCall(prefix, name, notSpa, bufferGroup) {
|
|
161
178
|
return function () {
|
|
162
179
|
(0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/' + name + '/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
|
|
163
180
|
if (bufferGroup) (0, _handle.handle)(prefix + name, [(0, _now.now)(), ...arguments], notSpa ? null : this, bufferGroup, instanceEE); // no bufferGroup means only the SM is emitted
|
|
164
|
-
return notSpa ?
|
|
181
|
+
return notSpa ? undefined : this;
|
|
165
182
|
};
|
|
166
183
|
}
|
|
167
184
|
apiInterface.noticeError = function (err, customAttributes) {
|
|
@@ -21,10 +21,10 @@ function setAPI(agentIdentifier) {
|
|
|
21
21
|
var scheme = (0, _config.getConfigurationValue)(agentIdentifier, 'ssl') === false ? 'http' : 'https';
|
|
22
22
|
var api = {
|
|
23
23
|
finished: (0, _invoke.single)(finished),
|
|
24
|
-
setErrorHandler
|
|
25
|
-
addToTrace
|
|
26
|
-
inlineHit
|
|
27
|
-
addRelease
|
|
24
|
+
setErrorHandler,
|
|
25
|
+
addToTrace,
|
|
26
|
+
inlineHit,
|
|
27
|
+
addRelease
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// Hook all of the api functions up to the queues/stubs created in loader/api.js
|
|
@@ -60,29 +60,28 @@ function setAPI(agentIdentifier) {
|
|
|
60
60
|
(0, _handle.handle)('bstApi', [report], undefined, _features.FEATURE_NAMES.sessionTrace, instanceEE);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// NREUM.inlineHit(
|
|
63
|
+
// NREUM.inlineHit(requestName, queueTime, appTime, totalBackEndTime, domTime, frontEndTime)
|
|
64
64
|
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
function inlineHit(t,
|
|
65
|
+
// requestName - the 'web page' name or service name
|
|
66
|
+
// queueTime - the amount of time spent in the app tier queue
|
|
67
|
+
// appTime - the amount of time spent in the application code
|
|
68
|
+
// totalBackEndTime - the total roundtrip time of the remote service call
|
|
69
|
+
// domTime - the time spent processing the result of the service call (or user defined)
|
|
70
|
+
// frontEndTime - the time spent rendering the result of the service call (or user defined)
|
|
71
|
+
function inlineHit(t, requestName, queueTime, appTime, totalBackEndTime, domTime, frontEndTime) {
|
|
72
72
|
if (!_runtime.isBrowserScope) return;
|
|
73
|
-
|
|
73
|
+
requestName = window.encodeURIComponent(requestName);
|
|
74
74
|
cycle += 1;
|
|
75
75
|
const agentInfo = (0, _config.getInfo)(agentIdentifier);
|
|
76
|
-
const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
77
76
|
if (!agentInfo.beacon) return;
|
|
78
77
|
var url = scheme + '://' + agentInfo.beacon + '/1/' + agentInfo.licenseKey;
|
|
79
78
|
url += '?a=' + agentInfo.applicationID + '&';
|
|
80
|
-
url += 't=' +
|
|
81
|
-
url += 'qt=' + ~~
|
|
82
|
-
url += 'ap=' + ~~
|
|
83
|
-
url += 'be=' + ~~
|
|
84
|
-
url += 'dc=' + ~~
|
|
85
|
-
url += 'fe=' + ~~
|
|
79
|
+
url += 't=' + requestName + '&';
|
|
80
|
+
url += 'qt=' + ~~queueTime + '&';
|
|
81
|
+
url += 'ap=' + ~~appTime + '&';
|
|
82
|
+
url += 'be=' + ~~totalBackEndTime + '&';
|
|
83
|
+
url += 'dc=' + ~~domTime + '&';
|
|
84
|
+
url += 'fe=' + ~~frontEndTime + '&';
|
|
86
85
|
url += 'c=' + cycle;
|
|
87
86
|
submitData.xhr({
|
|
88
87
|
url
|
|
@@ -13,6 +13,7 @@ function configure(agentIdentifier) {
|
|
|
13
13
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
14
|
let loaderType = arguments.length > 2 ? arguments[2] : undefined;
|
|
15
15
|
let forceDrain = arguments.length > 3 ? arguments[3] : undefined;
|
|
16
|
+
// eslint-disable-next-line camelcase
|
|
16
17
|
let {
|
|
17
18
|
init,
|
|
18
19
|
info,
|
|
@@ -26,9 +27,11 @@ function configure(agentIdentifier) {
|
|
|
26
27
|
if (!info) {
|
|
27
28
|
init = nr.init;
|
|
28
29
|
info = nr.info;
|
|
30
|
+
// eslint-disable-next-line camelcase
|
|
29
31
|
loader_config = nr.loader_config;
|
|
30
32
|
}
|
|
31
33
|
(0, _config.setConfiguration)(agentIdentifier, init || {});
|
|
34
|
+
// eslint-disable-next-line camelcase
|
|
32
35
|
(0, _config.setLoaderConfig)(agentIdentifier, loader_config || {});
|
|
33
36
|
info.jsAttributes ??= {};
|
|
34
37
|
if (_runtime.isWorkerScope) {
|
|
@@ -44,7 +44,14 @@ class MicroAgent extends _agentBase.AgentBase {
|
|
|
44
44
|
isolatedBacklog: true
|
|
45
45
|
}
|
|
46
46
|
}, options.loaderType || 'micro-agent'));
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Starts a set of agent features if not running in "autoStart" mode
|
|
50
|
+
* {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
|
|
51
|
+
* @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
|
|
52
|
+
*/
|
|
53
|
+
this.start = features => this.run(features);
|
|
54
|
+
this.run(nonAutoFeatures.filter(featureName => (0, _config.getConfigurationValue)(agentIdentifier, "".concat(featureName, ".autoStart"))));
|
|
48
55
|
}
|
|
49
56
|
get config() {
|
|
50
57
|
return {
|
|
@@ -54,7 +61,17 @@ class MicroAgent extends _agentBase.AgentBase {
|
|
|
54
61
|
runtime: (0, _config.getRuntime)(this.agentIdentifier)
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
|
-
|
|
64
|
+
run(features) {
|
|
65
|
+
try {
|
|
66
|
+
const featNames = nonAutoFeatures;
|
|
67
|
+
if (features === undefined) features = featNames;else {
|
|
68
|
+
features = Array.isArray(features) && features.length ? features : [features];
|
|
69
|
+
if (features.some(f => !featNames.includes(f))) return (0, _console.warn)("Invalid feature name supplied. Acceptable feature names are: ".concat(featNames));
|
|
70
|
+
if (!features.includes(_features.FEATURE_NAMES.pageViewEvent)) features.push(_features.FEATURE_NAMES.pageViewEvent);
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
(0, _console.warn)('An unexpected issue occurred', err);
|
|
74
|
+
}
|
|
58
75
|
try {
|
|
59
76
|
const enabledFeatures = (0, _enabledFeatures.getEnabledFeatures)(this.agentIdentifier);
|
|
60
77
|
try {
|
|
@@ -66,7 +83,7 @@ class MicroAgent extends _agentBase.AgentBase {
|
|
|
66
83
|
(0, _load.onWindowLoad)(() => {
|
|
67
84
|
// these features do not import an "instrument" file, meaning they are only hooked up to the API.
|
|
68
85
|
nonAutoFeatures.forEach(f => {
|
|
69
|
-
if (enabledFeatures[f]) {
|
|
86
|
+
if (enabledFeatures[f] && features.includes(f)) {
|
|
70
87
|
Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(_ref => {
|
|
71
88
|
let {
|
|
72
89
|
lazyFeatureLoader
|