@newrelic/browser-agent 1.269.0 → 1.270.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 +11 -0
- 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 +1 -2
- package/dist/cjs/common/harvest/harvest-scheduler.js +3 -4
- package/dist/cjs/common/unload/eol.js +2 -5
- package/dist/cjs/common/util/submit-data.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +8 -17
- package/dist/cjs/features/ajax/instrument/index.js +8 -10
- package/dist/cjs/features/generic_events/aggregate/index.js +15 -22
- package/dist/cjs/features/generic_events/instrument/index.js +5 -8
- package/dist/cjs/features/jserrors/aggregate/index.js +17 -22
- package/dist/cjs/features/jserrors/instrument/index.js +3 -3
- package/dist/cjs/features/logging/aggregate/index.js +16 -23
- package/dist/cjs/features/logging/instrument/index.js +3 -3
- package/dist/cjs/features/metrics/aggregate/index.js +13 -16
- package/dist/cjs/features/metrics/instrument/index.js +3 -3
- package/dist/cjs/features/page_view_event/aggregate/index.js +15 -29
- package/dist/cjs/features/page_view_event/instrument/index.js +3 -3
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -23
- package/dist/cjs/features/page_view_timing/instrument/index.js +3 -3
- package/dist/cjs/features/session_replay/aggregate/index.js +15 -29
- package/dist/cjs/features/session_replay/instrument/index.js +7 -5
- package/dist/cjs/features/session_trace/aggregate/index.js +25 -31
- package/dist/cjs/features/session_trace/instrument/index.js +4 -5
- package/dist/cjs/features/soft_navigations/aggregate/index.js +6 -11
- package/dist/cjs/features/soft_navigations/instrument/index.js +3 -3
- package/dist/cjs/features/spa/aggregate/index.js +19 -30
- package/dist/cjs/features/spa/instrument/index.js +4 -4
- package/dist/cjs/features/utils/aggregate-base.js +11 -12
- package/dist/cjs/features/utils/feature-base.js +5 -3
- package/dist/cjs/features/utils/instrument-base.js +18 -10
- package/dist/cjs/loaders/agent.js +1 -5
- package/dist/cjs/loaders/micro-agent.js +6 -9
- 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 +0 -1
- package/dist/esm/common/harvest/harvest-scheduler.js +3 -4
- package/dist/esm/common/unload/eol.js +2 -5
- package/dist/esm/common/util/submit-data.js +2 -2
- package/dist/esm/features/ajax/aggregate/index.js +8 -17
- package/dist/esm/features/ajax/instrument/index.js +8 -10
- package/dist/esm/features/generic_events/aggregate/index.js +11 -18
- package/dist/esm/features/generic_events/instrument/index.js +5 -8
- package/dist/esm/features/jserrors/aggregate/index.js +15 -20
- package/dist/esm/features/jserrors/instrument/index.js +3 -3
- package/dist/esm/features/logging/aggregate/index.js +16 -23
- package/dist/esm/features/logging/instrument/index.js +3 -3
- package/dist/esm/features/metrics/aggregate/index.js +8 -11
- package/dist/esm/features/metrics/instrument/index.js +3 -3
- package/dist/esm/features/page_view_event/aggregate/index.js +16 -30
- package/dist/esm/features/page_view_event/instrument/index.js +3 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +6 -23
- package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
- package/dist/esm/features/session_replay/aggregate/index.js +13 -27
- package/dist/esm/features/session_replay/instrument/index.js +7 -5
- package/dist/esm/features/session_trace/aggregate/index.js +22 -28
- package/dist/esm/features/session_trace/instrument/index.js +4 -5
- package/dist/esm/features/soft_navigations/aggregate/index.js +6 -11
- package/dist/esm/features/soft_navigations/instrument/index.js +3 -3
- package/dist/esm/features/spa/aggregate/index.js +17 -28
- package/dist/esm/features/spa/instrument/index.js +4 -4
- package/dist/esm/features/utils/aggregate-base.js +13 -14
- package/dist/esm/features/utils/feature-base.js +5 -3
- package/dist/esm/features/utils/instrument-base.js +18 -10
- package/dist/esm/loaders/agent.js +1 -5
- package/dist/esm/loaders/micro-agent.js +6 -9
- package/dist/types/common/constants/runtime.d.ts +0 -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/unload/eol.d.ts +1 -1
- package/dist/types/common/unload/eol.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +1 -2
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/instrument/index.d.ts +1 -1
- package/dist/types/features/generic_events/instrument/index.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/jserrors/instrument/index.d.ts +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +1 -2
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/instrument/index.d.ts +1 -1
- package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts +1 -1
- package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/instrument/index.d.ts +1 -0
- package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts +1 -1
- package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +1 -5
- 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 +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 +0 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +1 -3
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/spa/instrument/index.d.ts +1 -1
- package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +2 -2
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/feature-base.d.ts +2 -3
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +3 -3
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts +0 -2
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts +0 -2
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/constants/__mocks__/runtime.js +0 -1
- package/src/common/constants/runtime.js +0 -2
- package/src/common/harvest/harvest-scheduler.js +3 -4
- package/src/common/unload/eol.js +2 -5
- package/src/common/util/submit-data.js +2 -2
- package/src/features/ajax/aggregate/index.js +8 -18
- package/src/features/ajax/instrument/index.js +8 -10
- package/src/features/generic_events/aggregate/index.js +11 -20
- package/src/features/generic_events/instrument/index.js +7 -10
- package/src/features/jserrors/aggregate/index.js +15 -20
- package/src/features/jserrors/instrument/index.js +3 -4
- package/src/features/logging/aggregate/index.js +15 -23
- package/src/features/logging/instrument/index.js +3 -3
- package/src/features/metrics/aggregate/index.js +8 -11
- package/src/features/metrics/instrument/index.js +3 -3
- package/src/features/page_view_event/aggregate/index.js +16 -22
- package/src/features/page_view_event/instrument/index.js +3 -3
- package/src/features/page_view_timing/aggregate/index.js +6 -23
- package/src/features/page_view_timing/instrument/index.js +3 -3
- package/src/features/session_replay/aggregate/index.js +13 -21
- package/src/features/session_replay/instrument/index.js +7 -5
- package/src/features/session_trace/aggregate/index.js +22 -28
- package/src/features/session_trace/instrument/index.js +4 -5
- package/src/features/soft_navigations/aggregate/index.js +6 -8
- package/src/features/soft_navigations/instrument/index.js +3 -3
- package/src/features/spa/aggregate/index.js +17 -26
- package/src/features/spa/instrument/index.js +4 -4
- package/src/features/utils/__mocks__/feature-base.js +1 -2
- package/src/features/utils/aggregate-base.js +13 -14
- package/src/features/utils/feature-base.js +6 -3
- package/src/features/utils/instrument-base.js +16 -10
- package/src/loaders/agent.js +1 -3
- package/src/loaders/micro-agent.js +7 -9
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Aggregate = void 0;
|
|
7
|
-
var _init = require("../../../common/config/init");
|
|
8
|
-
var _runtime = require("../../../common/config/runtime");
|
|
9
7
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
10
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
11
9
|
var _constants = require("../constants");
|
|
@@ -13,17 +11,16 @@ var _frameworkDetection = require("./framework-detection");
|
|
|
13
11
|
var _protocol = require("../../../common/url/protocol");
|
|
14
12
|
var _load = require("../../../common/window/load");
|
|
15
13
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
16
|
-
var
|
|
14
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
17
15
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
18
|
-
var _drain = require("../../../common/drain/drain");
|
|
19
16
|
var _iframe = require("../../../common/dom/iframe");
|
|
20
17
|
// import { WEBSOCKET_TAG } from '../../../common/wrap/wrap-websocket'
|
|
21
18
|
// import { handleWebsocketEvents } from './websocket-detection'
|
|
22
19
|
|
|
23
20
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
24
21
|
static featureName = _constants.FEATURE_NAME;
|
|
25
|
-
constructor(
|
|
26
|
-
super(
|
|
22
|
+
constructor(agentRef) {
|
|
23
|
+
super(agentRef, _constants.FEATURE_NAME);
|
|
27
24
|
this.waitForFlags(['err']).then(([errFlag]) => {
|
|
28
25
|
if (errFlag) {
|
|
29
26
|
// *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
|
|
@@ -32,12 +29,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
32
29
|
}, this);
|
|
33
30
|
// this is needed to ensure EoL is "on" and sent
|
|
34
31
|
scheduler.harvest.on('jserrors', () => ({
|
|
35
|
-
body: this.
|
|
32
|
+
body: this.agentRef.sharedAggregator.take(['cm', 'sm'])
|
|
36
33
|
}));
|
|
37
34
|
this.drain();
|
|
38
35
|
} else {
|
|
39
36
|
this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
|
|
40
|
-
|
|
37
|
+
this.deregisterDrain();
|
|
41
38
|
}
|
|
42
39
|
});
|
|
43
40
|
|
|
@@ -53,7 +50,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
53
50
|
const params = {
|
|
54
51
|
name
|
|
55
52
|
};
|
|
56
|
-
this.
|
|
53
|
+
this.agentRef.sharedAggregator.storeMetric(type, name, params, value);
|
|
57
54
|
}
|
|
58
55
|
storeEventMetrics(name, metrics) {
|
|
59
56
|
if (this.blocked) return;
|
|
@@ -61,21 +58,21 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
61
58
|
const params = {
|
|
62
59
|
name
|
|
63
60
|
};
|
|
64
|
-
this.
|
|
61
|
+
this.agentRef.sharedAggregator.store(type, name, params, metrics);
|
|
65
62
|
}
|
|
66
63
|
singleChecks() {
|
|
67
64
|
// report loaderType
|
|
68
65
|
const {
|
|
69
66
|
distMethod,
|
|
70
67
|
loaderType
|
|
71
|
-
} =
|
|
68
|
+
} = this.agentRef.runtime;
|
|
72
69
|
const {
|
|
73
70
|
proxy,
|
|
74
71
|
privacy
|
|
75
|
-
} =
|
|
72
|
+
} = this.agentRef.init;
|
|
76
73
|
if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
|
|
77
74
|
if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
|
|
78
|
-
if (
|
|
75
|
+
if (_runtime.isBrowserScope) {
|
|
79
76
|
this.storeSupportabilityMetrics('Generic/Runtime/Browser/Detected');
|
|
80
77
|
const nonce = document?.currentScript?.nonce;
|
|
81
78
|
if (nonce && nonce !== '') {
|
|
@@ -89,7 +86,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
89
86
|
});
|
|
90
87
|
});
|
|
91
88
|
if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
|
|
92
|
-
} else if (
|
|
89
|
+
} else if (_runtime.isWorkerScope) {
|
|
93
90
|
this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
|
|
94
91
|
} else {
|
|
95
92
|
this.storeSupportabilityMetrics('Generic/Runtime/Unknown/Detected');
|
|
@@ -111,7 +108,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
111
108
|
// Check if proxy for either chunks or beacon is being used
|
|
112
109
|
if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
|
|
113
110
|
if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
|
|
114
|
-
if (
|
|
111
|
+
if (_runtime.isBrowserScope && window.MutationObserver) {
|
|
115
112
|
if ((0, _iframe.isIFrameWindow)(window)) {
|
|
116
113
|
this.storeSupportabilityMetrics('Generic/Runtime/IFrame/Detected');
|
|
117
114
|
}
|
|
@@ -144,7 +141,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
144
141
|
// })
|
|
145
142
|
}
|
|
146
143
|
eachSessionChecks() {
|
|
147
|
-
if (!
|
|
144
|
+
if (!_runtime.isBrowserScope) return;
|
|
148
145
|
|
|
149
146
|
// [Temporary] Report restores from BFCache to NR1 while feature flag is in place in lieu of sending pageshow events.
|
|
150
147
|
(0, _eventListenerOpts.windowAddEventListener)('pageshow', evt => {
|
|
@@ -11,8 +11,8 @@ var _constants = require("../constants");
|
|
|
11
11
|
|
|
12
12
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
13
13
|
static featureName = _constants.FEATURE_NAME;
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
14
|
+
constructor(agentRef, auto = true) {
|
|
15
|
+
super(agentRef, _constants.FEATURE_NAME, auto);
|
|
16
16
|
// wrapWebSocket(this.ee)
|
|
17
17
|
|
|
18
18
|
// WATCHABLE_WEB_SOCKET_EVENTS.forEach((suffix) => {
|
|
@@ -21,7 +21,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
21
21
|
// })
|
|
22
22
|
// })
|
|
23
23
|
|
|
24
|
-
this.importAggregator();
|
|
24
|
+
this.importAggregator(agentRef);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.Instrument = Instrument;
|
|
@@ -8,7 +8,6 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
8
8
|
var _navTiming = require("../../../common/timing/nav-timing");
|
|
9
9
|
var _stringify = require("../../../common/util/stringify");
|
|
10
10
|
var _info = require("../../../common/config/info");
|
|
11
|
-
var _runtime2 = require("../../../common/config/runtime");
|
|
12
11
|
var _harvest = require("../../../common/harvest/harvest");
|
|
13
12
|
var CONSTANTS = _interopRequireWildcard(require("../constants"));
|
|
14
13
|
var _initializedFeatures = require("./initialized-features");
|
|
@@ -25,13 +24,13 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
25
24
|
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 && {}.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; }
|
|
26
25
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
27
26
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
27
|
+
constructor(agentRef) {
|
|
28
|
+
super(agentRef, CONSTANTS.FEATURE_NAME);
|
|
30
29
|
this.timeToFirstByte = 0;
|
|
31
30
|
this.firstByteToWindowLoad = 0; // our "frontend" duration
|
|
32
31
|
this.firstByteToDomContent = 0; // our "dom processing" duration
|
|
33
|
-
this.timeKeeper = new _timeKeeper.TimeKeeper(
|
|
34
|
-
if (!(0, _info.isValid)(agentIdentifier)) {
|
|
32
|
+
this.timeKeeper = new _timeKeeper.TimeKeeper(agentRef.agentIdentifier);
|
|
33
|
+
if (!(0, _info.isValid)(agentRef.agentIdentifier)) {
|
|
35
34
|
this.ee.abort();
|
|
36
35
|
return (0, _console.warn)(43);
|
|
37
36
|
}
|
|
@@ -53,43 +52,30 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
sendRum() {
|
|
56
|
-
const info =
|
|
57
|
-
const agentRuntime = (0, _runtime2.getRuntime)(this.agentIdentifier);
|
|
55
|
+
const info = this.agentRef.info;
|
|
58
56
|
const harvester = new _harvest.Harvest(this);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (info.applicationTime) this.aggregator.store('measures', 'ap', {
|
|
63
|
-
value: info.applicationTime
|
|
64
|
-
});
|
|
57
|
+
const measures = {};
|
|
58
|
+
if (info.queueTime) measures.qt = info.queueTime;
|
|
59
|
+
if (info.applicationTime) measures.ap = info.applicationTime;
|
|
65
60
|
|
|
66
61
|
// These 3 values should've been recorded after load and before this func runs. They are part of the minimum required for PageView events to be created.
|
|
67
62
|
// Following PR #428, which demands that all agents send RUM call, these need to be sent even outside of the main window context where PerformanceTiming
|
|
68
63
|
// or PerformanceNavigationTiming do not exists. Hence, they'll be filled in by 0s instead in, for example, worker threads that still init the PVE module.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.aggregator.store('measures', 'fe', {
|
|
73
|
-
value: this.firstByteToWindowLoad
|
|
74
|
-
});
|
|
75
|
-
this.aggregator.store('measures', 'dc', {
|
|
76
|
-
value: this.firstByteToDomContent
|
|
77
|
-
});
|
|
64
|
+
measures.be = this.timeToFirstByte;
|
|
65
|
+
measures.fe = this.firstByteToWindowLoad;
|
|
66
|
+
measures.dc = this.firstByteToDomContent;
|
|
78
67
|
const queryParameters = {
|
|
79
68
|
tt: info.ttGuid,
|
|
80
69
|
us: info.user,
|
|
81
70
|
ac: info.account,
|
|
82
71
|
pr: info.product,
|
|
83
72
|
af: (0, _initializedFeatures.getActivatedFeaturesFlags)(this.agentIdentifier).join(','),
|
|
84
|
-
...
|
|
85
|
-
aggregator[metricName] = measure.params?.value;
|
|
86
|
-
return aggregator;
|
|
87
|
-
}, {}),
|
|
73
|
+
...measures,
|
|
88
74
|
xx: info.extra,
|
|
89
75
|
ua: info.userAttributes,
|
|
90
76
|
at: info.atts
|
|
91
77
|
};
|
|
92
|
-
if (
|
|
78
|
+
if (this.agentRef.runtime.session) queryParameters.fsh = Number(this.agentRef.runtime.session.isNew); // "first session harvest" aka RUM request or PageView event of a session
|
|
93
79
|
|
|
94
80
|
let body;
|
|
95
81
|
if (typeof info.jsAttributes === 'object' && Object.keys(info.jsAttributes).length > 0) {
|
|
@@ -150,13 +136,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
150
136
|
try {
|
|
151
137
|
this.timeKeeper.processRumRequest(xhr, rumStartTime, rumEndTime, app.nrServerTime);
|
|
152
138
|
if (!this.timeKeeper.ready) throw new Error('TimeKeeper not ready');
|
|
153
|
-
|
|
139
|
+
this.agentRef.runtime.timeKeeper = this.timeKeeper;
|
|
154
140
|
} catch (error) {
|
|
155
141
|
this.ee.abort();
|
|
156
142
|
(0, _console.warn)(17, error);
|
|
157
143
|
return;
|
|
158
144
|
}
|
|
159
|
-
|
|
145
|
+
this.agentRef.runtime.appMetadata = app;
|
|
160
146
|
(0, _featureFlags.activateFeatures)(flags, this.agentIdentifier);
|
|
161
147
|
this.drain();
|
|
162
148
|
} catch (err) {
|
|
@@ -10,9 +10,9 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
10
10
|
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 && {}.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; }
|
|
11
11
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
12
12
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
15
|
-
this.importAggregator();
|
|
13
|
+
constructor(agentRef, auto = true) {
|
|
14
|
+
super(agentRef, CONSTANTS.FEATURE_NAME, auto);
|
|
15
|
+
this.importAggregator(agentRef);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.Instrument = Instrument;
|
|
@@ -8,8 +8,6 @@ var _belSerializer = require("../../../common/serialize/bel-serializer");
|
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
9
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
10
10
|
var _handle = require("../../../common/event-emitter/handle");
|
|
11
|
-
var _info = require("../../../common/config/info");
|
|
12
|
-
var _init = require("../../../common/config/init");
|
|
13
11
|
var _constants = require("../constants");
|
|
14
12
|
var _features = require("../../../loaders/features/features");
|
|
15
13
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
@@ -37,13 +35,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
37
35
|
}) => {
|
|
38
36
|
this.addTiming(name, value, attrs);
|
|
39
37
|
};
|
|
40
|
-
constructor(
|
|
41
|
-
super(
|
|
38
|
+
constructor(agentRef) {
|
|
39
|
+
super(agentRef, _constants.FEATURE_NAME);
|
|
42
40
|
this.timings = new _eventBuffer.EventBuffer();
|
|
43
41
|
this.curSessEndRecorded = false;
|
|
44
42
|
(0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
// Add the time of _window pagehide event_ firing to the next PVT harvest == NRDB windowUnload attr:
|
|
44
|
+
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.addTiming('unload', msTimestamp, null), this.featureName, this.ee);
|
|
45
|
+
const harvestTimeSeconds = agentRef.init.page_view_timing.harvestTimeSeconds || 30;
|
|
47
46
|
this.waitForFlags([]).then(() => {
|
|
48
47
|
/* It's important that CWV api, like "onLCP", is called before the **scheduler** is initialized. The reason is because they listen to the same
|
|
49
48
|
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". */
|
|
@@ -90,21 +89,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
90
89
|
this.curSessEndRecorded = true;
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Add the time of _window pagehide event_ firing to the next PVT harvest == NRDB windowUnload attr.
|
|
96
|
-
*/
|
|
97
|
-
recordPageUnload(timestamp) {
|
|
98
|
-
this.addTiming('unload', timestamp, null);
|
|
99
|
-
/*
|
|
100
|
-
Issue: Because window's pageHide commonly fires BEFORE vis change and "final" harvest would happen at the former in this case, we also have to add our vis-change event now or it may not be sent.
|
|
101
|
-
Affected: Safari < v14.1/.5 ; versions that don't support 'visiilitychange' event
|
|
102
|
-
Impact: For affected w/o this, NR 'pageHide' attribute may not be sent. For other browsers w/o this, NR 'pageHide' gets fragmented into its own harvest call on page unloading because of dual EoL logic.
|
|
103
|
-
Mitigation: NR 'unload' and 'pageHide' are both recorded when window pageHide fires, rather than only recording 'unload'.
|
|
104
|
-
Future: When EoL can become the singular subscribeToVisibilityChange, it's likely endCurrentSession isn't needed here as 'unload'-'pageHide' can be untangled.
|
|
105
|
-
*/
|
|
106
|
-
this.endCurrentSession(timestamp);
|
|
107
|
-
}
|
|
108
92
|
addTiming(name, value, attrs) {
|
|
109
93
|
attrs = attrs || {};
|
|
110
94
|
addConnectionAttributes(attrs); // network conditions may differ from the actual for VitalMetrics when they were captured
|
|
@@ -132,9 +116,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
132
116
|
}
|
|
133
117
|
appendGlobalCustomAttributes(timing) {
|
|
134
118
|
var timingAttributes = timing.attrs || {};
|
|
135
|
-
var customAttributes = (0, _info.getInfo)(this.agentIdentifier).jsAttributes || {};
|
|
136
119
|
var reservedAttributes = ['size', 'eid', 'cls', 'type', 'fid', 'elTag', 'elUrl', 'net-type', 'net-etype', 'net-rtt', 'net-dlink'];
|
|
137
|
-
Object.entries(
|
|
120
|
+
Object.entries(this.agentRef.info.jsAttributes || {}).forEach(([key, val]) => {
|
|
138
121
|
if (reservedAttributes.indexOf(key) < 0) {
|
|
139
122
|
timingAttributes[key] = val;
|
|
140
123
|
}
|
|
@@ -18,8 +18,8 @@ var _now = require("../../../common/timing/now");
|
|
|
18
18
|
|
|
19
19
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
20
20
|
static featureName = _constants.FEATURE_NAME;
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
21
|
+
constructor(agentRef, auto = true) {
|
|
22
|
+
super(agentRef, _constants.FEATURE_NAME, auto);
|
|
23
23
|
if (!_runtime.isBrowserScope) return; // CWV is irrelevant outside web context
|
|
24
24
|
|
|
25
25
|
// While we try to replicate web-vital's visibilitywatcher logic in an effort to defer that library to post-pageload, this isn't perfect and doesn't consider prerendering.
|
|
@@ -27,7 +27,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
27
27
|
|
|
28
28
|
// Window fires its pagehide event (typically on navigation--this occurrence is a *subset* of vis change); don't defer this unless it's guarantee it cannot happen before load(?)
|
|
29
29
|
(0, _eventListenerOpts.windowAddEventListener)('pagehide', () => (0, _handle.handle)('winPagehide', [(0, _now.now)()], undefined, _constants.FEATURE_NAME, this.ee));
|
|
30
|
-
this.importAggregator();
|
|
30
|
+
this.importAggregator(agentRef);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.Instrument = Instrument;
|
|
@@ -7,14 +7,11 @@ exports.Aggregate = void 0;
|
|
|
7
7
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
9
|
var _constants = require("../constants");
|
|
10
|
-
var _info = require("../../../common/config/info");
|
|
11
|
-
var _init = require("../../../common/config/init");
|
|
12
|
-
var _runtime = require("../../../common/config/runtime");
|
|
13
10
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
14
11
|
var _sharedChannel = require("../../../common/constants/shared-channel");
|
|
15
12
|
var _encode = require("../../../common/url/encode");
|
|
16
13
|
var _console = require("../../../common/util/console");
|
|
17
|
-
var
|
|
14
|
+
var _runtime = require("../../../common/constants/runtime");
|
|
18
15
|
var _constants2 = require("../../metrics/constants");
|
|
19
16
|
var _handle = require("../../../common/event-emitter/handle");
|
|
20
17
|
var _features = require("../../../loaders/features/features");
|
|
@@ -22,7 +19,6 @@ var _env = require("../../../common/constants/env.npm");
|
|
|
22
19
|
var _constants3 = require("../../../common/session/constants");
|
|
23
20
|
var _stringify = require("../../../common/util/stringify");
|
|
24
21
|
var _stylesheetEvaluator = require("../shared/stylesheet-evaluator");
|
|
25
|
-
var _drain = require("../../../common/drain/drain");
|
|
26
22
|
var _now = require("../../../common/timing/now");
|
|
27
23
|
var _utils = require("../shared/utils");
|
|
28
24
|
var _agentConstants = require("../../../common/constants/agent-constants");
|
|
@@ -39,10 +35,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
39
35
|
mode = _constants3.MODE.OFF;
|
|
40
36
|
|
|
41
37
|
// pass the recorder into the aggregator
|
|
42
|
-
constructor(
|
|
43
|
-
super(
|
|
38
|
+
constructor(agentRef, args) {
|
|
39
|
+
super(agentRef, _constants.FEATURE_NAME);
|
|
44
40
|
/** The interval to harvest at. This gets overridden if the size of the payload exceeds certain thresholds */
|
|
45
|
-
this.harvestTimeSeconds =
|
|
41
|
+
this.harvestTimeSeconds = agentRef.init.session_replay.harvestTimeSeconds || 60;
|
|
46
42
|
/** Set once the recorder has fully initialized after flag checks and sampling */
|
|
47
43
|
this.initialized = false;
|
|
48
44
|
/** Set once the feature has been "aborted" to prevent other side-effects from continuing */
|
|
@@ -76,10 +72,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
76
72
|
this.ee.on(_constants3.SESSION_EVENTS.RESUME, () => {
|
|
77
73
|
if (!this.recorder) return;
|
|
78
74
|
// if the mode changed on a different tab, it needs to update this instance to match
|
|
79
|
-
|
|
80
|
-
session
|
|
81
|
-
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
82
|
-
this.mode = session.state.sessionReplayMode;
|
|
75
|
+
this.mode = agentRef.runtime.session.state.sessionReplayMode;
|
|
83
76
|
if (!this.initialized || this.mode === _constants3.MODE.OFF) return;
|
|
84
77
|
this.recorder?.startRecording();
|
|
85
78
|
});
|
|
@@ -111,11 +104,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
111
104
|
mask_all_inputs,
|
|
112
105
|
inline_images,
|
|
113
106
|
collect_fonts
|
|
114
|
-
} =
|
|
107
|
+
} = agentRef.init.session_replay;
|
|
115
108
|
this.waitForFlags(['srs', 'sr']).then(([srMode, entitled]) => {
|
|
116
109
|
this.entitled = !!entitled;
|
|
117
110
|
if (!this.entitled) {
|
|
118
|
-
|
|
111
|
+
this.deregisterDrain();
|
|
119
112
|
if (this.recorder?.recording) {
|
|
120
113
|
this.abort(_constants.ABORT_REASONS.ENTITLEMENTS);
|
|
121
114
|
(0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/EnabledNotEntitled/Detected'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
|
|
@@ -145,7 +138,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
145
138
|
handleError(e) {
|
|
146
139
|
if (this.recorder) this.recorder.currentBufferTarget.hasError = true;
|
|
147
140
|
// run once
|
|
148
|
-
if (this.mode === _constants3.MODE.ERROR &&
|
|
141
|
+
if (this.mode === _constants3.MODE.ERROR && _runtime.globalScope?.document.visibilityState === 'visible') {
|
|
149
142
|
this.switchToFull();
|
|
150
143
|
}
|
|
151
144
|
}
|
|
@@ -185,7 +178,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
185
178
|
const {
|
|
186
179
|
session,
|
|
187
180
|
timeKeeper
|
|
188
|
-
} =
|
|
181
|
+
} = this.agentRef.runtime;
|
|
189
182
|
this.timeKeeper = timeKeeper;
|
|
190
183
|
if (this.recorder?.parent.trigger === _constants.TRIGGERS.API && this.recorder?.recording) {
|
|
191
184
|
this.mode = _constants3.MODE.FULL;
|
|
@@ -301,10 +294,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
301
294
|
return;
|
|
302
295
|
}
|
|
303
296
|
// TODO -- Gracefully handle the buffer for retries.
|
|
304
|
-
|
|
305
|
-
session
|
|
306
|
-
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
307
|
-
if (!session.state.sessionReplaySentFirstChunk) this.syncWithSessionManager({
|
|
297
|
+
if (!this.agentRef.runtime.session.state.sessionReplaySentFirstChunk) this.syncWithSessionManager({
|
|
308
298
|
sessionReplaySentFirstChunk: true
|
|
309
299
|
});
|
|
310
300
|
this.recorder.clearBuffer();
|
|
@@ -319,9 +309,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
319
309
|
getHarvestContents(recorderEvents) {
|
|
320
310
|
recorderEvents ??= this.recorder.getEvents();
|
|
321
311
|
let events = recorderEvents.events;
|
|
322
|
-
const agentRuntime =
|
|
323
|
-
const
|
|
324
|
-
const endUserId = info.jsAttributes?.['enduser.id'];
|
|
312
|
+
const agentRuntime = this.agentRef.runtime;
|
|
313
|
+
const endUserId = this.agentRef.info.jsAttributes?.['enduser.id'];
|
|
325
314
|
|
|
326
315
|
// do not let the first node be a full snapshot node, since this NEEDS to be preceded by a meta node
|
|
327
316
|
// we will manually inject it if this happens
|
|
@@ -349,9 +338,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
349
338
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
|
|
350
339
|
return {
|
|
351
340
|
qs: {
|
|
352
|
-
browser_monitoring_key: info.licenseKey,
|
|
341
|
+
browser_monitoring_key: this.agentRef.info.licenseKey,
|
|
353
342
|
type: 'SessionReplay',
|
|
354
|
-
app_id: info.applicationID,
|
|
343
|
+
app_id: this.agentRef.info.applicationID,
|
|
355
344
|
protocol_version: '0',
|
|
356
345
|
timestamp: firstTimestamp,
|
|
357
346
|
attributes: (0, _encode.obj)({
|
|
@@ -428,10 +417,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
428
417
|
while (this.recorder?.getEvents().events.length) this.recorder?.clearBuffer?.();
|
|
429
418
|
}
|
|
430
419
|
syncWithSessionManager(state = {}) {
|
|
431
|
-
|
|
432
|
-
session
|
|
433
|
-
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
434
|
-
session.write(state);
|
|
420
|
+
this.agentRef.runtime.session.write(state);
|
|
435
421
|
}
|
|
436
422
|
}
|
|
437
423
|
exports.Aggregate = Aggregate;
|
|
@@ -19,21 +19,23 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
19
19
|
class Instrument extends _instrumentBase.InstrumentBase {
|
|
20
20
|
static featureName = _constants2.FEATURE_NAME;
|
|
21
21
|
#mode;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
#agentRef;
|
|
23
|
+
constructor(agentRef, auto = true) {
|
|
24
|
+
super(agentRef, _constants2.FEATURE_NAME, auto);
|
|
24
25
|
let session;
|
|
25
26
|
this.replayRunning = false;
|
|
27
|
+
this.#agentRef = agentRef;
|
|
26
28
|
try {
|
|
27
29
|
session = JSON.parse(localStorage.getItem("".concat(_constants.PREFIX, "_").concat(_constants.DEFAULT_KEY)));
|
|
28
30
|
} catch (err) {}
|
|
29
|
-
if ((0, _utils.hasReplayPrerequisite)(agentIdentifier)) {
|
|
31
|
+
if ((0, _utils.hasReplayPrerequisite)(agentRef.agentIdentifier)) {
|
|
30
32
|
this.ee.on(_constants2.SR_EVENT_EMITTER_TYPES.RECORD, () => this.#apiStartOrRestartReplay());
|
|
31
33
|
}
|
|
32
34
|
if (this.#canPreloadRecorder(session)) {
|
|
33
35
|
this.#mode = session?.sessionReplayMode;
|
|
34
36
|
this.#preloadStartRecording();
|
|
35
37
|
} else {
|
|
36
|
-
this.importAggregator();
|
|
38
|
+
this.importAggregator(agentRef);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/** If the recorder is running, we can pass error events on to the agg to help it switch to full mode later */
|
|
@@ -87,7 +89,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
87
89
|
this.recorder.startRecording();
|
|
88
90
|
this.abortHandler = this.recorder.stopRecording;
|
|
89
91
|
} catch (e) {}
|
|
90
|
-
this.importAggregator({
|
|
92
|
+
this.importAggregator(this.#agentRef, {
|
|
91
93
|
recorder: this.recorder,
|
|
92
94
|
errorNoticed: this.errorNoticed
|
|
93
95
|
});
|