@newrelic/browser-agent 1.233.1 → 1.235.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -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/constants/shared-channel.js +19 -0
- package/dist/cjs/common/event-emitter/contextual-ee.test.js +10 -10
- package/dist/cjs/common/harvest/{harvest-scheduler.test.js → harvest-scheduler.component-test.js} +2 -2
- package/dist/cjs/common/harvest/harvest-scheduler.js +21 -5
- package/dist/cjs/common/harvest/harvest.component-test.js +224 -0
- package/dist/cjs/common/harvest/harvest.js +4 -11
- package/dist/cjs/common/session/{session-entity.test.js → session-entity.component-test.js} +79 -42
- package/dist/cjs/common/session/session-entity.js +19 -11
- package/dist/cjs/common/timer/interaction-timer.js +1 -1
- package/dist/cjs/common/url/canonicalize-url.test.js +26 -30
- package/dist/cjs/common/url/encode.js +2 -2
- package/dist/cjs/common/util/console.test.js +30 -0
- package/dist/cjs/common/util/data-size.test.js +37 -20
- package/dist/cjs/common/util/feature-flags.js +23 -12
- package/dist/cjs/common/util/feature-flags.test.js +84 -0
- package/dist/cjs/common/util/get-or-set.js +8 -1
- package/dist/cjs/common/util/get-or-set.test.js +47 -0
- package/dist/cjs/common/util/global-scope.js +1 -32
- package/dist/cjs/common/util/global-scope.test.js +72 -0
- package/dist/cjs/common/util/obfuscate.component-test.js +129 -0
- package/dist/cjs/common/util/obfuscate.js +2 -2
- package/dist/cjs/common/util/stringify.test.js +48 -0
- package/dist/cjs/common/util/submit-data.js +18 -18
- package/dist/cjs/common/util/submit-data.test.js +245 -0
- package/dist/cjs/common/util/traverse.js +19 -27
- package/dist/cjs/common/util/traverse.test.js +44 -0
- package/dist/cjs/common/wrap/wrap-raf.js +1 -1
- package/dist/cjs/common/wrap/wrap-timer.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +4 -0
- package/dist/cjs/features/jserrors/instrument/index.js +2 -15
- package/dist/cjs/features/metrics/aggregate/endpoint-map.js +14 -0
- package/dist/cjs/features/metrics/aggregate/index.js +3 -2
- package/dist/cjs/features/metrics/instrument/index.js +0 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +58 -44
- package/dist/cjs/features/session_replay/aggregate/index.component-test.js +457 -0
- package/dist/cjs/features/session_replay/aggregate/index.js +99 -82
- package/dist/cjs/features/session_replay/replay-mode.js +28 -0
- package/dist/cjs/features/session_trace/aggregate/index.js +222 -99
- package/dist/cjs/features/session_trace/constants.js +1 -3
- package/dist/cjs/features/session_trace/instrument/index.js +0 -16
- package/dist/cjs/features/spa/constants.js +0 -1
- package/dist/cjs/features/utils/agent-session.js +20 -36
- package/dist/cjs/features/utils/agent-session.test.js +211 -0
- package/dist/cjs/features/utils/aggregate-base.js +7 -12
- package/dist/cjs/features/utils/aggregate-base.test.js +110 -0
- package/dist/cjs/features/utils/feature-base.test.js +42 -0
- package/dist/cjs/features/utils/handler-cache.js +28 -23
- package/dist/cjs/features/utils/handler-cache.test.js +53 -0
- package/dist/cjs/features/utils/instrument-base.js +58 -39
- package/dist/cjs/features/utils/instrument-base.test.js +179 -0
- package/dist/cjs/features/utils/lazy-feature-loader.test.js +30 -0
- package/dist/cjs/loaders/agent.js +0 -1
- package/dist/cjs/loaders/api/api.js +1 -1
- package/dist/cjs/loaders/configure/configure.js +0 -1
- package/dist/cjs/loaders/features/featureDependencies.js +2 -0
- 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/shared-channel.js +12 -0
- package/dist/esm/common/event-emitter/contextual-ee.test.js +10 -10
- package/dist/esm/common/harvest/{harvest-scheduler.test.js → harvest-scheduler.component-test.js} +2 -2
- package/dist/esm/common/harvest/harvest-scheduler.js +21 -5
- package/dist/esm/common/harvest/harvest.component-test.js +222 -0
- package/dist/esm/common/harvest/harvest.js +4 -11
- package/dist/esm/common/session/{session-entity.test.js → session-entity.component-test.js} +77 -40
- package/dist/esm/common/session/session-entity.js +17 -11
- package/dist/esm/common/timer/interaction-timer.js +1 -1
- package/dist/esm/common/url/canonicalize-url.test.js +25 -29
- package/dist/esm/common/url/encode.js +2 -2
- package/dist/esm/common/util/console.test.js +28 -0
- package/dist/esm/common/util/data-size.test.js +35 -20
- package/dist/esm/common/util/feature-flags.js +23 -12
- package/dist/esm/common/util/feature-flags.test.js +80 -0
- package/dist/esm/common/util/get-or-set.js +8 -1
- package/dist/esm/common/util/get-or-set.test.js +45 -0
- package/dist/esm/common/util/global-scope.js +1 -29
- package/dist/esm/common/util/global-scope.test.js +70 -0
- package/dist/esm/common/util/obfuscate.component-test.js +125 -0
- package/dist/esm/common/util/obfuscate.js +2 -2
- package/dist/esm/common/util/stringify.test.js +46 -0
- package/dist/esm/common/util/submit-data.js +18 -18
- package/dist/esm/common/util/submit-data.test.js +241 -0
- package/dist/esm/common/util/traverse.js +19 -27
- package/dist/esm/common/util/traverse.test.js +42 -0
- package/dist/esm/common/wrap/wrap-raf.js +1 -1
- package/dist/esm/common/wrap/wrap-timer.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +4 -0
- package/dist/esm/features/jserrors/instrument/index.js +2 -15
- package/dist/esm/features/metrics/aggregate/endpoint-map.js +7 -0
- package/dist/esm/features/metrics/aggregate/index.js +3 -2
- package/dist/esm/features/metrics/instrument/index.js +0 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +58 -44
- package/dist/esm/features/session_replay/aggregate/index.component-test.js +453 -0
- package/dist/esm/features/session_replay/aggregate/index.js +92 -78
- package/dist/esm/features/session_replay/replay-mode.js +23 -0
- package/dist/esm/features/session_trace/aggregate/index.js +223 -100
- package/dist/esm/features/session_trace/constants.js +0 -1
- package/dist/esm/features/session_trace/instrument/index.js +1 -17
- package/dist/esm/features/spa/constants.js +0 -1
- package/dist/esm/features/utils/agent-session.js +21 -37
- package/dist/esm/features/utils/agent-session.test.js +207 -0
- package/dist/esm/features/utils/aggregate-base.js +7 -12
- package/dist/esm/features/utils/aggregate-base.test.js +108 -0
- package/dist/esm/features/utils/feature-base.test.js +40 -0
- package/dist/esm/features/utils/handler-cache.js +28 -23
- package/dist/esm/features/utils/handler-cache.test.js +51 -0
- package/dist/esm/features/utils/instrument-base.js +58 -39
- package/dist/esm/features/utils/instrument-base.test.js +175 -0
- package/dist/esm/features/utils/lazy-feature-loader.test.js +29 -0
- package/dist/esm/loaders/agent.js +0 -1
- package/dist/esm/loaders/api/api.js +2 -2
- package/dist/esm/loaders/configure/configure.js +0 -1
- package/dist/esm/loaders/features/featureDependencies.js +2 -0
- package/dist/types/common/config/state/init.d.ts.map +1 -1
- package/dist/types/common/constants/shared-channel.d.ts +5 -0
- package/dist/types/common/constants/shared-channel.d.ts.map +1 -0
- package/dist/types/common/context/shared-context.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +2 -0
- package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts +4 -0
- package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.component-test.d.ts +2 -0
- package/dist/types/common/harvest/harvest.component-test.d.ts.map +1 -0
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/session/session-entity.component-test.d.ts +2 -0
- package/dist/types/common/session/session-entity.component-test.d.ts.map +1 -0
- package/dist/types/common/session/session-entity.d.ts +9 -5
- package/dist/types/common/session/session-entity.d.ts.map +1 -1
- package/dist/types/common/timer/interaction-timer.component-test.d.ts +2 -0
- package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +1 -0
- package/dist/types/common/timer/timer.d.ts.map +1 -1
- package/dist/types/common/url/encode.component-test.d.ts +2 -0
- package/dist/types/common/url/encode.component-test.d.ts.map +1 -0
- package/dist/types/common/url/protocol.component-test.d.ts +2 -0
- package/dist/types/common/url/protocol.component-test.d.ts.map +1 -0
- package/dist/types/common/util/feature-flags.d.ts +1 -0
- package/dist/types/common/util/feature-flags.d.ts.map +1 -1
- package/dist/types/common/util/get-or-set.d.ts +9 -1
- package/dist/types/common/util/get-or-set.d.ts.map +1 -1
- package/dist/types/common/util/global-scope.d.ts +0 -9
- package/dist/types/common/util/global-scope.d.ts.map +1 -1
- package/dist/types/common/util/obfuscate.component-test.d.ts +2 -0
- package/dist/types/common/util/obfuscate.component-test.d.ts.map +1 -0
- package/dist/types/common/util/submit-data.d.ts +14 -10
- package/dist/types/common/util/submit-data.d.ts.map +1 -1
- package/dist/types/common/util/traverse.d.ts +10 -1
- package/dist/types/common/util/traverse.d.ts.map +1 -1
- package/dist/types/common/window/nreum.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts +1 -0
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +8 -0
- package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +1 -0
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -1
- package/dist/types/features/metrics/instrument/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_event/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +2 -0
- package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +1 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts +14 -5
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/replay-mode.d.ts +9 -0
- package/dist/types/features/session_replay/replay-mode.d.ts.map +1 -0
- package/dist/types/features/session_trace/aggregate/index.d.ts +21 -3
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/constants.d.ts +0 -1
- package/dist/types/features/session_trace/constants.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts +0 -2
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/constants.d.ts.map +1 -1
- package/dist/types/features/utils/agent-session.d.ts.map +1 -1
- package/dist/types/features/utils/aggregate-base.d.ts +6 -1
- package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
- package/dist/types/features/utils/handler-cache.d.ts +12 -11
- package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
- package/dist/types/features/utils/instrument-base.d.ts +17 -1
- package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
- package/dist/types/loaders/agent.d.ts.map +1 -1
- package/dist/types/loaders/configure/configure.d.ts.map +1 -1
- package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
- package/package.json +14 -8
- package/src/common/config/state/init.js +0 -1
- package/src/common/constants/shared-channel.js +13 -0
- package/src/common/context/shared-context.js +0 -1
- package/src/common/event-emitter/contextual-ee.test.js +10 -10
- package/src/common/harvest/{harvest-scheduler.test.js → harvest-scheduler.component-test.js} +2 -2
- package/src/common/harvest/harvest-scheduler.js +17 -6
- package/src/common/harvest/harvest.component-test.js +169 -0
- package/src/common/harvest/harvest.js +5 -9
- package/src/common/session/{session-entity.test.js → session-entity.component-test.js} +70 -48
- package/src/common/session/session-entity.js +15 -12
- package/src/common/timer/interaction-timer.js +1 -1
- package/src/common/timer/timer.js +0 -1
- package/src/common/url/canonicalize-url.test.js +32 -21
- package/src/common/url/encode.js +2 -2
- package/src/common/util/console.test.js +34 -0
- package/src/common/util/data-size.test.js +27 -20
- package/src/common/util/feature-flags.js +24 -12
- package/src/common/util/feature-flags.test.js +98 -0
- package/src/common/util/get-or-set.js +8 -1
- package/src/common/util/get-or-set.test.js +58 -0
- package/src/common/util/global-scope.js +0 -26
- package/src/common/util/global-scope.test.js +87 -0
- package/src/common/util/obfuscate.component-test.js +173 -0
- package/src/common/util/obfuscate.js +2 -2
- package/src/common/util/stringify.test.js +49 -0
- package/src/common/util/submit-data.js +18 -19
- package/src/common/util/submit-data.test.js +226 -0
- package/src/common/util/traverse.js +18 -27
- package/src/common/util/traverse.test.js +50 -0
- package/src/common/window/nreum.js +0 -1
- package/src/common/wrap/wrap-raf.js +1 -1
- package/src/common/wrap/wrap-timer.js +1 -1
- package/src/features/jserrors/aggregate/index.js +5 -0
- package/src/features/jserrors/instrument/index.js +2 -15
- package/src/features/metrics/aggregate/endpoint-map.js +7 -0
- package/src/features/metrics/aggregate/index.js +3 -2
- package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -1
- package/src/features/metrics/instrument/index.js +0 -2
- package/src/features/page_view_event/aggregate/index.js +48 -51
- package/src/features/page_view_event/instrument/index.js +0 -1
- package/src/features/session_replay/aggregate/index.component-test.js +368 -0
- package/src/features/session_replay/aggregate/index.js +96 -71
- package/src/features/session_replay/instrument/index.js +0 -1
- package/src/features/session_replay/replay-mode.js +23 -0
- package/src/features/session_trace/aggregate/index.js +198 -79
- package/src/features/session_trace/constants.js +0 -1
- package/src/features/session_trace/instrument/index.js +2 -19
- package/src/features/spa/constants.js +0 -1
- package/src/features/utils/agent-session.js +22 -34
- package/src/features/utils/agent-session.test.js +194 -0
- package/src/features/utils/aggregate-base.js +12 -9
- package/src/features/utils/aggregate-base.test.js +122 -0
- package/src/features/utils/feature-base.test.js +45 -0
- package/src/features/utils/handler-cache.js +29 -24
- package/src/features/utils/handler-cache.test.js +72 -0
- package/src/features/utils/instrument-base.js +45 -29
- package/src/features/utils/instrument-base.test.js +190 -0
- package/src/features/utils/lazy-feature-loader.test.js +37 -0
- package/src/loaders/agent.js +0 -1
- package/src/loaders/api/api.js +2 -2
- package/src/loaders/configure/configure.js +0 -1
- package/src/loaders/features/featureDependencies.js +2 -0
- package/dist/cjs/common/storage/local-memory.js +0 -35
- package/dist/cjs/common/storage/local-memory.test.js +0 -20
- package/dist/cjs/common/util/s-hash.js +0 -19
- package/dist/cjs/features/metrics/instrument/workers-helper.js +0 -124
- package/dist/esm/common/storage/local-memory.js +0 -28
- package/dist/esm/common/storage/local-memory.test.js +0 -18
- package/dist/esm/common/util/s-hash.js +0 -13
- package/dist/esm/features/metrics/instrument/workers-helper.js +0 -119
- package/dist/types/common/storage/local-memory.d.ts +0 -8
- package/dist/types/common/storage/local-memory.d.ts.map +0 -1
- package/dist/types/common/util/s-hash.d.ts +0 -2
- package/dist/types/common/util/s-hash.d.ts.map +0 -1
- package/dist/types/features/metrics/instrument/workers-helper.d.ts +0 -7
- package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +0 -1
- package/src/common/storage/local-memory.js +0 -30
- package/src/common/storage/local-memory.test.js +0 -19
- package/src/common/util/s-hash.js +0 -14
- package/src/features/metrics/instrument/workers-helper.js +0 -113
- /package/dist/cjs/common/timer/{interaction-timer.test.js → interaction-timer.component-test.js} +0 -0
- /package/dist/cjs/common/url/{encode.test.js → encode.component-test.js} +0 -0
- /package/dist/cjs/common/url/{protocol.test.js → protocol.component-test.js} +0 -0
- /package/dist/esm/common/timer/{interaction-timer.test.js → interaction-timer.component-test.js} +0 -0
- /package/dist/esm/common/url/{encode.test.js → encode.component-test.js} +0 -0
- /package/dist/esm/common/url/{protocol.test.js → protocol.component-test.js} +0 -0
- /package/src/common/timer/{interaction-timer.test.js → interaction-timer.component-test.js} +0 -0
- /package/src/common/url/{encode.test.js → encode.component-test.js} +0 -0
- /package/src/common/url/{protocol.test.js → protocol.component-test.js} +0 -0
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Aggregate = void 0;
|
|
7
7
|
var _registerHandler = require("../../../common/event-emitter/register-handler");
|
|
8
8
|
var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
|
|
9
|
-
var _stringify = require("../../../common/util/stringify");
|
|
10
9
|
var _parseUrl = require("../../../common/url/parse-url");
|
|
11
10
|
var _config = require("../../../common/config/config");
|
|
12
11
|
var _now = require("../../../common/timing/now");
|
|
13
12
|
var _constants = require("../constants");
|
|
14
13
|
var _drain = require("../../../common/drain/drain");
|
|
15
14
|
var _handlerCache = require("../../utils/handler-cache");
|
|
15
|
+
var _sessionEntity = require("../../../common/session/session-entity");
|
|
16
|
+
var _replayMode = require("../../session_replay/replay-mode");
|
|
16
17
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
17
18
|
/*
|
|
18
19
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
@@ -41,16 +42,21 @@ const toAggregate = {
|
|
|
41
42
|
mousing: [1000, 2000],
|
|
42
43
|
touching: [1000, 2000]
|
|
43
44
|
};
|
|
44
|
-
const MAX_TRACE_DURATION =
|
|
45
|
+
const MAX_TRACE_DURATION = 10 * 60 * 1000; // 10 minutes
|
|
46
|
+
const REQ_THRESHOLD_TO_SEND = 30;
|
|
47
|
+
const ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
|
|
45
48
|
|
|
46
49
|
class Aggregate extends _aggregateBase.AggregateBase {
|
|
47
50
|
static featureName = _constants.FEATURE_NAME;
|
|
51
|
+
#scheduler;
|
|
48
52
|
constructor(agentIdentifier, aggregator, argsObj) {
|
|
49
53
|
var _this;
|
|
50
|
-
// Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
|
|
51
54
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
52
55
|
_this = this;
|
|
53
|
-
|
|
56
|
+
this.agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
57
|
+
|
|
58
|
+
// Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
|
|
59
|
+
if (!this.agentRuntime.xhrWrappable) return;
|
|
54
60
|
this.resourceObserver = argsObj?.resourceObserver; // undefined if observer couldn't be created
|
|
55
61
|
this.ptid = '';
|
|
56
62
|
this.trace = {};
|
|
@@ -58,105 +64,217 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
58
64
|
this.sentTrace = null;
|
|
59
65
|
this.harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.harvestTimeSeconds') || 10;
|
|
60
66
|
this.maxNodesPerHarvest = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.maxNodesPerHarvest') || 1000;
|
|
61
|
-
this.
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
this.isStandalone = false;
|
|
68
|
+
const operationalGate = new _handlerCache.HandlerCache(); // acts as a controller-intermediary that can enable or disable this feature's collection dynamically
|
|
69
|
+
const sessionEntity = this.agentRuntime.session;
|
|
70
|
+
|
|
71
|
+
/* --- The following section deals with user sessions concept & contains non-trivial control flow. --- */
|
|
72
|
+
const controlTraceOp = traceMode => {
|
|
73
|
+
switch (traceMode) {
|
|
74
|
+
case _sessionEntity.MODE.ERROR:
|
|
75
|
+
this.startTracing(operationalGate, true);
|
|
76
|
+
break;
|
|
77
|
+
case _sessionEntity.MODE.FULL:
|
|
78
|
+
case true:
|
|
79
|
+
this.startTracing(operationalGate);
|
|
80
|
+
break;
|
|
81
|
+
case _sessionEntity.MODE.OFF:
|
|
82
|
+
case false:
|
|
83
|
+
default:
|
|
84
|
+
// this feature becomes "off" (does nothing & nothing is sent)
|
|
85
|
+
operationalGate.decide(false);
|
|
86
|
+
break;
|
|
68
87
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
};
|
|
89
|
+
if (!sessionEntity) {
|
|
90
|
+
// Since session manager isn't around, do the old Trace behavior of waiting for RUM response to decide feature activation.
|
|
91
|
+
this.isStandalone = true;
|
|
92
|
+
(0, _registerHandler.registerHandler)('rumresp-stn', on => controlTraceOp(on), this.featureName, this.ee);
|
|
93
|
+
} else {
|
|
94
|
+
let seenAnError = false;
|
|
95
|
+
let mostRecentModeKnown;
|
|
96
|
+
(0, _registerHandler.registerHandler)('errorAgg', () => {
|
|
97
|
+
// Switch to full capture mode on next harvest on first exception thrown only. Only done once so that sessionTraceMode isn't constantly overwritten after decision block.
|
|
98
|
+
if (!seenAnError) {
|
|
99
|
+
seenAnError = true;
|
|
100
|
+
/* If this cb executes before Trace has started, then no further action needed. But if...
|
|
101
|
+
- startTracing already ran under ERROR mode, then it will NOT have kicked off the harvest-scheduler so that needs to be done & switch mode.
|
|
102
|
+
- startTracing never ran because mode is OFF or Replay aborted or Traced turned off elsewhere OR trace already in FULL, then this should do nothing. */
|
|
103
|
+
if (sessionEntity.state.sessionTraceMode === _sessionEntity.MODE.ERROR && this.#scheduler) {
|
|
104
|
+
sessionEntity.write({
|
|
105
|
+
sessionTraceMode: mostRecentModeKnown = _sessionEntity.MODE.FULL
|
|
106
|
+
});
|
|
107
|
+
this.trimSTNs(ERROR_MODE_SECONDS_WINDOW); // up until now, Trace would've been just buffering nodes up to max, which needs to be trimmed to last X seconds
|
|
108
|
+
this.#scheduler.runHarvest({
|
|
109
|
+
needResponse: true
|
|
110
|
+
});
|
|
111
|
+
}
|
|
83
112
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
}, this.featureName, this.ee);
|
|
114
|
+
const stopTracePerm = () => {
|
|
115
|
+
if (sessionEntity.state.sessionTraceMode !== _sessionEntity.MODE.OFF) sessionEntity.write({
|
|
116
|
+
sessionTraceMode: _sessionEntity.MODE.OFF
|
|
117
|
+
});
|
|
118
|
+
operationalGate.permanentlyDecide(false);
|
|
119
|
+
this.#scheduler?.stopTimer(true);
|
|
120
|
+
if (mostRecentModeKnown === _sessionEntity.MODE.FULL) this.#scheduler?.runHarvest(); // allow queued nodes (past opGate) to final harvest, unless they were buffered in other modes
|
|
121
|
+
this.#scheduler = null;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// CAUTION: everything inside this promise runs post-load; event subscribers must be pre-load aka synchronous with constructor
|
|
125
|
+
this.waitForFlags(['stn', 'sr']).then(async _ref => {
|
|
126
|
+
let [traceOn, replayOn] = _ref;
|
|
127
|
+
if (!replayOn) {
|
|
128
|
+
// When sr = 0 from BCS, also do the old Trace behavior:
|
|
129
|
+
this.isStandalone = true;
|
|
130
|
+
controlTraceOp(traceOn);
|
|
131
|
+
} else {
|
|
132
|
+
this.ee.on('REPLAY_ABORTED', () => stopTracePerm());
|
|
133
|
+
/* Assuming on page visible that the trace mode is updated from shared session,
|
|
134
|
+
- if trace is turned off from the other page, it should be likewise here.
|
|
135
|
+
- if trace switches to Full mode, harvest should start (prev: Error) if not already running (prev: Full). */
|
|
136
|
+
this.ee.on(_sessionEntity.SESSION_EVENTS.RESUME, () => {
|
|
137
|
+
const updatedTraceMode = sessionEntity.state.sessionTraceMode;
|
|
138
|
+
if (updatedTraceMode === _sessionEntity.MODE.OFF) stopTracePerm();else if (updatedTraceMode === _sessionEntity.MODE.FULL && this.#scheduler && !this.#scheduler.started) this.#scheduler.runHarvest({
|
|
139
|
+
needResponse: true
|
|
140
|
+
});
|
|
141
|
+
mostRecentModeKnown = updatedTraceMode;
|
|
91
142
|
});
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
143
|
+
this.ee.on(_sessionEntity.SESSION_EVENTS.PAUSE, () => mostRecentModeKnown = sessionEntity.state.sessionTraceMode);
|
|
144
|
+
if (!sessionEntity.isNew) {
|
|
145
|
+
// inherit the same mode as existing session's Trace
|
|
146
|
+
const existingTraceMode = mostRecentModeKnown = sessionEntity.state.sessionTraceMode;
|
|
147
|
+
if (existingTraceMode === _sessionEntity.MODE.OFF) this.isStandalone = true;
|
|
148
|
+
controlTraceOp(existingTraceMode);
|
|
149
|
+
} else {
|
|
150
|
+
// for new sessions, see the truth table associated with NEWRELIC-8662 wrt the new Trace behavior under session management
|
|
151
|
+
const replayMode = await (0, _replayMode.getSessionReplayMode)(agentIdentifier);
|
|
152
|
+
if (replayMode === _sessionEntity.MODE.OFF) this.isStandalone = true; // without SR, Traces are still subject to old harvest limits
|
|
153
|
+
|
|
154
|
+
let startingMode;
|
|
155
|
+
if (traceOn === true) {
|
|
156
|
+
// CASE: both trace (entitlement+sampling) & replay (entitlement) flags are true from RUM
|
|
157
|
+
startingMode = _sessionEntity.MODE.FULL; // always full capture regardless of replay sampling decisions
|
|
158
|
+
} else {
|
|
159
|
+
// CASE: trace flag is off, BUT it must still run if replay is on (possibly)
|
|
160
|
+
// At this point, it's possible that 1 or more exception was thrown, in which case just start in full if Replay originally started in ERROR mode.
|
|
161
|
+
if (replayMode === _sessionEntity.MODE.ERROR && seenAnError) startingMode = _sessionEntity.MODE.FULL;else startingMode = replayMode;
|
|
162
|
+
}
|
|
163
|
+
sessionEntity.write({
|
|
164
|
+
sessionTraceMode: mostRecentModeKnown = startingMode
|
|
165
|
+
});
|
|
166
|
+
controlTraceOp(startingMode);
|
|
167
|
+
}
|
|
101
168
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}, this.featureName, this.ee);
|
|
107
|
-
(0, _registerHandler.registerHandler)('block-stn', () => handlerCache.decide(false), this.featureName, this.ee);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/* --- EoS --- */
|
|
108
172
|
|
|
109
173
|
// register the handlers immediately... but let the handlerCache decide if the data should actually get stored...
|
|
110
174
|
(0, _registerHandler.registerHandler)('bst', function () {
|
|
111
175
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
112
176
|
args[_key] = arguments[_key];
|
|
113
177
|
}
|
|
114
|
-
return
|
|
178
|
+
return operationalGate.settle(() => _this.storeEvent(...args));
|
|
115
179
|
}, this.featureName, this.ee);
|
|
116
|
-
(0, _registerHandler.registerHandler)('
|
|
180
|
+
(0, _registerHandler.registerHandler)('bstResource', function () {
|
|
117
181
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
118
182
|
args[_key2] = arguments[_key2];
|
|
119
183
|
}
|
|
120
|
-
return
|
|
184
|
+
return operationalGate.settle(() => _this.storeResources(...args));
|
|
121
185
|
}, this.featureName, this.ee);
|
|
122
|
-
(0, _registerHandler.registerHandler)('
|
|
186
|
+
(0, _registerHandler.registerHandler)('bstHist', function () {
|
|
123
187
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
124
188
|
args[_key3] = arguments[_key3];
|
|
125
189
|
}
|
|
126
|
-
return
|
|
190
|
+
return operationalGate.settle(() => _this.storeHist(...args));
|
|
127
191
|
}, this.featureName, this.ee);
|
|
128
|
-
(0, _registerHandler.registerHandler)('
|
|
192
|
+
(0, _registerHandler.registerHandler)('bstXhrAgg', function () {
|
|
129
193
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
130
194
|
args[_key4] = arguments[_key4];
|
|
131
195
|
}
|
|
132
|
-
return
|
|
196
|
+
return operationalGate.settle(() => _this.storeXhrAgg(...args));
|
|
133
197
|
}, this.featureName, this.ee);
|
|
134
|
-
(0, _registerHandler.registerHandler)('
|
|
198
|
+
(0, _registerHandler.registerHandler)('bstApi', function () {
|
|
135
199
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
136
200
|
args[_key5] = arguments[_key5];
|
|
137
201
|
}
|
|
138
|
-
return
|
|
202
|
+
return operationalGate.settle(() => _this.storeSTN(...args));
|
|
139
203
|
}, this.featureName, this.ee);
|
|
140
|
-
(0, _registerHandler.registerHandler)('
|
|
204
|
+
(0, _registerHandler.registerHandler)('errorAgg', function () {
|
|
141
205
|
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
142
206
|
args[_key6] = arguments[_key6];
|
|
143
207
|
}
|
|
144
|
-
return
|
|
208
|
+
return operationalGate.settle(() => _this.storeErrorAgg(...args));
|
|
145
209
|
}, this.featureName, this.ee);
|
|
146
|
-
(0, _registerHandler.registerHandler)('
|
|
210
|
+
(0, _registerHandler.registerHandler)('pvtAdded', function () {
|
|
147
211
|
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
148
212
|
args[_key7] = arguments[_key7];
|
|
149
213
|
}
|
|
150
|
-
return
|
|
151
|
-
}, this.featureName, this.ee);
|
|
152
|
-
(0, _registerHandler.registerHandler)('pvtAdded', function () {
|
|
153
|
-
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
154
|
-
args[_key8] = arguments[_key8];
|
|
155
|
-
}
|
|
156
|
-
return handlerCache.settle(() => _this.processPVT(...args));
|
|
214
|
+
return operationalGate.settle(() => _this.processPVT(...args));
|
|
157
215
|
}, this.featureName, this.ee);
|
|
158
216
|
(0, _drain.drain)(this.agentIdentifier, this.featureName);
|
|
159
217
|
}
|
|
218
|
+
startTracing(startupBuffer) {
|
|
219
|
+
let dontStartHarvestYet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
220
|
+
if (typeof PerformanceNavigationTiming !== 'undefined') {
|
|
221
|
+
this.storeTiming(window.performance.getEntriesByType('navigation')[0]);
|
|
222
|
+
} else {
|
|
223
|
+
this.storeTiming(window.performance.timing);
|
|
224
|
+
}
|
|
225
|
+
this.#scheduler = new _harvestScheduler.HarvestScheduler('resources', {
|
|
226
|
+
onFinished: this.#onHarvestFinished.bind(this),
|
|
227
|
+
retryDelay: this.harvestTimeSeconds
|
|
228
|
+
}, this);
|
|
229
|
+
this.#scheduler.harvest.on('resources', this.#prepareHarvest.bind(this));
|
|
230
|
+
if (dontStartHarvestYet === false) this.#scheduler.runHarvest({
|
|
231
|
+
needResponse: true
|
|
232
|
+
}); // sends first stn harvest immediately
|
|
233
|
+
startupBuffer.decide(true); // signal to ALLOW & process data in EE's buffer into internal nodes queued for next harvest
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
#onHarvestFinished(result) {
|
|
237
|
+
if (result.sent && result.responseText && !this.ptid) {
|
|
238
|
+
// continue interval harvest only if ptid was returned by server on the first
|
|
239
|
+
this.agentRuntime.ptid = this.ptid = result.responseText;
|
|
240
|
+
this.#scheduler.startTimer(this.harvestTimeSeconds);
|
|
241
|
+
}
|
|
242
|
+
if (result.sent && result.retry && this.sentTrace) {
|
|
243
|
+
// merge previous trace back into buffer to retry for next harvest
|
|
244
|
+
Object.entries(this.sentTrace).forEach(_ref2 => {
|
|
245
|
+
let [name, listOfSTNodes] = _ref2;
|
|
246
|
+
if (this.nodeCount >= this.maxNodesPerHarvest) return;
|
|
247
|
+
this.nodeCount += listOfSTNodes.length;
|
|
248
|
+
this.trace[name] = this.trace[name] ? listOfSTNodes.concat(this.trace[name]) : listOfSTNodes;
|
|
249
|
+
});
|
|
250
|
+
this.sentTrace = null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
#prepareHarvest(options) {
|
|
254
|
+
/* Standalone refers to the legacy version of ST before the idea of 'session' or the Replay feature existed.
|
|
255
|
+
It has a different behavior on returning a payload for harvest than when used in tandem with either of those concepts. */
|
|
256
|
+
if (this.isStandalone) {
|
|
257
|
+
if ((0, _now.now)() > MAX_TRACE_DURATION) {
|
|
258
|
+
// been collecting for over the longest duration we should run for, empty trace object so ST has nothing to send
|
|
259
|
+
this.#scheduler.stopTimer();
|
|
260
|
+
this.trace = {};
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
// Only harvest when more than some threshold of nodes are pending, after the very first harvest.
|
|
264
|
+
if (this.ptid && this.nodeCount <= REQ_THRESHOLD_TO_SEND) return;
|
|
265
|
+
} else {
|
|
266
|
+
// -- *cli May '26 - Update: Not rate limiting backgrounded pages either for now.
|
|
267
|
+
// if (this.ptid && document.visibilityState === 'hidden' && this.nodeCount <= REQ_THRESHOLD_TO_SEND) return
|
|
268
|
+
|
|
269
|
+
const currentMode = this.agentRuntime.session.state.sessionTraceMode;
|
|
270
|
+
/* There could still be nodes previously collected even after Trace (w/ session mgmt) is turned off. Hence, continue to send the last batch.
|
|
271
|
+
* The intermediary controller SHOULD be already switched off so that no nodes are further queued. */
|
|
272
|
+
if (currentMode === _sessionEntity.MODE.OFF && Object.keys(this.trace).length === 0) return;
|
|
273
|
+
if (currentMode === _sessionEntity.MODE.ERROR) return; // Trace in this mode should never be harvesting, even on unload
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return this.takeSTNs(options.retry);
|
|
277
|
+
}
|
|
160
278
|
|
|
161
279
|
// PageViewTiming (FEATURE) events and metrics, such as 'load', 'lcp', etc. pipes into ST here.
|
|
162
280
|
processPVT(name, value, attrs) {
|
|
@@ -198,18 +316,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
198
316
|
}
|
|
199
317
|
}
|
|
200
318
|
|
|
201
|
-
// Tracks duration of native APIs wrapped by wrap-timer & wrap-raf.
|
|
202
|
-
storeTimer(target, start, end, type) {
|
|
203
|
-
const evt = {
|
|
204
|
-
n: type,
|
|
205
|
-
s: start,
|
|
206
|
-
e: end,
|
|
207
|
-
o: 'window',
|
|
208
|
-
t: type === 'requestAnimationFrame' ? type : 'timer'
|
|
209
|
-
};
|
|
210
|
-
this.storeSTN(evt);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
319
|
// Tracks the events and their listener's duration on objects wrapped by wrap-events.
|
|
214
320
|
storeEvent(currentEvent, target, start, end) {
|
|
215
321
|
if (this.shouldIgnoreEvent(currentEvent, target)) return;
|
|
@@ -290,12 +396,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
290
396
|
};
|
|
291
397
|
this.storeSTN(node);
|
|
292
398
|
}
|
|
293
|
-
|
|
399
|
+
#laststart = 0;
|
|
294
400
|
// Processes all the PerformanceResourceTiming entries captured (by observer).
|
|
295
401
|
storeResources(resources) {
|
|
296
402
|
if (!resources || resources.length === 0) return;
|
|
297
403
|
resources.forEach(currentResource => {
|
|
298
|
-
if ((currentResource.fetchStart | 0) <= this
|
|
404
|
+
if ((currentResource.fetchStart | 0) <= this.#laststart) return; // don't recollect already-seen resources
|
|
299
405
|
|
|
300
406
|
const parsed = (0, _parseUrl.parseUrl)(currentResource.name);
|
|
301
407
|
const res = {
|
|
@@ -308,7 +414,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
308
414
|
};
|
|
309
415
|
this.storeSTN(res);
|
|
310
416
|
});
|
|
311
|
-
this
|
|
417
|
+
this.#laststart = resources[resources.length - 1].fetchStart | 0;
|
|
312
418
|
}
|
|
313
419
|
|
|
314
420
|
// JavascriptError (FEATURE) events pipes into ST here.
|
|
@@ -339,20 +445,50 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
339
445
|
|
|
340
446
|
// Central function called by all the other store__ & addToTrace API to append a trace node.
|
|
341
447
|
storeSTN(stn) {
|
|
342
|
-
if (this.nodeCount >= this.maxNodesPerHarvest)
|
|
343
|
-
|
|
448
|
+
if (this.nodeCount >= this.maxNodesPerHarvest) {
|
|
449
|
+
// limit the amount of pending data awaiting next harvest
|
|
450
|
+
if (this.isStandalone || this.agentRuntime.session.state.sessionTraceMode !== _sessionEntity.MODE.ERROR) return;
|
|
451
|
+
const openedSpace = this.trimSTNs(ERROR_MODE_SECONDS_WINDOW); // but maybe we could make some space by discarding irrelevant nodes if we're in sessioned Error mode
|
|
452
|
+
if (openedSpace == 0) return;
|
|
453
|
+
}
|
|
344
454
|
if (this.trace[stn.n]) this.trace[stn.n].push(stn);else this.trace[stn.n] = [stn];
|
|
345
455
|
this.nodeCount++;
|
|
346
456
|
}
|
|
347
457
|
|
|
458
|
+
/**
|
|
459
|
+
* Trim the collection of nodes awaiting harvest such that those seen outside a certain span of time are discarded.
|
|
460
|
+
* @param {number} lookbackDuration Past length of time until now for which we care about nodes, in milliseconds
|
|
461
|
+
* @returns {number} However many nodes were discarded after trimming.
|
|
462
|
+
*/
|
|
463
|
+
trimSTNs(lookbackDuration) {
|
|
464
|
+
let prunedNodes = 0;
|
|
465
|
+
const cutoffHighResTime = Math.max((0, _now.now)() - lookbackDuration, 0);
|
|
466
|
+
Object.keys(this.trace).forEach(nameCategory => {
|
|
467
|
+
const nodeList = this.trace[nameCategory];
|
|
468
|
+
/* Notice nodes are appending under their name's list as they end and are stored. This means each list is already (roughly) sorted in chronological order by end time.
|
|
469
|
+
* This isn't exact since nodes go through some processing & EE handlers chain, but it's close enough as we still capture nodes whose duration overlaps the lookback window.
|
|
470
|
+
* ASSUMPTION: all 'end' timings stored are relative to timeOrigin (DOMHighResTimeStamp) and not Unix epoch based. */
|
|
471
|
+
let cutoffIdx = nodeList.findIndex(node => cutoffHighResTime <= node.e);
|
|
472
|
+
if (cutoffIdx == 0) return;else if (cutoffIdx < 0) {
|
|
473
|
+
// whole list falls outside lookback window and is irrelevant
|
|
474
|
+
cutoffIdx = nodeList.length;
|
|
475
|
+
delete this.trace[nameCategory];
|
|
476
|
+
} else nodeList.splice(0, cutoffIdx); // chop off everything outside our window i.e. before the last <lookbackDuration> timeframe
|
|
477
|
+
|
|
478
|
+
this.nodeCount -= cutoffIdx;
|
|
479
|
+
prunedNodes += cutoffIdx;
|
|
480
|
+
});
|
|
481
|
+
return prunedNodes;
|
|
482
|
+
}
|
|
483
|
+
|
|
348
484
|
// Used by session trace's harvester to create the payload body.
|
|
349
485
|
takeSTNs(retry) {
|
|
350
486
|
if (!this.resourceObserver) {
|
|
351
487
|
// if PO isn't supported, this checks resourcetiming buffer every harvest.
|
|
352
488
|
this.storeResources(window.performance.getEntriesByType('resource'));
|
|
353
489
|
}
|
|
354
|
-
const stns = Object.entries(this.trace).flatMap(
|
|
355
|
-
let [name, listOfSTNodes] =
|
|
490
|
+
const stns = Object.entries(this.trace).flatMap(_ref3 => {
|
|
491
|
+
let [name, listOfSTNodes] = _ref3;
|
|
356
492
|
// basically take the "this.trace" map-obj and concat all the list-type values
|
|
357
493
|
if (!(name in toAggregate)) return listOfSTNodes;
|
|
358
494
|
// Special processing for event nodes dealing with user inputs:
|
|
@@ -366,7 +502,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
366
502
|
}
|
|
367
503
|
this.trace = {};
|
|
368
504
|
this.nodeCount = 0;
|
|
369
|
-
|
|
505
|
+
return {
|
|
370
506
|
qs: {
|
|
371
507
|
st: String((0, _config.getRuntime)(this.agentIdentifier).offset)
|
|
372
508
|
},
|
|
@@ -374,19 +510,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
374
510
|
res: stns
|
|
375
511
|
}
|
|
376
512
|
};
|
|
377
|
-
if (!this.ptid) {
|
|
378
|
-
// send custom and user attributes on the very first ST harvest only
|
|
379
|
-
const {
|
|
380
|
-
userAttributes,
|
|
381
|
-
atts,
|
|
382
|
-
jsAttributes
|
|
383
|
-
} = (0, _config.getInfo)(this.agentIdentifier);
|
|
384
|
-
stnInfo.qs.ua = userAttributes;
|
|
385
|
-
stnInfo.qs.at = atts;
|
|
386
|
-
const ja = (0, _stringify.stringify)(jsAttributes);
|
|
387
|
-
stnInfo.qs.ja = ja === '{}' ? null : ja;
|
|
388
|
-
}
|
|
389
|
-
return stnInfo;
|
|
390
513
|
}
|
|
391
514
|
smearEvtsByOrigin(name) {
|
|
392
515
|
const maxGap = toAggregate[name][0];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.START = exports.RESOURCE = exports.PUSH_STATE = exports.FN_START = exports.FN_END = exports.FEATURE_NAME = exports.END = exports.
|
|
6
|
+
exports.START = exports.RESOURCE = exports.PUSH_STATE = exports.FN_START = exports.FN_END = exports.FEATURE_NAME = exports.END = exports.BST_RESOURCE = void 0;
|
|
7
7
|
var _features = require("../../loaders/features/features");
|
|
8
8
|
const FEATURE_NAME = _features.FEATURE_NAMES.sessionTrace;
|
|
9
9
|
exports.FEATURE_NAME = FEATURE_NAME;
|
|
@@ -19,7 +19,5 @@ const FN_START = 'fn' + START;
|
|
|
19
19
|
exports.FN_START = FN_START;
|
|
20
20
|
const FN_END = 'fn' + END;
|
|
21
21
|
exports.FN_END = FN_END;
|
|
22
|
-
const BST_TIMER = 'bstTimer';
|
|
23
|
-
exports.BST_TIMER = BST_TIMER;
|
|
24
22
|
const PUSH_STATE = 'pushState';
|
|
25
23
|
exports.PUSH_STATE = PUSH_STATE;
|
|
@@ -21,7 +21,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
21
|
const {
|
|
22
22
|
BST_RESOURCE,
|
|
23
23
|
RESOURCE,
|
|
24
|
-
BST_TIMER,
|
|
25
24
|
START,
|
|
26
25
|
END,
|
|
27
26
|
FEATURE_NAME,
|
|
@@ -37,8 +36,6 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
37
36
|
if (!_globalScope.isBrowserScope) return; // session traces not supported outside web env
|
|
38
37
|
|
|
39
38
|
const thisInstrumentEE = this.ee;
|
|
40
|
-
this.timerEE = (0, _wrap.wrapTimer)(thisInstrumentEE);
|
|
41
|
-
this.rafEE = (0, _wrap.wrapRaf)(thisInstrumentEE);
|
|
42
39
|
(0, _wrap.wrapHistory)(thisInstrumentEE);
|
|
43
40
|
this.eventsEE = (0, _wrap.wrapEvents)(thisInstrumentEE);
|
|
44
41
|
this.eventsEE.on(FN_START, function (args, target) {
|
|
@@ -49,19 +46,6 @@ class Instrument extends _instrumentBase.InstrumentBase {
|
|
|
49
46
|
// When ajax is disabled, this may fail without making ajax a dependency of session_trace
|
|
50
47
|
(0, _handle.handle)('bst', [args[0], target, this.bstStart, (0, _now.now)()], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
51
48
|
});
|
|
52
|
-
this.timerEE.on(FN_START, function (args, obj, type) {
|
|
53
|
-
this.bstStart = (0, _now.now)();
|
|
54
|
-
this.bstType = type;
|
|
55
|
-
});
|
|
56
|
-
this.timerEE.on(FN_END, function (args, target) {
|
|
57
|
-
(0, _handle.handle)(BST_TIMER, [target, this.bstStart, (0, _now.now)(), this.bstType], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
58
|
-
});
|
|
59
|
-
this.rafEE.on(FN_START, function () {
|
|
60
|
-
this.bstStart = (0, _now.now)();
|
|
61
|
-
});
|
|
62
|
-
this.rafEE.on(FN_END, function (args, target) {
|
|
63
|
-
(0, _handle.handle)(BST_TIMER, [target, this.bstStart, (0, _now.now)(), 'requestAnimationFrame'], undefined, _features.FEATURE_NAMES.sessionTrace, thisInstrumentEE);
|
|
64
|
-
});
|
|
65
49
|
thisInstrumentEE.on(PUSH_STATE + START, function (args) {
|
|
66
50
|
this.time = (0, _now.now)();
|
|
67
51
|
this.startPath = location.pathname + location.hash;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.originalSetTimeout = exports.START = exports.SPA_NODE = exports.REMAINING = exports.MAX_TIMER_BUDGET = exports.JS_TIME = exports.JSONP_NODE = exports.JSONP_END = exports.INTERACTION_EVENTS = exports.INTERACTION_API = exports.INTERACTION = exports.FN_START = exports.FN_END = exports.FETCH_START = exports.FETCH_DONE = exports.FETCH_BODY = exports.FETCH = exports.FEATURE_NAME = exports.END = exports.CB_START = exports.CB_END = exports.BODY = void 0;
|
|
7
7
|
var _config = require("../../common/config/config");
|
|
8
|
-
var _globalScope = require("../../common/util/global-scope");
|
|
9
8
|
var _features = require("../../loaders/features/features");
|
|
10
9
|
const FEATURE_NAME = _features.FEATURE_NAMES.spa;
|
|
11
10
|
exports.FEATURE_NAME = FEATURE_NAME;
|
|
@@ -8,7 +8,6 @@ var _config = require("../../common/config/config");
|
|
|
8
8
|
var _drain = require("../../common/drain/drain");
|
|
9
9
|
var _contextualEe = require("../../common/event-emitter/contextual-ee");
|
|
10
10
|
var _registerHandler = require("../../common/event-emitter/register-handler");
|
|
11
|
-
var _globalScope = require("../../common/util/global-scope");
|
|
12
11
|
var _sessionEntity = require("../../common/session/session-entity");
|
|
13
12
|
var _localStorage = require("../../common/storage/local-storage.js");
|
|
14
13
|
var _firstPartyCookies = require("../../common/storage/first-party-cookies");
|
|
@@ -16,43 +15,28 @@ let ranOnce = 0;
|
|
|
16
15
|
function setupAgentSession(agentIdentifier) {
|
|
17
16
|
const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
18
17
|
if (ranOnce++) return agentRuntime.session;
|
|
19
|
-
const
|
|
18
|
+
const sessionInit = (0, _config.getConfiguration)(agentIdentifier).session;
|
|
19
|
+
/* Domain is a string that can be specified by customer. The only way to keep the session object across subdomains is using first party cookies.
|
|
20
|
+
This determines which storage wrapper the session manager will use to keep state. */
|
|
21
|
+
const storageTypeInst = sessionInit?.domain ? new _firstPartyCookies.FirstPartyCookies(sessionInit.domain) : new _localStorage.LocalStorage();
|
|
22
|
+
agentRuntime.session = new _sessionEntity.SessionEntity({
|
|
23
|
+
agentIdentifier,
|
|
24
|
+
key: 'SESSION',
|
|
25
|
+
storage: storageTypeInst,
|
|
26
|
+
expiresMs: sessionInit?.expiresMs,
|
|
27
|
+
inactiveMs: sessionInit?.inactiveMs
|
|
28
|
+
});
|
|
20
29
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (cookiesEnabled) {
|
|
30
|
-
// defaults to "LocalMemory" if storageAPI is undefined, such as in Worker build
|
|
31
|
-
agentRuntime.session = new _sessionEntity.SessionEntity({
|
|
32
|
-
agentIdentifier,
|
|
33
|
-
key: 'SESSION',
|
|
34
|
-
storageAPI,
|
|
35
|
-
expiresMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.expiresMs'),
|
|
36
|
-
inactiveMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.inactiveMs')
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// The first time the agent runs on a page, it should put everything
|
|
41
|
-
// that's currently stored in the storage API into the local info.jsAttributes object
|
|
42
|
-
if (_globalScope.isBrowserScope) {
|
|
43
|
-
// retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
|
|
44
|
-
const customSessionData = agentRuntime.session.state.custom;
|
|
45
|
-
const agentInfo = (0, _config.getInfo)(agentIdentifier);
|
|
46
|
-
if (customSessionData) {
|
|
47
|
-
(0, _config.setInfo)(agentIdentifier, {
|
|
48
|
-
...agentInfo,
|
|
49
|
-
jsAttributes: {
|
|
50
|
-
...agentInfo.jsAttributes,
|
|
51
|
-
...customSessionData
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
30
|
+
// Retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s), if any was stored.
|
|
31
|
+
const customSessionData = agentRuntime.session.state.custom;
|
|
32
|
+
const agentInfo = (0, _config.getInfo)(agentIdentifier);
|
|
33
|
+
if (customSessionData) {
|
|
34
|
+
agentInfo.jsAttributes = {
|
|
35
|
+
...agentInfo.jsAttributes,
|
|
36
|
+
...customSessionData
|
|
37
|
+
};
|
|
55
38
|
}
|
|
39
|
+
const sharedEE = _contextualEe.ee.get(agentIdentifier);
|
|
56
40
|
|
|
57
41
|
// any calls to newrelic.setCustomAttribute(<persisted>) will need to be added to:
|
|
58
42
|
// local info.jsAttributes {}
|