@newrelic/browser-agent 1.316.0 → 1.317.0-rc.0

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