@newrelic/browser-agent 1.238.0 → 1.239.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 (249) hide show
  1. package/dist/cjs/common/config/state/init.js +21 -13
  2. package/dist/cjs/common/config/state/runtime.js +0 -4
  3. package/dist/cjs/common/constants/env.cdn.js +1 -1
  4. package/dist/cjs/common/constants/env.npm.js +1 -1
  5. package/dist/cjs/common/constants/runtime.js +3 -3
  6. package/dist/cjs/common/constants/shared-channel.js +3 -1
  7. package/dist/cjs/common/deny-list/deny-list.js +2 -8
  8. package/dist/cjs/common/drain/drain.js +1 -1
  9. package/dist/cjs/common/event-emitter/contextual-ee.js +6 -6
  10. package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
  11. package/dist/cjs/common/harvest/harvest.js +2 -6
  12. package/dist/cjs/common/serialize/bel-serializer.js +1 -1
  13. package/dist/cjs/common/session/session-entity.js +16 -12
  14. package/dist/cjs/common/storage/first-party-cookies.js +5 -4
  15. package/dist/cjs/common/storage/local-storage.js +3 -2
  16. package/dist/cjs/common/timer/interaction-timer.js +14 -6
  17. package/dist/cjs/common/timing/nav-timing.js +1 -1
  18. package/dist/cjs/common/unload/eol.js +4 -30
  19. package/dist/cjs/common/util/feature-flags.js +14 -15
  20. package/dist/cjs/common/util/invoke.js +3 -1
  21. package/dist/cjs/common/util/obfuscate.js +3 -5
  22. package/dist/cjs/common/util/traverse.js +1 -0
  23. package/dist/cjs/common/window/page-visibility.js +1 -2
  24. package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
  25. package/dist/cjs/features/ajax/aggregate/index.js +5 -7
  26. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -8
  27. package/dist/cjs/features/ajax/instrument/index.js +47 -15
  28. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
  29. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  30. package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
  31. package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
  32. package/dist/cjs/features/metrics/aggregate/index.js +20 -37
  33. package/dist/cjs/features/metrics/instrument/index.js +0 -2
  34. package/dist/cjs/features/page_action/aggregate/index.js +17 -19
  35. package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
  36. package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
  37. package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
  38. package/dist/cjs/features/session_replay/aggregate/index.js +3 -3
  39. package/dist/cjs/features/session_trace/aggregate/index.js +8 -8
  40. package/dist/cjs/features/spa/aggregate/index.js +14 -20
  41. package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
  42. package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
  43. package/dist/cjs/features/utils/aggregate-base.js +4 -0
  44. package/dist/cjs/features/utils/handler-cache.js +3 -1
  45. package/dist/cjs/features/utils/instrument-base.js +24 -6
  46. package/dist/cjs/loaders/agent-base.js +11 -0
  47. package/dist/cjs/loaders/agent.js +7 -7
  48. package/dist/cjs/loaders/api/api.js +21 -4
  49. package/dist/cjs/loaders/api/apiAsync.js +19 -20
  50. package/dist/cjs/loaders/configure/configure.js +3 -0
  51. package/dist/cjs/loaders/micro-agent.js +20 -3
  52. package/dist/esm/common/config/state/init.js +21 -13
  53. package/dist/esm/common/config/state/runtime.js +0 -4
  54. package/dist/esm/common/constants/env.cdn.js +1 -1
  55. package/dist/esm/common/constants/env.npm.js +1 -1
  56. package/dist/esm/common/constants/runtime.js +1 -1
  57. package/dist/esm/common/constants/shared-channel.js +3 -1
  58. package/dist/esm/common/deny-list/deny-list.js +2 -8
  59. package/dist/esm/common/drain/drain.js +1 -1
  60. package/dist/esm/common/event-emitter/contextual-ee.js +6 -6
  61. package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
  62. package/dist/esm/common/harvest/harvest.js +2 -6
  63. package/dist/esm/common/serialize/bel-serializer.js +1 -1
  64. package/dist/esm/common/session/session-entity.js +16 -12
  65. package/dist/esm/common/storage/first-party-cookies.js +5 -4
  66. package/dist/esm/common/storage/local-storage.js +3 -2
  67. package/dist/esm/common/timer/interaction-timer.js +14 -6
  68. package/dist/esm/common/timing/nav-timing.js +1 -1
  69. package/dist/esm/common/unload/eol.js +5 -31
  70. package/dist/esm/common/util/feature-flags.js +14 -15
  71. package/dist/esm/common/util/invoke.js +3 -1
  72. package/dist/esm/common/util/obfuscate.js +3 -5
  73. package/dist/esm/common/util/traverse.js +1 -0
  74. package/dist/esm/common/window/page-visibility.js +1 -2
  75. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  76. package/dist/esm/features/ajax/aggregate/index.js +5 -7
  77. package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -8
  78. package/dist/esm/features/ajax/instrument/index.js +47 -15
  79. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
  80. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  81. package/dist/esm/features/jserrors/aggregate/index.js +4 -5
  82. package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
  83. package/dist/esm/features/metrics/aggregate/index.js +22 -39
  84. package/dist/esm/features/metrics/instrument/index.js +1 -3
  85. package/dist/esm/features/page_action/aggregate/index.js +17 -19
  86. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  87. package/dist/esm/features/page_view_event/instrument/index.js +4 -2
  88. package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
  89. package/dist/esm/features/session_replay/aggregate/index.js +2 -2
  90. package/dist/esm/features/session_trace/aggregate/index.js +8 -8
  91. package/dist/esm/features/spa/aggregate/index.js +14 -20
  92. package/dist/esm/features/spa/aggregate/interaction.js +0 -2
  93. package/dist/esm/features/spa/aggregate/serializer.js +1 -1
  94. package/dist/esm/features/utils/aggregate-base.js +4 -0
  95. package/dist/esm/features/utils/handler-cache.js +3 -1
  96. package/dist/esm/features/utils/instrument-base.js +24 -6
  97. package/dist/esm/loaders/agent-base.js +11 -0
  98. package/dist/esm/loaders/agent.js +7 -7
  99. package/dist/esm/loaders/api/api.js +21 -4
  100. package/dist/esm/loaders/api/apiAsync.js +19 -20
  101. package/dist/esm/loaders/configure/configure.js +3 -0
  102. package/dist/esm/loaders/features/enabled-features.js +1 -1
  103. package/dist/esm/loaders/micro-agent.js +21 -4
  104. package/dist/types/common/config/state/init.d.ts.map +1 -1
  105. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  106. package/dist/types/common/constants/runtime.d.ts +1 -1
  107. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  108. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  110. package/dist/types/common/session/session-entity.d.ts +6 -9
  111. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  112. package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
  113. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
  114. package/dist/types/common/storage/local-storage.d.ts.map +1 -1
  115. package/dist/types/common/timer/interaction-timer.d.ts +3 -0
  116. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  117. package/dist/types/common/unload/eol.d.ts +1 -2
  118. package/dist/types/common/unload/eol.d.ts.map +1 -1
  119. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  120. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  121. package/dist/types/common/util/traverse.d.ts.map +1 -1
  122. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  123. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  124. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  125. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
  126. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  127. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  128. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -1
  129. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  130. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  131. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  132. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  133. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  134. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  135. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  136. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  137. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  138. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  139. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  140. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  141. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  142. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  143. package/dist/types/loaders/agent-base.d.ts +6 -0
  144. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  145. package/dist/types/loaders/agent.d.ts +1 -1
  146. package/dist/types/loaders/agent.d.ts.map +1 -1
  147. package/dist/types/loaders/api/api.d.ts +1 -0
  148. package/dist/types/loaders/api/api.d.ts.map +1 -1
  149. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  150. package/dist/types/loaders/configure/configure.d.ts +1 -0
  151. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  152. package/dist/types/loaders/micro-agent.d.ts +7 -1
  153. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  154. package/package.json +41 -12
  155. package/src/common/aggregate/aggregator.test.js +107 -0
  156. package/src/common/config/state/configurable.test.js +73 -0
  157. package/src/common/config/state/info.test.js +31 -0
  158. package/src/common/config/state/init.js +13 -12
  159. package/src/common/config/state/init.test.js +28 -0
  160. package/src/common/config/state/loader-config.test.js +21 -0
  161. package/src/common/config/state/runtime.js +0 -2
  162. package/src/common/config/state/runtime.test.js +21 -0
  163. package/src/common/constants/__mocks__/runtime.js +1 -1
  164. package/src/common/constants/runtime.js +1 -1
  165. package/src/common/constants/runtime.test.js +2 -2
  166. package/src/common/constants/shared-channel.js +1 -1
  167. package/src/common/deny-list/deny-list.js +2 -10
  168. package/src/common/drain/drain.js +1 -1
  169. package/src/common/drain/drain.test.js +74 -0
  170. package/src/common/event-emitter/contextual-ee.js +6 -6
  171. package/src/common/harvest/harvest-scheduler.js +2 -5
  172. package/src/common/harvest/harvest-scheduler.test.js +2 -6
  173. package/src/common/harvest/harvest.js +2 -6
  174. package/src/common/harvest/harvest.test.js +0 -2
  175. package/src/common/ids/id.test.js +6 -6
  176. package/src/common/serialize/bel-serializer.js +1 -1
  177. package/src/common/session/session-entity.component-test.js +3 -2
  178. package/src/common/session/session-entity.js +11 -9
  179. package/src/common/storage/first-party-cookies.js +5 -4
  180. package/src/common/storage/local-storage.js +3 -2
  181. package/src/common/timer/interaction-timer.component-test.js +52 -7
  182. package/src/common/timer/interaction-timer.js +15 -6
  183. package/src/common/timer/timer.test.js +0 -1
  184. package/src/common/timing/nav-timing.js +1 -1
  185. package/src/common/unload/eol.js +5 -31
  186. package/src/common/url/encode.test.js +1 -0
  187. package/src/common/util/__mocks__/invoke.js +1 -0
  188. package/src/common/util/data-size.test.js +0 -1
  189. package/src/common/util/feature-flags.js +15 -17
  190. package/src/common/util/feature-flags.test.js +4 -8
  191. package/src/common/util/invoke.js +1 -1
  192. package/src/common/util/obfuscate.js +3 -5
  193. package/src/common/util/submit-data.test.js +1 -1
  194. package/src/common/util/traverse.js +1 -0
  195. package/src/common/window/__mocks__/nreum.js +3 -1
  196. package/src/common/window/page-visibility.js +1 -2
  197. package/src/common/wrap/wrap-jsonp.js +1 -1
  198. package/src/features/ajax/aggregate/index.js +5 -7
  199. package/src/features/ajax/instrument/distributed-tracing.js +8 -8
  200. package/src/features/ajax/instrument/index.js +40 -17
  201. package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
  202. package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  203. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  204. package/src/features/jserrors/aggregate/index.js +4 -5
  205. package/src/features/metrics/aggregate/framework-detection.js +129 -8
  206. package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
  207. package/src/features/metrics/aggregate/index.js +22 -45
  208. package/src/features/metrics/instrument/index.js +1 -3
  209. package/src/features/page_action/aggregate/index.js +12 -13
  210. package/src/features/page_view_event/aggregate/index.js +1 -2
  211. package/src/features/page_view_event/instrument/index.js +2 -2
  212. package/src/features/page_view_timing/aggregate/index.js +7 -8
  213. package/src/features/session_replay/aggregate/index.component-test.js +3 -15
  214. package/src/features/session_replay/aggregate/index.js +2 -2
  215. package/src/features/session_trace/aggregate/index.js +6 -9
  216. package/src/features/spa/aggregate/index.js +14 -20
  217. package/src/features/spa/aggregate/interaction.js +0 -2
  218. package/src/features/spa/aggregate/serializer.js +1 -1
  219. package/src/features/utils/aggregate-base.js +5 -0
  220. package/src/features/utils/aggregate-base.test.js +2 -1
  221. package/src/features/utils/handler-cache.js +3 -2
  222. package/src/features/utils/instrument-base.js +25 -6
  223. package/src/features/utils/instrument-base.test.js +2 -2
  224. package/src/loaders/agent-base.js +11 -0
  225. package/src/loaders/agent.js +7 -7
  226. package/src/loaders/api/api.js +21 -4
  227. package/src/loaders/api/api.test.js +85 -0
  228. package/src/loaders/api/apiAsync.js +19 -20
  229. package/src/loaders/api/apiAsync.test.js +17 -0
  230. package/src/loaders/configure/configure.js +3 -0
  231. package/src/loaders/features/enabled-features.js +1 -1
  232. package/src/loaders/micro-agent.js +22 -4
  233. package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
  234. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
  235. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
  236. package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
  237. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  238. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
  239. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
  240. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
  241. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
  242. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
  243. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
  244. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
  245. package/src/features/metrics/aggregate/endpoint-map.js +0 -7
  246. package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  247. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
  248. package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
  249. package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
@@ -16,7 +16,6 @@ var _cleanUrl = require("../../../common/url/clean-url");
16
16
  var _handle = require("../../../common/event-emitter/handle");
17
17
  var _config = require("../../../common/config/config");
18
18
  var _constants = require("../constants");
19
- var _drain = require("../../../common/drain/drain");
20
19
  var _features = require("../../../loaders/features/features");
21
20
  var _aggregateBase = require("../../utils/aggregate-base");
22
21
  /*
@@ -51,7 +50,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
51
50
  });
52
51
 
53
52
  /* First Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
54
- if (_runtime.iOS_below16) {
53
+ if (_runtime.iOSBelow16) {
55
54
  try {
56
55
  if (!pageStartedHidden) {
57
56
  // see ios-version.js for detail on this following bug case; tldr: buffered flag doesn't work but getEntriesByType does
@@ -127,7 +126,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
127
126
  let {
128
127
  value
129
128
  } = _ref5;
130
- return this.cls = value;
129
+ this.cls = value;
131
130
  }, {
132
131
  reportAllChanges: true
133
132
  });
@@ -176,7 +175,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
176
175
  this.ee.on("drain-".concat(this.featureName), () => {
177
176
  this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
178
177
  });
179
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
178
+ this.drain();
180
179
  }
181
180
 
182
181
  // takes an attributes object and appends connection attributes if available
@@ -230,9 +229,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
230
229
  attrs.cls = this.cls;
231
230
  }
232
231
  this.timings.push({
233
- name: name,
234
- value: value,
235
- attrs: attrs
232
+ name,
233
+ value,
234
+ attrs
236
235
  });
237
236
  (0, _handle.handle)('pvtAdded', [name, value, attrs], undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
238
237
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.RRWEB_VERSION = exports.MAX_PAYLOAD_SIZE = exports.IDEAL_PAYLOAD_SIZE = exports.Aggregate = exports.AVG_COMPRESSION = void 0;
7
- var _drain = require("../../../common/drain/drain");
8
7
  var _registerHandler = require("../../../common/event-emitter/register-handler");
9
8
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
10
9
  var _constants = require("../constants");
@@ -14,6 +13,7 @@ var _sessionEntity = require("../../../common/session/session-entity");
14
13
  var _aggregateBase = require("../../utils/aggregate-base");
15
14
  var _sharedChannel = require("../../../common/constants/shared-channel");
16
15
  var _encode = require("../../../common/url/encode");
16
+ var _console = require("../../../common/util/console");
17
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /*
19
19
  * Copyright 2023 New Relic Corporation. All rights reserved.
@@ -135,7 +135,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
135
135
  return this.initializeRecording(flagOn, Math.random() < (0, _config.getConfigurationValue)(this.agentIdentifier, 'session_replay.errorSampleRate'), Math.random() < (0, _config.getConfigurationValue)(this.agentIdentifier, 'session_replay.sampleRate'));
136
136
  }).then(() => _sharedChannel.sharedChannel.onReplayReady(this.mode)); // notify watchers that replay started with the mode
137
137
 
138
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
138
+ this.drain();
139
139
  }
140
140
  }
141
141
 
@@ -268,7 +268,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
268
268
  /** Begin recording using configured recording lib */
269
269
  startRecording() {
270
270
  if (!recorder) {
271
- warn('Recording library was never imported');
271
+ (0, _console.warn)('Recording library was never imported');
272
272
  return this.abort();
273
273
  }
274
274
  this.recording = true;
@@ -10,7 +10,6 @@ var _parseUrl = require("../../../common/url/parse-url");
10
10
  var _config = require("../../../common/config/config");
11
11
  var _now = require("../../../common/timing/now");
12
12
  var _constants = require("../constants");
13
- var _drain = require("../../../common/drain/drain");
14
13
  var _handlerCache = require("../../utils/handler-cache");
15
14
  var _sessionEntity = require("../../../common/session/session-entity");
16
15
  var _replayMode = require("../../session_replay/replay-mode");
@@ -144,7 +143,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
144
143
  });
145
144
  mostRecentModeKnown = updatedTraceMode;
146
145
  });
147
- this.ee.on(_sessionEntity.SESSION_EVENTS.PAUSE, () => mostRecentModeKnown = sessionEntity.state.sessionTraceMode);
146
+ this.ee.on(_sessionEntity.SESSION_EVENTS.PAUSE, () => {
147
+ mostRecentModeKnown = sessionEntity.state.sessionTraceMode;
148
+ });
148
149
  if (!sessionEntity.isNew) {
149
150
  // inherit the same mode as existing session's Trace
150
151
  if (sessionEntity.state.sessionReplay === _sessionEntity.MODE.OFF) this.isStandalone = true;
@@ -216,7 +217,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
216
217
  }
217
218
  return operationalGate.settle(() => _this.processPVT(...args));
218
219
  }, this.featureName, this.ee);
219
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
220
+ this.drain();
220
221
  }
221
222
  startTracing(startupBuffer) {
222
223
  let dontStartHarvestYet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -340,8 +341,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
340
341
  const origin = this.evtOrigin(event.target, target);
341
342
  if (event.type in ignoredEvents.global) return true;
342
343
  if (!!ignoredEvents[origin] && ignoredEvents[origin].ignoreAll) return true;
343
- if (!!ignoredEvents[origin] && event.type in ignoredEvents[origin]) return true;
344
- return false;
344
+ return !!(!!ignoredEvents[origin] && event.type in ignoredEvents[origin]);
345
345
  }
346
346
  evtName(type) {
347
347
  switch (type) {
@@ -451,7 +451,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
451
451
  // limit the amount of pending data awaiting next harvest
452
452
  if (this.isStandalone || this.agentRuntime.session.state.sessionTraceMode !== _sessionEntity.MODE.ERROR) return;
453
453
  const openedSpace = this.trimSTNs(ERROR_MODE_SECONDS_WINDOW); // but maybe we could make some space by discarding irrelevant nodes if we're in sessioned Error mode
454
- if (openedSpace == 0) return;
454
+ if (openedSpace === 0) return;
455
455
  }
456
456
  if (this.isStandalone && (0, _now.now)() >= MAX_TRACE_DURATION) {
457
457
  return;
@@ -474,7 +474,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
474
474
  * This isn't exact since nodes go through some processing & EE handlers chain, but it's close enough as we still capture nodes whose duration overlaps the lookback window.
475
475
  * ASSUMPTION: all 'end' timings stored are relative to timeOrigin (DOMHighResTimeStamp) and not Unix epoch based. */
476
476
  let cutoffIdx = nodeList.findIndex(node => cutoffHighResTime <= node.e);
477
- if (cutoffIdx == 0) return;else if (cutoffIdx < 0) {
477
+ if (cutoffIdx === 0) return;else if (cutoffIdx < 0) {
478
478
  // whole list falls outside lookback window and is irrelevant
479
479
  cutoffIdx = nodeList.length;
480
480
  delete this.trace[nameCategory];
@@ -538,7 +538,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
538
538
  };
539
539
  function trivial(node) {
540
540
  const limit = 4;
541
- if (node && typeof node.e === 'number' && typeof node.s === 'number' && node.e - node.s < limit) return true;else return false;
541
+ return !!(node && typeof node.e === 'number' && typeof node.s === 'number' && node.e - node.s < limit);
542
542
  }
543
543
  }
544
544
  }
@@ -18,7 +18,6 @@ var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
18
18
  var _serializer = require("./serializer");
19
19
  var _contextualEe = require("../../../common/event-emitter/contextual-ee");
20
20
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
21
- var _drain = require("../../../common/drain/drain");
22
21
  var _features = require("../../../loaders/features/features");
23
22
  var _aggregateBase = require("../../utils/aggregate-base");
24
23
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -144,8 +143,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
144
143
 
145
144
  // register plugins
146
145
  var pluginApi = {
147
- getCurrentNode: getCurrentNode,
148
- setCurrentNode: setCurrentNode
146
+ getCurrentNode,
147
+ setCurrentNode
149
148
  };
150
149
  (0, _registerHandler.registerHandler)('spa-register', function (init) {
151
150
  if (typeof init === 'function') {
@@ -210,21 +209,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
210
209
  // If this event was emitted by an XHR, restore the node ID associated with
211
210
  // that XHR.
212
211
  setCurrentNode(baseEE.context(eventSource).spaNode);
213
- } else if (!state.currentNode) {
212
+ } else if (!state.currentNode && INTERACTION_EVENTS.indexOf(evName) !== -1) {
214
213
  // Otherwise, if no interaction is currently active, create a new node ID,
215
214
  // and let the aggregator know that we entered a new event handler callback
216
215
  // so that it has a chance to possibly start an interaction.
217
- if (INTERACTION_EVENTS.indexOf(evName) !== -1) {
218
- var ixn = new _interaction.Interaction(evName, this[FN_START], state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
216
+ var ixn = new _interaction.Interaction(evName, this[FN_START], state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
219
217
 
220
- // Store the interaction as prevInteraction in case it is prematurely discarded
221
- state.prevInteraction = ixn;
222
- setCurrentNode(ixn.root);
223
- if (evName === 'click') {
224
- var value = getActionText(ev.target);
225
- if (value) {
226
- state.currentNode.attrs.custom.actionText = value;
227
- }
218
+ // Store the interaction as prevInteraction in case it is prematurely discarded
219
+ state.prevInteraction = ixn;
220
+ setCurrentNode(ixn.root);
221
+ if (evName === 'click') {
222
+ var value = getActionText(ev.target);
223
+ if (value) {
224
+ state.currentNode.attrs.custom.actionText = value;
228
225
  }
229
226
  }
230
227
  }
@@ -506,7 +503,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
506
503
  }, this.featureName, promiseEE);
507
504
  (0, _registerHandler.registerHandler)(INTERACTION_API + 'get', function (t) {
508
505
  var interaction;
509
- if (state?.currentNode?.[INTERACTION]) interaction = this.ixn = state.currentNode[INTERACTION];else if (state?.prevNode?.end === null && state?.prevNode?.[INTERACTION]?.root?.[INTERACTION]?.eventName != 'initialPageLoad') interaction = this.ixn = state.prevNode[INTERACTION];else interaction = this.ixn = new _interaction.Interaction('api', t, state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
506
+ if (state?.currentNode?.[INTERACTION]) interaction = this.ixn = state.currentNode[INTERACTION];else if (state?.prevNode?.end === null && state?.prevNode?.[INTERACTION]?.root?.[INTERACTION]?.eventName !== 'initialPageLoad') interaction = this.ixn = state.prevNode[INTERACTION];else interaction = this.ixn = new _interaction.Interaction('api', t, state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
510
507
  if (!state.currentNode) {
511
508
  interaction.checkFinish();
512
509
  if (state.depth) setCurrentNode(interaction.root);
@@ -674,12 +671,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
674
671
  }
675
672
  function isEnabled() {
676
673
  var enabled = (0, _config.getConfigurationValue)(agentIdentifier, 'spa.enabled');
677
- if (enabled === false) {
678
- return false;
679
- }
680
- return true;
674
+ return enabled !== false;
681
675
  }
682
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
676
+ this.drain();
683
677
  }
684
678
  }
685
679
  exports.Aggregate = Aggregate;
@@ -8,7 +8,6 @@ var _config = require("../../../common/config/config");
8
8
  var _mapOwn = require("../../../common/util/map-own");
9
9
  var _contextualEe = require("../../../common/event-emitter/contextual-ee");
10
10
  var _interactionNode = require("./interaction-node");
11
- var _now = require("../../../common/timing/now");
12
11
  /*
13
12
  * Copyright 2020 New Relic Corporation. All rights reserved.
14
13
  * SPDX-License-Identifier: Apache-2.0
@@ -84,7 +83,6 @@ InteractionPrototype.finish = function finishInteraction() {
84
83
  var root = interaction.root;
85
84
  if (root.end !== null) return;
86
85
  var endTimestamp = Math.max(interaction.lastCb, interaction.lastFinish);
87
- var delta = (0, _now.now)() - endTimestamp;
88
86
  var attrs = root.attrs;
89
87
  var customAttrs = attrs.custom;
90
88
  if (this.onFinished) {
@@ -126,7 +126,7 @@ class Serializer extends _sharedContext.SharedContext {
126
126
  // (since its the same as interaction.start)
127
127
  // and limit to just the first 20 values we know about
128
128
  (0, _mapOwn.mapOwn)(navTiming.slice(1, 21), function (i, v) {
129
- if (v !== void 0) {
129
+ if (v !== undefined) {
130
130
  navTimingNode += seperator + (0, _belSerializer.numeric)(v - prev);
131
131
  seperator = ',';
132
132
  prev = v;
@@ -9,6 +9,7 @@ var _featureBase = require("./feature-base");
9
9
  var _config = require("../../common/config/config");
10
10
  var _configure = require("../../loaders/configure/configure");
11
11
  var _nreum = require("../../common/window/nreum");
12
+ var _drain = require("../../common/drain/drain");
12
13
  class AggregateBase extends _featureBase.FeatureBase {
13
14
  constructor() {
14
15
  super(...arguments);
@@ -26,6 +27,9 @@ class AggregateBase extends _featureBase.FeatureBase {
26
27
  (0, _registerHandler.registerHandler)("rumresp-".concat(fName), isOn => resolve(isOn), this.featureName, this.ee);
27
28
  })));
28
29
  }
30
+ drain() {
31
+ (0, _drain.drain)(this.agentIdentifier, this.featureName);
32
+ }
29
33
 
30
34
  /**
31
35
  * Checks for additional `jsAttributes` items to support backward compatibility with implementations of the agent where
@@ -42,7 +42,9 @@ class HandlerCache {
42
42
  * @returns {void}
43
43
  */
44
44
  settle(handler) {
45
- if (this.#decision === false) return;else if (this.#decision === undefined) this.#cache.push(handler);else handler();
45
+ if (this.#decision === false) {
46
+ // Do nothing
47
+ } else if (this.#decision === undefined) this.#cache.push(handler);else handler();
46
48
  }
47
49
 
48
50
  /**
@@ -37,18 +37,24 @@ class InstrumentBase extends _featureBase.FeatureBase {
37
37
  this.auto = auto;
38
38
 
39
39
  /** @type {Function | undefined} This should be set by any derived Instrument class if it has things to do when feature fails or is killed. */
40
- this.abortHandler;
40
+ this.abortHandler = undefined;
41
+
41
42
  /**
42
43
  * @type {Class} Holds the reference to the feature's aggregate module counterpart, if and after it has been initialized. This may not be assigned until after page loads!
43
44
  * The only purpose of this for now is to expose it to the NREUM interface, as the feature's instrument instance is already exposed.
44
45
  */
45
- this.featAggregate;
46
+ this.featAggregate = undefined;
47
+
46
48
  /**
47
49
  * @type {Promise} Assigned immediately after @see importAggregator runs. Serves as a signal for when the inner async fn finishes execution. Useful for features to await
48
50
  * one another if there are inter-features dependencies.
49
51
  */
50
- this.onAggregateImported;
51
- if (auto) (0, _drain.registerDrain)(agentIdentifier, featureName);
52
+ this.onAggregateImported = undefined;
53
+
54
+ /** used in conjunction with newrelic.start() to defer harvesting in features */
55
+ if ((0, _config.getConfigurationValue)(this.agentIdentifier, "".concat(this.featureName, ".autoStart")) === false) this.auto = false;
56
+ /** if the feature requires opt-in (!auto-start), it will get registered once the api has been called */
57
+ if (this.auto) (0, _drain.registerDrain)(agentIdentifier, featureName);
52
58
  }
53
59
 
54
60
  /**
@@ -59,7 +65,19 @@ class InstrumentBase extends _featureBase.FeatureBase {
59
65
  */
60
66
  importAggregator() {
61
67
  let argsObjFromInstrument = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
- if (this.featAggregate || !this.auto) return;
68
+ if (this.featAggregate) return;
69
+ if (!this.auto) {
70
+ // this feature requires an opt in...
71
+ // wait for API to be called
72
+ this.ee.on("".concat(this.featureName, "-opt-in"), () => {
73
+ // register the feature to drain only once the API has been called, it will drain when importAggregator finishes for all the features
74
+ // called by the api in that cycle
75
+ (0, _drain.registerDrain)(this.agentIdentifier, this.featureName);
76
+ this.auto = true;
77
+ this.importAggregator();
78
+ });
79
+ return;
80
+ }
63
81
  const enableSessionTracking = _runtime.isBrowserScope && (0, _config.getConfigurationValue)(this.agentIdentifier, 'privacy.cookies_enabled') === true;
64
82
  let loadedSuccessfully;
65
83
  this.onAggregateImported = new Promise(resolve => {
@@ -80,7 +98,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
80
98
  }
81
99
 
82
100
  /**
83
- * Note this try-catch differs from the one in Agent.start() in that it's placed later in a page's lifecycle and
101
+ * Note this try-catch differs from the one in Agent.run() in that it's placed later in a page's lifecycle and
84
102
  * it's only responsible for aborting its one specific feature, rather than all.
85
103
  */
86
104
  try {
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.AgentBase = void 0;
7
7
  var _console = require("../common/util/console");
8
+ /* eslint-disable n/handle-callback-err */
9
+
8
10
  class AgentBase {
9
11
  /**
10
12
  * Reports a browser PageAction event along with a name and optional attributes.
@@ -95,5 +97,14 @@ class AgentBase {
95
97
  addRelease(name, id) {
96
98
  (0, _console.warn)('Call to agent api addRelease failed. The agent is not currently initialized.');
97
99
  }
100
+
101
+ /**
102
+ * Starts a set of agent features if not running in "autoStart" mode
103
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
104
+ * @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
105
+ */
106
+ start(featureNames) {
107
+ (0, _console.warn)('Call to agent api addRelease failed. The agent is not currently initialized.');
108
+ }
98
109
  }
99
110
  exports.AgentBase = AgentBase;
@@ -52,7 +52,7 @@ class Agent extends _agentBase.AgentBase {
52
52
  // Future work is being planned to evaluate removing this behavior from the backend, but for now we must ensure this call is made
53
53
  this.desiredFeatures.add(_instrument.Instrument);
54
54
  Object.assign(this, (0, _configure.configure)(this.agentIdentifier, options, options.loaderType || 'agent'));
55
- this.start();
55
+ this.run();
56
56
  }
57
57
  get config() {
58
58
  return {
@@ -62,20 +62,20 @@ class Agent extends _agentBase.AgentBase {
62
62
  runtime: (0, _config.getRuntime)(this.agentIdentifier)
63
63
  };
64
64
  }
65
- start() {
65
+ run() {
66
66
  const NR_FEATURES_REF_NAME = 'features';
67
67
  // Attempt to initialize all the requested features (sequentially in prio order & synchronously), with any failure aborting the whole process.
68
68
  try {
69
69
  const enabledFeatures = (0, _enabledFeatures.getEnabledFeatures)(this.agentIdentifier);
70
70
  const featuresToStart = [...this.desiredFeatures];
71
71
  featuresToStart.sort((a, b) => _features.featurePriority[a.featureName] - _features.featurePriority[b.featureName]);
72
- featuresToStart.forEach(f => {
72
+ featuresToStart.forEach(InstrumentCtor => {
73
73
  // pageViewEvent must be enabled because RUM calls are not optional. See comment in constructor and PR 428.
74
- if (enabledFeatures[f.featureName] || f.featureName === _features.FEATURE_NAMES.pageViewEvent) {
75
- const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(f.featureName);
74
+ if (enabledFeatures[InstrumentCtor.featureName] || InstrumentCtor.featureName === _features.FEATURE_NAMES.pageViewEvent) {
75
+ const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(InstrumentCtor.featureName);
76
76
  const hasAllDeps = dependencies.every(x => enabledFeatures[x]);
77
- if (!hasAllDeps) (0, _console.warn)("".concat(f.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..."));
78
- this.features[f.featureName] = new f(this.agentIdentifier, this.sharedAggregator);
77
+ 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..."));
78
+ this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator);
79
79
  }
80
80
  });
81
81
  (0, _nreum.gosNREUMInitializedAgents)(this.agentIdentifier, this.features, NR_FEATURES_REF_NAME);
@@ -26,7 +26,7 @@ const CUSTOM_ATTR_GROUP = 'CUSTOM/'; // the subgroup items should be stored unde
26
26
  exports.CUSTOM_ATTR_GROUP = CUSTOM_ATTR_GROUP;
27
27
  function setTopLevelCallers() {
28
28
  const nr = (0, _nreum.gosCDN)();
29
- const funcs = ['setErrorHandler', 'finished', 'addToTrace', 'inlineHit', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion'];
29
+ const funcs = ['setErrorHandler', 'finished', 'addToTrace', 'inlineHit', 'addRelease', 'addPageAction', 'setCurrentRouteName', 'setPageViewName', 'setCustomAttribute', 'interaction', 'noticeError', 'setUserId', 'setApplicationVersion', 'start'];
30
30
  funcs.forEach(f => {
31
31
  nr[f] = function () {
32
32
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -58,7 +58,9 @@ function setAPI(agentIdentifier, forceDrain) {
58
58
  var spaPrefix = prefix + 'ixn-';
59
59
 
60
60
  // Setup stub functions that queue calls for later processing.
61
- asyncApiFns.forEach(fnName => apiInterface[fnName] = apiCall(prefix, fnName, true, 'api'));
61
+ asyncApiFns.forEach(fnName => {
62
+ apiInterface[fnName] = apiCall(prefix, fnName, true, 'api');
63
+ });
62
64
  apiInterface.addPageAction = apiCall(prefix, 'addPageAction', true, _features.FEATURE_NAMES.pageAction);
63
65
  apiInterface.setCurrentRouteName = apiCall(prefix, 'routeName', true, _features.FEATURE_NAMES.spa);
64
66
  apiInterface.setPageViewName = function (name, host) {
@@ -128,6 +130,21 @@ function setAPI(agentIdentifier, forceDrain) {
128
130
  }
129
131
  return appendJsAttribute('application.version', value, 'setApplicationVersion', false);
130
132
  };
133
+ apiInterface.start = features => {
134
+ try {
135
+ const featNames = Object.values(_features.FEATURE_NAMES);
136
+ if (features === undefined) features = featNames;else {
137
+ features = Array.isArray(features) && features.length ? features : [features];
138
+ if (features.some(f => !featNames.includes(f))) return (0, _console.warn)("Invalid feature name supplied. Acceptable feature names are: ".concat(featNames));
139
+ if (!features.includes(_features.FEATURE_NAMES.pageViewEvent)) features.push(_features.FEATURE_NAMES.pageViewEvent);
140
+ }
141
+ features.forEach(feature => {
142
+ instanceEE.emit("".concat(feature, "-opt-in"));
143
+ });
144
+ } catch (err) {
145
+ (0, _console.warn)('An unexpected issue occurred', err);
146
+ }
147
+ };
131
148
  apiInterface.interaction = function () {
132
149
  return new InteractionHandle().get();
133
150
  };
@@ -154,14 +171,14 @@ function setAPI(agentIdentifier, forceDrain) {
154
171
  };
155
172
  }
156
173
  };
157
- void ['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
174
+ ['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
158
175
  InteractionApiProto[name] = apiCall(spaPrefix, name, undefined, _features.FEATURE_NAMES.spa);
159
176
  });
160
177
  function apiCall(prefix, name, notSpa, bufferGroup) {
161
178
  return function () {
162
179
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/' + name + '/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
163
180
  if (bufferGroup) (0, _handle.handle)(prefix + name, [(0, _now.now)(), ...arguments], notSpa ? null : this, bufferGroup, instanceEE); // no bufferGroup means only the SM is emitted
164
- return notSpa ? void 0 : this;
181
+ return notSpa ? undefined : this;
165
182
  };
166
183
  }
167
184
  apiInterface.noticeError = function (err, customAttributes) {
@@ -21,10 +21,10 @@ function setAPI(agentIdentifier) {
21
21
  var scheme = (0, _config.getConfigurationValue)(agentIdentifier, 'ssl') === false ? 'http' : 'https';
22
22
  var api = {
23
23
  finished: (0, _invoke.single)(finished),
24
- setErrorHandler: setErrorHandler,
25
- addToTrace: addToTrace,
26
- inlineHit: inlineHit,
27
- addRelease: addRelease
24
+ setErrorHandler,
25
+ addToTrace,
26
+ inlineHit,
27
+ addRelease
28
28
  };
29
29
 
30
30
  // Hook all of the api functions up to the queues/stubs created in loader/api.js
@@ -60,29 +60,28 @@ function setAPI(agentIdentifier) {
60
60
  (0, _handle.handle)('bstApi', [report], undefined, _features.FEATURE_NAMES.sessionTrace, instanceEE);
61
61
  }
62
62
 
63
- // NREUM.inlineHit(request_name, queue_time, app_time, total_be_time, dom_time, fe_time)
63
+ // NREUM.inlineHit(requestName, queueTime, appTime, totalBackEndTime, domTime, frontEndTime)
64
64
  //
65
- // request_name - the 'web page' name or service name
66
- // queue_time - the amount of time spent in the app tier queue
67
- // app_time - the amount of time spent in the application code
68
- // total_be_time - the total roundtrip time of the remote service call
69
- // dom_time - the time spent processing the result of the service call (or user defined)
70
- // fe_time - the time spent rendering the result of the service call (or user defined)
71
- function inlineHit(t, request_name, queue_time, app_time, total_be_time, dom_time, fe_time) {
65
+ // requestName - the 'web page' name or service name
66
+ // queueTime - the amount of time spent in the app tier queue
67
+ // appTime - the amount of time spent in the application code
68
+ // totalBackEndTime - the total roundtrip time of the remote service call
69
+ // domTime - the time spent processing the result of the service call (or user defined)
70
+ // frontEndTime - the time spent rendering the result of the service call (or user defined)
71
+ function inlineHit(t, requestName, queueTime, appTime, totalBackEndTime, domTime, frontEndTime) {
72
72
  if (!_runtime.isBrowserScope) return;
73
- request_name = window.encodeURIComponent(request_name);
73
+ requestName = window.encodeURIComponent(requestName);
74
74
  cycle += 1;
75
75
  const agentInfo = (0, _config.getInfo)(agentIdentifier);
76
- const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
77
76
  if (!agentInfo.beacon) return;
78
77
  var url = scheme + '://' + agentInfo.beacon + '/1/' + agentInfo.licenseKey;
79
78
  url += '?a=' + agentInfo.applicationID + '&';
80
- url += 't=' + request_name + '&';
81
- url += 'qt=' + ~~queue_time + '&';
82
- url += 'ap=' + ~~app_time + '&';
83
- url += 'be=' + ~~total_be_time + '&';
84
- url += 'dc=' + ~~dom_time + '&';
85
- url += 'fe=' + ~~fe_time + '&';
79
+ url += 't=' + requestName + '&';
80
+ url += 'qt=' + ~~queueTime + '&';
81
+ url += 'ap=' + ~~appTime + '&';
82
+ url += 'be=' + ~~totalBackEndTime + '&';
83
+ url += 'dc=' + ~~domTime + '&';
84
+ url += 'fe=' + ~~frontEndTime + '&';
86
85
  url += 'c=' + cycle;
87
86
  submitData.xhr({
88
87
  url
@@ -13,6 +13,7 @@ function configure(agentIdentifier) {
13
13
  let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
14
  let loaderType = arguments.length > 2 ? arguments[2] : undefined;
15
15
  let forceDrain = arguments.length > 3 ? arguments[3] : undefined;
16
+ // eslint-disable-next-line camelcase
16
17
  let {
17
18
  init,
18
19
  info,
@@ -26,9 +27,11 @@ function configure(agentIdentifier) {
26
27
  if (!info) {
27
28
  init = nr.init;
28
29
  info = nr.info;
30
+ // eslint-disable-next-line camelcase
29
31
  loader_config = nr.loader_config;
30
32
  }
31
33
  (0, _config.setConfiguration)(agentIdentifier, init || {});
34
+ // eslint-disable-next-line camelcase
32
35
  (0, _config.setLoaderConfig)(agentIdentifier, loader_config || {});
33
36
  info.jsAttributes ??= {};
34
37
  if (_runtime.isWorkerScope) {
@@ -44,7 +44,14 @@ class MicroAgent extends _agentBase.AgentBase {
44
44
  isolatedBacklog: true
45
45
  }
46
46
  }, options.loaderType || 'micro-agent'));
47
- this.start();
47
+
48
+ /**
49
+ * Starts a set of agent features if not running in "autoStart" mode
50
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/start/}
51
+ * @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
52
+ */
53
+ this.start = features => this.run(features);
54
+ this.run(nonAutoFeatures.filter(featureName => (0, _config.getConfigurationValue)(agentIdentifier, "".concat(featureName, ".autoStart"))));
48
55
  }
49
56
  get config() {
50
57
  return {
@@ -54,7 +61,17 @@ class MicroAgent extends _agentBase.AgentBase {
54
61
  runtime: (0, _config.getRuntime)(this.agentIdentifier)
55
62
  };
56
63
  }
57
- start() {
64
+ run(features) {
65
+ try {
66
+ const featNames = nonAutoFeatures;
67
+ if (features === undefined) features = featNames;else {
68
+ features = Array.isArray(features) && features.length ? features : [features];
69
+ if (features.some(f => !featNames.includes(f))) return (0, _console.warn)("Invalid feature name supplied. Acceptable feature names are: ".concat(featNames));
70
+ if (!features.includes(_features.FEATURE_NAMES.pageViewEvent)) features.push(_features.FEATURE_NAMES.pageViewEvent);
71
+ }
72
+ } catch (err) {
73
+ (0, _console.warn)('An unexpected issue occurred', err);
74
+ }
58
75
  try {
59
76
  const enabledFeatures = (0, _enabledFeatures.getEnabledFeatures)(this.agentIdentifier);
60
77
  try {
@@ -66,7 +83,7 @@ class MicroAgent extends _agentBase.AgentBase {
66
83
  (0, _load.onWindowLoad)(() => {
67
84
  // these features do not import an "instrument" file, meaning they are only hooked up to the API.
68
85
  nonAutoFeatures.forEach(f => {
69
- if (enabledFeatures[f]) {
86
+ if (enabledFeatures[f] && features.includes(f)) {
70
87
  Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(_ref => {
71
88
  let {
72
89
  lazyFeatureLoader