@newrelic/browser-agent 1.254.1 → 1.255.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/CHANGELOG.md +10 -0
- package/dist/cjs/common/config/state/runtime.js +2 -1
- 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 +1 -1
- package/dist/cjs/common/harvest/harvest.js +1 -1
- package/dist/cjs/common/timing/time-keeper.js +24 -19
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +12 -5
- package/dist/cjs/common/vitals/first-contentful-paint.js +10 -6
- package/dist/cjs/common/vitals/first-input-delay.js +12 -10
- package/dist/cjs/common/vitals/first-paint.js +1 -2
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +11 -7
- package/dist/cjs/common/vitals/largest-contentful-paint.js +19 -17
- package/dist/cjs/common/vitals/long-task.js +0 -1
- package/dist/cjs/common/vitals/time-to-first-byte.js +11 -6
- package/dist/cjs/common/vitals/vital-metric.js +1 -4
- package/dist/cjs/common/window/nreum.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +3 -2
- package/dist/cjs/features/ajax/instrument/index.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +3 -2
- package/dist/cjs/features/jserrors/instrument/index.js +1 -1
- package/dist/cjs/features/page_action/aggregate/index.js +3 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +10 -5
- package/dist/cjs/features/page_view_timing/aggregate/index.js +21 -7
- package/dist/cjs/features/page_view_timing/instrument/index.js +1 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +14 -9
- package/dist/cjs/features/session_replay/shared/recorder-events.js +9 -1
- package/dist/cjs/features/session_replay/shared/recorder.js +56 -12
- package/dist/cjs/features/session_trace/aggregate/index.js +1 -1
- package/dist/cjs/features/session_trace/instrument/index.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +2 -2
- package/dist/cjs/features/soft_navigations/instrument/index.js +1 -1
- package/dist/cjs/features/spa/aggregate/index.js +19 -10
- package/dist/cjs/features/spa/instrument/index.js +1 -1
- package/dist/cjs/features/utils/feature-base.js +0 -2
- package/dist/cjs/loaders/agent-base.js +0 -2
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/api.js +1 -1
- package/dist/cjs/loaders/micro-agent.js +4 -7
- package/dist/esm/common/config/state/runtime.js +2 -1
- 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 +1 -1
- package/dist/esm/common/harvest/harvest.js +1 -1
- package/dist/esm/common/timing/time-keeper.js +24 -19
- package/dist/esm/common/vitals/cumulative-layout-shift.js +11 -4
- package/dist/esm/common/vitals/first-contentful-paint.js +9 -5
- package/dist/esm/common/vitals/first-input-delay.js +11 -9
- package/dist/esm/common/vitals/first-paint.js +1 -2
- package/dist/esm/common/vitals/interaction-to-next-paint.js +10 -6
- package/dist/esm/common/vitals/largest-contentful-paint.js +18 -16
- package/dist/esm/common/vitals/long-task.js +0 -1
- package/dist/esm/common/vitals/time-to-first-byte.js +10 -5
- package/dist/esm/common/vitals/vital-metric.js +1 -4
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +3 -2
- package/dist/esm/features/ajax/instrument/index.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +3 -2
- package/dist/esm/features/jserrors/instrument/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +3 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +10 -5
- package/dist/esm/features/page_view_timing/aggregate/index.js +21 -7
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +14 -9
- package/dist/esm/features/session_replay/shared/recorder-events.js +9 -1
- package/dist/esm/features/session_replay/shared/recorder.js +56 -12
- package/dist/esm/features/session_trace/aggregate/index.js +1 -1
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +2 -2
- package/dist/esm/features/soft_navigations/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +19 -10
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/feature-base.js +0 -2
- package/dist/esm/loaders/agent-base.js +0 -2
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/api.js +1 -1
- package/dist/esm/loaders/micro-agent.js +4 -7
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +4 -9
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/common/vitals/vital-metric.d.ts +1 -2
- package/dist/types/common/vitals/vital-metric.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/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- 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/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +4 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder-events.d.ts +8 -0
- package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts +17 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +0 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/feature-base.d.ts +0 -1
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +0 -2
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/config/state/runtime.js +2 -1
- package/src/common/context/__mocks__/shared-context.js +3 -0
- package/src/common/context/shared-context.js +1 -1
- package/src/common/harvest/harvest.js +1 -1
- package/src/common/timing/__mocks__/time-keeper.js +2 -0
- package/src/common/timing/time-keeper.js +26 -21
- package/src/common/vitals/cumulative-layout-shift.js +10 -4
- package/src/common/vitals/first-contentful-paint.js +9 -4
- package/src/common/vitals/first-input-delay.js +11 -6
- package/src/common/vitals/first-paint.js +1 -1
- package/src/common/vitals/interaction-to-next-paint.js +10 -3
- package/src/common/vitals/largest-contentful-paint.js +19 -15
- package/src/common/vitals/long-task.js +0 -1
- package/src/common/vitals/time-to-first-byte.js +5 -4
- package/src/common/vitals/vital-metric.js +2 -4
- package/src/common/window/nreum.js +1 -1
- package/src/features/ajax/aggregate/index.js +3 -2
- package/src/features/ajax/instrument/index.js +1 -1
- package/src/features/jserrors/aggregate/index.js +3 -2
- package/src/features/jserrors/instrument/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +3 -2
- package/src/features/page_view_event/aggregate/index.js +11 -5
- package/src/features/page_view_timing/aggregate/index.js +16 -6
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/aggregate/index.js +13 -9
- package/src/features/session_replay/shared/recorder-events.js +6 -1
- package/src/features/session_replay/shared/recorder.js +33 -9
- package/src/features/session_trace/aggregate/index.js +1 -1
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/soft_navigations/aggregate/index.js +2 -2
- package/src/features/soft_navigations/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +19 -8
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/feature-base.js +0 -3
- package/src/loaders/agent-base.js +0 -2
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/api.js +1 -1
- package/src/loaders/micro-agent.js +4 -6
- package/src/common/vitals/__mocks__/web-vitals.js +0 -19
|
@@ -21,6 +21,8 @@ var _interactionToNextPaint = require("../../../common/vitals/interaction-to-nex
|
|
|
21
21
|
var _largestContentfulPaint = require("../../../common/vitals/largest-contentful-paint");
|
|
22
22
|
var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
|
|
23
23
|
var _longTask = require("../../../common/vitals/long-task");
|
|
24
|
+
var _pageVisibility = require("../../../common/window/page-visibility");
|
|
25
|
+
var _constants2 = require("../../../common/vitals/constants");
|
|
24
26
|
/*
|
|
25
27
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
26
28
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -44,15 +46,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
44
46
|
this.timingsSent = [];
|
|
45
47
|
this.curSessEndRecorded = false;
|
|
46
48
|
if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
|
|
47
|
-
|
|
48
|
-
/* It's important that CWV api, like "onLCP", is called before this scheduler is initialized. The reason is because they listen to the same
|
|
49
|
-
on vis change or pagehide events, and we'd want ex. onLCP to record the timing (win the race) before we try to send "final harvest". */
|
|
50
|
-
|
|
51
49
|
(0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
52
50
|
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
|
|
53
51
|
const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
|
|
54
52
|
const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
55
53
|
this.waitForFlags([]).then(() => {
|
|
54
|
+
/* It's important that CWV api, like "onLCP", is called before the **scheduler** is initialized. The reason is because they listen to the same
|
|
55
|
+
on vis change or pagehide events, and we'd want ex. onLCP to record the timing (win the race) before we try to send "final harvest". */
|
|
56
56
|
_firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
|
|
57
57
|
_firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
|
|
58
58
|
_firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
|
|
@@ -60,10 +60,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
60
60
|
_interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
|
|
61
61
|
_timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
|
|
62
62
|
let {
|
|
63
|
-
|
|
63
|
+
attrs
|
|
64
64
|
} = _ref2;
|
|
65
|
-
this.addTiming('load', Math.round(
|
|
65
|
+
this.addTiming('load', Math.round(attrs.navigationEntry.loadEventEnd));
|
|
66
66
|
});
|
|
67
|
+
(0, _pageVisibility.subscribeToVisibilityChange)(() => {
|
|
68
|
+
/* Downstream, the event consumer interprets all timing node value as ms-unit and converts it to seconds via division by 1000. CLS is unitless so this normally is a problem.
|
|
69
|
+
bel.6 schema also doesn't support decimal values, of which cls within [0,1). However, the two nicely cancels out, and we can multiply cls by 1000 to both negate the division
|
|
70
|
+
and send an integer > 1. We effectively lose some precision down to 3 decimal places for this workaround. E.g. (real) 0.749132... -> 749.132...-> 749 -> 0.749 (final) */
|
|
71
|
+
const {
|
|
72
|
+
name,
|
|
73
|
+
value,
|
|
74
|
+
attrs
|
|
75
|
+
} = _cumulativeLayoutShift.cumulativeLayoutShift.current;
|
|
76
|
+
if (value === undefined) return;
|
|
77
|
+
this.addTiming(name, value * 1000, attrs);
|
|
78
|
+
}, true); // CLS node should only reports on vis change rather than on every change
|
|
79
|
+
|
|
67
80
|
const scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
68
81
|
onFinished: function () {
|
|
69
82
|
return _this.onHarvestFinished(...arguments);
|
|
@@ -113,8 +126,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
113
126
|
Issue: Because NR 'pageHide' was only sent once with what is considered the "final" CLS value, in the case that 'pageHide' fires before 'load' happens, we incorrectly a final CLS of 0 for that page.
|
|
114
127
|
Mitigation: We've set initial CLS to null so that it's omitted from timings like 'pageHide' in that edge case. It should only be included if onCLS callback was executed at least once.
|
|
115
128
|
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.
|
|
129
|
+
*cli Mar'24 update: CLS now emitted as its own timing node in addition to as-property under other nodes. The 'cls' property is unnecessary for cls nodes.
|
|
116
130
|
*/
|
|
117
|
-
if (_cumulativeLayoutShift.cumulativeLayoutShift.current.value >= 0) {
|
|
131
|
+
if (name !== _constants2.VITAL_NAMES.CUMULATIVE_LAYOUT_SHIFT && _cumulativeLayoutShift.cumulativeLayoutShift.current.value >= 0) {
|
|
118
132
|
attrs.cls = _cumulativeLayoutShift.cumulativeLayoutShift.current.value;
|
|
119
133
|
}
|
|
120
134
|
this.timings.push({
|
|
@@ -7,10 +7,10 @@ exports.Instrument = void 0;
|
|
|
7
7
|
var _handle = require("../../../common/event-emitter/handle");
|
|
8
8
|
var _pageVisibility = require("../../../common/window/page-visibility");
|
|
9
9
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
10
|
-
var _now = require("../../../common/timing/now");
|
|
11
10
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
12
11
|
var _constants = require("../constants");
|
|
13
12
|
var _runtime = require("../../../common/constants/runtime");
|
|
13
|
+
var _now = require("../../../common/timing/now");
|
|
14
14
|
/*
|
|
15
15
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
16
16
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -17,11 +17,11 @@ var _constants2 = require("../../metrics/constants");
|
|
|
17
17
|
var _handle = require("../../../common/event-emitter/handle");
|
|
18
18
|
var _features = require("../../../loaders/features/features");
|
|
19
19
|
var _env = require("../../../common/constants/env.npm");
|
|
20
|
-
var _now = require("../../../common/timing/now");
|
|
21
20
|
var _constants3 = require("../../../common/session/constants");
|
|
22
21
|
var _stringify = require("../../../common/util/stringify");
|
|
23
22
|
var _stylesheetEvaluator = require("../shared/stylesheet-evaluator");
|
|
24
23
|
var _drain = require("../../../common/drain/drain");
|
|
24
|
+
var _now = require("../../../common/timing/now");
|
|
25
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
26
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
|
|
27
27
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
@@ -56,6 +56,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
56
56
|
|
|
57
57
|
/** set by BCS response */
|
|
58
58
|
this.entitled = false;
|
|
59
|
+
/** set at BCS response, stored in runtime */
|
|
60
|
+
this.timeKeeper = undefined;
|
|
59
61
|
this.recorder = args?.recorder;
|
|
60
62
|
if (this.recorder) this.recorder.parent = this;
|
|
61
63
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/Enabled'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
@@ -189,8 +191,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
189
191
|
// session replay samples can only be decided on the first load of a session
|
|
190
192
|
// session replays can continue if already in progress
|
|
191
193
|
const {
|
|
192
|
-
session
|
|
194
|
+
session,
|
|
195
|
+
timeKeeper
|
|
193
196
|
} = (0, _config.getRuntime)(this.agentIdentifier);
|
|
197
|
+
this.timeKeeper = timeKeeper;
|
|
194
198
|
if (!session.isNew && !ignoreSession) {
|
|
195
199
|
// inherit the mode of the existing session
|
|
196
200
|
this.mode = session.state.sessionReplayMode;
|
|
@@ -256,7 +260,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
256
260
|
let {
|
|
257
261
|
opts
|
|
258
262
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
259
|
-
if (!this.recorder) return;
|
|
263
|
+
if (!this.recorder || !this.timeKeeper?.ready) return;
|
|
260
264
|
const recorderEvents = this.recorder.getEvents();
|
|
261
265
|
// get the event type and use that to trigger another harvest if needed
|
|
262
266
|
if (!recorderEvents.events.length || this.mode !== _constants3.MODE.FULL || this.blocked) return;
|
|
@@ -267,7 +271,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
267
271
|
}
|
|
268
272
|
let len = 0;
|
|
269
273
|
if (!!this.gzipper && !!this.u8) {
|
|
270
|
-
payload.body = this.gzipper(this.u8("[".concat(payload.body.map(e =>
|
|
274
|
+
payload.body = this.gzipper(this.u8("[".concat(payload.body.map(e => {
|
|
275
|
+
if (e.__serialized) return e.__serialized;
|
|
276
|
+
return (0, _stringify.stringify)(e);
|
|
277
|
+
}).join(','), "]")));
|
|
271
278
|
len = payload.body.length;
|
|
272
279
|
this.scheduler.opts.gzip = true;
|
|
273
280
|
} else {
|
|
@@ -320,12 +327,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
320
327
|
events = events.slice(0, events.length - 1);
|
|
321
328
|
recorderEvents.hasMeta = !!events.find(x => x.type === _constants.RRWEB_EVENT_TYPES.Meta);
|
|
322
329
|
}
|
|
323
|
-
const agentOffset = (0, _config.getRuntime)(this.agentIdentifier).offset;
|
|
324
330
|
const relativeNow = (0, _now.now)();
|
|
325
331
|
const firstEventTimestamp = events[0]?.timestamp; // from rrweb node
|
|
326
332
|
const lastEventTimestamp = events[events.length - 1]?.timestamp; // from rrweb node
|
|
327
|
-
const firstTimestamp = firstEventTimestamp || recorderEvents.cycleTimestamp; // from rrweb node || from when the harvest cycle started
|
|
328
|
-
const lastTimestamp = lastEventTimestamp ||
|
|
333
|
+
const firstTimestamp = firstEventTimestamp || this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp); // from rrweb node || from when the harvest cycle started
|
|
334
|
+
const lastTimestamp = lastEventTimestamp || this.timeKeeper.convertRelativeTimestamp(relativeNow);
|
|
329
335
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
|
|
330
336
|
return {
|
|
331
337
|
qs: {
|
|
@@ -333,6 +339,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
333
339
|
type: 'SessionReplay',
|
|
334
340
|
app_id: info.applicationID,
|
|
335
341
|
protocol_version: '0',
|
|
342
|
+
timestamp: firstTimestamp,
|
|
336
343
|
attributes: (0, _encode.obj)({
|
|
337
344
|
// this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
|
|
338
345
|
// if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
|
|
@@ -343,9 +350,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
343
350
|
entityGuid: agentMetadata.entityGuid
|
|
344
351
|
}),
|
|
345
352
|
'replay.firstTimestamp': firstTimestamp,
|
|
346
|
-
'replay.firstTimestampOffset': firstTimestamp - agentOffset,
|
|
347
353
|
'replay.lastTimestamp': lastTimestamp,
|
|
348
|
-
'replay.durationMs': lastTimestamp - firstTimestamp,
|
|
349
354
|
'replay.nodes': events.length,
|
|
350
355
|
'session.durationMs': agentRuntime.session.getDuration(),
|
|
351
356
|
agentVersion: agentRuntime.version,
|
|
@@ -5,13 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.RecorderEvents = void 0;
|
|
7
7
|
class RecorderEvents {
|
|
8
|
-
constructor() {
|
|
8
|
+
constructor(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
canCorrectTimestamps
|
|
11
|
+
} = _ref;
|
|
9
12
|
/** The buffer to hold recorder event nodes */
|
|
10
13
|
this.events = [];
|
|
11
14
|
/** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
|
|
12
15
|
* cycle timestamps are used as fallbacks if event timestamps cannot be used
|
|
13
16
|
*/
|
|
14
17
|
this.cycleTimestamp = Date.now();
|
|
18
|
+
/** Payload metadata -- Whether timestamps can be corrected, defaults as false, can be set to true if timekeeper is present at init time. Used to determine
|
|
19
|
+
* if harvest needs to re-loop through nodes and correct them before sending. Ideal behavior is to correct them as they flow into the recorder
|
|
20
|
+
* to prevent re-looping, but is not always possible since the timekeeper is not set until after page load and the recorder can be preloaded.
|
|
21
|
+
*/
|
|
22
|
+
this.canCorrectTimestamps = !!canCorrectTimestamps;
|
|
15
23
|
/** A value which increments with every new mutation node reported. Resets after a harvest is sent */
|
|
16
24
|
this.payloadBytesEstimation = 0;
|
|
17
25
|
/** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
|
|
@@ -16,14 +16,23 @@ var _constants3 = require("../../metrics/constants");
|
|
|
16
16
|
var _features = require("../../../loaders/features/features");
|
|
17
17
|
class Recorder {
|
|
18
18
|
/** Each page mutation or event will be stored (raw) in this array. This array will be cleared on each harvest */
|
|
19
|
-
#events
|
|
19
|
+
#events;
|
|
20
20
|
/** Backlog used for a 2-part sliding window to guarantee a 15-30s buffer window */
|
|
21
|
-
#backloggedEvents
|
|
21
|
+
#backloggedEvents;
|
|
22
22
|
/** array of recorder events -- Will be filled only if forced harvest was triggered and harvester does not exist */
|
|
23
|
-
#preloaded
|
|
23
|
+
#preloaded;
|
|
24
24
|
/** flag that if true, blocks events from being "stored". Only set to true when a full snapshot has incomplete nodes (only stylesheets ATM) */
|
|
25
25
|
#fixing = false;
|
|
26
26
|
constructor(parent) {
|
|
27
|
+
this.#events = new _recorderEvents.RecorderEvents({
|
|
28
|
+
canCorrectTimestamps: !!parent.timeKeeper?.ready
|
|
29
|
+
});
|
|
30
|
+
this.#backloggedEvents = new _recorderEvents.RecorderEvents({
|
|
31
|
+
canCorrectTimestamps: !!parent.timeKeeper?.ready
|
|
32
|
+
});
|
|
33
|
+
this.#preloaded = [new _recorderEvents.RecorderEvents({
|
|
34
|
+
canCorrectTimestamps: !!parent.timeKeeper?.ready
|
|
35
|
+
})];
|
|
27
36
|
/** True when actively recording, false when paused or stopped */
|
|
28
37
|
this.recording = false;
|
|
29
38
|
/** The pointer to the current bucket holding rrweb events */
|
|
@@ -40,12 +49,18 @@ class Recorder {
|
|
|
40
49
|
this.stopRecording = () => {/* no-op until set by rrweb initializer */};
|
|
41
50
|
}
|
|
42
51
|
getEvents() {
|
|
43
|
-
if (this.#preloaded[0]?.events.length)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
if (this.#preloaded[0]?.events.length) {
|
|
53
|
+
const preloadedEvents = this.returnCorrectTimestamps(this.#preloaded[0]);
|
|
54
|
+
return {
|
|
55
|
+
...this.#preloaded[0],
|
|
56
|
+
events: preloadedEvents,
|
|
57
|
+
type: 'preloaded'
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const backloggedEvents = this.returnCorrectTimestamps(this.#backloggedEvents);
|
|
61
|
+
const events = this.returnCorrectTimestamps(this.#events);
|
|
47
62
|
return {
|
|
48
|
-
events: [...
|
|
63
|
+
events: [...backloggedEvents, ...events].filter(x => x),
|
|
49
64
|
type: 'standard',
|
|
50
65
|
cycleTimestamp: Math.min(this.#backloggedEvents.cycleTimestamp, this.#events.cycleTimestamp),
|
|
51
66
|
payloadBytesEstimation: this.#backloggedEvents.payloadBytesEstimation + this.#events.payloadBytesEstimation,
|
|
@@ -56,10 +71,34 @@ class Recorder {
|
|
|
56
71
|
};
|
|
57
72
|
}
|
|
58
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Returns time-corrected events. If the events were correctable from the beginning, this correction will have already been applied.
|
|
76
|
+
* @param {SessionReplayEvent[]} events The array of buffered SR nodes
|
|
77
|
+
* @returns {CorrectedSessionReplayEvent[]}
|
|
78
|
+
*/
|
|
79
|
+
returnCorrectTimestamps(events) {
|
|
80
|
+
if (!this.parent.timeKeeper?.ready) return events.events;
|
|
81
|
+
return events.canCorrectTimestamps ? events.events : events.events.map(_ref => {
|
|
82
|
+
let {
|
|
83
|
+
__serialized,
|
|
84
|
+
timestamp,
|
|
85
|
+
...e
|
|
86
|
+
} = _ref;
|
|
87
|
+
return {
|
|
88
|
+
timestamp: this.parent.timeKeeper.correctAbsoluteTimestamp(timestamp),
|
|
89
|
+
...e
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
59
94
|
/** Clears the buffer (this.#events), and resets all payload metadata properties */
|
|
60
95
|
clearBuffer() {
|
|
61
|
-
if (this.#preloaded[0]?.events.length) this.#preloaded.shift();else if (this.parent.mode === _constants2.MODE.ERROR) this.#backloggedEvents = this.#events;else this.#backloggedEvents = new _recorderEvents.RecorderEvents(
|
|
62
|
-
|
|
96
|
+
if (this.#preloaded[0]?.events.length) this.#preloaded.shift();else if (this.parent.mode === _constants2.MODE.ERROR) this.#backloggedEvents = this.#events;else this.#backloggedEvents = new _recorderEvents.RecorderEvents({
|
|
97
|
+
canCorrectTimestamps: !!this.parent.timeKeeper?.ready
|
|
98
|
+
});
|
|
99
|
+
this.#events = new _recorderEvents.RecorderEvents({
|
|
100
|
+
canCorrectTimestamps: !!this.parent.timeKeeper?.ready
|
|
101
|
+
});
|
|
63
102
|
}
|
|
64
103
|
|
|
65
104
|
/** Begin recording using configured recording lib */
|
|
@@ -136,9 +175,12 @@ class Recorder {
|
|
|
136
175
|
/** Store a payload in the buffer (this.#events). This should be the callback to the recording lib noticing a mutation */
|
|
137
176
|
store(event, isCheckout) {
|
|
138
177
|
if (!event) return;
|
|
139
|
-
event.__serialized = (0, _stringify.stringify)(event);
|
|
140
178
|
if (!this.parent.scheduler && this.#preloaded.length) this.currentBufferTarget = this.#preloaded[this.#preloaded.length - 1];else this.currentBufferTarget = this.#events;
|
|
141
179
|
if (this.parent.blocked) return;
|
|
180
|
+
if (this.currentBufferTarget.canCorrectTimestamps) {
|
|
181
|
+
event.timestamp = this.parent.timeKeeper.correctAbsoluteTimestamp(event.timestamp);
|
|
182
|
+
}
|
|
183
|
+
event.__serialized = (0, _stringify.stringify)(event);
|
|
142
184
|
const eventBytes = event.__serialized.length;
|
|
143
185
|
/** The estimated size of the payload after compression */
|
|
144
186
|
const payloadSize = this.getPayloadSize(eventBytes);
|
|
@@ -170,7 +212,9 @@ class Recorder {
|
|
|
170
212
|
this.parent.scheduler.runHarvest();
|
|
171
213
|
} else {
|
|
172
214
|
// we are still in "preload" and it triggered a "stop point". Make a new set, which will get pointed at on next cycle
|
|
173
|
-
this.#preloaded.push(new _recorderEvents.RecorderEvents(
|
|
215
|
+
this.#preloaded.push(new _recorderEvents.RecorderEvents({
|
|
216
|
+
canCorrectTimestamps: !!this.parent.timeKeeper?.ready
|
|
217
|
+
}));
|
|
174
218
|
}
|
|
175
219
|
}
|
|
176
220
|
}
|
|
@@ -8,12 +8,12 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
|
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
9
|
var _parseUrl = require("../../../common/url/parse-url");
|
|
10
10
|
var _config = require("../../../common/config/config");
|
|
11
|
-
var _now = require("../../../common/timing/now");
|
|
12
11
|
var _constants = require("../constants");
|
|
13
12
|
var _handlerCache = require("../../utils/handler-cache");
|
|
14
13
|
var _replayMode = require("../../session_replay/shared/replay-mode");
|
|
15
14
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
16
15
|
var _constants2 = require("../../../common/session/constants");
|
|
16
|
+
var _now = require("../../../common/timing/now");
|
|
17
17
|
/*
|
|
18
18
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
19
19
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Instrument = void 0;
|
|
7
7
|
var _handle = require("../../../common/event-emitter/handle");
|
|
8
8
|
var _wrap = require("../../../common/wrap");
|
|
9
|
-
var _now = require("../../../common/timing/now");
|
|
10
9
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
11
10
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
12
11
|
var _features = require("../../../loaders/features/features");
|
|
13
12
|
var _runtime = require("../../../common/constants/runtime");
|
|
13
|
+
var _now = require("../../../common/timing/now");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
/*
|
|
@@ -32,9 +32,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
32
32
|
this.initialPageLoadInteraction = new _initialPageLoadInteraction.InitialPageLoadInteraction(agentIdentifier);
|
|
33
33
|
_timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
|
|
34
34
|
let {
|
|
35
|
-
|
|
35
|
+
attrs
|
|
36
36
|
} = _ref2;
|
|
37
|
-
const loadEventTime =
|
|
37
|
+
const loadEventTime = attrs.navigationEntry.loadEventEnd;
|
|
38
38
|
this.initialPageLoadInteraction.forceSave = true;
|
|
39
39
|
this.initialPageLoadInteraction.done(loadEventTime);
|
|
40
40
|
this.interactionsToHarvest.push(this.initialPageLoadInteraction);
|
|
@@ -8,11 +8,11 @@ var _config = require("../../../common/config/config");
|
|
|
8
8
|
var _runtime = require("../../../common/constants/runtime");
|
|
9
9
|
var _handle = require("../../../common/event-emitter/handle");
|
|
10
10
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
11
|
-
var _now = require("../../../common/timing/now");
|
|
12
11
|
var _invoke = require("../../../common/util/invoke");
|
|
13
12
|
var _wrap = require("../../../common/wrap");
|
|
14
13
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
15
14
|
var _constants = require("../constants");
|
|
15
|
+
var _now = require("../../../common/timing/now");
|
|
16
16
|
/** The minimal time after a UI event for which no further events will be processed - i.e. a throttling rate to reduce spam.
|
|
17
17
|
* This also give some time for the new interaction to complete without being discarded by a subsequent UI event and wrongly attributed.
|
|
18
18
|
* This value is still subject to change and critique, as it is derived from beyond worst case time to next frame of a page.
|
|
@@ -26,6 +26,7 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
26
26
|
var _handle = require("../../../common/event-emitter/handle");
|
|
27
27
|
var _constants2 = require("../../metrics/constants");
|
|
28
28
|
var _drain = require("../../../common/drain/drain");
|
|
29
|
+
var _console = require("../../../common/util/console");
|
|
29
30
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
30
31
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
31
32
|
/*
|
|
@@ -56,9 +57,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
56
57
|
static featureName = FEATURE_NAME;
|
|
57
58
|
constructor(agentIdentifier, aggregator) {
|
|
58
59
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
60
|
+
const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
59
61
|
this.state = {
|
|
60
|
-
initialPageURL:
|
|
61
|
-
lastSeenUrl:
|
|
62
|
+
initialPageURL: agentRuntime.origin,
|
|
63
|
+
lastSeenUrl: agentRuntime.origin,
|
|
62
64
|
lastSeenRouteName: null,
|
|
63
65
|
timerMap: {},
|
|
64
66
|
timerBudget: MAX_TIMER_BUDGET,
|
|
@@ -81,9 +83,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
81
83
|
state,
|
|
82
84
|
serializer
|
|
83
85
|
} = this;
|
|
84
|
-
let {
|
|
85
|
-
blocked
|
|
86
|
-
} = this;
|
|
87
86
|
const baseEE = _contextualEe.ee.get(agentIdentifier); // <-- parent baseEE
|
|
88
87
|
const mutationEE = baseEE.get('mutation');
|
|
89
88
|
const promiseEE = baseEE.get('promise');
|
|
@@ -130,14 +129,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
130
129
|
this.waitForFlags(['spa']).then(_ref => {
|
|
131
130
|
let [spaFlag] = _ref;
|
|
132
131
|
if (spaFlag) {
|
|
133
|
-
scheduler =
|
|
132
|
+
scheduler = new _harvestScheduler.HarvestScheduler('events', {
|
|
134
133
|
onFinished: onHarvestFinished,
|
|
135
134
|
retryDelay: state.harvestTimeSeconds
|
|
136
135
|
}, {
|
|
137
136
|
agentIdentifier,
|
|
138
137
|
ee: baseEE
|
|
139
138
|
});
|
|
140
|
-
|
|
139
|
+
scheduler.harvest.on('events', onHarvestStarted);
|
|
141
140
|
this.drain();
|
|
142
141
|
} else {
|
|
143
142
|
this.blocked = true;
|
|
@@ -316,6 +315,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
316
315
|
if (node && !this.sent) {
|
|
317
316
|
this.sent = true;
|
|
318
317
|
node.dt = this.dt;
|
|
318
|
+
if (node.dt?.timestamp) {
|
|
319
|
+
node.dt.timestamp = agentRuntime.timeKeeper.correctAbsoluteTimestamp(node.dt.timestamp);
|
|
320
|
+
}
|
|
319
321
|
node.jsEnd = node.start = this.startTime;
|
|
320
322
|
node[INTERACTION][REMAINING]++;
|
|
321
323
|
}
|
|
@@ -400,7 +402,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
400
402
|
}
|
|
401
403
|
if (state.currentNode) {
|
|
402
404
|
this[SPA_NODE] = state.currentNode.child('ajax', this[FETCH_START]);
|
|
403
|
-
if (dtPayload && this[SPA_NODE])
|
|
405
|
+
if (dtPayload && this[SPA_NODE]) {
|
|
406
|
+
this[SPA_NODE].dt = dtPayload;
|
|
407
|
+
if (this[SPA_NODE].dt?.timestamp) {
|
|
408
|
+
this[SPA_NODE].dt.timestamp = agentRuntime.timeKeeper.correctAbsoluteTimestamp(this[SPA_NODE].dt.timestamp);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
404
411
|
}
|
|
405
412
|
}
|
|
406
413
|
}, this.featureName, fetchEE);
|
|
@@ -620,8 +627,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
620
627
|
});
|
|
621
628
|
setCurrentNode(null);
|
|
622
629
|
}
|
|
630
|
+
const classThis = this;
|
|
623
631
|
function onHarvestStarted(options) {
|
|
624
|
-
if (state.interactionsToHarvest.length === 0 || blocked) return {};
|
|
632
|
+
if (state.interactionsToHarvest.length === 0 || classThis.blocked) return {};
|
|
625
633
|
var payload = serializer.serializeMultiple(state.interactionsToHarvest, 0, _navTiming.navTimingValues);
|
|
626
634
|
if (options.retry) {
|
|
627
635
|
state.interactionsToHarvest.forEach(function (interaction) {
|
|
@@ -683,7 +691,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
683
691
|
let smCategory;
|
|
684
692
|
if (interaction.root?.attrs?.trigger === 'initialPageLoad') smCategory = 'InitialPageLoad';else if (interaction.routeChange) smCategory = 'RouteChange';else smCategory = 'Custom';
|
|
685
693
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ["Spa/Interaction/".concat(smCategory, "/Duration/Ms"), Math.max((interaction.root?.end || 0) - (interaction.root?.start || 0), 0)], undefined, _features.FEATURE_NAMES.metrics, baseEE);
|
|
686
|
-
scheduler
|
|
694
|
+
scheduler?.scheduleHarvest(0);
|
|
695
|
+
if (!scheduler) (0, _console.warn)('SPA scheduler is not initialized. Saved interaction is not sent!');
|
|
687
696
|
}
|
|
688
697
|
function isEnabled() {
|
|
689
698
|
var enabled = (0, _config.getConfigurationValue)(agentIdentifier, 'spa.enabled');
|
|
@@ -8,9 +8,9 @@ var _wrap = require("../../../common/wrap");
|
|
|
8
8
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
9
9
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
10
10
|
var _config = require("../../../common/config/config");
|
|
11
|
-
var _now = require("../../../common/timing/now");
|
|
12
11
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
13
12
|
var _runtime = require("../../../common/constants/runtime");
|
|
13
|
+
var _now = require("../../../common/timing/now");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
/*
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FeatureBase = void 0;
|
|
7
7
|
var _contextualEe = require("../../common/event-emitter/contextual-ee");
|
|
8
|
-
var _timeKeeper = require("../../common/timing/time-keeper");
|
|
9
8
|
class FeatureBase {
|
|
10
9
|
constructor(agentIdentifier, aggregator, featureName) {
|
|
11
10
|
/** @type {string} */
|
|
@@ -22,7 +21,6 @@ class FeatureBase {
|
|
|
22
21
|
* @type {boolean}
|
|
23
22
|
*/
|
|
24
23
|
this.blocked = false;
|
|
25
|
-
this.timeKeeper = _timeKeeper.TimeKeeper.getTimeKeeperByAgentIdentifier(this.agentIdentifier);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
exports.FeatureBase = FeatureBase;
|
|
@@ -7,7 +7,6 @@ exports.AgentBase = void 0;
|
|
|
7
7
|
var _console = require("../common/util/console");
|
|
8
8
|
var _constants = require("../features/session_replay/constants");
|
|
9
9
|
var _uniqueId = require("../common/ids/unique-id");
|
|
10
|
-
var _timeKeeper = require("../common/timing/time-keeper");
|
|
11
10
|
/* eslint-disable n/handle-callback-err */
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -16,7 +15,6 @@ var _timeKeeper = require("../common/timing/time-keeper");
|
|
|
16
15
|
|
|
17
16
|
class AgentBase {
|
|
18
17
|
agentIdentifier;
|
|
19
|
-
timeKeeper = new _timeKeeper.TimeKeeper(this);
|
|
20
18
|
constructor() {
|
|
21
19
|
let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _uniqueId.generateRandomHexString)(16);
|
|
22
20
|
this.agentIdentifier = agentIdentifier;
|
|
@@ -35,7 +35,7 @@ class Agent extends _agentBase.AgentBase {
|
|
|
35
35
|
if (!_runtime.globalScope) {
|
|
36
36
|
// We could not determine the runtime environment. Short-circuite the agent here
|
|
37
37
|
// to avoid possible exceptions later that may cause issues with customer's application.
|
|
38
|
-
(0, _console.warn)('Failed to
|
|
38
|
+
(0, _console.warn)('Failed to initialize the agent. Could not determine the runtime environment.');
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
this.sharedAggregator = new _aggregator.Aggregator({
|
|
@@ -9,7 +9,6 @@ var _features = require("../features/features");
|
|
|
9
9
|
var _config = require("../../common/config/config");
|
|
10
10
|
var _handle = require("../../common/event-emitter/handle");
|
|
11
11
|
var _contextualEe = require("../../common/event-emitter/contextual-ee");
|
|
12
|
-
var _now = require("../../common/timing/now");
|
|
13
12
|
var _drain = require("../../common/drain/drain");
|
|
14
13
|
var _load = require("../../common/window/load");
|
|
15
14
|
var _runtime = require("../../common/constants/runtime");
|
|
@@ -18,6 +17,7 @@ var _constants = require("../../features/metrics/constants");
|
|
|
18
17
|
var _nreum = require("../../common/window/nreum");
|
|
19
18
|
var _apiMethods = require("./api-methods");
|
|
20
19
|
var _constants2 = require("../../features/session_replay/constants");
|
|
20
|
+
var _now = require("../../common/timing/now");
|
|
21
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
|
|
23
23
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -9,7 +9,6 @@ var _enabledFeatures = require("./features/enabled-features");
|
|
|
9
9
|
var _configure = require("./configure/configure");
|
|
10
10
|
var _aggregator = require("../common/aggregate/aggregator");
|
|
11
11
|
var _nreum = require("../common/window/nreum");
|
|
12
|
-
var _uniqueId = require("../common/ids/unique-id");
|
|
13
12
|
var _config = require("../common/config/config");
|
|
14
13
|
var _features = require("./features/features");
|
|
15
14
|
var _console = require("../common/util/console");
|
|
@@ -30,15 +29,13 @@ class MicroAgent extends _agentBase.AgentBase {
|
|
|
30
29
|
* @param {Object} options - Specifies features and runtime configuration,
|
|
31
30
|
* @param {string=} agentIdentifier - The optional unique ID of the agent.
|
|
32
31
|
*/
|
|
33
|
-
constructor(options) {
|
|
34
|
-
|
|
35
|
-
super();
|
|
36
|
-
this.agentIdentifier = agentIdentifier;
|
|
32
|
+
constructor(options, agentIdentifier) {
|
|
33
|
+
super(agentIdentifier);
|
|
37
34
|
this.sharedAggregator = new _aggregator.Aggregator({
|
|
38
35
|
agentIdentifier: this.agentIdentifier
|
|
39
36
|
});
|
|
40
37
|
this.features = {};
|
|
41
|
-
(0, _nreum.setNREUMInitializedAgent)(agentIdentifier, this);
|
|
38
|
+
(0, _nreum.setNREUMInitializedAgent)(this.agentIdentifier, this);
|
|
42
39
|
(0, _configure.configure)(this, {
|
|
43
40
|
...options,
|
|
44
41
|
runtime: {
|
|
@@ -53,7 +50,7 @@ class MicroAgent extends _agentBase.AgentBase {
|
|
|
53
50
|
* @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
|
|
54
51
|
*/
|
|
55
52
|
this.start = features => this.run(features);
|
|
56
|
-
this.run(nonAutoFeatures.filter(featureName => (0, _config.getConfigurationValue)(agentIdentifier, "".concat(featureName, ".autoStart"))));
|
|
53
|
+
this.run(nonAutoFeatures.filter(featureName => (0, _config.getConfigurationValue)(this.agentIdentifier, "".concat(featureName, ".autoStart"))));
|
|
57
54
|
}
|
|
58
55
|
get config() {
|
|
59
56
|
return {
|
|
@@ -23,7 +23,8 @@ const model = {
|
|
|
23
23
|
xhrWrappable: typeof globalScope.XMLHttpRequest?.prototype?.addEventListener === 'function',
|
|
24
24
|
version: VERSION,
|
|
25
25
|
denyList: undefined,
|
|
26
|
-
harvestCount: 0
|
|
26
|
+
harvestCount: 0,
|
|
27
|
+
timeKeeper: undefined
|
|
27
28
|
};
|
|
28
29
|
const _cache = {};
|
|
29
30
|
export function getRuntime(id) {
|
|
@@ -14,7 +14,7 @@ export class SharedContext {
|
|
|
14
14
|
if (Object.keys(model).includes(key)) this.sharedContext[key] = value;
|
|
15
15
|
});
|
|
16
16
|
} catch (err) {
|
|
17
|
-
warn('An error
|
|
17
|
+
warn('An error occurred while setting SharedContext', err);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -9,7 +9,6 @@ import * as submitData from '../util/submit-data';
|
|
|
9
9
|
import { getLocation } from '../url/location';
|
|
10
10
|
import { getInfo, getConfigurationValue, getRuntime, getConfiguration } from '../config/config';
|
|
11
11
|
import { cleanURL } from '../url/clean-url';
|
|
12
|
-
import { now } from '../timing/now';
|
|
13
12
|
import { eventListenerOpts } from '../event-listener/event-listener-opts';
|
|
14
13
|
import { Obfuscator } from '../util/obfuscate';
|
|
15
14
|
import { applyFnToProps } from '../util/traverse';
|
|
@@ -17,6 +16,7 @@ import { SharedContext } from '../context/shared-context';
|
|
|
17
16
|
import { VERSION } from "../constants/env.npm";
|
|
18
17
|
import { isWorkerScope, isIE } from '../constants/runtime';
|
|
19
18
|
import { warn } from '../util/console';
|
|
19
|
+
import { now } from '../timing/now';
|
|
20
20
|
const warnings = {};
|
|
21
21
|
|
|
22
22
|
/**
|