@newrelic/browser-agent 1.289.0 → 1.290.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 (236) hide show
  1. package/README.md +32 -0
  2. package/dist/cjs/common/constants/env.cdn.js +1 -1
  3. package/dist/cjs/common/constants/env.npm.js +1 -1
  4. package/dist/cjs/features/ajax/instrument/index.js +5 -5
  5. package/dist/cjs/features/generic_events/aggregate/index.js +1 -0
  6. package/dist/cjs/features/generic_events/aggregate/user-actions/aggregated-user-action.js +2 -0
  7. package/dist/cjs/features/generic_events/instrument/index.js +15 -5
  8. package/dist/cjs/features/jserrors/instrument/index.js +15 -5
  9. package/dist/cjs/features/logging/instrument/index.js +13 -5
  10. package/dist/cjs/features/metrics/instrument/index.js +5 -5
  11. package/dist/cjs/features/page_action/instrument/index.js +1 -5
  12. package/dist/cjs/features/page_view_event/instrument/index.js +8 -6
  13. package/dist/cjs/features/page_view_timing/instrument/index.js +5 -5
  14. package/dist/cjs/features/session_replay/instrument/index.js +10 -4
  15. package/dist/cjs/features/session_trace/instrument/index.js +10 -6
  16. package/dist/cjs/features/soft_navigations/instrument/index.js +9 -5
  17. package/dist/cjs/features/spa/instrument/index.js +8 -6
  18. package/dist/cjs/features/utils/instrument-base.js +27 -23
  19. package/dist/cjs/loaders/agent-base.js +4 -95
  20. package/dist/cjs/loaders/agent.js +11 -0
  21. package/dist/cjs/loaders/api/addPageAction.js +23 -0
  22. package/dist/cjs/loaders/api/addRelease.js +20 -0
  23. package/dist/cjs/loaders/api/addToTrace.js +29 -0
  24. package/dist/cjs/loaders/api/constants.js +32 -0
  25. package/dist/cjs/loaders/api/finished.js +31 -0
  26. package/dist/cjs/loaders/api/interaction.js +58 -0
  27. package/dist/cjs/loaders/api/log.js +26 -0
  28. package/dist/cjs/loaders/api/noticeError.js +30 -0
  29. package/dist/cjs/loaders/api/pauseReplay.js +20 -0
  30. package/dist/cjs/loaders/api/recordCustomEvent.js +21 -0
  31. package/dist/cjs/loaders/api/recordReplay.js +20 -0
  32. package/dist/cjs/loaders/api/register.js +182 -0
  33. package/dist/cjs/loaders/api/setApplicationVersion.js +28 -0
  34. package/dist/cjs/loaders/api/setCustomAttribute.js +27 -0
  35. package/dist/cjs/loaders/api/setErrorHandler.js +18 -0
  36. package/dist/cjs/loaders/api/setPageViewName.js +23 -0
  37. package/dist/cjs/loaders/api/setUserId.js +28 -0
  38. package/dist/cjs/loaders/api/sharedHandlers.js +76 -0
  39. package/dist/cjs/loaders/api/start.js +18 -0
  40. package/dist/cjs/loaders/api/topLevelCallers.js +29 -0
  41. package/dist/cjs/loaders/api/wrapLogger.js +26 -0
  42. package/dist/cjs/loaders/api-base.js +224 -0
  43. package/dist/cjs/loaders/configure/configure.js +2 -4
  44. package/dist/cjs/loaders/micro-agent-base.js +3 -134
  45. package/dist/cjs/loaders/micro-agent.js +34 -6
  46. package/dist/esm/common/constants/env.cdn.js +1 -1
  47. package/dist/esm/common/constants/env.npm.js +1 -1
  48. package/dist/esm/features/ajax/instrument/index.js +3 -3
  49. package/dist/esm/features/generic_events/aggregate/index.js +1 -0
  50. package/dist/esm/features/generic_events/aggregate/user-actions/aggregated-user-action.js +2 -0
  51. package/dist/esm/features/generic_events/instrument/index.js +13 -3
  52. package/dist/esm/features/jserrors/instrument/index.js +13 -3
  53. package/dist/esm/features/logging/instrument/index.js +11 -3
  54. package/dist/esm/features/metrics/instrument/index.js +3 -3
  55. package/dist/esm/features/page_action/instrument/index.js +1 -5
  56. package/dist/esm/features/page_view_event/instrument/index.js +7 -3
  57. package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
  58. package/dist/esm/features/session_replay/instrument/index.js +10 -4
  59. package/dist/esm/features/session_trace/instrument/index.js +9 -3
  60. package/dist/esm/features/soft_navigations/instrument/index.js +7 -3
  61. package/dist/esm/features/spa/instrument/index.js +7 -3
  62. package/dist/esm/features/utils/instrument-base.js +27 -23
  63. package/dist/esm/loaders/agent-base.js +4 -95
  64. package/dist/esm/loaders/agent.js +10 -0
  65. package/dist/esm/loaders/api/addPageAction.js +15 -0
  66. package/dist/esm/loaders/api/addRelease.js +13 -0
  67. package/dist/esm/loaders/api/addToTrace.js +22 -0
  68. package/dist/esm/loaders/api/constants.js +26 -0
  69. package/dist/esm/loaders/api/finished.js +24 -0
  70. package/dist/esm/loaders/api/interaction.js +52 -0
  71. package/dist/esm/loaders/api/log.js +19 -0
  72. package/dist/esm/loaders/api/noticeError.js +22 -0
  73. package/dist/esm/loaders/api/pauseReplay.js +13 -0
  74. package/dist/esm/loaders/api/recordCustomEvent.js +14 -0
  75. package/dist/esm/loaders/api/recordReplay.js +13 -0
  76. package/dist/esm/loaders/api/register.js +175 -0
  77. package/dist/esm/loaders/api/setApplicationVersion.js +21 -0
  78. package/dist/esm/loaders/api/setCustomAttribute.js +20 -0
  79. package/dist/esm/loaders/api/setErrorHandler.js +11 -0
  80. package/dist/esm/loaders/api/setPageViewName.js +16 -0
  81. package/dist/esm/loaders/api/setUserId.js +21 -0
  82. package/dist/esm/loaders/api/sharedHandlers.js +69 -0
  83. package/dist/esm/loaders/api/start.js +11 -0
  84. package/dist/esm/loaders/api/topLevelCallers.js +22 -0
  85. package/dist/esm/loaders/api/wrapLogger.js +19 -0
  86. package/dist/esm/loaders/api-base.js +217 -0
  87. package/dist/esm/loaders/configure/configure.js +2 -4
  88. package/dist/esm/loaders/micro-agent-base.js +3 -134
  89. package/dist/esm/loaders/micro-agent.js +34 -6
  90. package/dist/tsconfig.tsbuildinfo +1 -1
  91. package/dist/types/features/ajax/instrument/index.d.ts +1 -1
  92. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  93. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  94. package/dist/types/features/generic_events/aggregate/user-actions/aggregated-user-action.d.ts +1 -0
  95. package/dist/types/features/generic_events/aggregate/user-actions/aggregated-user-action.d.ts.map +1 -1
  96. package/dist/types/features/generic_events/instrument/index.d.ts +1 -1
  97. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
  98. package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
  99. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  100. package/dist/types/features/logging/instrument/index.d.ts +1 -1
  101. package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
  102. package/dist/types/features/metrics/instrument/index.d.ts +1 -1
  103. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  104. package/dist/types/features/page_action/instrument/index.d.ts +0 -1
  105. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
  106. package/dist/types/features/page_view_event/instrument/index.d.ts +1 -1
  107. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
  108. package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -1
  109. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
  110. package/dist/types/features/session_replay/instrument/index.d.ts +1 -1
  111. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  112. package/dist/types/features/session_trace/instrument/index.d.ts +1 -1
  113. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  114. package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -1
  115. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
  116. package/dist/types/features/spa/instrument/index.d.ts +1 -1
  117. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  118. package/dist/types/features/utils/instrument-base.d.ts +9 -7
  119. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  120. package/dist/types/loaders/agent-base.d.ts +3 -71
  121. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  122. package/dist/types/loaders/agent.d.ts.map +1 -1
  123. package/dist/types/loaders/api/addPageAction.d.ts +3 -0
  124. package/dist/types/loaders/api/addPageAction.d.ts.map +1 -0
  125. package/dist/types/loaders/api/addRelease.d.ts +2 -0
  126. package/dist/types/loaders/api/addRelease.d.ts.map +1 -0
  127. package/dist/types/loaders/api/addToTrace.d.ts +2 -0
  128. package/dist/types/loaders/api/addToTrace.d.ts.map +1 -0
  129. package/dist/types/loaders/api/constants.d.ts +27 -0
  130. package/dist/types/loaders/api/constants.d.ts.map +1 -0
  131. package/dist/types/loaders/api/finished.d.ts +2 -0
  132. package/dist/types/loaders/api/finished.d.ts.map +1 -0
  133. package/dist/types/loaders/api/interaction.d.ts +2 -0
  134. package/dist/types/loaders/api/interaction.d.ts.map +1 -0
  135. package/dist/types/loaders/api/log.d.ts +6 -0
  136. package/dist/types/loaders/api/log.d.ts.map +1 -0
  137. package/dist/types/loaders/api/noticeError.d.ts +3 -0
  138. package/dist/types/loaders/api/noticeError.d.ts.map +1 -0
  139. package/dist/types/loaders/api/pauseReplay.d.ts +2 -0
  140. package/dist/types/loaders/api/pauseReplay.d.ts.map +1 -0
  141. package/dist/types/loaders/api/recordCustomEvent.d.ts +2 -0
  142. package/dist/types/loaders/api/recordCustomEvent.d.ts.map +1 -0
  143. package/dist/types/loaders/api/recordReplay.d.ts +2 -0
  144. package/dist/types/loaders/api/recordReplay.d.ts.map +1 -0
  145. package/dist/types/loaders/api/register.d.ts +20 -0
  146. package/dist/types/loaders/api/register.d.ts.map +1 -0
  147. package/dist/types/loaders/api/setApplicationVersion.d.ts +2 -0
  148. package/dist/types/loaders/api/setApplicationVersion.d.ts.map +1 -0
  149. package/dist/types/loaders/api/setCustomAttribute.d.ts +2 -0
  150. package/dist/types/loaders/api/setCustomAttribute.d.ts.map +1 -0
  151. package/dist/types/loaders/api/setErrorHandler.d.ts +2 -0
  152. package/dist/types/loaders/api/setErrorHandler.d.ts.map +1 -0
  153. package/dist/types/loaders/api/setPageViewName.d.ts +2 -0
  154. package/dist/types/loaders/api/setPageViewName.d.ts.map +1 -0
  155. package/dist/types/loaders/api/setUserId.d.ts +2 -0
  156. package/dist/types/loaders/api/setUserId.d.ts.map +1 -0
  157. package/dist/types/loaders/api/sharedHandlers.d.ts +20 -0
  158. package/dist/types/loaders/api/sharedHandlers.d.ts.map +1 -0
  159. package/dist/types/loaders/api/start.d.ts +2 -0
  160. package/dist/types/loaders/api/start.d.ts.map +1 -0
  161. package/dist/types/loaders/api/topLevelCallers.d.ts +2 -0
  162. package/dist/types/loaders/api/topLevelCallers.d.ts.map +1 -0
  163. package/dist/types/loaders/api/wrapLogger.d.ts +2 -0
  164. package/dist/types/loaders/api/wrapLogger.d.ts.map +1 -0
  165. package/dist/types/loaders/api-base.d.ts +169 -0
  166. package/dist/types/loaders/api-base.d.ts.map +1 -0
  167. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  168. package/dist/types/loaders/micro-agent-base.d.ts +2 -95
  169. package/dist/types/loaders/micro-agent-base.d.ts.map +1 -1
  170. package/dist/types/loaders/micro-agent.d.ts +1 -1
  171. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  172. package/package.json +6 -1
  173. package/src/features/ajax/instrument/index.js +3 -3
  174. package/src/features/generic_events/aggregate/index.js +1 -0
  175. package/src/features/generic_events/aggregate/user-actions/aggregated-user-action.js +2 -0
  176. package/src/features/generic_events/instrument/index.js +13 -3
  177. package/src/features/jserrors/instrument/index.js +13 -3
  178. package/src/features/logging/instrument/index.js +11 -3
  179. package/src/features/metrics/instrument/index.js +3 -3
  180. package/src/features/page_action/instrument/index.js +1 -3
  181. package/src/features/page_view_event/instrument/index.js +7 -3
  182. package/src/features/page_view_timing/instrument/index.js +3 -3
  183. package/src/features/session_replay/instrument/index.js +11 -4
  184. package/src/features/session_trace/instrument/index.js +10 -3
  185. package/src/features/soft_navigations/instrument/index.js +8 -3
  186. package/src/features/spa/instrument/index.js +8 -3
  187. package/src/features/utils/instrument-base.js +27 -20
  188. package/src/loaders/agent-base.js +4 -96
  189. package/src/loaders/agent.js +11 -0
  190. package/src/loaders/api/addPageAction.js +17 -0
  191. package/src/loaders/api/addRelease.js +14 -0
  192. package/src/loaders/api/addToTrace.js +25 -0
  193. package/src/loaders/api/constants.js +28 -0
  194. package/src/loaders/api/finished.js +19 -0
  195. package/src/loaders/api/interaction.js +59 -0
  196. package/src/loaders/api/log.js +18 -0
  197. package/src/loaders/api/noticeError.js +26 -0
  198. package/src/loaders/api/pauseReplay.js +14 -0
  199. package/src/loaders/api/recordCustomEvent.js +15 -0
  200. package/src/loaders/api/recordReplay.js +14 -0
  201. package/src/loaders/api/register.js +168 -0
  202. package/src/loaders/api/setApplicationVersion.js +22 -0
  203. package/src/loaders/api/setCustomAttribute.js +21 -0
  204. package/src/loaders/api/setErrorHandler.js +12 -0
  205. package/src/loaders/api/setPageViewName.js +17 -0
  206. package/src/loaders/api/setUserId.js +22 -0
  207. package/src/loaders/api/sharedHandlers.js +63 -0
  208. package/src/loaders/api/start.js +12 -0
  209. package/src/loaders/api/topLevelCallers.js +24 -0
  210. package/src/loaders/api/wrapLogger.js +14 -0
  211. package/src/loaders/api-base.js +218 -0
  212. package/src/loaders/configure/configure.js +2 -3
  213. package/src/loaders/micro-agent-base.js +3 -136
  214. package/src/loaders/micro-agent.js +34 -4
  215. package/tools/bundler-tools/bundler-tools.js +27 -0
  216. package/tools/bundler-tools/bundler-tools.mjs +23 -0
  217. package/dist/cjs/features/utils/lazy-feature-loader.js +0 -53
  218. package/dist/cjs/loaders/api/api-methods.js +0 -14
  219. package/dist/cjs/loaders/api/api.js +0 -259
  220. package/dist/cjs/loaders/api/apiAsync.js +0 -63
  221. package/dist/esm/features/utils/lazy-feature-loader.js +0 -47
  222. package/dist/esm/loaders/api/api-methods.js +0 -7
  223. package/dist/esm/loaders/api/api.js +0 -251
  224. package/dist/esm/loaders/api/apiAsync.js +0 -56
  225. package/dist/types/features/utils/lazy-feature-loader.d.ts +0 -13
  226. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +0 -1
  227. package/dist/types/loaders/api/api-methods.d.ts +0 -3
  228. package/dist/types/loaders/api/api-methods.d.ts.map +0 -1
  229. package/dist/types/loaders/api/api.d.ts +0 -3
  230. package/dist/types/loaders/api/api.d.ts.map +0 -1
  231. package/dist/types/loaders/api/apiAsync.d.ts +0 -2
  232. package/dist/types/loaders/api/apiAsync.d.ts.map +0 -1
  233. package/src/features/utils/lazy-feature-loader.js +0 -47
  234. package/src/loaders/api/api-methods.js +0 -16
  235. package/src/loaders/api/api.js +0 -264
  236. package/src/loaders/api/apiAsync.js +0 -56
package/README.md CHANGED
@@ -251,6 +251,38 @@ import { Agent } from '@newrelic/browser-agent/loaders/agent'
251
251
  import { Metrics } from '@newrelic/browser-agent/src/features/metrics'
252
252
  ```
253
253
 
254
+ ## Bundling
255
+ As an outcome of the design patterns employed in the browser agent package, building the agent can generate lazy-loaded chunks for many of the utilized modules. To concatenate, deduplicate and reduce those modules to a single lazy-loaded file the same way we do internally when shipping to our CDN, you can choose to utilize the `"build-tools"` directory which includes rulesets for various build tools.
256
+
257
+ **Please note - This is an optional step. The browser agent can be built without any rules instructing the build tools about the handling of the lazy-loaded chunks, or the chunks can be handled in any way you see fit to conform to your build process. This ruleset serves as an example of what we do internally when shipping to our CDN.**
258
+
259
+ ### Webpack
260
+ For Webpack (v4+), you can choose to use our [webpack cache group rule](https://github.com/newrelic/newrelic-browser-agent/blob/main/tools/bundler-tools/bundler-tools.mjs) to instruct webpack on how to handle the agent's lazy chunks. The cacheGroup rule acts as a rule within the [SplitChunksPlugin](https://webpack.js.org/plugins/split-chunks-plugin/). Please observe the relevant documentation for use of this plugin. The output of this cache group rule will generate a lazy aggregate module, and lazy chunks for session replay, which matches the pattern found on our CDN distribution.
261
+
262
+ ### Other
263
+ Plugins for other bundling tools are planned for the future.
264
+
265
+ ```javascript
266
+ // in webpack.config.js
267
+ const { webpackCacheGroup } = require('@newrelic/browser-agent/tools/bundler-tools')
268
+ // ... or ...
269
+ import { webpackCacheGroup } from '@newrelic/browser-agent/tools/bundler-tools'
270
+
271
+ {
272
+ // ...
273
+ optimization: {
274
+ splitChunks: {
275
+ cacheGroups: {
276
+ // A ruleset for handling the browser agent modules
277
+ ...webpackCacheGroup(),
278
+ // ... other cache groups
279
+ }
280
+ }
281
+ },
282
+ // ...
283
+ }
284
+ ```
285
+
254
286
  ## Library Support
255
287
 
256
288
  The browser agent is written to be agnostic to any JavaScript library or framework. The agent exposes a number of [API methods](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/using-browser-apis/) that can be incorporated into libraries and frameworks. For example, export or make available the initialized agent and create a new error boundary in your react application that calls `browserAgent.noticeError()`.
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.289.0";
20
+ const VERSION = exports.VERSION = "1.290.0-rc.0";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.289.0";
20
+ const VERSION = exports.VERSION = "1.290.0-rc.0";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -21,11 +21,11 @@ var _features = require("../../../loaders/features/features");
21
21
  var _constants2 = require("../../metrics/constants");
22
22
  var _now = require("../../../common/timing/now");
23
23
  var _denyList = require("../../../common/deny-list/deny-list");
24
- /**
24
+ 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); }
25
+ 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 && {}.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; } /**
25
26
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
26
27
  * SPDX-License-Identifier: Apache-2.0
27
28
  */
28
-
29
29
  var handlers = ['load', 'error', 'abort', 'timeout'];
30
30
  var handlersLen = handlers.length;
31
31
  var origRequest = (0, _nreum.gosNREUMOriginals)().o.REQ;
@@ -33,8 +33,8 @@ var origXHR = (0, _nreum.gosNREUMOriginals)().o.XHR;
33
33
  const NR_CAT_HEADER = 'X-NewRelic-App-Data';
34
34
  class Instrument extends _instrumentBase.InstrumentBase {
35
35
  static featureName = _constants.FEATURE_NAME;
36
- constructor(agentRef, auto = true) {
37
- super(agentRef, _constants.FEATURE_NAME, auto);
36
+ constructor(agentRef) {
37
+ super(agentRef, _constants.FEATURE_NAME);
38
38
  this.dt = new _distributedTracing.DT(agentRef);
39
39
  this.handler = (type, args, ctx, group) => (0, _handle.handle)(type, args, ctx, group, this.ee);
40
40
 
@@ -72,7 +72,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
72
72
  (0, _wrapFetch.wrapFetch)(this.ee);
73
73
  (0, _wrapXhr.wrapXhr)(this.ee);
74
74
  subscribeToEvents(agentRef, this.ee, this.handler, this.dt);
75
- this.importAggregator(agentRef);
75
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "ajax-aggregate" */'../aggregate/index.js'))));
76
76
  }
77
77
  }
78
78
  exports.Instrument = Instrument;
@@ -83,6 +83,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
83
83
  actionMs: aggregatedUserAction.relativeMs,
84
84
  rageClick: aggregatedUserAction.rageClick,
85
85
  target: aggregatedUserAction.selectorPath,
86
+ currentUrl: aggregatedUserAction.currentUrl,
86
87
  ...((0, _iframe.isIFrameWindow)(window) && {
87
88
  iframe: true
88
89
  }),
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.AggregatedUserAction = void 0;
7
7
  var _constants = require("../../constants");
8
+ var _cleanUrl = require("../../../../common/url/clean-url");
8
9
  /**
9
10
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
10
11
  * SPDX-License-Identifier: Apache-2.0
@@ -19,6 +20,7 @@ class AggregatedUserAction {
19
20
  this.selectorPath = selectorPath;
20
21
  this.rageClick = undefined;
21
22
  this.nearestTargetFields = nearestTargetFields;
23
+ this.currentUrl = (0, _cleanUrl.cleanURL)('' + location);
22
24
  }
23
25
 
24
26
  /**
@@ -8,19 +8,29 @@ var _runtime = require("../../../common/constants/runtime");
8
8
  var _handle = require("../../../common/event-emitter/handle");
9
9
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
10
10
  var _invoke = require("../../../common/util/invoke");
11
+ var _addPageAction = require("../../../loaders/api/addPageAction");
12
+ var _finished = require("../../../loaders/api/finished");
13
+ var _recordCustomEvent = require("../../../loaders/api/recordCustomEvent");
14
+ var _register = require("../../../loaders/api/register");
11
15
  var _instrumentBase = require("../../utils/instrument-base");
12
16
  var _constants = require("../constants");
13
- /**
17
+ 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); }
18
+ 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 && {}.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; } /**
14
19
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
15
20
  * SPDX-License-Identifier: Apache-2.0
16
21
  */
17
-
18
22
  class Instrument extends _instrumentBase.InstrumentBase {
19
23
  static featureName = _constants.FEATURE_NAME;
20
- constructor(agentRef, auto = true) {
21
- super(agentRef, _constants.FEATURE_NAME, auto);
24
+ constructor(agentRef) {
25
+ super(agentRef, _constants.FEATURE_NAME);
22
26
  /** config values that gate whether the generic events aggregator should be imported at all */
23
27
  const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.performance.capture_marks, agentRef.init.performance.capture_measures, agentRef.init.user_actions.enabled, agentRef.init.performance.resources.enabled];
28
+
29
+ /** feature specific APIs */
30
+ (0, _addPageAction.setupAddPageActionAPI)(agentRef);
31
+ (0, _recordCustomEvent.setupRecordCustomEventAPI)(agentRef);
32
+ (0, _finished.setupFinishedAPI)(agentRef);
33
+ (0, _register.setupRegisterAPI)(agentRef);
24
34
  if (_runtime.isBrowserScope) {
25
35
  if (agentRef.init.user_actions.enabled) {
26
36
  _constants.OBSERVED_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee), true));
@@ -49,7 +59,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
49
59
  }
50
60
 
51
61
  /** If any of the sources are active, import the aggregator. otherwise deregister */
52
- if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef);else this.deregisterDrain();
62
+ if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "generic_events-aggregate" */'../aggregate'))));else this.deregisterDrain();
53
63
  }
54
64
  }
55
65
  exports.Instrument = Instrument;
@@ -12,16 +12,26 @@ var _eventListenerOpts = require("../../../common/event-listener/event-listener-
12
12
  var _now = require("../../../common/timing/now");
13
13
  var _constants2 = require("../../session_replay/constants");
14
14
  var _castError = require("../shared/cast-error");
15
- /**
15
+ var _noticeError = require("../../../loaders/api/noticeError");
16
+ var _setErrorHandler = require("../../../loaders/api/setErrorHandler");
17
+ var _addRelease = require("../../../loaders/api/addRelease");
18
+ var _register = require("../../../loaders/api/register");
19
+ 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); }
20
+ 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 && {}.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
21
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
17
22
  * SPDX-License-Identifier: Apache-2.0
18
23
  */
19
-
20
24
  class Instrument extends _instrumentBase.InstrumentBase {
21
25
  static featureName = _constants.FEATURE_NAME;
22
26
  #replayRunning = false;
23
- constructor(agentRef, auto = true) {
24
- super(agentRef, _constants.FEATURE_NAME, auto);
27
+ constructor(agentRef) {
28
+ super(agentRef, _constants.FEATURE_NAME);
29
+
30
+ /** feature specific APIs */
31
+ (0, _noticeError.setupNoticeErrorAPI)(agentRef);
32
+ (0, _setErrorHandler.setupSetErrorHandlerAPI)(agentRef);
33
+ (0, _addRelease.setupAddReleaseAPI)(agentRef);
34
+ (0, _register.setupRegisterAPI)(agentRef);
25
35
  try {
26
36
  // this try-catch can be removed when IE11 is completely unsupported & gone
27
37
  this.removeOnAbort = new AbortController();
@@ -44,7 +54,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
44
54
  (0, _handle.handle)('err', [(0, _castError.castErrorEvent)(errorEvent), (0, _now.now)(), false, {}, this.#replayRunning], undefined, this.featureName, this.ee);
45
55
  }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort?.signal));
46
56
  this.abortHandler = this.#abort; // we also use this as a flag to denote that the feature is active or on and handling errors
47
- this.importAggregator(agentRef);
57
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "jserrors-aggregate" */'../aggregate'))));
48
58
  }
49
59
 
50
60
  /** Restoration and resource release tasks to be done if JS error loader is being aborted. Unwind changes to globals. */
@@ -9,15 +9,23 @@ var _constants = require("../constants");
9
9
  var _utils = require("../shared/utils");
10
10
  var _wrapLogger = require("../../../common/wrap/wrap-logger");
11
11
  var _runtime = require("../../../common/constants/runtime");
12
- /**
12
+ var _log = require("../../../loaders/api/log");
13
+ var _wrapLogger2 = require("../../../loaders/api/wrapLogger");
14
+ var _register = require("../../../loaders/api/register");
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); }
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 && {}.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; } /**
13
17
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
14
18
  * SPDX-License-Identifier: Apache-2.0
15
19
  */
16
-
17
20
  class Instrument extends _instrumentBase.InstrumentBase {
18
21
  static featureName = _constants.FEATURE_NAME;
19
- constructor(agentRef, auto = true) {
20
- super(agentRef, _constants.FEATURE_NAME, auto);
22
+ constructor(agentRef) {
23
+ super(agentRef, _constants.FEATURE_NAME);
24
+
25
+ /** feature specific APIs */
26
+ (0, _log.setupLogAPI)(agentRef);
27
+ (0, _wrapLogger2.setupWrapLoggerAPI)(agentRef);
28
+ (0, _register.setupRegisterAPI)(agentRef);
21
29
  const instanceEE = this.ee;
22
30
  (0, _wrapLogger.wrapLogger)(instanceEE, _runtime.globalScope.console, 'log', {
23
31
  level: 'info'
@@ -45,7 +53,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
45
53
  } = this;
46
54
  (0, _utils.bufferLog)(instanceEE, message, customAttributes, level);
47
55
  });
48
- this.importAggregator(agentRef);
56
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "logging-aggregate" */'../aggregate'))));
49
57
  }
50
58
  }
51
59
  exports.Instrument = Instrument;
@@ -8,18 +8,18 @@ var _runtime = require("../../../common/constants/runtime");
8
8
  var _handle = require("../../../common/event-emitter/handle");
9
9
  var _instrumentBase = require("../../utils/instrument-base");
10
10
  var _constants = require("../constants");
11
- /**
11
+ 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); }
12
+ 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 && {}.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; } /**
12
13
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
13
14
  * SPDX-License-Identifier: Apache-2.0
14
15
  */
15
-
16
16
  // import { handle } from '../../../common/event-emitter/handle'
17
17
  // import { WEBSOCKET_TAG, wrapWebSocket } from '../../../common/wrap/wrap-websocket'
18
18
 
19
19
  class Instrument extends _instrumentBase.InstrumentBase {
20
20
  static featureName = _constants.FEATURE_NAME;
21
- constructor(agentRef, auto = true) {
22
- super(agentRef, _constants.FEATURE_NAME, auto);
21
+ constructor(agentRef) {
22
+ super(agentRef, _constants.FEATURE_NAME);
23
23
  // wrapWebSocket(this.ee) - feb'25 : removing wrapping again to avoid integration issues
24
24
 
25
25
  // WATCHABLE_WEB_SOCKET_EVENTS.forEach((suffix) => {
@@ -33,7 +33,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
33
33
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Generic/CSPViolation/Detected'], undefined, this.featureName, this.ee);
34
34
  });
35
35
  }
36
- this.importAggregator(agentRef);
36
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "metrics-aggregate" */'../aggregate'))));
37
37
  }
38
38
  }
39
39
  exports.Instrument = Instrument;
@@ -13,11 +13,7 @@ var _generic_events = require("../../generic_events");
13
13
  /**
14
14
  * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
15
15
  */
16
- class Instrument extends _generic_events.GenericEvents {
17
- constructor(agentIdentifier, aggregator, auto = true) {
18
- super(agentIdentifier, aggregator, auto);
19
- }
20
- }
16
+ class Instrument extends _generic_events.GenericEvents {}
21
17
 
22
18
  /**
23
19
  * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
@@ -5,23 +5,25 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.PageViewEvent = exports.Instrument = void 0;
7
7
  var _handle = require("../../../common/event-emitter/handle");
8
+ var _setPageViewName = require("../../../loaders/api/setPageViewName");
8
9
  var _instrumentBase = require("../../utils/instrument-base");
9
10
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
10
11
  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); }
11
- 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 && {}.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; }
12
- /**
12
+ 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 && {}.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; } /**
13
13
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
14
14
  * SPDX-License-Identifier: Apache-2.0
15
15
  */
16
-
17
16
  class Instrument extends _instrumentBase.InstrumentBase {
18
17
  static featureName = CONSTANTS.FEATURE_NAME;
19
- constructor(agentRef, auto = true) {
20
- super(agentRef, CONSTANTS.FEATURE_NAME, auto);
18
+ constructor(agentRef) {
19
+ super(agentRef, CONSTANTS.FEATURE_NAME);
20
+
21
+ /** feature specific APIs */
22
+ (0, _setPageViewName.setupSetPageViewNameAPI)(agentRef);
21
23
 
22
24
  /** messages from the register API that can trigger a new RUM call */
23
25
  this.ee.on('api-send-rum', (attrs, target) => (0, _handle.handle)('send-rum', [attrs, target], undefined, this.featureName, this.ee));
24
- this.importAggregator(agentRef);
26
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "page_view_event-aggregate" */'../aggregate'))));
25
27
  }
26
28
  }
27
29
  exports.Instrument = Instrument;
@@ -11,15 +11,15 @@ var _instrumentBase = require("../../utils/instrument-base");
11
11
  var _constants = require("../constants");
12
12
  var _runtime = require("../../../common/constants/runtime");
13
13
  var _now = require("../../../common/timing/now");
14
- /**
14
+ 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
+ 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 && {}.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; } /**
15
16
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
16
17
  * SPDX-License-Identifier: Apache-2.0
17
18
  */
18
-
19
19
  class Instrument extends _instrumentBase.InstrumentBase {
20
20
  static featureName = _constants.FEATURE_NAME;
21
- constructor(agentRef, auto = true) {
22
- super(agentRef, _constants.FEATURE_NAME, auto);
21
+ constructor(agentRef) {
22
+ super(agentRef, _constants.FEATURE_NAME);
23
23
  if (!_runtime.isBrowserScope) return; // CWV is irrelevant outside web context
24
24
 
25
25
  // While we try to replicate web-vital's visibilitywatcher logic in an effort to defer that library to post-pageload, this isn't perfect and doesn't consider prerendering.
@@ -27,7 +27,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
27
27
 
28
28
  // Window fires its pagehide event (typically on navigation--this occurrence is a *subset* of vis change); don't defer this unless it's guarantee it cannot happen before load(?)
29
29
  (0, _eventListenerOpts.windowAddEventListener)('pagehide', () => (0, _handle.handle)('winPagehide', [(0, _now.now)()], undefined, _constants.FEATURE_NAME, this.ee));
30
- this.importAggregator(agentRef);
30
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "page_view_timing-aggregate" */'../aggregate'))));
31
31
  }
32
32
  }
33
33
  exports.Instrument = Instrument;
@@ -9,6 +9,8 @@ var _constants = require("../../../common/session/constants");
9
9
  var _instrumentBase = require("../../utils/instrument-base");
10
10
  var _utils = require("../shared/utils");
11
11
  var _constants2 = require("../constants");
12
+ var _recordReplay = require("../../../loaders/api/recordReplay");
13
+ var _pauseReplay = require("../../../loaders/api/pauseReplay");
12
14
  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); }
13
15
  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 && {}.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; } /**
14
16
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
@@ -20,8 +22,12 @@ class Instrument extends _instrumentBase.InstrumentBase {
20
22
  static featureName = _constants2.FEATURE_NAME;
21
23
  #mode;
22
24
  #agentRef;
23
- constructor(agentRef, auto = true) {
24
- super(agentRef, _constants2.FEATURE_NAME, auto);
25
+ constructor(agentRef) {
26
+ super(agentRef, _constants2.FEATURE_NAME);
27
+
28
+ /** feature specific APIs */
29
+ (0, _recordReplay.setupRecordReplayAPI)(agentRef);
30
+ (0, _pauseReplay.setupPauseReplayAPI)(agentRef);
25
31
  let session;
26
32
  this.replayRunning = false;
27
33
  this.#agentRef = agentRef;
@@ -35,7 +41,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
35
41
  this.#mode = session?.sessionReplayMode;
36
42
  this.#preloadStartRecording();
37
43
  } else {
38
- this.importAggregator(agentRef);
44
+ this.importAggregator(this.#agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "session_replay-aggregate" */'../aggregate'))));
39
45
  }
40
46
 
41
47
  /** If the recorder is running, we can pass error events on to the agg to help it switch to full mode later */
@@ -90,7 +96,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
90
96
  this.recorder.startRecording();
91
97
  this.abortHandler = this.recorder.stopRecording;
92
98
  } catch (e) {} // TODO add internal error handling
93
- this.importAggregator(this.#agentRef, {
99
+ this.importAggregator(this.#agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "session_replay-aggregate" */'../aggregate'))), {
94
100
  recorder: this.recorder,
95
101
  errorNoticed: this.errorNoticed
96
102
  });
@@ -12,13 +12,13 @@ var CONSTANTS = _interopRequireWildcard(require("../constants"));
12
12
  var _features = require("../../../loaders/features/features");
13
13
  var _featureGates = require("../../utils/feature-gates");
14
14
  var _now = require("../../../common/timing/now");
15
+ var _addToTrace = require("../../../loaders/api/addToTrace");
16
+ var _finished = require("../../../loaders/api/finished");
15
17
  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); }
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 && {}.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; }
17
- /**
18
+ 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 && {}.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; } /**
18
19
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
19
20
  * SPDX-License-Identifier: Apache-2.0
20
21
  */
21
-
22
22
  const {
23
23
  BST_RESOURCE,
24
24
  RESOURCE,
@@ -31,8 +31,12 @@ const {
31
31
  } = CONSTANTS;
32
32
  class Instrument extends _instrumentBase.InstrumentBase {
33
33
  static featureName = FEATURE_NAME;
34
- constructor(agentRef, auto = true) {
35
- super(agentRef, FEATURE_NAME, auto);
34
+ constructor(agentRef) {
35
+ super(agentRef, FEATURE_NAME);
36
+
37
+ /** feature specific APIs */
38
+ (0, _addToTrace.setupAddToTraceAPI)(agentRef);
39
+ (0, _finished.setupFinishedAPI)(agentRef);
36
40
  const canTrackSession = (0, _featureGates.canEnableSessionTracking)(agentRef.init);
37
41
  if (!canTrackSession) {
38
42
  this.deregisterDrain();
@@ -71,7 +75,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
71
75
  } catch (e) {
72
76
  // Per NEWRELIC-8525, we don't have a fallback for capturing resources for older versions that don't support PO at this time.
73
77
  }
74
- this.importAggregator(agentRef, {
78
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "session_trace-aggregate" */'../aggregate'))), {
75
79
  resourceObserver: observer
76
80
  });
77
81
  }
@@ -13,11 +13,12 @@ var _wrapHistory = require("../../../common/wrap/wrap-history");
13
13
  var _instrumentBase = require("../../utils/instrument-base");
14
14
  var _constants = require("../constants");
15
15
  var _now = require("../../../common/timing/now");
16
- /**
16
+ var _interaction = require("../../../loaders/api/interaction");
17
+ 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); }
18
+ 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 && {}.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; } /**
17
19
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
18
20
  * SPDX-License-Identifier: Apache-2.0
19
21
  */
20
-
21
22
  /**
22
23
  * The minimal time after a UI event for which no further events will be processed - i.e. a throttling rate to reduce spam.
23
24
  * This also give some time for the new interaction to complete without being discarded by a subsequent UI event and wrongly attributed.
@@ -27,8 +28,11 @@ const UI_WAIT_INTERVAL = 1 / 10 * 1000; // assume 10 fps
27
28
 
28
29
  class Instrument extends _instrumentBase.InstrumentBase {
29
30
  static featureName = _constants.FEATURE_NAME;
30
- constructor(agentRef, auto = true) {
31
- super(agentRef, _constants.FEATURE_NAME, auto);
31
+ constructor(agentRef) {
32
+ super(agentRef, _constants.FEATURE_NAME);
33
+
34
+ /** feature specific APIs */
35
+ (0, _interaction.setupInteractionAPI)(agentRef);
32
36
  if (!_runtime.isBrowserScope || !(0, _nreum.gosNREUMOriginals)().o.MO) return; // soft navigations is not supported outside web env or browsers without the mutation observer API
33
37
 
34
38
  const historyEE = (0, _wrapHistory.wrapHistory)(this.ee);
@@ -67,7 +71,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
67
71
  leading: true
68
72
  });
69
73
  this.abortHandler = abort;
70
- this.importAggregator(agentRef, {
74
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "soft_navigations-aggregate" */'../aggregate'))), {
71
75
  domObserver
72
76
  });
73
77
  function abort() {
@@ -17,13 +17,12 @@ var _wrapXhr = require("../../../common/wrap/wrap-xhr");
17
17
  var _wrapFetch = require("../../../common/wrap/wrap-fetch");
18
18
  var _wrapHistory = require("../../../common/wrap/wrap-history");
19
19
  var _wrapMutation = require("../../../common/wrap/wrap-mutation");
20
+ var _interaction = require("../../../loaders/api/interaction");
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
- 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 && {}.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
- /**
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 && {}.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; } /**
23
23
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
24
24
  * SPDX-License-Identifier: Apache-2.0
25
25
  */
26
-
27
26
  const {
28
27
  FEATURE_NAME,
29
28
  START,
@@ -42,8 +41,11 @@ const {
42
41
  */
43
42
  class Instrument extends _instrumentBase.InstrumentBase {
44
43
  static featureName = FEATURE_NAME;
45
- constructor(agentRef, auto = true) {
46
- super(agentRef, FEATURE_NAME, auto);
44
+ constructor(agentRef) {
45
+ super(agentRef, FEATURE_NAME);
46
+
47
+ /** feature specific APIs */
48
+ (0, _interaction.setupInteractionAPI)(agentRef);
47
49
  if (!_runtime.isBrowserScope) return; // SPA not supported outside web env
48
50
 
49
51
  try {
@@ -114,7 +116,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
114
116
  });
115
117
  }
116
118
  this.abortHandler = this.#abort;
117
- this.importAggregator(agentRef);
119
+ this.importAggregator(agentRef, () => Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "spa-aggregate" */'../aggregate'))));
118
120
  }
119
121
 
120
122
  /** Restoration and resource release tasks to be done if SPA loader is being aborted. Unwind changes to globals and subscription to DOM events. */
@@ -31,13 +31,9 @@ class InstrumentBase extends _featureBase.FeatureBase {
31
31
  * Instantiate InstrumentBase.
32
32
  * @param {string} agentIdentifier - The unique ID of the instantiated agent (relative to global scope).
33
33
  * @param {string} featureName - The name of the feature module (used to construct file path).
34
- * @param {boolean} [auto=true] - Determines whether the feature should automatically register to have the draining
35
- * of its pooled instrumentation data handled by the agent's centralized drain functionality, rather than draining
36
- * immediately. Primarily useful for fine-grained control in tests.
37
34
  */
38
- constructor(agentRef, featureName, auto = true) {
35
+ constructor(agentRef, featureName) {
39
36
  super(agentRef.agentIdentifier, featureName);
40
- this.auto = auto;
41
37
 
42
38
  /** @type {Function | undefined} This should be set by any derived Instrument class if it has things to do when feature fails or is killed. */
43
39
  this.abortHandler = undefined;
@@ -54,34 +50,45 @@ class InstrumentBase extends _featureBase.FeatureBase {
54
50
  */
55
51
  this.onAggregateImported = undefined;
56
52
 
57
- /** used in conjunction with newrelic.start() to defer harvesting in features */
58
- if (agentRef.init[this.featureName].autoStart === false) this.auto = false;
59
- /** if the feature requires opt-in (!auto-start), it will get registered once the api has been called */
60
- if (this.auto) (0, _drain.registerDrain)(agentRef.agentIdentifier, featureName);else {
61
- this.ee.on('manual-start-all', (0, _invoke.single)(() => {
62
- // register the feature to drain only once the API has been called, it will drain when importAggregator finishes for all the features
63
- // called by the api in that cycle
64
- (0, _drain.registerDrain)(agentRef.agentIdentifier, this.featureName);
65
- this.auto = true;
66
- this.importAggregator(agentRef);
67
- }));
53
+ /**
54
+ * used in conjunction with newrelic.start() to defer harvesting in features
55
+ * @type {Promise} Resolves when the feature is ready to import its aggregator, either immediately or after the start API has been called if the feature is autoStart: false.
56
+ */
57
+ this.deferred = Promise.resolve();
58
+ if (agentRef.init[this.featureName].autoStart === false) {
59
+ this.deferred = new Promise((resolve, reject) => {
60
+ this.ee.on('manual-start-all', (0, _invoke.single)(() => {
61
+ // register the feature to drain only once the API has been called, it will drain when importAggregator finishes for all the features
62
+ // called by the api in that cycle
63
+ (0, _drain.registerDrain)(agentRef.agentIdentifier, this.featureName);
64
+ resolve();
65
+ }));
66
+ });
67
+ } else {
68
+ /** if the feature requires opt-in (!auto-start), it will get registered once the api has been called */
69
+ (0, _drain.registerDrain)(agentRef.agentIdentifier, featureName);
68
70
  }
69
71
  }
70
72
 
71
73
  /**
72
74
  * Lazy-load the latter part of the feature: its aggregator. This method is called by the first part of the feature
73
75
  * (the instrumentation) when instrumentation is complete.
74
- * @param agentRef - reference to the base agent ancestor that this feature belongs to
76
+ * @param {Object} agentRef - reference to the base agent ancestor that this feature belongs to
77
+ * @param {Function} fetchAggregator - a function that returns a promise that resolves to the aggregate module
75
78
  * @param {Object} [argsObjFromInstrument] - any values or references to pass down to aggregate
76
79
  * @returns void
77
80
  */
78
- importAggregator(agentRef, argsObjFromInstrument = {}) {
79
- if (this.featAggregate || !this.auto) return;
81
+ importAggregator(agentRef, fetchAggregator, argsObjFromInstrument = {}) {
82
+ if (this.featAggregate) return;
80
83
  let loadedSuccessfully;
81
84
  this.onAggregateImported = new Promise(resolve => {
82
85
  loadedSuccessfully = resolve;
83
86
  });
84
87
  const importLater = async () => {
88
+ // wait for the deferred promise to resolve before proceeding
89
+ // this will resolve immediately if the feature is auto-started,
90
+ // or otherwise when the manual-start-all event is emitted by the start API
91
+ await this.deferred;
85
92
  let session;
86
93
  try {
87
94
  if ((0, _featureGates.canEnableSessionTracking)(agentRef.init)) {
@@ -107,12 +114,9 @@ class InstrumentBase extends _featureBase.FeatureBase {
107
114
  loadedSuccessfully(false); // aggregate module isn't loaded at all
108
115
  return;
109
116
  }
110
- const {
111
- lazyFeatureLoader
112
- } = await Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "lazy-feature-loader" */'./lazy-feature-loader')));
113
117
  const {
114
118
  Aggregate
115
- } = await lazyFeatureLoader(this.featureName, 'aggregate');
119
+ } = await fetchAggregator();
116
120
  this.featAggregate = new Aggregate(agentRef, argsObjFromInstrument);
117
121
  agentRef.runtime.harvester.initializedAggregates.push(this.featAggregate); // "subscribe" the feature to future harvest intervals (PVE will start the timer)
118
122
  loadedSuccessfully(true);