@newrelic/browser-agent 1.252.1 → 1.253.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 (203) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/cdn/experimental.js +6 -2
  4. package/dist/cjs/cdn/spa.js +5 -3
  5. package/dist/cjs/common/aggregate/aggregator.js +1 -8
  6. package/dist/cjs/common/config/state/init.js +7 -0
  7. package/dist/cjs/common/constants/env.cdn.js +1 -1
  8. package/dist/cjs/common/constants/env.npm.js +1 -1
  9. package/dist/cjs/common/context/observation-context-manager.js +56 -0
  10. package/dist/cjs/common/event-emitter/contextual-ee.js +12 -9
  11. package/dist/cjs/common/session/constants.js +2 -1
  12. package/dist/cjs/common/timing/nav-timing.js +8 -3
  13. package/dist/cjs/common/timing/now.js +1 -1
  14. package/dist/cjs/common/util/feature-flags.js +1 -1
  15. package/dist/cjs/common/wrap/index.js +0 -7
  16. package/dist/cjs/common/wrap/wrap-events.js +2 -2
  17. package/dist/cjs/common/wrap/wrap-fetch.js +2 -1
  18. package/dist/cjs/common/wrap/wrap-function.js +5 -7
  19. package/dist/cjs/common/wrap/wrap-promise.js +2 -1
  20. package/dist/cjs/features/ajax/aggregate/index.js +34 -16
  21. package/dist/cjs/features/jserrors/aggregate/index.js +77 -66
  22. package/dist/cjs/features/page_view_event/aggregate/index.js +1 -1
  23. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -0
  24. package/dist/cjs/features/session_replay/aggregate/index.js +96 -94
  25. package/dist/cjs/features/session_replay/constants.js +5 -1
  26. package/dist/cjs/features/session_replay/instrument/index.js +24 -8
  27. package/dist/cjs/features/session_replay/shared/utils.js +26 -0
  28. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +50 -0
  29. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +29 -0
  30. package/dist/cjs/features/soft_navigations/aggregate/index.js +263 -0
  31. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +62 -0
  32. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +146 -0
  33. package/dist/cjs/features/soft_navigations/constants.js +31 -0
  34. package/dist/cjs/features/soft_navigations/index.js +12 -0
  35. package/dist/cjs/features/soft_navigations/instrument/index.js +79 -0
  36. package/dist/cjs/features/spa/aggregate/index.js +4 -4
  37. package/dist/cjs/features/utils/agent-session.js +2 -1
  38. package/dist/cjs/features/utils/instrument-base.js +6 -9
  39. package/dist/cjs/features/utils/lazy-feature-loader.js +2 -0
  40. package/dist/cjs/loaders/agent-base.js +18 -3
  41. package/dist/cjs/loaders/agent.js +15 -18
  42. package/dist/cjs/loaders/api/api-methods.js +2 -1
  43. package/dist/cjs/loaders/api/api.js +14 -11
  44. package/dist/cjs/loaders/configure/configure.js +4 -1
  45. package/dist/cjs/loaders/features/enabled-features.js +1 -1
  46. package/dist/cjs/loaders/features/features.js +3 -1
  47. package/dist/esm/cdn/experimental.js +5 -2
  48. package/dist/esm/cdn/spa.js +3 -1
  49. package/dist/esm/common/aggregate/aggregator.js +1 -8
  50. package/dist/esm/common/config/state/init.js +7 -0
  51. package/dist/esm/common/constants/env.cdn.js +1 -1
  52. package/dist/esm/common/constants/env.npm.js +1 -1
  53. package/dist/esm/common/context/observation-context-manager.js +49 -0
  54. package/dist/esm/common/event-emitter/contextual-ee.js +12 -9
  55. package/dist/esm/common/session/constants.js +1 -0
  56. package/dist/esm/common/timing/nav-timing.js +8 -3
  57. package/dist/esm/common/timing/now.js +1 -1
  58. package/dist/esm/common/util/feature-flags.js +1 -1
  59. package/dist/esm/common/wrap/index.js +1 -2
  60. package/dist/esm/common/wrap/wrap-events.js +3 -3
  61. package/dist/esm/common/wrap/wrap-fetch.js +3 -2
  62. package/dist/esm/common/wrap/wrap-function.js +4 -5
  63. package/dist/esm/common/wrap/wrap-promise.js +3 -2
  64. package/dist/esm/features/ajax/aggregate/index.js +36 -18
  65. package/dist/esm/features/jserrors/aggregate/index.js +77 -66
  66. package/dist/esm/features/page_view_event/aggregate/index.js +1 -1
  67. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -0
  68. package/dist/esm/features/session_replay/aggregate/index.js +97 -95
  69. package/dist/esm/features/session_replay/constants.js +4 -0
  70. package/dist/esm/features/session_replay/instrument/index.js +25 -9
  71. package/dist/esm/features/session_replay/shared/utils.js +17 -0
  72. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +43 -0
  73. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +22 -0
  74. package/dist/esm/features/soft_navigations/aggregate/index.js +256 -0
  75. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +55 -0
  76. package/dist/esm/features/soft_navigations/aggregate/interaction.js +140 -0
  77. package/dist/esm/features/soft_navigations/constants.js +25 -0
  78. package/dist/esm/features/soft_navigations/index.js +1 -0
  79. package/dist/esm/features/soft_navigations/instrument/index.js +73 -0
  80. package/dist/esm/features/spa/aggregate/index.js +4 -4
  81. package/dist/esm/features/utils/agent-session.js +2 -1
  82. package/dist/esm/features/utils/instrument-base.js +7 -10
  83. package/dist/esm/features/utils/lazy-feature-loader.js +2 -0
  84. package/dist/esm/loaders/agent-base.js +18 -3
  85. package/dist/esm/loaders/agent.js +15 -18
  86. package/dist/esm/loaders/api/api-methods.js +2 -1
  87. package/dist/esm/loaders/api/api.js +14 -11
  88. package/dist/esm/loaders/configure/configure.js +4 -1
  89. package/dist/esm/loaders/features/enabled-features.js +1 -1
  90. package/dist/esm/loaders/features/features.js +3 -1
  91. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
  92. package/dist/types/common/config/state/init.d.ts.map +1 -1
  93. package/dist/types/common/context/event-context.d.ts.map +1 -0
  94. package/dist/types/common/context/observation-context-manager.d.ts +28 -0
  95. package/dist/types/common/context/observation-context-manager.d.ts.map +1 -0
  96. package/dist/types/common/event-emitter/contextual-ee.d.ts +2 -2
  97. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
  98. package/dist/types/common/session/constants.d.ts +1 -0
  99. package/dist/types/common/session/constants.d.ts.map +1 -1
  100. package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
  101. package/dist/types/common/wrap/index.d.ts +1 -2
  102. package/dist/types/common/wrap/index.d.ts.map +1 -1
  103. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  104. package/dist/types/common/wrap/wrap-function.d.ts +0 -1
  105. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
  106. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
  107. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  108. package/dist/types/features/jserrors/aggregate/index.d.ts +4 -3
  109. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  110. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
  111. package/dist/types/features/session_replay/aggregate/index.d.ts +1 -1
  112. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  113. package/dist/types/features/session_replay/constants.d.ts +4 -0
  114. package/dist/types/features/session_replay/constants.d.ts.map +1 -1
  115. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  116. package/dist/types/features/session_replay/shared/utils.d.ts +4 -0
  117. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -0
  118. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +19 -0
  119. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -0
  120. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts +16 -0
  121. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts.map +1 -0
  122. package/dist/types/features/soft_navigations/aggregate/index.d.ts +36 -0
  123. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -0
  124. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts +12 -0
  125. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts.map +1 -0
  126. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +50 -0
  127. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -0
  128. package/dist/types/features/soft_navigations/constants.d.ts +20 -0
  129. package/dist/types/features/soft_navigations/constants.d.ts.map +1 -0
  130. package/dist/types/features/soft_navigations/index.d.ts +2 -0
  131. package/dist/types/features/soft_navigations/index.d.ts.map +1 -0
  132. package/dist/types/features/soft_navigations/instrument/index.d.ts +7 -0
  133. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -0
  134. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  135. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  136. package/dist/types/features/utils/instrument-base.d.ts +1 -7
  137. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  138. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -1
  139. package/dist/types/loaders/agent-base.d.ts +5 -1
  140. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  141. package/dist/types/loaders/agent.d.ts +2 -2
  142. package/dist/types/loaders/agent.d.ts.map +1 -1
  143. package/dist/types/loaders/api/api-methods.d.ts.map +1 -1
  144. package/dist/types/loaders/api/api.d.ts +3 -5
  145. package/dist/types/loaders/api/api.d.ts.map +1 -1
  146. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  147. package/dist/types/loaders/features/features.d.ts +1 -0
  148. package/dist/types/loaders/features/features.d.ts.map +1 -1
  149. package/dist/types/loaders/micro-agent.d.ts +0 -1
  150. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  151. package/package.json +1 -1
  152. package/src/cdn/experimental.js +4 -2
  153. package/src/cdn/spa.js +3 -1
  154. package/src/common/aggregate/aggregator.js +2 -11
  155. package/src/common/config/state/init.js +3 -1
  156. package/src/common/context/observation-context-manager.js +55 -0
  157. package/src/common/event-emitter/contextual-ee.js +20 -10
  158. package/src/common/session/constants.js +1 -0
  159. package/src/common/timing/nav-timing.js +7 -3
  160. package/src/common/timing/now.js +1 -1
  161. package/src/common/util/feature-flags.js +1 -1
  162. package/src/common/wrap/index.js +1 -2
  163. package/src/common/wrap/wrap-events.js +3 -3
  164. package/src/common/wrap/wrap-fetch.js +3 -2
  165. package/src/common/wrap/wrap-function.js +4 -6
  166. package/src/common/wrap/wrap-promise.js +3 -2
  167. package/src/features/ajax/aggregate/index.js +36 -18
  168. package/src/features/jserrors/aggregate/index.js +70 -73
  169. package/src/features/page_view_event/aggregate/index.js +1 -1
  170. package/src/features/page_view_event/aggregate/initialized-features.js +1 -0
  171. package/src/features/session_replay/aggregate/index.js +92 -95
  172. package/src/features/session_replay/constants.js +5 -0
  173. package/src/features/session_replay/instrument/index.js +24 -9
  174. package/src/features/session_replay/shared/utils.js +19 -0
  175. package/src/features/soft_navigations/aggregate/ajax-node.js +57 -0
  176. package/src/features/soft_navigations/aggregate/bel-node.js +26 -0
  177. package/src/features/soft_navigations/aggregate/index.js +254 -0
  178. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +53 -0
  179. package/src/features/soft_navigations/aggregate/interaction.js +159 -0
  180. package/src/features/soft_navigations/constants.js +29 -0
  181. package/src/features/soft_navigations/index.js +1 -0
  182. package/src/features/soft_navigations/instrument/index.js +67 -0
  183. package/src/features/spa/aggregate/index.js +5 -4
  184. package/src/features/utils/agent-session.js +2 -1
  185. package/src/features/utils/instrument-base.js +7 -10
  186. package/src/features/utils/lazy-feature-loader.js +2 -0
  187. package/src/loaders/agent-base.js +18 -3
  188. package/src/loaders/agent.js +18 -17
  189. package/src/loaders/api/api-methods.js +4 -1
  190. package/src/loaders/api/api.js +14 -12
  191. package/src/loaders/configure/configure.js +4 -1
  192. package/src/loaders/features/enabled-features.js +1 -1
  193. package/src/loaders/features/features.js +3 -1
  194. package/dist/cjs/common/wrap/wrap-raf.js +0 -55
  195. package/dist/esm/common/wrap/wrap-raf.js +0 -48
  196. package/dist/types/common/event-emitter/event-context.d.ts.map +0 -1
  197. package/dist/types/common/wrap/wrap-raf.d.ts +0 -16
  198. package/dist/types/common/wrap/wrap-raf.d.ts.map +0 -1
  199. package/src/common/wrap/wrap-raf.js +0 -52
  200. /package/dist/cjs/common/{event-emitter → context}/event-context.js +0 -0
  201. /package/dist/esm/common/{event-emitter → context}/event-context.js +0 -0
  202. /package/dist/types/common/{event-emitter → context}/event-context.d.ts +0 -0
  203. /package/src/common/{event-emitter → context}/event-context.js +0 -0
@@ -11,6 +11,7 @@ var _runtime = require("../../common/constants/runtime");
11
11
  var _console = require("../../common/util/console");
12
12
  var _features = require("../../loaders/features/features");
13
13
  var _config = require("../../common/config/config");
14
+ var _utils = require("../session_replay/shared/utils");
14
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /**
16
17
  * @file Defines `InstrumentBase` to be used as the super of the Instrument classes implemented by each feature.
@@ -78,7 +79,6 @@ class InstrumentBase extends _featureBase.FeatureBase {
78
79
  });
79
80
  return;
80
81
  }
81
- const enableSessionTracking = _runtime.isBrowserScope && (0, _config.getConfigurationValue)(this.agentIdentifier, 'privacy.cookies_enabled') === true;
82
82
  let loadedSuccessfully;
83
83
  this.onAggregateImported = new Promise(resolve => {
84
84
  loadedSuccessfully = resolve;
@@ -86,7 +86,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
86
86
  const importLater = async () => {
87
87
  let session;
88
88
  try {
89
- if (enableSessionTracking) {
89
+ if ((0, _utils.enableSessionTracking)(this.agentIdentifier)) {
90
90
  // would require some setup before certain features start
91
91
  const {
92
92
  setupAgentSession
@@ -95,6 +95,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
95
95
  }
96
96
  } catch (e) {
97
97
  (0, _console.warn)('A problem occurred when starting up session manager. This page will not start or extend any session.', e);
98
+ if (this.featureName === _features.FEATURE_NAMES.sessionReplay) this.abortHandler?.(); // SR should stop recording if session DNE
98
99
  }
99
100
 
100
101
  /**
@@ -102,7 +103,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
102
103
  * it's only responsible for aborting its one specific feature, rather than all.
103
104
  */
104
105
  try {
105
- if (!this.shouldImportAgg(this.featureName, session)) {
106
+ if (!this.#shouldImportAgg(this.featureName, session)) {
106
107
  (0, _drain.drain)(this.agentIdentifier, this.featureName);
107
108
  loadedSuccessfully(false); // aggregate module isn't loaded at all
108
109
  return;
@@ -135,12 +136,8 @@ class InstrumentBase extends _featureBase.FeatureBase {
135
136
  * @param {import('../../common/session/session-entity').SessionEntity} session
136
137
  * @returns
137
138
  */
138
- shouldImportAgg(featureName, session) {
139
- if (featureName === _features.FEATURE_NAMES.sessionReplay) {
140
- if (!_config.originals.MO) return false; // Session Replay cannot work without Mutation Observer
141
- if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'session_trace.enabled') === false) return false; // Session Replay as of now is tightly coupled with Session Trace in the UI
142
- return !!session?.isNew || !!session?.state.sessionReplayMode; // Session Replay should only try to run if already running from a previous page, or at the beginning of a session
143
- }
139
+ #shouldImportAgg(featureName, session) {
140
+ if (featureName === _features.FEATURE_NAMES.sessionReplay) return (0, _utils.canImportReplayAgg)(this.agentIdentifier, session);
144
141
  return true;
145
142
  }
146
143
  }
@@ -39,6 +39,8 @@ function lazyFeatureLoader(featureName, featurePart) {
39
39
  return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "session_trace-aggregate" */'../session_trace/aggregate')));
40
40
  case _features.FEATURE_NAMES.spa:
41
41
  return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "spa-aggregate" */'../spa/aggregate')));
42
+ case _features.FEATURE_NAMES.softNav:
43
+ return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "basic-spa-aggregate" */'../soft_navigations/aggregate')));
42
44
  default:
43
45
  throw new Error("Attempted to load unsupported agent feature: ".concat(featureName, " ").concat(featurePart));
44
46
  }
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.AgentBase = void 0;
7
7
  var _console = require("../common/util/console");
8
+ var _constants = require("../features/session_replay/constants");
9
+ var _observationContextManager = require("../common/context/observation-context-manager");
10
+ var _uniqueId = require("../common/ids/unique-id");
11
+ var _contextualEe = require("../common/event-emitter/contextual-ee");
8
12
  /* eslint-disable n/handle-callback-err */
9
13
 
10
14
  /**
@@ -12,6 +16,17 @@ var _console = require("../common/util/console");
12
16
  */
13
17
 
14
18
  class AgentBase {
19
+ agentIdentifier;
20
+ observationContext = new _observationContextManager.ObservationContextManager();
21
+ constructor() {
22
+ let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _uniqueId.generateRandomHexString)(16);
23
+ this.agentIdentifier = agentIdentifier;
24
+
25
+ // Assign the observation context to the event emitter, so it knows how to create observation contexts
26
+ const eventEmitter = _contextualEe.ee.get(agentIdentifier);
27
+ eventEmitter.observationContext = this.observationContext;
28
+ }
29
+
15
30
  /**
16
31
  * Tries to execute the api and generates a generic warning message with the api name injected if unsuccessful
17
32
  * @param {string} methodName
@@ -129,17 +144,17 @@ class AgentBase {
129
144
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordReplay/}
130
145
  */
131
146
  recordReplay() {
132
- return this.#callMethod('recordReplay');
147
+ return this.#callMethod(_constants.SR_EVENT_EMITTER_TYPES.RECORD);
133
148
  }
134
149
 
135
150
  /**
136
151
  * Forces an active replay to pause recording. If a replay is already actively recording, this call will cause the recording to pause.
137
152
  * If a recording is not currently recording, this call will be ignored. This API will pause both manual and automatic replays that are in progress.
138
153
  * The only way to resume recording after manually pausing a replay is to manually record again using the recordReplay() API.
139
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/recordReplay/}
154
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/pauseReplay/}
140
155
  */
141
156
  pauseReplay() {
142
- return this.#callMethod('pauseReplay');
157
+ return this.#callMethod(_constants.SR_EVENT_EMITTER_TYPES.PAUSE);
143
158
  }
144
159
 
145
160
  /**
@@ -14,8 +14,6 @@ var _features = require("./features/features");
14
14
  var _instrument = require("../features/page_view_event/instrument");
15
15
  var _aggregator = require("../common/aggregate/aggregator");
16
16
  var _nreum = require("../common/window/nreum");
17
- var _uniqueId = require("../common/ids/unique-id");
18
- var _config = require("../common/config/config");
19
17
  var _console = require("../common/util/console");
20
18
  var _stringify = require("../common/util/stringify");
21
19
  var _runtime = require("../common/constants/runtime");
@@ -32,37 +30,36 @@ var _runtime = require("../common/constants/runtime");
32
30
  * sensitive to network load, this may result in smaller builds with slightly lower performance impact.
33
31
  */
34
32
  class Agent extends _agentBase.AgentBase {
35
- constructor(options) {
36
- let agentIdentifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _uniqueId.generateRandomHexString)(16);
37
- super();
33
+ constructor(options, agentIdentifier) {
34
+ super(agentIdentifier);
38
35
  if (!_runtime.globalScope) {
39
36
  // We could not determine the runtime environment. Short-circuite the agent here
40
37
  // to avoid possible exceptions later that may cause issues with customer's application.
41
38
  (0, _console.warn)('Failed to initial the agent. Could not determine the runtime environment.');
42
39
  return;
43
40
  }
44
- this.agentIdentifier = agentIdentifier;
45
41
  this.sharedAggregator = new _aggregator.Aggregator({
46
42
  agentIdentifier: this.agentIdentifier
47
43
  });
48
44
  this.features = {};
49
- (0, _nreum.setNREUMInitializedAgent)(agentIdentifier, this); // append this agent onto the global NREUM.initializedAgents
45
+ (0, _nreum.setNREUMInitializedAgent)(this.agentIdentifier, this); // append this agent onto the global NREUM.initializedAgents
50
46
 
51
47
  this.desiredFeatures = new Set(options.features || []); // expected to be a list of static Instrument/InstrumentBase classes, see "spa.js" for example
52
48
  // For Now... ALL agents must make the rum call whether the page_view_event feature was enabled or not.
53
49
  // NR1 creates an index on the rum call, and if not seen for a few days, will remove the browser app!
54
50
  // Future work is being planned to evaluate removing this behavior from the backend, but for now we must ensure this call is made
55
51
  this.desiredFeatures.add(_instrument.Instrument);
52
+ this.runSoftNavOverSpa = [...this.desiredFeatures].some(instr => instr.featureName === _features.FEATURE_NAMES.softNav);
56
53
  (0, _configure.configure)(this, options, options.loaderType || 'agent'); // add api, exposed, and other config properties
57
54
 
58
55
  this.run();
59
56
  }
60
57
  get config() {
61
58
  return {
62
- info: (0, _config.getInfo)(this.agentIdentifier),
63
- init: (0, _config.getConfiguration)(this.agentIdentifier),
64
- loader_config: (0, _config.getLoaderConfig)(this.agentIdentifier),
65
- runtime: (0, _config.getRuntime)(this.agentIdentifier)
59
+ info: this.info,
60
+ init: this.init,
61
+ loader_config: this.loader_config,
62
+ runtime: this.runtime
66
63
  };
67
64
  }
68
65
  run() {
@@ -72,13 +69,13 @@ class Agent extends _agentBase.AgentBase {
72
69
  const featuresToStart = [...this.desiredFeatures];
73
70
  featuresToStart.sort((a, b) => _features.featurePriority[a.featureName] - _features.featurePriority[b.featureName]);
74
71
  featuresToStart.forEach(InstrumentCtor => {
75
- // pageViewEvent must be enabled because RUM calls are not optional. See comment in constructor and PR 428.
76
- if (enabledFeatures[InstrumentCtor.featureName] || InstrumentCtor.featureName === _features.FEATURE_NAMES.pageViewEvent) {
77
- const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(InstrumentCtor.featureName);
78
- const hasAllDeps = dependencies.every(x => enabledFeatures[x]);
79
- if (!hasAllDeps) (0, _console.warn)("".concat(InstrumentCtor.featureName, " is enabled but one or more dependent features has been disabled (").concat((0, _stringify.stringify)(dependencies), "). This may cause unintended consequences or missing data..."));
80
- this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator);
81
- }
72
+ if (!enabledFeatures[InstrumentCtor.featureName] && InstrumentCtor.featureName !== _features.FEATURE_NAMES.pageViewEvent) return; // PVE is required to run even if it's marked disabled
73
+ if (this.runSoftNavOverSpa && InstrumentCtor.featureName === _features.FEATURE_NAMES.spa) return;
74
+ if (!this.runSoftNavOverSpa && InstrumentCtor.featureName === _features.FEATURE_NAMES.softNav) return;
75
+ const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(InstrumentCtor.featureName);
76
+ const hasAllDeps = dependencies.every(featName => featName in this.features); // any other feature(s) this depends on should've been initialized on prior iterations by priority order
77
+ if (!hasAllDeps) (0, _console.warn)("".concat(InstrumentCtor.featureName, " is enabled but one or more dependent features has not been initialized (").concat((0, _stringify.stringify)(dependencies), "). This may cause unintended consequences or missing data..."));
78
+ this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator);
82
79
  });
83
80
  } catch (err) {
84
81
  (0, _console.warn)('Failed to initialize all enabled instrument classes (agent aborted) -', err);
@@ -4,5 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.asyncApiMethods = exports.apiMethods = void 0;
7
- const apiMethods = exports.apiMethods = ['setErrorHandler', 'finished', 'addToTrace', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start', 'recordReplay', 'pauseReplay'];
7
+ var _constants = require("../../features/session_replay/constants");
8
+ const apiMethods = exports.apiMethods = ['setErrorHandler', 'finished', 'addToTrace', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start', 'recordReplay', 'pauseReplay', _constants.SR_EVENT_EMITTER_TYPES.RECORD, _constants.SR_EVENT_EMITTER_TYPES.PAUSE];
8
9
  const asyncApiMethods = exports.asyncApiMethods = ['setErrorHandler', 'finished', 'addToTrace', 'addRelease'];
@@ -17,6 +17,7 @@ var _console = require("../../common/util/console");
17
17
  var _constants = require("../../features/metrics/constants");
18
18
  var _nreum = require("../../common/window/nreum");
19
19
  var _apiMethods = require("./api-methods");
20
+ var _constants2 = require("../../features/session_replay/constants");
20
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
22
23
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -46,6 +47,7 @@ function setTopLevelCallers() {
46
47
  }
47
48
  }
48
49
  function setAPI(agentIdentifier, forceDrain) {
50
+ let runSoftNavOverSpa = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
49
51
  if (!forceDrain) (0, _drain.registerDrain)(agentIdentifier, 'api');
50
52
  const apiInterface = {};
51
53
  var instanceEE = _contextualEe.ee.get(agentIdentifier);
@@ -58,7 +60,6 @@ function setAPI(agentIdentifier, forceDrain) {
58
60
  apiInterface[fnName] = apiCall(prefix, fnName, true, 'api');
59
61
  });
60
62
  apiInterface.addPageAction = apiCall(prefix, 'addPageAction', true, _features.FEATURE_NAMES.pageAction);
61
- apiInterface.setCurrentRouteName = apiCall(prefix, 'routeName', true, _features.FEATURE_NAMES.spa);
62
63
  apiInterface.setPageViewName = function (name, host) {
63
64
  if (typeof name !== 'string') return;
64
65
  if (name.charAt(0) !== '/') name = '/' + name;
@@ -143,25 +144,26 @@ function setAPI(agentIdentifier, forceDrain) {
143
144
  (0, _console.warn)('An unexpected issue occurred', err);
144
145
  }
145
146
  };
146
- apiInterface.recordReplay = function () {
147
+ apiInterface[_constants2.SR_EVENT_EMITTER_TYPES.RECORD] = function () {
147
148
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/recordReplay/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
148
- (0, _handle.handle)('recordReplay', [], undefined, _features.FEATURE_NAMES.sessionReplay, instanceEE);
149
+ (0, _handle.handle)(_constants2.SR_EVENT_EMITTER_TYPES.RECORD, [], undefined, _features.FEATURE_NAMES.sessionReplay, instanceEE);
149
150
  };
150
- apiInterface.pauseReplay = function () {
151
+ apiInterface[_constants2.SR_EVENT_EMITTER_TYPES.PAUSE] = function () {
151
152
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/pauseReplay/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
152
- (0, _handle.handle)('pauseReplay', [], undefined, _features.FEATURE_NAMES.sessionReplay, instanceEE);
153
+ (0, _handle.handle)(_constants2.SR_EVENT_EMITTER_TYPES.PAUSE, [], undefined, _features.FEATURE_NAMES.sessionReplay, instanceEE);
153
154
  };
154
- apiInterface.interaction = function () {
155
- return new InteractionHandle().get();
155
+ apiInterface.interaction = function (options) {
156
+ return new InteractionHandle().get(typeof options === 'object' ? options : {});
156
157
  };
157
158
  function InteractionHandle() {}
158
- var InteractionApiProto = InteractionHandle.prototype = {
159
+ const InteractionApiProto = InteractionHandle.prototype = {
159
160
  createTracer: function (name, cb) {
160
161
  var contextStore = {};
161
162
  var ixn = this;
162
163
  var hasCb = typeof cb === 'function';
163
164
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/createTracer/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
164
- (0, _handle.handle)(spaPrefix + 'tracer', [(0, _now.now)(), name, contextStore], ixn, _features.FEATURE_NAMES.spa, instanceEE);
165
+ // Soft navigations won't support Tracer nodes, but this fn should still work the same otherwise (e.g., run the orig cb).
166
+ if (!runSoftNavOverSpa) (0, _handle.handle)(spaPrefix + 'tracer', [(0, _now.now)(), name, contextStore], ixn, _features.FEATURE_NAMES.spa, instanceEE);
165
167
  return function () {
166
168
  tracerEE.emit((hasCb ? '' : 'no-') + 'fn-start', [(0, _now.now)(), ixn, hasCb], contextStore);
167
169
  if (hasCb) {
@@ -179,13 +181,14 @@ function setAPI(agentIdentifier, forceDrain) {
179
181
  }
180
182
  };
181
183
  ['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
182
- InteractionApiProto[name] = apiCall(spaPrefix, name, undefined, _features.FEATURE_NAMES.spa);
184
+ InteractionApiProto[name] = apiCall(spaPrefix, name, undefined, runSoftNavOverSpa ? _features.FEATURE_NAMES.softNav : _features.FEATURE_NAMES.spa);
183
185
  });
186
+ apiInterface.setCurrentRouteName = runSoftNavOverSpa ? apiCall(spaPrefix, 'routeName', undefined, _features.FEATURE_NAMES.softNav) : apiCall(prefix, 'routeName', true, _features.FEATURE_NAMES.spa);
184
187
  function apiCall(prefix, name, notSpa, bufferGroup) {
185
188
  return function () {
186
189
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/' + name + '/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
187
190
  if (bufferGroup) (0, _handle.handle)(prefix + name, [(0, _now.now)(), ...arguments], notSpa ? null : this, bufferGroup, instanceEE); // no bufferGroup means only the SM is emitted
188
- return notSpa ? undefined : this;
191
+ return notSpa ? undefined : this; // returns the InteractionHandle which allows these methods to be chained
189
192
  };
190
193
  }
191
194
  apiInterface.noticeError = function (err, customAttributes) {
@@ -55,10 +55,13 @@ function configure(agent) {
55
55
  if (updatedInit.proxy.beacon) internalTrafficList.push(updatedInit.proxy.beacon);
56
56
  (0, _api.setTopLevelCallers)(); // no need to set global APIs on newrelic obj more than once
57
57
  (0, _nreum.addToNREUM)('activatedFeatures', _featureFlags.activatedFeatures);
58
+
59
+ // Update if soft_navigations is allowed to run AND part of this agent build, used to override old spa functions.
60
+ agent.runSoftNavOverSpa &&= updatedInit.soft_navigations.enabled === true && updatedInit.feature_flags.includes('soft_nav');
58
61
  }
59
62
  runtime.denyList = [...(updatedInit.ajax.deny_list || []), ...(updatedInit.ajax.block_internal ? internalTrafficList : [])];
60
63
  (0, _config.setRuntime)(agent.agentIdentifier, runtime);
61
- if (agent.api === undefined) agent.api = (0, _api.setAPI)(agent.agentIdentifier, forceDrain);
64
+ if (agent.api === undefined) agent.api = (0, _api.setAPI)(agent.agentIdentifier, forceDrain, agent.runSoftNavOverSpa);
62
65
  if (agent.exposed === undefined) agent.exposed = exposed;
63
66
  alreadySetOnce = true;
64
67
  }
@@ -8,7 +8,7 @@ var _features = require("./features");
8
8
  var _config = require("../../common/config/config");
9
9
  const featureNames = Object.values(_features.FEATURE_NAMES);
10
10
  function isEnabled(name, agentIdentifier) {
11
- return (0, _config.getConfigurationValue)(agentIdentifier, "".concat(name, ".enabled")) !== false;
11
+ return (0, _config.getConfigurationValue)(agentIdentifier, "".concat(name, ".enabled")) === true;
12
12
  }
13
13
  function getEnabledFeatures(agentIdentifier) {
14
14
  const enabledFeatures = {};
@@ -13,6 +13,7 @@ const FEATURE_NAMES = exports.FEATURE_NAMES = {
13
13
  pageViewTiming: 'page_view_timing',
14
14
  sessionReplay: 'session_replay',
15
15
  sessionTrace: 'session_trace',
16
+ softNav: 'soft_navigations',
16
17
  spa: 'spa'
17
18
  };
18
19
 
@@ -29,5 +30,6 @@ const featurePriority = exports.featurePriority = {
29
30
  [FEATURE_NAMES.sessionTrace]: 6,
30
31
  [FEATURE_NAMES.pageAction]: 7,
31
32
  [FEATURE_NAMES.spa]: 8,
32
- [FEATURE_NAMES.sessionReplay]: 9
33
+ [FEATURE_NAMES.softNav]: 9,
34
+ [FEATURE_NAMES.sessionReplay]: 10
33
35
  };
@@ -16,9 +16,12 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
16
16
  import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
17
17
  import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
18
18
  import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument';
19
- import { Instrument as InstrumentSpa } from '../features/spa/instrument';
19
+ // import { Instrument as InstrumentSpa } from '../features/spa/instrument'
20
+ import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument';
20
21
  import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
21
22
  new Agent({
22
- features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentSpa],
23
+ features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors,
24
+ // InstrumentSpa,
25
+ InstrumentSoftNav],
23
26
  loaderType: 'experimental'
24
27
  });
@@ -10,9 +10,11 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
10
10
  import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
11
11
  import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
12
12
  import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument';
13
+ import { Instrument as InstrumentSoftNav } from '../features/soft_navigations/instrument';
13
14
  import { Instrument as InstrumentSpa } from '../features/spa/instrument';
14
15
  import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
15
16
  new Agent({
16
- features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentSpa],
17
+ features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentSessionReplay, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentSoftNav, InstrumentSpa // either the softnav or the old spa will be used (not both), but we still need to pack both to avoid dynamic import for instrument files
18
+ ],
17
19
  loaderType: 'spa'
18
20
  });
@@ -77,7 +77,7 @@ export class Aggregator extends SharedContext {
77
77
  var hasData = false;
78
78
  for (var i = 0; i < types.length; i++) {
79
79
  type = types[i];
80
- results[type] = toArray(this.aggregatedData[type]);
80
+ results[type] = Object.values(this.aggregatedData[type] || {});
81
81
  if (results[type].length) hasData = true;
82
82
  delete this.aggregatedData[type];
83
83
  }
@@ -151,11 +151,4 @@ function createMetricObject(value) {
151
151
  sos: value * value,
152
152
  c: 1
153
153
  };
154
- }
155
- function toArray(obj) {
156
- if (typeof obj !== 'object') return [];
157
- return mapOwn(obj, getValue);
158
- }
159
- function getValue(key, value) {
160
- return value;
161
154
  }
@@ -98,6 +98,8 @@ const model = () => {
98
98
  autoStart: true,
99
99
  enabled: false,
100
100
  harvestTimeSeconds: 60,
101
+ preload: false,
102
+ // if true, enables the agent to load rrweb immediately instead of waiting to do so after the window.load event
101
103
  sampling_rate: 10,
102
104
  // float from 0 - 100
103
105
  error_sampling_rate: 100,
@@ -150,6 +152,11 @@ const model = () => {
150
152
  enabled: true,
151
153
  harvestTimeSeconds: 10,
152
154
  autoStart: true
155
+ },
156
+ soft_navigations: {
157
+ enabled: true,
158
+ harvestTimeSeconds: 10,
159
+ autoStart: true
153
160
  }
154
161
  };
155
162
  };
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.252.1";
9
+ export const VERSION = "1.253.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.252.1";
9
+ export const VERSION = "1.253.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -0,0 +1,49 @@
1
+ import { gosNREUM } from '../window/nreum';
2
+ import { bundleId } from '../ids/bundle-id';
3
+ import { EventContext } from './event-context';
4
+ export class ObservationContextManager {
5
+ // These IDs are provided for backwards compatibility until the agent is fully updated
6
+ // use the observation context class.
7
+
8
+ static contextId = "nr@context:".concat(bundleId);
9
+ static contextOriginalId = "nr@original:".concat(bundleId);
10
+ static contextWrappedId = "nr@wrapped:".concat(ObservationContextManager.contextId);
11
+ static getObservationContextByAgentIdentifier(agentIdentifier) {
12
+ const nr = gosNREUM();
13
+ return Object.keys(nr?.initializedAgents || {}).indexOf(agentIdentifier) > -1 ? nr.initializedAgents[agentIdentifier].observationContext : undefined;
14
+ }
15
+
16
+ /**
17
+ * @type {WeakMap<WeakKey, {[key: string]: unknown}>}
18
+ */
19
+ #observationContext = new WeakMap();
20
+
21
+ /**
22
+ * Returns the observation context tied to the supplied construct. If there has been
23
+ * no observation construct created, an empty object is created and stored as the current
24
+ * context.
25
+ * @param key {unknown} The construct being observed such as an XHR instance
26
+ * @return {EventContext} An object of key:value pairs to track as
27
+ * part of the observation
28
+ */
29
+ getCreateContext(key) {
30
+ if (!this.#observationContext.has(key)) {
31
+ this.#observationContext.set(key, new EventContext());
32
+ }
33
+ return this.#observationContext.get(key);
34
+ }
35
+
36
+ /**
37
+ * Set the observation context for an observed construct. If values of the context
38
+ * need to be updated, they should be done so directly on the context. This function
39
+ * is only for the setting of a whole context.
40
+ * @param key {unknown} The construct being observed such as an XHR instance
41
+ * @param value {EventContext} An object of key:value pairs to track as
42
+ * part of the observation
43
+ * @return {EventContext} The updated observation context
44
+ */
45
+ setContext(key, value) {
46
+ this.#observationContext.set(key, value);
47
+ return this.#observationContext.get(key);
48
+ }
49
+ }
@@ -6,11 +6,9 @@
6
6
  import { gosNREUM } from '../window/nreum';
7
7
  import { getOrSet } from '../util/get-or-set';
8
8
  import { getRuntime } from '../config/config';
9
- import { EventContext } from './event-context';
10
- import { bundleId } from '../ids/bundle-id';
9
+ import { EventContext } from '../context/event-context';
10
+ import { ObservationContextManager } from '../context/observation-context-manager';
11
11
 
12
- // create a unique id to store event context data for the current agent bundle
13
- const contextId = "nr@context:".concat(bundleId);
14
12
  // create global emitter instance that can be shared among bundles
15
13
  const globalInstance = ee(undefined, 'globalEE');
16
14
 
@@ -19,7 +17,7 @@ const nr = gosNREUM();
19
17
  if (!nr.ee) {
20
18
  nr.ee = globalInstance;
21
19
  }
22
- export { globalInstance as ee, contextId };
20
+ export { globalInstance as ee };
23
21
  function ee(old, debugId) {
24
22
  var handlers = {};
25
23
  var bufferGroupMap = {};
@@ -49,16 +47,17 @@ function ee(old, debugId) {
49
47
  aborted: false,
50
48
  isBuffering,
51
49
  debugId,
52
- backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {}
50
+ backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {},
51
+ observationContextManager: null
53
52
  };
54
53
  return emitter;
55
54
  function context(contextOrStore) {
56
55
  if (contextOrStore && contextOrStore instanceof EventContext) {
57
56
  return contextOrStore;
58
57
  } else if (contextOrStore) {
59
- return getOrSet(contextOrStore, contextId, () => new EventContext(contextId));
58
+ return getOrSet(contextOrStore, ObservationContextManager.contextId, () => emitter.observationContextManager ? emitter.observationContextManager.getCreateContext(contextOrStore) : new EventContext(ObservationContextManager.contextId));
60
59
  } else {
61
- return new EventContext(contextId);
60
+ return emitter.observationContextManager ? emitter.observationContextManager.getCreateContext({}) : new EventContext(ObservationContextManager.contextId);
62
61
  }
63
62
  }
64
63
  function emit(type, args, contextOrStore, force, bubble) {
@@ -102,7 +101,11 @@ function ee(old, debugId) {
102
101
  return handlers[type] || [];
103
102
  }
104
103
  function getOrCreate(name) {
105
- return emitters[name] = emitters[name] || ee(emitter, name);
104
+ const newEventEmitter = emitters[name] = emitters[name] || ee(emitter, name);
105
+ if (!newEventEmitter.observationContextManager && emitter.observationContextManager) {
106
+ newEventEmitter.observationContextManager = emitter.observationContextManager;
107
+ }
108
+ return newEventEmitter;
106
109
  }
107
110
  function bufferEventsByGroup(types, group) {
108
111
  const eventBuffer = getBuffer();
@@ -1,4 +1,5 @@
1
1
  export const PREFIX = 'NRBA';
2
+ export const DEFAULT_KEY = 'SESSION';
2
3
  export const DEFAULT_EXPIRES_MS = 14400000;
3
4
  export const DEFAULT_INACTIVE_MS = 1800000;
4
5
  export const SESSION_EVENTS = {
@@ -24,7 +24,7 @@ var REQUEST = 'request';
24
24
  var RESPONSE = 'response';
25
25
  var LOAD_EVENT = 'loadEvent';
26
26
  var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent';
27
- export var navTimingValues = [];
27
+ export const navTimingValues = [];
28
28
  function getPntType(type) {
29
29
  if (typeof type === 'number') return type;
30
30
  const types = {
@@ -70,6 +70,11 @@ export function addPN(pn, v) {
70
70
  handleValue(pn.redirectCount, v, 'rc');
71
71
  return v;
72
72
  }
73
+
74
+ /**
75
+ * By side effect, this modifies 'obj' with a mapping of the 'prop' provided to a 'value', and invalid values are not added.
76
+ * On the other hand, the local navTimingValues array gets the value appended if valid and 'undefined' appended if invalid, regardless.
77
+ */
73
78
  function handleValue(value, obj, prop, isOldApi) {
74
79
  /*
75
80
  For L2 Timing API, the value will already be a relative-to-previous-document DOMHighResTimeStamp.
@@ -84,6 +89,6 @@ function handleValue(value, obj, prop, isOldApi) {
84
89
  }
85
90
  value = Math.round(value);
86
91
  obj[prop] = value;
87
- }
88
- navTimingValues.push(value);
92
+ navTimingValues.push(value);
93
+ } else navTimingValues.push(undefined);
89
94
  }
@@ -5,5 +5,5 @@
5
5
 
6
6
  // This is our own layer around performance.now. It's not strictly necessary, but we keep it in case of future mod-ing of the value for refactor purpose.
7
7
  export function now() {
8
- return Math.round(performance.now());
8
+ return Math.floor(performance.now());
9
9
  }
@@ -10,7 +10,7 @@ const bucketMap = {
10
10
  stn: [FEATURE_NAMES.sessionTrace],
11
11
  err: [FEATURE_NAMES.jserrors, FEATURE_NAMES.metrics],
12
12
  ins: [FEATURE_NAMES.pageAction],
13
- spa: [FEATURE_NAMES.spa],
13
+ spa: [FEATURE_NAMES.spa, FEATURE_NAMES.softNav],
14
14
  sr: [FEATURE_NAMES.sessionReplay, FEATURE_NAMES.sessionTrace]
15
15
  };
16
16
  const sentIds = new Set();
@@ -8,7 +8,6 @@ import { wrapHistory } from './wrap-history';
8
8
  import { wrapJsonP } from './wrap-jsonp';
9
9
  import { wrapMutation } from './wrap-mutation';
10
10
  import { wrapPromise } from './wrap-promise';
11
- import { wrapRaf } from './wrap-raf';
12
11
  import { wrapTimer } from './wrap-timer';
13
12
  import { wrapXhr } from './wrap-xhr';
14
- export { wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapRaf, wrapTimer, wrapXhr };
13
+ export { wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapTimer, wrapXhr };
@@ -7,15 +7,15 @@
7
7
  * This module is used directly by: session_trace.
8
8
  * It is also called by -> wrapXhr <-, so see "wrap-xhr.js" for features that use this indirectly.
9
9
  */
10
- import { ee as baseEE, contextId } from '../event-emitter/contextual-ee';
10
+ import { ee as baseEE } from '../event-emitter/contextual-ee';
11
11
  import { createWrapperWithEmitter as wfn } from './wrap-function';
12
12
  import { getOrSet } from '../util/get-or-set';
13
13
  import { globalScope, isBrowserScope } from '../constants/runtime';
14
+ import { ObservationContextManager } from '../context/observation-context-manager';
14
15
  const wrapped = {};
15
16
  const XHR = globalScope.XMLHttpRequest;
16
17
  const ADD_EVENT_LISTENER = 'addEventListener';
17
18
  const REMOVE_EVENT_LISTENER = 'removeEventListener';
18
- const flag = "nr@wrapped:".concat(contextId);
19
19
 
20
20
  /**
21
21
  * Wraps `addEventListener` and `removeEventListener` on: global scope; the prototype of `XMLHttpRequest`, and
@@ -44,7 +44,7 @@ export function wrapEvents(sharedEE) {
44
44
  if (originalListener === null || typeof originalListener !== 'function' && typeof originalListener !== 'object') {
45
45
  return;
46
46
  }
47
- var wrapped = getOrSet(originalListener, flag, function () {
47
+ var wrapped = getOrSet(originalListener, ObservationContextManager.contextWrappedId, function () {
48
48
  var listener = {
49
49
  object: wrapHandleEvent,
50
50
  function: originalListener