@newrelic/browser-agent 1.258.2 → 1.260.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/cdn/polyfills.js +3 -1
  3. package/dist/cjs/common/constants/env.cdn.js +1 -1
  4. package/dist/cjs/common/constants/env.npm.js +1 -1
  5. package/dist/cjs/common/drain/drain.js +1 -1
  6. package/dist/cjs/common/harvest/harvest-scheduler.js +4 -2
  7. package/dist/cjs/common/session/session-entity.js +8 -1
  8. package/dist/cjs/common/timing/time-keeper.js +9 -30
  9. package/dist/cjs/features/ajax/constants.js +3 -2
  10. package/dist/cjs/features/jserrors/instrument/index.js +3 -4
  11. package/dist/cjs/features/metrics/aggregate/index.js +0 -8
  12. package/dist/cjs/features/page_view_event/aggregate/index.js +8 -6
  13. package/dist/cjs/features/session_replay/aggregate/index.js +31 -36
  14. package/dist/cjs/features/session_replay/constants.js +5 -2
  15. package/dist/cjs/features/session_replay/instrument/index.js +53 -13
  16. package/dist/cjs/features/session_replay/shared/recorder.js +8 -1
  17. package/dist/cjs/features/session_replay/shared/utils.js +3 -5
  18. package/dist/cjs/features/session_trace/aggregate/index.js +181 -527
  19. package/dist/cjs/features/session_trace/aggregate/trace/node.js +19 -0
  20. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +289 -0
  21. package/dist/cjs/features/session_trace/constants.js +3 -2
  22. package/dist/cjs/features/session_trace/instrument/index.js +7 -3
  23. package/dist/cjs/features/utils/aggregate-base.js +1 -0
  24. package/dist/cjs/features/utils/feature-gates.js +17 -0
  25. package/dist/cjs/features/utils/instrument-base.js +2 -1
  26. package/dist/cjs/loaders/agent-base.js +4 -0
  27. package/dist/cjs/loaders/api/api-methods.js +1 -1
  28. package/dist/cjs/loaders/api/api.js +2 -2
  29. package/dist/cjs/loaders/configure/configure.js +1 -0
  30. package/dist/esm/cdn/polyfills.js +3 -1
  31. package/dist/esm/common/constants/env.cdn.js +1 -1
  32. package/dist/esm/common/constants/env.npm.js +1 -1
  33. package/dist/esm/common/drain/drain.js +1 -1
  34. package/dist/esm/common/harvest/harvest-scheduler.js +4 -2
  35. package/dist/esm/common/session/session-entity.js +8 -1
  36. package/dist/esm/common/timing/time-keeper.js +9 -30
  37. package/dist/esm/features/ajax/constants.js +2 -1
  38. package/dist/esm/features/jserrors/instrument/index.js +3 -4
  39. package/dist/esm/features/metrics/aggregate/index.js +0 -8
  40. package/dist/esm/features/page_view_event/aggregate/index.js +8 -6
  41. package/dist/esm/features/session_replay/aggregate/index.js +32 -37
  42. package/dist/esm/features/session_replay/constants.js +4 -1
  43. package/dist/esm/features/session_replay/instrument/index.js +54 -14
  44. package/dist/esm/features/session_replay/shared/recorder.js +8 -1
  45. package/dist/esm/features/session_replay/shared/utils.js +4 -6
  46. package/dist/esm/features/session_trace/aggregate/index.js +182 -527
  47. package/dist/esm/features/session_trace/aggregate/trace/node.js +12 -0
  48. package/dist/esm/features/session_trace/aggregate/trace/storage.js +282 -0
  49. package/dist/esm/features/session_trace/constants.js +2 -1
  50. package/dist/esm/features/session_trace/instrument/index.js +7 -3
  51. package/dist/esm/features/utils/aggregate-base.js +1 -0
  52. package/dist/esm/features/utils/feature-gates.js +11 -0
  53. package/dist/esm/features/utils/instrument-base.js +3 -2
  54. package/dist/esm/loaders/agent-base.js +4 -0
  55. package/dist/esm/loaders/api/api-methods.js +1 -1
  56. package/dist/esm/loaders/api/api.js +2 -2
  57. package/dist/esm/loaders/configure/configure.js +1 -0
  58. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -0
  59. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  60. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  61. package/dist/types/common/timing/time-keeper.d.ts +2 -0
  62. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  63. package/dist/types/features/ajax/constants.d.ts +1 -0
  64. package/dist/types/features/ajax/constants.d.ts.map +1 -1
  65. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  66. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  67. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -0
  68. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  69. package/dist/types/features/session_replay/aggregate/index.d.ts +1 -1
  70. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  71. package/dist/types/features/session_replay/constants.d.ts +3 -0
  72. package/dist/types/features/session_replay/instrument/index.d.ts +0 -1
  73. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  74. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  75. package/dist/types/features/session_replay/shared/utils.d.ts +1 -1
  76. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
  77. package/dist/types/features/session_trace/aggregate/index.d.ts +39 -52
  78. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  79. package/dist/types/features/session_trace/aggregate/trace/node.d.ts +12 -0
  80. package/dist/types/features/session_trace/aggregate/trace/node.d.ts.map +1 -0
  81. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +43 -0
  82. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -0
  83. package/dist/types/features/session_trace/constants.d.ts +1 -0
  84. package/dist/types/features/session_trace/constants.d.ts.map +1 -1
  85. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  86. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  87. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  88. package/dist/types/features/utils/feature-gates.d.ts +2 -0
  89. package/dist/types/features/utils/feature-gates.d.ts.map +1 -0
  90. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  91. package/dist/types/loaders/agent-base.d.ts +1 -0
  92. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  93. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  94. package/package.json +1 -1
  95. package/src/cdn/polyfills.js +2 -0
  96. package/src/common/drain/drain.js +1 -1
  97. package/src/common/harvest/harvest-scheduler.js +4 -2
  98. package/src/common/session/session-entity.js +3 -1
  99. package/src/common/timing/time-keeper.js +9 -30
  100. package/src/features/ajax/constants.js +2 -0
  101. package/src/features/jserrors/instrument/index.js +3 -4
  102. package/src/features/metrics/aggregate/index.js +0 -8
  103. package/src/features/page_view_event/aggregate/index.js +9 -5
  104. package/src/features/session_replay/aggregate/index.js +30 -39
  105. package/src/features/session_replay/constants.js +4 -0
  106. package/src/features/session_replay/instrument/index.js +48 -8
  107. package/src/features/session_replay/shared/__mocks__/utils.js +0 -1
  108. package/src/features/session_replay/shared/recorder.js +8 -1
  109. package/src/features/session_replay/shared/utils.js +4 -7
  110. package/src/features/session_trace/aggregate/index.js +157 -493
  111. package/src/features/session_trace/aggregate/trace/node.js +12 -0
  112. package/src/features/session_trace/aggregate/trace/storage.js +287 -0
  113. package/src/features/session_trace/constants.js +1 -0
  114. package/src/features/session_trace/instrument/index.js +7 -2
  115. package/src/features/utils/__mocks__/feature-gates.js +1 -0
  116. package/src/features/utils/aggregate-base.js +1 -0
  117. package/src/features/utils/feature-gates.js +11 -0
  118. package/src/features/utils/instrument-base.js +3 -2
  119. package/src/loaders/agent-base.js +4 -0
  120. package/src/loaders/api/api-methods.js +1 -1
  121. package/src/loaders/api/api.js +2 -2
  122. package/src/loaders/configure/configure.js +1 -0
  123. package/dist/cjs/features/session_replay/shared/replay-mode.js +0 -28
  124. package/dist/cjs/features/utils/handler-cache.js +0 -70
  125. package/dist/esm/features/session_replay/shared/replay-mode.js +0 -23
  126. package/dist/esm/features/utils/handler-cache.js +0 -63
  127. package/dist/types/features/session_replay/shared/replay-mode.d.ts +0 -9
  128. package/dist/types/features/session_replay/shared/replay-mode.d.ts.map +0 -1
  129. package/dist/types/features/utils/handler-cache.d.ts +0 -23
  130. package/dist/types/features/utils/handler-cache.d.ts.map +0 -1
  131. package/src/features/session_replay/shared/replay-mode.js +0 -23
  132. package/src/features/utils/handler-cache.js +0 -65
@@ -6,581 +6,235 @@ 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 _parseUrl = require("../../../common/url/parse-url");
10
9
  var _config = require("../../../common/config/config");
11
10
  var _constants = require("../constants");
12
- var _handlerCache = require("../../utils/handler-cache");
13
- var _replayMode = require("../../session_replay/shared/replay-mode");
14
11
  var _aggregateBase = require("../../utils/aggregate-base");
15
- var _constants2 = require("../../../common/session/constants");
16
- var _now = require("../../../common/timing/now");
12
+ var _storage = require("./trace/storage");
13
+ var _encode = require("../../../common/url/encode");
14
+ var _drain = require("../../../common/drain/drain");
17
15
  var _runtime = require("../../../common/constants/runtime");
18
- /*
19
- * Copyright 2020 New Relic Corporation. All rights reserved.
20
- * SPDX-License-Identifier: Apache-2.0
21
- */
22
-
23
- const ignoredEvents = {
24
- // we find that certain events make the data too noisy to be useful
25
- global: {
26
- mouseup: true,
27
- mousedown: true
28
- },
29
- // certain events are present both in the window and in PVT metrics. PVT metrics are prefered so the window events should be ignored
30
- window: {
31
- load: true,
32
- pagehide: true
33
- },
34
- // when ajax instrumentation is disabled, all XMLHttpRequest events will return with origin = xhrOriginMissing and should be ignored
35
- xhrOriginMissing: {
36
- ignoreAll: true
37
- }
38
- };
39
- const toAggregate = {
40
- typing: [1000, 2000],
41
- scrolling: [100, 1000],
42
- mousing: [1000, 2000],
43
- touching: [1000, 2000]
44
- };
45
- const MAX_TRACE_DURATION = 10 * 60 * 1000; // 10 minutes
46
- const REQ_THRESHOLD_TO_SEND = 30;
16
+ var _constants2 = require("../../../common/session/constants");
47
17
  const ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
48
-
18
+ /** Reserved room for query param attrs */
19
+ const QUERY_PARAM_PADDING = 5000;
49
20
  class Aggregate extends _aggregateBase.AggregateBase {
50
21
  static featureName = _constants.FEATURE_NAME;
51
- #scheduler;
52
- constructor(agentIdentifier, aggregator, argsObj) {
53
- var _this;
22
+ constructor(agentIdentifier, aggregator) {
54
23
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
55
- _this = this;
56
24
  this.agentRuntime = (0, _config.getRuntime)(agentIdentifier);
57
- this.resourceObserver = argsObj?.resourceObserver; // undefined if observer couldn't be created
58
- this.ptid = '';
59
- this.trace = {};
60
- this.nodeCount = 0;
61
- this.sentTrace = null;
62
- this.prevStoredEvents = new Set();
63
- this.harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.harvestTimeSeconds') || 10;
64
- this.maxNodesPerHarvest = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.maxNodesPerHarvest') || 1000;
65
- /**
66
- * Standalone (mode) refers to the legacy version of ST before the idea of 'session' or the Replay feature existed.
67
- * It has some different behavior vs when used in tandem with replay. */
68
- this.isStandalone = false;
69
- const operationalGate = new _handlerCache.HandlerCache(); // acts as a controller-intermediary that can enable or disable this feature's collection dynamically
70
- const sessionEntity = this.agentRuntime.session;
71
- this.operationalGate = operationalGate;
25
+ this.agentInfo = (0, _config.getInfo)(agentIdentifier);
72
26
 
73
- /* --- The following section deals with user sessions concept & contains non-trivial control flow. --- */
74
- const controlTraceOp = traceMode => {
75
- switch (traceMode) {
76
- case _constants2.MODE.ERROR:
77
- this.startTracing(operationalGate, true);
78
- break;
79
- case _constants2.MODE.FULL:
80
- case true:
81
- this.startTracing(operationalGate);
82
- break;
83
- case _constants2.MODE.OFF:
84
- case false:
85
- default:
86
- // this feature becomes "off" (does nothing & nothing is sent)
87
- operationalGate.decide(false);
88
- break;
89
- }
90
- };
91
- let seenAnError = false;
92
- let mostRecentModeKnown;
93
- this.ee.on(_constants2.SESSION_EVENTS.UPDATE, (eventType, sessionState) => {
94
- // this will only have an effect if ST is NOT already in full mode
95
- if (sessionState.sessionReplayMode === _constants2.MODE.FULL) switchToFull();
27
+ /** A buffer to hold on to harvested traces in the case that a retry must be made later */
28
+ this.sentTrace = null;
29
+ this.harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.harvestTimeSeconds') || 30;
30
+ /** Tied to the entitlement flag response from BCS. Will short circuit operations of the agg if false */
31
+ this.entitled = undefined;
32
+ /** A flag used to decide if the 30 node threshold should be ignored on the first harvest to ensure sending on the first payload */
33
+ this.everHarvested = false;
34
+ /** If the harvest module is harvesting */
35
+ this.harvesting = false;
36
+ /** TraceStorage is the mechanism that holds, normalizes and aggregates ST nodes. It will be accessed and purged when harvests occur */
37
+ this.traceStorage = new _storage.TraceStorage(this);
38
+ /** This agg needs information about sampling (sts) and entitlements (st) to make the appropriate decisions on running */
39
+ this.waitForFlags(['sts', 'st']).then(_ref => {
40
+ let [stMode, stEntitled] = _ref;
41
+ return this.initialize(stMode, stEntitled);
96
42
  });
43
+ }
97
44
 
98
- /**
99
- * The goal of switchToFull is to take external input to trigger a change from off or error to full.
100
- * It will have no effect if already running in full mode.
101
- * "external" input in this case means errors thrown on the page or session replay itself being triggered to run in full mode by the API, which updates the session entity.
102
- */
103
- const switchToFull = () => {
104
- if (this.agentRuntime?.session?.state?.sessionReplayMode !== _constants2.MODE.FULL) return;
105
- if (mostRecentModeKnown !== _constants2.MODE.FULL) {
106
- const prevMode = mostRecentModeKnown;
107
- mostRecentModeKnown = _constants2.MODE.FULL;
108
- sessionEntity.write({
109
- sessionTraceMode: mostRecentModeKnown
110
- });
111
- this.isStandalone = false;
112
- if (prevMode === _constants2.MODE.ERROR && this.#scheduler) {
113
- 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
114
- this.#scheduler.runHarvest({
115
- needResponse: true
116
- });
117
- } else {
118
- controlTraceOp(_constants2.MODE.FULL);
119
- }
120
- }
121
- };
122
- if (!sessionEntity) {
123
- // Since session manager isn't around, do the old Trace behavior of waiting for RUM response to decide feature activation.
124
- this.isStandalone = true;
125
- this.waitForFlags(['stn']).then(_ref => {
126
- let [on] = _ref;
127
- return controlTraceOp(on);
128
- }, this.featureName, this.ee);
129
- } else {
130
- (0, _registerHandler.registerHandler)('trace-jserror', () => {
131
- seenAnError = true;
132
- switchToFull();
133
- }, this.featureName, this.ee);
134
- const stopTracePerm = () => {
135
- if (sessionEntity.state.sessionTraceMode !== _constants2.MODE.OFF) sessionEntity.write({
136
- sessionTraceMode: _constants2.MODE.OFF
137
- });
138
- operationalGate.permanentlyDecide(false);
139
- if (mostRecentModeKnown === _constants2.MODE.FULL) this.#scheduler?.runHarvest(); // allow queued nodes (past opGate) to final harvest, unless they were buffered in other modes
140
- this.#scheduler?.stopTimer(true); // the 'true' arg here will forcibly block any future call to runHarvest, so the last runHarvest above must be prior
141
- this.#scheduler = null;
142
- };
143
-
144
- // CAUTION: everything inside this promise runs post-load; event subscribers must be pre-load aka synchronous with constructor
145
- this.waitForFlags(['stn', 'sr']).then(async _ref2 => {
146
- let [traceOn, replayOn] = _ref2;
147
- if (!replayOn) {
148
- // When sr = 0 from BCS, also do the old Trace behavior:
149
- this.isStandalone = true;
150
- controlTraceOp(traceOn);
151
- } else {
152
- this.ee.on('REPLAY_ABORTED', () => stopTracePerm());
153
- /* Assuming on page visible that the trace mode is updated from shared session,
154
- - if trace is turned off from the other page, it should be likewise here.
155
- - if trace switches to Full mode, harvest should start (prev: Error) if not already running (prev: Full). */
156
- this.ee.on(_constants2.SESSION_EVENTS.RESUME, () => {
157
- const updatedTraceMode = sessionEntity.state.sessionTraceMode;
158
- if (updatedTraceMode === _constants2.MODE.OFF) stopTracePerm();else if (updatedTraceMode === _constants2.MODE.FULL && this.#scheduler && !this.#scheduler.started) this.#scheduler.runHarvest({
159
- needResponse: true
160
- });
161
- mostRecentModeKnown = updatedTraceMode;
162
- });
163
- this.ee.on(_constants2.SESSION_EVENTS.PAUSE, () => {
164
- mostRecentModeKnown = sessionEntity.state.sessionTraceMode;
165
- });
166
- if (!sessionEntity.isNew) {
167
- // inherit the same mode as existing session's Trace
168
- if (sessionEntity.state.sessionReplayMode === _constants2.MODE.OFF) this.isStandalone = true;
169
- controlTraceOp(mostRecentModeKnown = sessionEntity.state.sessionTraceMode);
170
- } else {
171
- // for new sessions, see the truth table associated with NEWRELIC-8662 wrt the new Trace behavior under session management
172
- const replayMode = await (0, _replayMode.getSessionReplayMode)(agentIdentifier);
173
- if (replayMode === _constants2.MODE.OFF) this.isStandalone = true; // without SR, Traces are still subject to old harvest limits
174
-
175
- let startingMode;
176
- if (traceOn) {
177
- // CASE: both trace (entitlement+sampling) & replay (entitlement) flags are true from RUM
178
- startingMode = _constants2.MODE.FULL; // always full capture regardless of replay sampling decisions
179
- } else {
180
- // CASE: trace flag is off, BUT it must still run if replay is on (possibly)
181
- // 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.
182
- if (replayMode === _constants2.MODE.ERROR && seenAnError) startingMode = _constants2.MODE.FULL;else startingMode = replayMode;
183
- }
184
- sessionEntity.write({
185
- sessionTraceMode: mostRecentModeKnown = startingMode
186
- });
187
- controlTraceOp(startingMode);
188
- }
189
- }
45
+ /** 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 */
46
+ initialize(stMode, stEntitled, ignoreSession) {
47
+ var _this = this;
48
+ this.entitled ??= stEntitled;
49
+ if (this.blocked || !this.entitled) return (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
50
+ if (!this.initialized) {
51
+ // 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.
52
+ this.ee.on(_constants2.SESSION_EVENTS.RESET, () => {
53
+ this.abort();
54
+ });
55
+ // The SessionEntity can have updates (locally or across tabs for SR mode changes), (across tabs for ST mode changes).
56
+ // Those updates should be sync'd here to ensure this page also honors the mode after initialization
57
+ this.ee.on(_constants2.SESSION_EVENTS.UPDATE, (eventType, sessionState) => {
58
+ // this will only have an effect if ST is NOT already in full mode
59
+ if (this.mode !== _constants2.MODE.FULL && (sessionState.sessionReplayMode === _constants2.MODE.FULL || sessionState.sessionTraceMode === _constants2.MODE.FULL)) this.switchToFull();
190
60
  });
191
61
  }
192
- /* --- EoS --- */
193
62
 
194
- // register the handlers immediately... but let the handlerCache decide if the data should actually get stored...
63
+ /** ST/SR sampling flow in BCS - https://drive.google.com/file/d/19hwt2oft-8Hh4RrjpLqEXfpP_9wYBLcq/view?usp=sharing */
64
+ /** 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 */
65
+ if (!this.agentRuntime.session.isNew && !ignoreSession) this.mode = this.agentRuntime.session.state.sessionTraceMode;else this.mode = stMode;
66
+ this.initialized = true;
67
+ /** If the mode is off, we do not want to hold up draining for other features, so we deregister the feature for now.
68
+ * If it drains later (due to a mode change), data and handlers will instantly drain instead of waiting for the registry. */
69
+ if (this.mode === _constants2.MODE.OFF) return (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
70
+ this.timeKeeper ??= this.agentRuntime.timeKeeper;
71
+ this.scheduler = new _harvestScheduler.HarvestScheduler('browser/blobs', {
72
+ onFinished: this.onHarvestFinished.bind(this),
73
+ retryDelay: this.harvestTimeSeconds,
74
+ getPayload: this.prepareHarvest.bind(this),
75
+ raw: true
76
+ }, this);
77
+
78
+ /** The handlers set up by the Inst file */
195
79
  (0, _registerHandler.registerHandler)('bst', function () {
196
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
197
- args[_key] = arguments[_key];
198
- }
199
- return operationalGate.settle(() => _this.storeEvent(...args));
80
+ return _this.traceStorage.storeEvent(...arguments);
200
81
  }, this.featureName, this.ee);
201
82
  (0, _registerHandler.registerHandler)('bstResource', function () {
202
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
203
- args[_key2] = arguments[_key2];
204
- }
205
- return operationalGate.settle(() => _this.storeResources(...args));
83
+ return _this.traceStorage.storeResources(...arguments);
206
84
  }, this.featureName, this.ee);
207
85
  (0, _registerHandler.registerHandler)('bstHist', function () {
208
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
209
- args[_key3] = arguments[_key3];
210
- }
211
- return operationalGate.settle(() => _this.storeHist(...args));
86
+ return _this.traceStorage.storeHist(...arguments);
212
87
  }, this.featureName, this.ee);
213
88
  (0, _registerHandler.registerHandler)('bstXhrAgg', function () {
214
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
215
- args[_key4] = arguments[_key4];
216
- }
217
- return operationalGate.settle(() => _this.storeXhrAgg(...args));
89
+ return _this.traceStorage.storeXhrAgg(...arguments);
218
90
  }, this.featureName, this.ee);
219
91
  (0, _registerHandler.registerHandler)('bstApi', function () {
220
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
221
- args[_key5] = arguments[_key5];
222
- }
223
- return operationalGate.settle(() => _this.storeSTN(...args));
92
+ return _this.traceStorage.storeSTN(...arguments);
224
93
  }, this.featureName, this.ee);
225
94
  (0, _registerHandler.registerHandler)('trace-jserror', function () {
226
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
227
- args[_key6] = arguments[_key6];
228
- }
229
- return operationalGate.settle(() => _this.storeErrorAgg(...args));
95
+ return _this.traceStorage.storeErrorAgg(...arguments);
230
96
  }, this.featureName, this.ee);
231
97
  (0, _registerHandler.registerHandler)('pvtAdded', function () {
232
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
233
- args[_key7] = arguments[_key7];
234
- }
235
- return operationalGate.settle(() => _this.processPVT(...args));
98
+ return _this.traceStorage.processPVT(...arguments);
236
99
  }, this.featureName, this.ee);
237
- this.drain();
238
- }
239
- startTracing(startupBuffer) {
240
- let dontStartHarvestYet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
241
100
  if (typeof PerformanceNavigationTiming !== 'undefined') {
242
- this.storeTiming(window.performance.getEntriesByType('navigation')[0]);
101
+ this.traceStorage.storeTiming(_runtime.globalScope.performance?.getEntriesByType?.('navigation')[0]);
243
102
  } else {
244
- this.storeTiming(window.performance.timing);
103
+ this.traceStorage.storeTiming(_runtime.globalScope.performance?.timing);
245
104
  }
246
- this.#scheduler = new _harvestScheduler.HarvestScheduler('resources', {
247
- onFinished: this.#onHarvestFinished.bind(this),
248
- retryDelay: this.harvestTimeSeconds
249
- }, this);
250
- this.#scheduler.harvest.on('resources', this.#prepareHarvest.bind(this));
251
- if (dontStartHarvestYet === false) this.#scheduler.runHarvest({
252
- needResponse: true
253
- }); // sends first stn harvest immediately
254
- startupBuffer.decide(true); // signal to ALLOW & process data in EE's buffer into internal nodes queued for next harvest
255
- }
256
- #onHarvestFinished(result) {
257
- if (result.sent && result.responseText && !this.ptid) {
258
- // continue interval harvest only if ptid was returned by server on the first
259
- this.agentRuntime.ptid = this.ptid = result.responseText;
260
- this.#scheduler.startTimer(this.harvestTimeSeconds);
261
- }
262
- if (result.sent && result.retry && this.sentTrace) {
263
- // merge previous trace back into buffer to retry for next harvest
264
- Object.entries(this.sentTrace).forEach(_ref3 => {
265
- let [name, listOfSTNodes] = _ref3;
266
- if (this.nodeCount >= this.maxNodesPerHarvest) return;
267
- this.nodeCount += listOfSTNodes.length;
268
- this.trace[name] = this.trace[name] ? listOfSTNodes.concat(this.trace[name]) : listOfSTNodes;
269
- });
270
- this.sentTrace = null;
271
- }
272
- }
273
- #prepareHarvest(options) {
274
- this.prevStoredEvents.clear(); // release references to past events for GC
275
- if (this.isStandalone) {
276
- if (this.ptid && (0, _now.now)() >= MAX_TRACE_DURATION) {
277
- // Perform a final harvest once we hit or exceed the max session trace time
278
- options.isFinalHarvest = true;
279
- this.operationalGate.permanentlyDecide(false);
280
- this.#scheduler.stopTimer(true);
281
- } else if (this.ptid && this.nodeCount <= REQ_THRESHOLD_TO_SEND && !options.isFinalHarvest) {
282
- // Only harvest when more than some threshold of nodes are pending, after the very first harvest, with the exception of the last outgoing harvest.
283
- return;
284
- }
285
- } else {
286
- // -- *cli May '26 - Update: Not rate limiting backgrounded pages either for now.
287
- // if (this.ptid && document.visibilityState === 'hidden' && this.nodeCount <= REQ_THRESHOLD_TO_SEND) return
288
105
 
289
- const currentMode = this.agentRuntime.session.state.sessionTraceMode;
290
- /* There could still be nodes previously collected even after Trace (w/ session mgmt) is turned off. Hence, continue to send the last batch.
291
- * The intermediary controller SHOULD be already switched off so that no nodes are further queued. */
292
- if (currentMode === _constants2.MODE.OFF && Object.keys(this.trace).length === 0) return;
293
- if (currentMode === _constants2.MODE.ERROR) return; // Trace in this mode should never be harvesting, even on unload
106
+ /** Only start actually harvesting if running in full mode at init time */
107
+ if (this.mode === _constants2.MODE.FULL) this.startHarvesting();else {
108
+ /** A separate handler for noticing errors, and switching to "full" mode if running in "error" mode */
109
+ (0, _registerHandler.registerHandler)('trace-jserror', () => {
110
+ if (this.mode === _constants2.MODE.ERROR) this.switchToFull();
111
+ }, this.featureName, this.ee);
294
112
  }
295
- return this.takeSTNs(options.retry);
113
+ this.agentRuntime.session.write({
114
+ sessionTraceMode: this.mode
115
+ });
116
+ this.drain();
296
117
  }
297
118
 
298
- // PageViewTiming (FEATURE) events and metrics, such as 'load', 'lcp', etc. pipes into ST here.
299
- processPVT(name, value, attrs) {
300
- this.storeTiming({
301
- [name]: value
119
+ /** This module does not auto harvest by default -- it needs to be kicked off. Once this method is called, it will then harvest on an interval */
120
+ startHarvesting() {
121
+ if (this.scheduler.started || this.blocked) return;
122
+ this.scheduler.runHarvest();
123
+ this.scheduler.startTimer(this.harvestTimeSeconds);
124
+ }
125
+
126
+ /** Called by the harvest scheduler at harvest time to retrieve the payload. This will only actually return a payload if running in full mode */
127
+ prepareHarvest() {
128
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
129
+ this.traceStorage.prevStoredEvents.clear(); // release references to past events for GC
130
+ if (!this.timeKeeper?.ready) return; // this should likely never happen, but just to be safe, we should never harvest if we cant correct time
131
+ if (this.mode === _constants2.MODE.OFF && this.traceStorage.nodeCount === 0) return;
132
+ if (this.mode === _constants2.MODE.ERROR) return; // Trace in this mode should never be harvesting, even on unload
133
+
134
+ /** Get the ST nodes from the traceStorage buffer. This also returns helpful metadata about the payload. */
135
+ const {
136
+ stns,
137
+ earliestTimeStamp,
138
+ latestTimeStamp
139
+ } = this.traceStorage.takeSTNs();
140
+ if (options.retry) {
141
+ this.sentTrace = stns;
142
+ }
143
+ const firstSessionHarvest = !this.agentRuntime.session.state.traceHarvestStarted;
144
+ if (firstSessionHarvest) this.agentRuntime.session.write({
145
+ traceHarvestStarted: true
302
146
  });
303
- if (hasFID(name, attrs)) this.storeEvent({
304
- type: 'fid',
305
- target: 'document'
306
- }, 'document', value, value + attrs.fid);
307
- function hasFID(name, attrs) {
308
- return name === 'fi' && !!attrs && typeof attrs.fid === 'number';
309
- }
147
+ const hasReplay = this.agentRuntime.session?.state.sessionReplayMode === 1;
148
+ const endUserId = this.agentInfo?.jsAttributes?.['enduser.id'];
149
+ this.everHarvested = true;
150
+
151
+ /** The blob consumer expects the following and will reject if not supplied:
152
+ * browser_monitoring_key
153
+ * type
154
+ * app_id
155
+ * protocol_version
156
+ * attributes
157
+ *
158
+ * For data that does not fit the schema of the above, it should be url-encoded and placed into `attributes`
159
+ */
160
+ const agentMetadata = this.agentRuntime.appMetadata?.agents?.[0] || {};
161
+ return {
162
+ qs: {
163
+ browser_monitoring_key: this.agentInfo.licenseKey,
164
+ type: 'BrowserSessionChunk',
165
+ app_id: this.agentInfo.applicationID,
166
+ protocol_version: '0',
167
+ timestamp: this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
168
+ attributes: (0, _encode.obj)({
169
+ ...(agentMetadata.entityGuid && {
170
+ entityGuid: agentMetadata.entityGuid
171
+ }),
172
+ harvestId: "".concat(this.agentRuntime.session?.state.value, "_").concat(this.agentRuntime.ptid, "_").concat(this.agentRuntime.harvestCount),
173
+ // this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
174
+ // if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
175
+ // trace payload metadata
176
+ 'trace.firstTimestamp': this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
177
+ 'trace.lastTimestamp': this.timeKeeper.convertRelativeTimestamp(latestTimeStamp),
178
+ 'trace.nodes': stns.length,
179
+ 'trace.originTimestamp': this.timeKeeper.correctedOriginTime,
180
+ // other payload metadata
181
+ agentVersion: this.agentRuntime.version,
182
+ ...(firstSessionHarvest && {
183
+ firstSessionHarvest
184
+ }),
185
+ ...(hasReplay && {
186
+ hasReplay
187
+ }),
188
+ ptid: "".concat(this.agentRuntime.ptid),
189
+ session: "".concat(this.agentRuntime.session?.state.value),
190
+ // customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
191
+ ...(endUserId && {
192
+ 'enduser.id': endUserId
193
+ })
194
+ // The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
195
+ }, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
196
+ },
197
+ body: stns
198
+ };
310
199
  }
311
200
 
312
- // This processes the aforementioned PVT and the first navigation entry of the page.
313
- storeTiming(timingEntry) {
314
- if (!timingEntry) return;
315
-
316
- // loop iterates through prototype also (for FF)
317
- for (let key in timingEntry) {
318
- let val = timingEntry[key];
319
-
320
- // ignore size and status type nodes that do not map to timestamp metrics
321
- const lck = key.toLowerCase();
322
- if (lck.indexOf('size') >= 0 || lck.indexOf('status') >= 0) continue;
323
-
324
- // ignore inherited methods, meaningless 0 values, and bogus timestamps
325
- // that are in the future (Microsoft Edge seems to sometimes produce these)
326
- if (!(typeof val === 'number' && val >= 0)) continue;
327
- val = Math.round(val);
328
- this.storeSTN({
329
- n: key,
330
- s: val,
331
- e: val,
332
- o: 'document',
333
- t: 'timing'
201
+ /** When the harvest scheduler finishes, this callback is executed. It's main purpose is to determine if the payload needs to be retried
202
+ * and if so, it will take all data from the temporary buffer and place it back into the traceStorage module
203
+ */
204
+ onHarvestFinished(result) {
205
+ if (result.sent && result.retry && this.sentTrace) {
206
+ // merge previous trace back into buffer to retry for next harvest
207
+ Object.entries(this.sentTrace).forEach(_ref2 => {
208
+ let [name, listOfSTNodes] = _ref2;
209
+ this.traceStorage.restoreNode(name, listOfSTNodes);
334
210
  });
211
+ this.sentTrace = null;
335
212
  }
336
213
  }
337
214
 
338
- // Tracks the events and their listener's duration on objects wrapped by wrap-events.
339
- storeEvent(currentEvent, target, start, end) {
340
- if (this.shouldIgnoreEvent(currentEvent, target)) return;
341
- if (this.prevStoredEvents.has(currentEvent)) return; // prevent multiple listeners of an event from creating duplicate trace nodes per occurrence. Cleared every harvest. near-zero chance for re-duplication after clearing per harvest since the timestamps of the event are considered for uniqueness.
342
- this.prevStoredEvents.add(currentEvent);
343
- const evt = {
344
- n: this.evtName(currentEvent.type),
345
- s: start,
346
- e: end,
347
- t: 'event'
348
- };
349
- try {
350
- // webcomponents-lite.js can trigger an exception on currentEvent.target getter because
351
- // it does not check currentEvent.currentTarget before calling getRootNode() on it
352
- evt.o = this.evtOrigin(currentEvent.target, target);
353
- } catch (e) {
354
- evt.o = this.evtOrigin(null, target);
355
- }
356
- this.storeSTN(evt);
357
- }
358
- shouldIgnoreEvent(event, target) {
359
- const origin = this.evtOrigin(event.target, target);
360
- if (event.type in ignoredEvents.global) return true;
361
- if (!!ignoredEvents[origin] && ignoredEvents[origin].ignoreAll) return true;
362
- return !!(!!ignoredEvents[origin] && event.type in ignoredEvents[origin]);
363
- }
364
- evtName(type) {
365
- switch (type) {
366
- case 'keydown':
367
- case 'keyup':
368
- case 'keypress':
369
- return 'typing';
370
- case 'mousemove':
371
- case 'mouseenter':
372
- case 'mouseleave':
373
- case 'mouseover':
374
- case 'mouseout':
375
- return 'mousing';
376
- case 'scroll':
377
- return 'scrolling';
378
- case 'touchstart':
379
- case 'touchmove':
380
- case 'touchend':
381
- case 'touchcancel':
382
- case 'touchenter':
383
- case 'touchleave':
384
- return 'touching';
385
- default:
386
- return type;
387
- }
388
- }
389
- evtOrigin(t, target) {
390
- let origin = 'unknown';
391
- if (t && t instanceof XMLHttpRequest) {
392
- const params = this.ee.context(t).params;
393
- if (!params || !params.status || !params.method || !params.host || !params.pathname) return 'xhrOriginMissing';
394
- origin = params.status + ' ' + params.method + ': ' + params.host + params.pathname;
395
- } else if (t && typeof t.tagName === 'string') {
396
- origin = t.tagName.toLowerCase();
397
- if (t.id) origin += '#' + t.id;
398
- if (t.className) {
399
- for (let i = 0; i < t.classList.length; i++) origin += '.' + t.classList[i];
400
- }
401
- }
402
- if (origin === 'unknown') {
403
- if (typeof target === 'string') origin = target;else if (target === document) origin = 'document';else if (target === window) origin = 'window';else if (target instanceof FileReader) origin = 'FileReader';
404
- }
405
- return origin;
406
- }
407
-
408
- // Tracks when the window history API specified by wrap-history is used.
409
- storeHist(path, old, time) {
410
- const node = {
411
- n: 'history.pushState',
412
- s: time,
413
- e: time,
414
- o: path,
415
- t: old
416
- };
417
- this.storeSTN(node);
418
- }
419
- #laststart = 0;
420
- // Processes all the PerformanceResourceTiming entries captured (by observer).
421
- storeResources(resources) {
422
- if (!resources || resources.length === 0) return;
423
- resources.forEach(currentResource => {
424
- if ((currentResource.fetchStart | 0) <= this.#laststart) return; // don't recollect already-seen resources
425
-
426
- const parsed = (0, _parseUrl.parseUrl)(currentResource.name);
427
- const res = {
428
- n: currentResource.initiatorType,
429
- s: currentResource.fetchStart | 0,
430
- e: currentResource.responseEnd | 0,
431
- o: parsed.protocol + '://' + parsed.hostname + ':' + parsed.port + parsed.pathname,
432
- // resource.name is actually a URL so it's the source
433
- t: currentResource.entryType
434
- };
435
- this.storeSTN(res);
215
+ /** Switch from "off" or "error" to full mode (if entitled) */
216
+ switchToFull() {
217
+ if (this.mode === _constants2.MODE.FULL || !this.entitled || this.blocked) return;
218
+ const prevMode = this.mode;
219
+ this.mode = _constants2.MODE.FULL;
220
+ this.agentRuntime.session.write({
221
+ sessionTraceMode: this.mode
436
222
  });
437
- this.#laststart = resources[resources.length - 1].fetchStart | 0;
438
- }
439
-
440
- // JavascriptError (FEATURE) events pipes into ST here.
441
- storeErrorAgg(type, name, params, metrics) {
442
- if (type !== 'err') return; // internal errors are purposefully ignored
443
- const node = {
444
- n: 'error',
445
- s: metrics.time,
446
- e: metrics.time,
447
- o: params.message,
448
- t: params.stackHash
449
- };
450
- this.storeSTN(node);
451
- }
452
-
453
- // Ajax (FEATURE) events--XML & fetches--pipes into ST here.
454
- storeXhrAgg(type, name, params, metrics) {
455
- if (type !== 'xhr') return;
456
- const node = {
457
- n: 'Ajax',
458
- s: metrics.time,
459
- e: metrics.time + metrics.duration,
460
- o: params.status + ' ' + params.method + ': ' + params.host + params.pathname,
461
- t: 'ajax'
462
- };
463
- this.storeSTN(node);
464
- }
465
-
466
- // Central function called by all the other store__ & addToTrace API to append a trace node.
467
- storeSTN(stn) {
468
- if (this.nodeCount >= this.maxNodesPerHarvest) {
469
- // limit the amount of pending data awaiting next harvest
470
- if (this.isStandalone || this.agentRuntime.session.state.sessionTraceMode !== _constants2.MODE.ERROR) return;
471
- 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
472
- if (openedSpace === 0) return;
473
- }
474
- if (this.isStandalone && (0, _now.now)() >= MAX_TRACE_DURATION) {
475
- return;
223
+ if (prevMode === _constants2.MODE.OFF || !this.initialized) return this.initialize(this.mode, this.entitled);
224
+ if (this.initialized) {
225
+ this.traceStorage.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
476
226
  }
477
- if (this.trace[stn.n]) this.trace[stn.n].push(stn);else this.trace[stn.n] = [stn];
478
- this.nodeCount++;
227
+ this.startHarvesting();
479
228
  }
480
229
 
481
- /**
482
- * Trim the collection of nodes awaiting harvest such that those seen outside a certain span of time are discarded.
483
- * @param {number} lookbackDuration Past length of time until now for which we care about nodes, in milliseconds
484
- * @returns {number} However many nodes were discarded after trimming.
485
- */
486
- trimSTNs(lookbackDuration) {
487
- let prunedNodes = 0;
488
- const cutoffHighResTime = Math.max((0, _now.now)() - lookbackDuration, 0);
489
- Object.keys(this.trace).forEach(nameCategory => {
490
- const nodeList = this.trace[nameCategory];
491
- /* 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.
492
- * 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.
493
- * ASSUMPTION: all 'end' timings stored are relative to timeOrigin (DOMHighResTimeStamp) and not Unix epoch based. */
494
- let cutoffIdx = nodeList.findIndex(node => cutoffHighResTime <= node.e);
495
- if (cutoffIdx === 0) return;else if (cutoffIdx < 0) {
496
- // whole list falls outside lookback window and is irrelevant
497
- cutoffIdx = nodeList.length;
498
- delete this.trace[nameCategory];
499
- } else nodeList.splice(0, cutoffIdx); // chop off everything outside our window i.e. before the last <lookbackDuration> timeframe
500
-
501
- this.nodeCount -= cutoffIdx;
502
- prunedNodes += cutoffIdx;
230
+ /** Stop running for the remainder of the page lifecycle */
231
+ abort() {
232
+ this.blocked = true;
233
+ this.mode = _constants2.MODE.OFF;
234
+ this.agentRuntime.session.write({
235
+ sessionTraceMode: this.mode
503
236
  });
504
- return prunedNodes;
505
- }
506
-
507
- // Used by session trace's harvester to create the payload body.
508
- takeSTNs(retry) {
509
- if (!this.resourceObserver) {
510
- // if PO isn't supported, this checks resourcetiming buffer every harvest.
511
- this.storeResources(window.performance.getEntriesByType('resource'));
512
- }
513
- let earliestTimeStamp = Infinity;
514
- const stns = Object.entries(this.trace).flatMap(_ref4 => {
515
- let [name, listOfSTNodes] = _ref4;
516
- // basically take the "this.trace" map-obj and concat all the list-type values
517
- const oldestNodeTS = listOfSTNodes.reduce((acc, next) => !acc || next.s < acc ? next.s : acc, undefined);
518
- if (oldestNodeTS < earliestTimeStamp) earliestTimeStamp = oldestNodeTS;
519
- if (!(name in toAggregate)) return listOfSTNodes;
520
- // Special processing for event nodes dealing with user inputs:
521
- const reindexByOriginFn = this.smearEvtsByOrigin(name);
522
- const partitionListByOriginMap = listOfSTNodes.sort((a, b) => a.s - b.s).reduce(reindexByOriginFn, {});
523
- return Object.values(partitionListByOriginMap).flat(); // join the partitions back into 1-D, now ordered by origin then start time
524
- }, this);
525
- if (stns.length === 0) return {};
526
- if (retry) {
527
- this.sentTrace = this.trace;
528
- }
529
- this.trace = {};
530
- this.nodeCount = 0;
531
- let firstHarvestOfSession;
532
- if (this.agentRuntime.session) {
533
- const isFirstPayload = !this.agentRuntime.session.state.traceHarvestStarted;
534
- firstHarvestOfSession = {
535
- fsh: Number(isFirstPayload)
536
- }; // converted to '0' | '1'
537
- if (isFirstPayload) this.agentRuntime.session.write({
538
- traceHarvestStarted: true
539
- });
540
- }
541
- return {
542
- qs: {
543
- st: _runtime.originTime,
544
- /** hr === "hasReplay" in NR1, standalone is always checked and processed before harvesting
545
- * so a race condition between ST and SR states should not be a concern if implemented here */
546
- hr: Number(!this.isStandalone),
547
- /** fts === "firstTimestamp" in NR1, indicates what the earliest NODE timestamp was
548
- * so that blob parsing doesn't need to happen to support UI/API functions */
549
- fts: _runtime.originTime + earliestTimeStamp,
550
- /** n === "nodeCount" in NR1, a count of nodes in the ST payload, so that blob parsing doesn't need to happen to support UI/API functions */
551
- n: stns.length,
552
- // node count
553
- ...firstHarvestOfSession
554
- },
555
- body: {
556
- res: stns
557
- }
558
- };
559
- }
560
- smearEvtsByOrigin(name) {
561
- const maxGap = toAggregate[name][0];
562
- const maxLen = toAggregate[name][1];
563
- const lastO = {};
564
- return (byOrigin, evtNode) => {
565
- let lastArr = byOrigin[evtNode.o];
566
- if (!lastArr) lastArr = byOrigin[evtNode.o] = [];
567
- const last = lastO[evtNode.o];
568
- if (name === 'scrolling' && !trivial(evtNode)) {
569
- lastO[evtNode.o] = null;
570
- evtNode.n = 'scroll';
571
- lastArr.push(evtNode);
572
- } else if (last && evtNode.s - last.s < maxLen && last.e > evtNode.s - maxGap) {
573
- last.e = evtNode.e;
574
- } else {
575
- lastO[evtNode.o] = evtNode;
576
- lastArr.push(evtNode);
577
- }
578
- return byOrigin;
579
- };
580
- function trivial(node) {
581
- const limit = 4;
582
- return !!(node && typeof node.e === 'number' && typeof node.s === 'number' && node.e - node.s < limit);
583
- }
237
+ this.scheduler.stopTimer();
584
238
  }
585
239
  }
586
240
  exports.Aggregate = Aggregate;