@newrelic/browser-agent 1.316.0 → 1.317.0-rc.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 +15 -0
- package/dist/cjs/common/config/configurable.js +1 -1
- package/dist/cjs/common/config/init-types.js +1 -0
- package/dist/cjs/common/config/init.js +6 -4
- package/dist/cjs/common/constants/env.cdn.js +2 -2
- package/dist/cjs/common/constants/env.npm.js +2 -2
- package/dist/cjs/common/constants/events.js +26 -0
- package/dist/cjs/common/harvest/harvester.js +9 -217
- package/dist/cjs/common/harvest/send.js +232 -0
- package/dist/cjs/common/harvest/types.js +9 -5
- package/dist/cjs/common/payloads/payloads.js +127 -0
- package/dist/cjs/common/serialize/bel-serializer.js +4 -3
- package/dist/cjs/common/session/session-entity.js +8 -8
- package/dist/cjs/common/util/data-size.js +2 -2
- package/dist/cjs/common/util/obfuscate.js +147 -3
- package/dist/cjs/common/v2/mfe-vitals.js +286 -0
- package/dist/cjs/common/wrap/wrap-websocket.js +2 -1
- package/dist/cjs/common/wrap/wrap-xhr.js +1 -1
- package/dist/cjs/features/ajax/aggregate/gql.js +40 -1
- package/dist/cjs/features/ajax/aggregate/index.js +51 -13
- package/dist/cjs/features/ajax/constants.js +6 -1
- package/dist/cjs/features/ajax/instrument/index.js +105 -17
- package/dist/cjs/features/generic_events/aggregate/index.js +15 -10
- package/dist/cjs/features/generic_events/constants.js +3 -2
- package/dist/cjs/features/jserrors/aggregate/format-stack-trace.js +2 -2
- package/dist/cjs/features/jserrors/aggregate/index.js +12 -3
- package/dist/cjs/features/logging/aggregate/index.js +12 -8
- package/dist/cjs/features/metrics/aggregate/index.js +5 -1
- package/dist/cjs/features/page_view_event/aggregate/index.js +72 -33
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +39 -29
- package/dist/cjs/features/session_trace/aggregate/index.js +35 -29
- package/dist/cjs/features/session_trace/constants.js +17 -3
- package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +36 -5
- package/dist/cjs/features/soft_navigations/aggregate/index.js +7 -1
- package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/interaction.js +6 -4
- package/dist/cjs/features/utils/aggregate-base.js +4 -3
- package/dist/cjs/loaders/api/register.js +26 -4
- package/dist/esm/common/config/configurable.js +1 -1
- package/dist/esm/common/config/init-types.js +1 -0
- package/dist/esm/common/config/init.js +3 -1
- package/dist/esm/common/constants/env.cdn.js +2 -2
- package/dist/esm/common/constants/env.npm.js +2 -2
- package/dist/esm/common/constants/events.js +20 -0
- package/dist/esm/common/harvest/harvester.js +9 -217
- package/dist/esm/common/harvest/send.js +226 -0
- package/dist/esm/common/harvest/types.js +9 -5
- package/dist/esm/common/payloads/payloads.js +118 -0
- package/dist/esm/common/serialize/bel-serializer.js +4 -3
- package/dist/esm/common/session/session-entity.js +9 -9
- package/dist/esm/common/util/data-size.js +2 -2
- package/dist/esm/common/util/obfuscate.js +147 -3
- package/dist/esm/common/v2/mfe-vitals.js +281 -0
- package/dist/esm/common/wrap/wrap-websocket.js +2 -1
- package/dist/esm/common/wrap/wrap-xhr.js +1 -1
- package/dist/esm/features/ajax/aggregate/gql.js +39 -1
- package/dist/esm/features/ajax/aggregate/index.js +52 -14
- package/dist/esm/features/ajax/constants.js +5 -0
- package/dist/esm/features/ajax/instrument/index.js +106 -18
- package/dist/esm/features/generic_events/aggregate/index.js +15 -10
- package/dist/esm/features/generic_events/constants.js +3 -2
- package/dist/esm/features/jserrors/aggregate/format-stack-trace.js +2 -2
- package/dist/esm/features/jserrors/aggregate/index.js +12 -3
- package/dist/esm/features/logging/aggregate/index.js +12 -8
- package/dist/esm/features/metrics/aggregate/index.js +5 -1
- package/dist/esm/features/page_view_event/aggregate/index.js +71 -32
- package/dist/esm/features/page_view_timing/aggregate/index.js +6 -1
- package/dist/esm/features/session_replay/aggregate/index.js +39 -29
- package/dist/esm/features/session_trace/aggregate/index.js +36 -30
- package/dist/esm/features/session_trace/constants.js +16 -2
- package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +36 -5
- package/dist/esm/features/soft_navigations/aggregate/index.js +7 -1
- package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/interaction.js +6 -4
- package/dist/esm/features/utils/aggregate-base.js +4 -3
- package/dist/esm/loaders/api/register.js +26 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common/config/init-types.d.ts +4 -0
- package/dist/types/common/config/init-types.d.ts.map +1 -1
- package/dist/types/common/config/init.d.ts.map +1 -1
- package/dist/types/common/constants/events.d.ts +16 -0
- package/dist/types/common/constants/events.d.ts.map +1 -0
- package/dist/types/common/harvest/harvester.d.ts +2 -16
- package/dist/types/common/harvest/harvester.d.ts.map +1 -1
- package/dist/types/common/harvest/send.d.ts +9 -0
- package/dist/types/common/harvest/send.d.ts.map +1 -0
- package/dist/types/common/harvest/types.d.ts +39 -10
- package/dist/types/common/harvest/types.d.ts.map +1 -1
- package/dist/types/common/payloads/payloads.d.ts +42 -0
- package/dist/types/common/payloads/payloads.d.ts.map +1 -0
- package/dist/types/common/serialize/bel-serializer.d.ts +1 -1
- package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.d.ts +23 -2
- package/dist/types/common/util/obfuscate.d.ts.map +1 -1
- package/dist/types/common/v2/mfe-vitals.d.ts +14 -0
- package/dist/types/common/v2/mfe-vitals.d.ts.map +1 -0
- package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/gql.d.ts +8 -0
- package/dist/types/features/ajax/aggregate/gql.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts +2 -0
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/constants.d.ts +5 -0
- package/dist/types/features/ajax/constants.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts +3 -1
- package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/generic_events/constants.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +8 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/logging/aggregate/index.d.ts +3 -1
- package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/index.d.ts +2 -0
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts +3 -0
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -0
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +4 -2
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts +3 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +17 -0
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +6 -1
- package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -0
- package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +3 -1
- package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +0 -1
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/loaders/api/register.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/config/configurable.js +1 -1
- package/src/common/config/init-types.js +1 -0
- package/src/common/config/init.js +2 -1
- package/src/common/constants/events.js +20 -0
- package/src/common/harvest/harvester.js +9 -201
- package/src/common/harvest/send.js +209 -0
- package/src/common/harvest/types.js +9 -5
- package/src/common/payloads/payloads.js +135 -0
- package/src/common/serialize/bel-serializer.js +4 -3
- package/src/common/session/session-entity.js +8 -9
- package/src/common/util/data-size.js +2 -2
- package/src/common/util/obfuscate.js +154 -3
- package/src/common/v2/mfe-vitals.js +260 -0
- package/src/common/wrap/wrap-websocket.js +2 -1
- package/src/common/wrap/wrap-xhr.js +1 -1
- package/src/features/ajax/aggregate/gql.js +42 -1
- package/src/features/ajax/aggregate/index.js +43 -13
- package/src/features/ajax/constants.js +5 -1
- package/src/features/ajax/instrument/index.js +114 -18
- package/src/features/generic_events/aggregate/index.js +14 -9
- package/src/features/generic_events/constants.js +3 -2
- package/src/features/jserrors/aggregate/format-stack-trace.js +3 -3
- package/src/features/jserrors/aggregate/index.js +12 -3
- package/src/features/logging/aggregate/index.js +12 -11
- package/src/features/metrics/aggregate/index.js +5 -1
- package/src/features/page_view_event/aggregate/index.js +58 -29
- package/src/features/page_view_timing/aggregate/index.js +6 -1
- package/src/features/session_replay/aggregate/index.js +37 -28
- package/src/features/session_trace/aggregate/index.js +37 -30
- package/src/features/session_trace/constants.js +7 -1
- package/src/features/soft_navigations/aggregate/ajax-node.js +26 -5
- package/src/features/soft_navigations/aggregate/index.js +7 -1
- package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
- package/src/features/soft_navigations/aggregate/interaction.js +6 -4
- package/src/features/utils/aggregate-base.js +3 -3
- package/src/loaders/api/register.js +24 -4
|
@@ -11,11 +11,12 @@ var _aggregateBase = require("../../utils/aggregate-base");
|
|
|
11
11
|
var _constants = require("../constants");
|
|
12
12
|
var _log = require("../shared/log");
|
|
13
13
|
var _utils = require("../shared/utils");
|
|
14
|
-
var
|
|
14
|
+
var _obfuscate = require("../../../common/util/obfuscate");
|
|
15
15
|
var _constants2 = require("../../../common/session/constants");
|
|
16
16
|
var _constants3 = require("../../session_replay/constants");
|
|
17
17
|
var _featureGates = require("../../utils/feature-gates");
|
|
18
18
|
var _utils2 = require("../../../common/v2/utils");
|
|
19
|
+
var _events = require("../../../common/constants/events");
|
|
19
20
|
/**
|
|
20
21
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
21
22
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -39,6 +40,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
39
40
|
this.harvestOpts.raw = true;
|
|
40
41
|
super.customAttributesAreSeparate = true;
|
|
41
42
|
|
|
43
|
+
// Create obfuscator for log entries
|
|
44
|
+
this.obfuscator = new _obfuscate.Obfuscator(agentRef, _events.EVENT_TYPES.LOG);
|
|
45
|
+
|
|
42
46
|
// The SessionEntity class can emit a message indicating the session was cleared and reset (expiry, inactivity). This feature must abort and never resume if that occurs.
|
|
43
47
|
this.ee.on(_constants2.SESSION_EVENTS.RESET, () => {
|
|
44
48
|
this.abort(_constants3.ABORT_REASONS.RESET);
|
|
@@ -57,7 +61,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
57
61
|
}; // likewise, don't want to overwrite the mode if it was set already
|
|
58
62
|
const session = this.agentRef.runtime.session;
|
|
59
63
|
if ((0, _featureGates.canEnableSessionTracking)(agentRef.init) && session) {
|
|
60
|
-
if (session.
|
|
64
|
+
if (session.state.loggingMode === null || session.state.logApiMode === null) this.#writeToStorage(this.loggingMode);else updateLocalLoggingMode(session.state.loggingMode, session.state.logApiMode);
|
|
61
65
|
}
|
|
62
66
|
if (this.loggingMode.auto === _constants.LOGGING_MODE.OFF && this.loggingMode.api === _constants.LOGGING_MODE.OFF) {
|
|
63
67
|
this.blocked = true;
|
|
@@ -119,7 +123,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
119
123
|
common: {
|
|
120
124
|
/** Attributes in the `common` section are added to `all` logs generated in the payload */
|
|
121
125
|
attributes: {
|
|
122
|
-
...
|
|
126
|
+
...this.obfuscator.traverseAndObfuscateEvents(this.agentRef.info.jsAttributes),
|
|
123
127
|
...(this.harvestEndpointVersion === 1 && {
|
|
124
128
|
'entity.guid': this.agentRef.runtime.appMetadata.agents[0].entityGuid,
|
|
125
129
|
appId: this.agentRef.info.applicationID
|
|
@@ -144,7 +148,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
144
148
|
}
|
|
145
149
|
},
|
|
146
150
|
/** logs section contains individual unique log entries */
|
|
147
|
-
logs:
|
|
151
|
+
logs: this.obfuscator.traverseAndObfuscateEvents(eventBuffer)
|
|
148
152
|
}];
|
|
149
153
|
}
|
|
150
154
|
queryStringsBuilder() {
|
|
@@ -165,13 +169,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
165
169
|
auto: _constants.LOGGING_MODE.OFF,
|
|
166
170
|
api: _constants.LOGGING_MODE.OFF
|
|
167
171
|
};
|
|
168
|
-
this.#
|
|
172
|
+
this.#writeToStorage(this.loggingMode);
|
|
169
173
|
this.deregisterDrain();
|
|
170
174
|
}
|
|
171
|
-
#
|
|
175
|
+
#writeToStorage(logModes) {
|
|
172
176
|
this.agentRef.runtime.session?.write({
|
|
173
|
-
loggingMode:
|
|
174
|
-
logApiMode:
|
|
177
|
+
loggingMode: logModes.auto,
|
|
178
|
+
logApiMode: logModes.api
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
}
|
|
@@ -14,8 +14,9 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
14
14
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
15
15
|
var _iframe = require("../../../common/dom/iframe");
|
|
16
16
|
var _harvestMetadata = require("./harvest-metadata");
|
|
17
|
+
var _obfuscate = require("../../../common/util/obfuscate");
|
|
17
18
|
/**
|
|
18
|
-
* Copyright 2020-
|
|
19
|
+
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
19
20
|
* SPDX-License-Identifier: Apache-2.0
|
|
20
21
|
*/
|
|
21
22
|
|
|
@@ -28,6 +29,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
28
29
|
super(agentRef, _constants.FEATURE_NAME);
|
|
29
30
|
this.harvestOpts.aggregatorTypes = ['cm', 'sm']; // the types in EventAggregator this feature cares about
|
|
30
31
|
|
|
32
|
+
// Create a generic obfuscator for checking if rules are configured
|
|
33
|
+
this.obfuscator = new _obfuscate.Obfuscator(agentRef);
|
|
34
|
+
|
|
31
35
|
/** all the harvest metadata metrics need to be evaluated simulataneously at unload time so just temporarily buffer them and dont make SMs immediately from the data */
|
|
32
36
|
this.harvestMetadata = {};
|
|
33
37
|
this.harvestOpts.beforeUnload = () => {
|
|
@@ -17,11 +17,13 @@ var _firstPaint = require("../../../common/vitals/first-paint");
|
|
|
17
17
|
var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
|
|
18
18
|
var _now = require("../../../common/timing/now");
|
|
19
19
|
var _timeKeeper = require("../../../common/timing/time-keeper");
|
|
20
|
-
var
|
|
21
|
-
var
|
|
20
|
+
var _send = require("../../../common/harvest/send");
|
|
21
|
+
var _featureGates = require("../../utils/feature-gates");
|
|
22
|
+
var _obfuscate = require("../../../common/util/obfuscate");
|
|
22
23
|
var _features = require("../../../loaders/features/features");
|
|
23
24
|
var _submitData = require("../../../common/util/submit-data");
|
|
24
25
|
var _webdriverDetection = require("../../../common/util/webdriver-detection");
|
|
26
|
+
var _events = require("../../../common/constants/events");
|
|
25
27
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
26
28
|
/**
|
|
27
29
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
@@ -32,14 +34,31 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
32
34
|
static featureName = CONSTANTS.FEATURE_NAME;
|
|
33
35
|
constructor(agentRef) {
|
|
34
36
|
super(agentRef, CONSTANTS.FEATURE_NAME);
|
|
37
|
+
this.isSessionTrackingEnabled = (0, _featureGates.canEnableSessionTracking)(agentRef.init) && !!agentRef.runtime.session;
|
|
35
38
|
this.sentRum = false; // flag to facilitate calling sendRum() once externally (by the consent API in agent-session.js)
|
|
36
39
|
|
|
37
40
|
this.timeToFirstByte = 0;
|
|
38
41
|
this.firstByteToWindowLoad = 0; // our "frontend" duration
|
|
39
42
|
this.firstByteToDomContent = 0; // our "dom processing" duration
|
|
40
43
|
this.retries = 0;
|
|
44
|
+
|
|
45
|
+
// Create obfuscator for page view events
|
|
46
|
+
this.obfuscator = new _obfuscate.Obfuscator(agentRef, _events.EVENT_TYPES.PVE);
|
|
41
47
|
agentRef.runtime.timeKeeper = new _timeKeeper.TimeKeeper(agentRef.runtime.session);
|
|
42
48
|
if (_runtime.isBrowserScope) {
|
|
49
|
+
const cached = this.isSessionTrackingEnabled && agentRef.runtime.session?.state.cachedRumResponse;
|
|
50
|
+
if (cached) {
|
|
51
|
+
const {
|
|
52
|
+
app: cachedApp,
|
|
53
|
+
...cachedFlags
|
|
54
|
+
} = cached;
|
|
55
|
+
|
|
56
|
+
// set the agent runtime objects that require the rum response or entity guid
|
|
57
|
+
if (!Object.keys(this.agentRef.runtime.appMetadata).length) agentRef.runtime.appMetadata = cachedApp;
|
|
58
|
+
this.drain();
|
|
59
|
+
agentRef.runtime.harvester.startTimer();
|
|
60
|
+
(0, _featureFlags.activateFeatures)(cachedFlags, agentRef);
|
|
61
|
+
}
|
|
43
62
|
_timeToFirstByte.timeToFirstByte.subscribe(({
|
|
44
63
|
value,
|
|
45
64
|
attrs
|
|
@@ -84,14 +103,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
84
103
|
ua: info.userAttributes,
|
|
85
104
|
at: info.atts
|
|
86
105
|
};
|
|
87
|
-
if (this.agentRef.runtime.session) queryParameters.fsh = Number(this.agentRef.runtime.session.
|
|
88
|
-
|
|
89
|
-
let body = (0, _traverse.applyFnToProps)({
|
|
106
|
+
if (this.agentRef.runtime.session) queryParameters.fsh = Number(!this.agentRef.runtime.session.state.cachedRumResponse);
|
|
107
|
+
let body = this.obfuscator.traverseAndObfuscateEvents({
|
|
90
108
|
ja: {
|
|
91
109
|
...customAttributes,
|
|
92
110
|
webdriverDetected: _webdriverDetection.webdriverDetected
|
|
93
111
|
}
|
|
94
|
-
}
|
|
112
|
+
});
|
|
95
113
|
if (_runtime.globalScope.performance) {
|
|
96
114
|
const navTimingEntry = (0, _runtime.getNavigationEntry)();
|
|
97
115
|
if (navTimingEntry) {
|
|
@@ -139,6 +157,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
139
157
|
}) {
|
|
140
158
|
const rumEndTime = (0, _now.now)();
|
|
141
159
|
let app, flags;
|
|
160
|
+
const hasCachedRumResponse = !!this.agentRef.runtime.session?.state.cachedRumResponse;
|
|
142
161
|
try {
|
|
143
162
|
({
|
|
144
163
|
app,
|
|
@@ -148,10 +167,20 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
148
167
|
// wont set entity stuff here, if main agent will later abort, if registered agent, nothing will happen
|
|
149
168
|
(0, _console.warn)(53, error);
|
|
150
169
|
}
|
|
170
|
+
const shouldCacheResponse = this.isSessionTrackingEnabled && !hasCachedRumResponse && !!app;
|
|
171
|
+
if (hasCachedRumResponse) {
|
|
172
|
+
let {
|
|
173
|
+
app: cachedApp,
|
|
174
|
+
...cachedFlags
|
|
175
|
+
} = this.agentRef.runtime.session.state.cachedRumResponse;
|
|
176
|
+
app ??= cachedApp;
|
|
177
|
+
flags = cachedFlags;
|
|
178
|
+
}
|
|
151
179
|
super.postHarvestCleanup({
|
|
152
180
|
sent,
|
|
153
|
-
retry
|
|
181
|
+
retry: retry && !hasCachedRumResponse
|
|
154
182
|
}); // this will set isRetrying & re-buffer the body if request is to be retried
|
|
183
|
+
|
|
155
184
|
if (this.isRetrying && this.retries++ < 1) {
|
|
156
185
|
// Only retry once
|
|
157
186
|
setTimeout(() => this.agentRef.runtime.harvester.triggerHarvestFor(this, {
|
|
@@ -161,7 +190,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
161
190
|
}
|
|
162
191
|
if (status >= 400 || status === 0) {
|
|
163
192
|
(0, _console.warn)(18, status);
|
|
164
|
-
this.blocked = true;
|
|
165
193
|
|
|
166
194
|
// Get estimated payload size of our backlog
|
|
167
195
|
const textEncoder = new TextEncoder();
|
|
@@ -172,15 +200,24 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
172
200
|
}, 0);
|
|
173
201
|
const BCSError = 'BCS/Error/';
|
|
174
202
|
// Send SMs about failed RUM request
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
203
|
+
const sm = [{
|
|
204
|
+
params: {
|
|
205
|
+
name: BCSError + status
|
|
206
|
+
},
|
|
207
|
+
stats: {
|
|
208
|
+
c: 1
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
params: {
|
|
212
|
+
name: BCSError + 'Duration/Ms'
|
|
213
|
+
},
|
|
214
|
+
stats: {
|
|
215
|
+
c: 1,
|
|
216
|
+
t: rumEndTime - this.rumStartTime
|
|
217
|
+
}
|
|
218
|
+
}];
|
|
219
|
+
if (!hasCachedRumResponse) {
|
|
220
|
+
sm.push({
|
|
184
221
|
params: {
|
|
185
222
|
name: BCSError + 'Dropped/Bytes'
|
|
186
223
|
},
|
|
@@ -188,28 +225,30 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
188
225
|
c: 1,
|
|
189
226
|
t: payloadSize
|
|
190
227
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
stats: {
|
|
196
|
-
c: 1,
|
|
197
|
-
t: rumEndTime - this.rumStartTime
|
|
198
|
-
}
|
|
199
|
-
}]
|
|
200
|
-
};
|
|
201
|
-
(0, _harvester.send)(this.agentRef, {
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
(0, _send.send)(this.agentRef, {
|
|
202
231
|
endpoint: _features.FEATURE_TO_ENDPOINT[_features.FEATURE_NAMES.metrics],
|
|
203
232
|
payload: {
|
|
204
|
-
body
|
|
233
|
+
body: {
|
|
234
|
+
sm
|
|
235
|
+
}
|
|
205
236
|
},
|
|
206
237
|
submitMethod: (0, _submitData.getSubmitMethod)(),
|
|
207
238
|
featureName: _features.FEATURE_NAMES.metrics
|
|
208
239
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
240
|
+
if (!hasCachedRumResponse) {
|
|
241
|
+
this.blocked = true;
|
|
242
|
+
this.ee.abort();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
} else if (shouldCacheResponse) {
|
|
246
|
+
this.agentRef.runtime.session.write({
|
|
247
|
+
cachedRumResponse: {
|
|
248
|
+
app,
|
|
249
|
+
...flags
|
|
250
|
+
}
|
|
251
|
+
});
|
|
213
252
|
}
|
|
214
253
|
try {
|
|
215
254
|
const wasReady = this.agentRef.runtime.timeKeeper.ready;
|
|
@@ -10,6 +10,7 @@ var _handle = require("../../../common/event-emitter/handle");
|
|
|
10
10
|
var _constants = require("../constants");
|
|
11
11
|
var _features = require("../../../loaders/features/features");
|
|
12
12
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
13
|
+
var _obfuscate = require("../../../common/util/obfuscate");
|
|
13
14
|
var _cumulativeLayoutShift = require("../../../common/vitals/cumulative-layout-shift");
|
|
14
15
|
var _firstContentfulPaint = require("../../../common/vitals/first-contentful-paint");
|
|
15
16
|
var _firstPaint = require("../../../common/vitals/first-paint");
|
|
@@ -22,6 +23,7 @@ var _eventOrigin = require("../../../common/util/event-origin");
|
|
|
22
23
|
var _loadTime = require("../../../common/vitals/load-time");
|
|
23
24
|
var _webdriverDetection = require("../../../common/util/webdriver-detection");
|
|
24
25
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
26
|
+
var _events = require("../../../common/constants/events");
|
|
25
27
|
/**
|
|
26
28
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
27
29
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -41,6 +43,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
41
43
|
this.curSessEndRecorded = false;
|
|
42
44
|
this.firstIxnRecorded = false;
|
|
43
45
|
super.customAttributesAreSeparate = true;
|
|
46
|
+
|
|
47
|
+
// Create obfuscator for page view timing events
|
|
48
|
+
this.obfuscator = new _obfuscate.Obfuscator(agentRef, _events.EVENT_TYPES.PVT);
|
|
44
49
|
(0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
45
50
|
// Add the time of _window pagehide event_ firing to the next PVT harvest == NRDB windowUnload attr:
|
|
46
51
|
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.addTiming('unload', msTimestamp, null), this.featureName, this.ee);
|
|
@@ -146,7 +151,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
146
151
|
// serialize array of timing data
|
|
147
152
|
serializer(eventBuffer) {
|
|
148
153
|
if (!eventBuffer?.length) return '';
|
|
149
|
-
var addString = (0, _belSerializer.getAddStringContext)(this.
|
|
154
|
+
var addString = (0, _belSerializer.getAddStringContext)(this.obfuscator);
|
|
150
155
|
var payload = 'bel.6;';
|
|
151
156
|
for (var i = 0; i < eventBuffer.length; i++) {
|
|
152
157
|
var timing = eventBuffer[i];
|
|
@@ -17,9 +17,11 @@ var _stringify = require("../../../common/util/stringify");
|
|
|
17
17
|
var _stylesheetEvaluator = require("../shared/stylesheet-evaluator");
|
|
18
18
|
var _now = require("../../../common/timing/now");
|
|
19
19
|
var _agentConstants = require("../../../common/constants/agent-constants");
|
|
20
|
+
var _events = require("../../../common/constants/events");
|
|
20
21
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
21
22
|
var _featureGates = require("../../utils/feature-gates");
|
|
22
23
|
var _constants3 = require("../../../loaders/api/constants");
|
|
24
|
+
var _obfuscate = require("../../../common/util/obfuscate");
|
|
23
25
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /**
|
|
24
26
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
25
27
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -28,11 +30,15 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
28
30
|
*/
|
|
29
31
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
30
32
|
static featureName = _constants.FEATURE_NAME;
|
|
31
|
-
mode =
|
|
33
|
+
mode = null;
|
|
32
34
|
|
|
33
35
|
// pass the recorder into the aggregator
|
|
34
36
|
constructor(agentRef, args) {
|
|
35
37
|
super(agentRef, _constants.FEATURE_NAME);
|
|
38
|
+
|
|
39
|
+
// Create obfuscator for session replay query params
|
|
40
|
+
this.obfuscator = new _obfuscate.Obfuscator(agentRef, _events.EVENT_TYPES.SR);
|
|
41
|
+
|
|
36
42
|
/** Set once the recorder has fully initialized after flag checks and sampling */
|
|
37
43
|
this.initialized = false;
|
|
38
44
|
/** Set once the feature has been "aborted" to prevent other side-effects from continuing */
|
|
@@ -69,7 +75,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
69
75
|
if (!this.recorder) return;
|
|
70
76
|
// if the mode changed on a different tab, it needs to update this instance to match
|
|
71
77
|
this.mode = agentRef.runtime.session.state.sessionReplayMode;
|
|
72
|
-
if (!this.initialized || this.mode === _constants2.MODE.OFF) return;
|
|
78
|
+
if (!this.initialized || this.mode === _constants2.MODE.OFF || !this.mode) return;
|
|
73
79
|
this.recorder?.startRecording(_constants.TRIGGERS.RESUME, this.mode);
|
|
74
80
|
});
|
|
75
81
|
this.ee.on(_constants2.SESSION_EVENTS.UPDATE, (type, data) => {
|
|
@@ -96,6 +102,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
96
102
|
this.waitForFlags(['srs', 'sr']).then(([srMode, entitled]) => {
|
|
97
103
|
this.entitled = !!entitled;
|
|
98
104
|
if (!this.entitled) {
|
|
105
|
+
this.mode = _constants2.MODE.OFF;
|
|
106
|
+
this.#writeToStorage({
|
|
107
|
+
sessionReplayMode: this.mode
|
|
108
|
+
});
|
|
99
109
|
this.deregisterDrain();
|
|
100
110
|
if (this.agentRef.runtime.isRecording) {
|
|
101
111
|
this.abort(_constants.ABORT_REASONS.ENTITLEMENTS);
|
|
@@ -107,7 +117,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
107
117
|
this.drain();
|
|
108
118
|
});
|
|
109
119
|
}).then(() => {
|
|
110
|
-
if (this.mode
|
|
120
|
+
if (!this.mode) {
|
|
111
121
|
this.recorder?.stopRecording(); // stop any conservative preload recording launched by instrument
|
|
112
122
|
while (this.recorder?.getEvents().events.length) this.recorder?.clearBuffer?.();
|
|
113
123
|
}
|
|
@@ -140,7 +150,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
140
150
|
// if the error was noticed AFTER the recorder was already imported....
|
|
141
151
|
if (this.recorder && this.initialized) {
|
|
142
152
|
if (!this.agentRef.runtime.isRecording) this.recorder.startRecording(_constants.TRIGGERS.SWITCH_TO_FULL, this.mode); // off --> full
|
|
143
|
-
this
|
|
153
|
+
this.#writeToStorage({
|
|
144
154
|
sessionReplayMode: this.mode
|
|
145
155
|
});
|
|
146
156
|
} else {
|
|
@@ -172,35 +182,35 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
172
182
|
this.timeKeeper = timeKeeper;
|
|
173
183
|
if (this.recorder?.trigger === _constants.TRIGGERS.API && this.agentRef.runtime.isRecording) {
|
|
174
184
|
this.mode = _constants2.MODE.FULL;
|
|
175
|
-
} else if (
|
|
185
|
+
} else if (session.state.sessionReplayMode !== null && !ignoreSession) {
|
|
176
186
|
// inherit the mode of the existing session
|
|
177
187
|
this.mode = session.state.sessionReplayMode;
|
|
178
188
|
} else {
|
|
179
189
|
// The session is new... determine the mode the new session should start in
|
|
180
190
|
this.mode = srMode;
|
|
181
191
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
192
|
+
if (this.mode !== _constants2.MODE.OFF) {
|
|
193
|
+
try {
|
|
194
|
+
/** will return a recorder instance if already imported, otherwise, will fetch the recorder and initialize it */
|
|
195
|
+
this.recorder ??= await this.instrumentClass.importRecorder();
|
|
196
|
+
} catch (err) {
|
|
197
|
+
/** if the recorder fails to import, abort the feature */
|
|
198
|
+
return this.abort(_constants.ABORT_REASONS.IMPORT, err);
|
|
199
|
+
}
|
|
191
200
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
201
|
+
// If an error was noticed before the mode could be set (like in the early lifecycle of the page), immediately set to FULL mode
|
|
202
|
+
if (this.mode === _constants2.MODE.ERROR && this.instrumentClass.errorNoticed) {
|
|
203
|
+
this.mode = _constants2.MODE.FULL;
|
|
204
|
+
}
|
|
196
205
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
// FULL mode records AND reports from the beginning, while ERROR mode only records (but does not report).
|
|
207
|
+
// ERROR mode will do this until an error is thrown, and then switch into FULL mode.
|
|
208
|
+
// The makeHarvestPayload should ensure that no payload is returned if we're not in FULL mode...
|
|
200
209
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
await this.prepUtils();
|
|
211
|
+
if (!this.agentRef.runtime.isRecording) this.recorder.startRecording(trigger, this.mode);
|
|
212
|
+
}
|
|
213
|
+
this.#writeToStorage({
|
|
204
214
|
sessionReplayMode: this.mode
|
|
205
215
|
});
|
|
206
216
|
}
|
|
@@ -247,7 +257,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
247
257
|
this.abort(_constants.ABORT_REASONS.TOO_BIG, len);
|
|
248
258
|
return;
|
|
249
259
|
}
|
|
250
|
-
if (!this.agentRef.runtime.session.state.sessionReplaySentFirstChunk) this
|
|
260
|
+
if (!this.agentRef.runtime.session.state.sessionReplaySentFirstChunk) this.#writeToStorage({
|
|
251
261
|
sessionReplaySentFirstChunk: true
|
|
252
262
|
});
|
|
253
263
|
this.recorder.clearBuffer();
|
|
@@ -310,7 +320,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
310
320
|
return {
|
|
311
321
|
qs: {
|
|
312
322
|
browser_monitoring_key: this.agentRef.info.licenseKey,
|
|
313
|
-
type:
|
|
323
|
+
type: _events.EVENT_TYPES.SR,
|
|
314
324
|
app_id: this.agentRef.info.applicationID,
|
|
315
325
|
protocol_version: '0',
|
|
316
326
|
timestamp: firstTimestamp,
|
|
@@ -376,7 +386,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
376
386
|
if (forceHarvest) this.agentRef.runtime.harvester.triggerHarvestFor(this);
|
|
377
387
|
this.mode = _constants2.MODE.OFF;
|
|
378
388
|
this.recorder?.stopRecording?.();
|
|
379
|
-
this
|
|
389
|
+
this.#writeToStorage({
|
|
380
390
|
sessionReplayMode: this.mode
|
|
381
391
|
});
|
|
382
392
|
}
|
|
@@ -388,13 +398,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
388
398
|
this.blocked = true;
|
|
389
399
|
this.mode = _constants2.MODE.OFF;
|
|
390
400
|
this.recorder?.stopRecording?.();
|
|
391
|
-
this
|
|
401
|
+
this.#writeToStorage({
|
|
392
402
|
sessionReplayMode: this.mode
|
|
393
403
|
});
|
|
394
404
|
this.recorder?.clearTimestamps?.();
|
|
395
405
|
while (this.recorder?.getEvents().events.length) this.recorder?.clearBuffer?.();
|
|
396
406
|
}
|
|
397
|
-
|
|
407
|
+
#writeToStorage(state = {}) {
|
|
398
408
|
if (this.isSessionTrackingEnabled) {
|
|
399
409
|
this.agentRef.runtime.session.write(state);
|
|
400
410
|
}
|
|
@@ -11,9 +11,10 @@ var _storage = require("./trace/storage");
|
|
|
11
11
|
var _encode = require("../../../common/url/encode");
|
|
12
12
|
var _runtime = require("../../../common/constants/runtime");
|
|
13
13
|
var _constants2 = require("../../../common/session/constants");
|
|
14
|
-
var
|
|
14
|
+
var _obfuscate = require("../../../common/util/obfuscate");
|
|
15
15
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
16
16
|
var _console = require("../../../common/util/console");
|
|
17
|
+
var _events = require("../../../common/constants/events");
|
|
17
18
|
/**
|
|
18
19
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
19
20
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -27,6 +28,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
27
28
|
super(agentRef, _constants.FEATURE_NAME);
|
|
28
29
|
this.harvestOpts.raw = true;
|
|
29
30
|
|
|
31
|
+
// Create obfuscator for session trace nodes
|
|
32
|
+
this.obfuscator = new _obfuscate.Obfuscator(agentRef, _events.EVENT_TYPES.ST);
|
|
33
|
+
|
|
30
34
|
/** Tied to the entitlement flag response from BCS. Will short circuit operations of the agg if false */
|
|
31
35
|
this.entitled = undefined;
|
|
32
36
|
/** A flag used to decide if the 30 node threshold should be ignored on the first harvest to ensure sending on the first payload */
|
|
@@ -43,8 +47,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
43
47
|
/** Sets up event listeners, and initializes this module to run in the correct "mode". Can be triggered from a few places, but makes an effort to only set up listeners once */
|
|
44
48
|
initialize(stMode, stEntitled, ignoreSession) {
|
|
45
49
|
this.entitled ??= stEntitled;
|
|
46
|
-
if (!this.entitled)
|
|
47
|
-
|
|
50
|
+
if (!this.entitled) {
|
|
51
|
+
this.abort(_constants.ABORT_REASONS.ENTITLEMENTS);
|
|
52
|
+
return this.deregisterDrain();
|
|
53
|
+
}
|
|
48
54
|
this.timeKeeper ??= this.agentRef.runtime.timeKeeper;
|
|
49
55
|
if (!this.initialized) {
|
|
50
56
|
this.initialized = true;
|
|
@@ -54,7 +60,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
54
60
|
// The SessionEntity class can emit a message indicating the session was cleared and reset (expiry, inactivity). This feature must abort and never resume if that occurs.
|
|
55
61
|
this.ee.on(_constants2.SESSION_EVENTS.RESET, () => {
|
|
56
62
|
if (this.blocked) return;
|
|
57
|
-
this.abort(
|
|
63
|
+
this.abort(_constants.ABORT_REASONS.RESET);
|
|
58
64
|
});
|
|
59
65
|
// The SessionEntity can have updates (locally or across tabs for SR mode changes), (across tabs for ST mode changes).
|
|
60
66
|
// Those updates should be sync'd here to ensure this page also honors the mode after initialization
|
|
@@ -63,7 +69,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
63
69
|
// this will only have an effect if ST is NOT already in full mode
|
|
64
70
|
if (this.mode !== _constants2.MODE.FULL && (sessionState.sessionReplayMode === _constants2.MODE.FULL || sessionState.sessionTraceMode === _constants2.MODE.FULL)) this.switchToFull();
|
|
65
71
|
// if another page's session entity has expired, or another page has transitioned to off and this one hasn't... we can just abort straight away here
|
|
66
|
-
if (this.sessionId !== sessionState.value || eventType === 'cross-tab' && sessionState.sessionTraceMode === _constants2.MODE.OFF) this.abort(
|
|
72
|
+
if (this.sessionId !== sessionState.value || eventType === 'cross-tab' && sessionState.sessionTraceMode === _constants2.MODE.OFF) this.abort(_constants.ABORT_REASONS.CROSS_TAB);
|
|
67
73
|
});
|
|
68
74
|
if (typeof PerformanceNavigationTiming !== 'undefined' && _runtime.globalScope.performance?.getEntriesByType('navigation')?.length > 0) {
|
|
69
75
|
this.traceStorage.storeTiming(_runtime.globalScope.performance.getEntriesByType('navigation')[0]);
|
|
@@ -74,30 +80,30 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
74
80
|
|
|
75
81
|
/** ST/SR sampling flow in BCS - https://drive.google.com/file/d/19hwt2oft-8Hh4RrjpLqEXfpP_9wYBLcq/view?usp=sharing */
|
|
76
82
|
/** ST will run in the mode provided by BCS if the session IS NEW. If not... it will use the state of the session entity to determine what mode to run in */
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
(0, _registerHandler.registerHandler)('trace-jserror', () => {
|
|
94
|
-
if (this.mode === _constants2.MODE.ERROR) this.switchToFull();
|
|
95
|
-
}, this.featureName, this.ee);
|
|
83
|
+
if (this.agentRef.runtime.session.state.sessionTraceMode !== null && !ignoreSession) this.mode = this.agentRef.runtime.session.state.sessionTraceMode;else this.mode = stMode;
|
|
84
|
+
if (this.mode !== _constants2.MODE.OFF) {
|
|
85
|
+
/** The handlers set up by the Inst file */
|
|
86
|
+
(0, _registerHandler.registerHandler)('bst', (...args) => this.traceStorage.storeEvent(...args), this.featureName, this.ee);
|
|
87
|
+
(0, _registerHandler.registerHandler)('bstResource', (...args) => this.traceStorage.storeResources(...args), this.featureName, this.ee);
|
|
88
|
+
(0, _registerHandler.registerHandler)('bstHist', (...args) => this.traceStorage.storeHist(...args), this.featureName, this.ee);
|
|
89
|
+
(0, _registerHandler.registerHandler)('bstXhrAgg', (...args) => this.traceStorage.storeXhrAgg(...args), this.featureName, this.ee);
|
|
90
|
+
(0, _registerHandler.registerHandler)('bstApi', (...args) => this.traceStorage.storeNode(...args), this.featureName, this.ee);
|
|
91
|
+
(0, _registerHandler.registerHandler)('trace-jserror', (...args) => this.traceStorage.storeErrorAgg(...args), this.featureName, this.ee);
|
|
92
|
+
(0, _registerHandler.registerHandler)('pvtAdded', (...args) => this.traceStorage.processPVT(...args), this.featureName, this.ee);
|
|
93
|
+
if (this.mode === _constants2.MODE.ERROR) {
|
|
94
|
+
/** A separate handler for noticing errors, and switching to "full" mode if running in "error" mode */
|
|
95
|
+
(0, _registerHandler.registerHandler)('trace-jserror', () => {
|
|
96
|
+
if (this.mode === _constants2.MODE.ERROR) this.switchToFull();
|
|
97
|
+
}, this.featureName, this.ee);
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
this.agentRef.runtime.session.write({
|
|
98
101
|
sessionTraceMode: this.mode
|
|
99
102
|
});
|
|
100
|
-
|
|
103
|
+
|
|
104
|
+
/** If the mode is off, we do not want to hold up draining for other features, so we deregister the feature for now.
|
|
105
|
+
* If it drains later (due to a mode change), data and handlers will instantly drain instead of waiting for the registry. */
|
|
106
|
+
this.mode === _constants2.MODE.OFF ? this.deregisterDrain() : this.drain();
|
|
101
107
|
}
|
|
102
108
|
preHarvestChecks() {
|
|
103
109
|
if (this.blocked || this.mode !== _constants2.MODE.FULL) return; // only allow harvest if running in full mode
|
|
@@ -105,7 +111,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
105
111
|
if (!this.agentRef.runtime.session) return; // session entity is required for trace to run and continue running
|
|
106
112
|
if (this.sessionId !== this.agentRef.runtime.session.state.value || this.ptid !== this.agentRef.runtime.ptid) {
|
|
107
113
|
// If something unexpected happened and we somehow still got to harvesting after a session identifier changed, we should force-exit instead of harvesting:
|
|
108
|
-
this.abort(
|
|
114
|
+
this.abort(_constants.ABORT_REASONS.SESSION_CHANGED);
|
|
109
115
|
return;
|
|
110
116
|
}
|
|
111
117
|
return true;
|
|
@@ -113,7 +119,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
113
119
|
serializer(stns) {
|
|
114
120
|
if (!stns.length) return; // there are no processed nodes
|
|
115
121
|
this.everHarvested = true;
|
|
116
|
-
return
|
|
122
|
+
return this.obfuscator.traverseAndObfuscateEvents(stns);
|
|
117
123
|
}
|
|
118
124
|
queryStringsBuilder(stns) {
|
|
119
125
|
const firstSessionHarvest = !this.agentRef.runtime.session.state.traceHarvestStarted;
|
|
@@ -190,8 +196,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
/** Stop running for the remainder of the page lifecycle */
|
|
193
|
-
abort(
|
|
194
|
-
(0, _console.warn)(60,
|
|
199
|
+
abort(reason = {}) {
|
|
200
|
+
(0, _console.warn)(60, reason.message);
|
|
195
201
|
this.blocked = true;
|
|
196
202
|
this.mode = _constants2.MODE.OFF;
|
|
197
203
|
this.agentRef.runtime.session.write({
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.START = exports.RESOURCE = exports.PUSH_STATE = exports.MAX_NODES_PER_HARVEST = exports.FN_START = exports.FN_END = exports.FEATURE_NAME = exports.ERROR_MODE_SECONDS_WINDOW = exports.END = exports.BST_RESOURCE = void 0;
|
|
6
|
+
exports.START = exports.RESOURCE = exports.PUSH_STATE = exports.MAX_NODES_PER_HARVEST = exports.FN_START = exports.FN_END = exports.FEATURE_NAME = exports.ERROR_MODE_SECONDS_WINDOW = exports.END = exports.BST_RESOURCE = exports.ABORT_REASONS = void 0;
|
|
7
7
|
var _features = require("../../loaders/features/features");
|
|
8
8
|
/**
|
|
9
|
-
* Copyright 2020-
|
|
9
|
+
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
10
10
|
* SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -19,4 +19,18 @@ const FN_START = exports.FN_START = 'fn' + START;
|
|
|
19
19
|
const FN_END = exports.FN_END = 'fn' + END;
|
|
20
20
|
const PUSH_STATE = exports.PUSH_STATE = 'pushState';
|
|
21
21
|
const MAX_NODES_PER_HARVEST = exports.MAX_NODES_PER_HARVEST = 1000;
|
|
22
|
-
const ERROR_MODE_SECONDS_WINDOW = exports.ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
|
|
22
|
+
const ERROR_MODE_SECONDS_WINDOW = exports.ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
|
|
23
|
+
const ABORT_REASONS = exports.ABORT_REASONS = {
|
|
24
|
+
CROSS_TAB: {
|
|
25
|
+
message: 'Session Entity was set to OFF on another tab'
|
|
26
|
+
},
|
|
27
|
+
ENTITLEMENTS: {
|
|
28
|
+
message: 'Session Trace is not allowed and will not be started'
|
|
29
|
+
},
|
|
30
|
+
RESET: {
|
|
31
|
+
message: 'Session was reset'
|
|
32
|
+
},
|
|
33
|
+
SESSION_CHANGED: {
|
|
34
|
+
message: 'Session identifier changed unexpectedly'
|
|
35
|
+
}
|
|
36
|
+
};
|