@newrelic/browser-agent 1.237.1 → 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 (307) 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 +3 -9
  8. package/dist/cjs/common/drain/drain.js +1 -1
  9. package/dist/cjs/common/event-emitter/contextual-ee.js +24 -32
  10. package/dist/cjs/common/event-emitter/event-context.js +12 -0
  11. package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
  12. package/dist/cjs/common/harvest/harvest.js +4 -7
  13. package/dist/cjs/common/ids/bundle-id.js +19 -0
  14. package/dist/cjs/common/serialize/bel-serializer.js +1 -1
  15. package/dist/cjs/common/session/session-entity.js +16 -12
  16. package/dist/cjs/common/storage/first-party-cookies.js +5 -4
  17. package/dist/cjs/common/storage/local-storage.js +3 -2
  18. package/dist/cjs/common/timer/interaction-timer.js +14 -6
  19. package/dist/cjs/common/timing/nav-timing.js +1 -1
  20. package/dist/cjs/common/unload/eol.js +4 -30
  21. package/dist/cjs/common/util/feature-flags.js +14 -15
  22. package/dist/cjs/common/util/invoke.js +3 -1
  23. package/dist/cjs/common/util/obfuscate.js +3 -5
  24. package/dist/cjs/common/util/traverse.js +1 -0
  25. package/dist/cjs/common/window/page-visibility.js +1 -2
  26. package/dist/cjs/common/wrap/wrap-events.js +3 -2
  27. package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
  28. package/dist/cjs/common/wrap/wrap-function.js +15 -46
  29. package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
  30. package/dist/cjs/common/wrap/wrap-mutation.js +1 -2
  31. package/dist/cjs/common/wrap/wrap-promise.js +2 -3
  32. package/dist/cjs/common/wrap/wrap-xhr.js +23 -27
  33. package/dist/cjs/features/ajax/aggregate/index.js +5 -7
  34. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -12
  35. package/dist/cjs/features/ajax/instrument/index.js +66 -24
  36. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
  37. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  38. package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
  39. package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
  40. package/dist/cjs/features/metrics/aggregate/index.js +20 -37
  41. package/dist/cjs/features/metrics/instrument/index.js +0 -2
  42. package/dist/cjs/features/page_action/aggregate/index.js +17 -19
  43. package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
  44. package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
  45. package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
  46. package/dist/cjs/features/session_replay/aggregate/index.js +5 -3
  47. package/dist/cjs/features/session_trace/aggregate/index.js +22 -16
  48. package/dist/cjs/features/spa/aggregate/index.js +14 -20
  49. package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
  50. package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
  51. package/dist/cjs/features/utils/aggregate-base.js +4 -0
  52. package/dist/cjs/features/utils/handler-cache.js +3 -1
  53. package/dist/cjs/features/utils/instrument-base.js +24 -6
  54. package/dist/cjs/loaders/agent-base.js +23 -0
  55. package/dist/cjs/loaders/agent.js +7 -7
  56. package/dist/cjs/loaders/api/api.js +34 -4
  57. package/dist/cjs/loaders/api/apiAsync.js +19 -20
  58. package/dist/cjs/loaders/api/interaction-types.js +11 -4
  59. package/dist/cjs/loaders/configure/configure.js +3 -0
  60. package/dist/cjs/loaders/micro-agent.js +20 -3
  61. package/dist/esm/common/config/state/init.js +21 -13
  62. package/dist/esm/common/config/state/runtime.js +0 -4
  63. package/dist/esm/common/constants/env.cdn.js +1 -1
  64. package/dist/esm/common/constants/env.npm.js +1 -1
  65. package/dist/esm/common/constants/runtime.js +1 -1
  66. package/dist/esm/common/constants/shared-channel.js +3 -1
  67. package/dist/esm/common/deny-list/deny-list.js +3 -9
  68. package/dist/esm/common/drain/drain.js +1 -1
  69. package/dist/esm/common/event-emitter/contextual-ee.js +22 -29
  70. package/dist/esm/common/event-emitter/event-context.js +5 -0
  71. package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
  72. package/dist/esm/common/harvest/harvest.js +4 -7
  73. package/dist/esm/common/ids/bundle-id.js +13 -0
  74. package/dist/esm/common/serialize/bel-serializer.js +1 -1
  75. package/dist/esm/common/session/session-entity.js +16 -12
  76. package/dist/esm/common/storage/first-party-cookies.js +5 -4
  77. package/dist/esm/common/storage/local-storage.js +3 -2
  78. package/dist/esm/common/timer/interaction-timer.js +14 -6
  79. package/dist/esm/common/timing/nav-timing.js +1 -1
  80. package/dist/esm/common/unload/eol.js +5 -31
  81. package/dist/esm/common/util/feature-flags.js +14 -15
  82. package/dist/esm/common/util/invoke.js +3 -1
  83. package/dist/esm/common/util/obfuscate.js +3 -5
  84. package/dist/esm/common/util/traverse.js +1 -0
  85. package/dist/esm/common/window/page-visibility.js +1 -2
  86. package/dist/esm/common/wrap/wrap-events.js +4 -3
  87. package/dist/esm/common/wrap/wrap-fetch.js +2 -4
  88. package/dist/esm/common/wrap/wrap-function.js +15 -44
  89. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  90. package/dist/esm/common/wrap/wrap-mutation.js +2 -3
  91. package/dist/esm/common/wrap/wrap-promise.js +3 -4
  92. package/dist/esm/common/wrap/wrap-xhr.js +23 -27
  93. package/dist/esm/features/ajax/aggregate/index.js +5 -7
  94. package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -12
  95. package/dist/esm/features/ajax/instrument/index.js +67 -25
  96. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
  97. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  98. package/dist/esm/features/jserrors/aggregate/index.js +4 -5
  99. package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
  100. package/dist/esm/features/metrics/aggregate/index.js +22 -39
  101. package/dist/esm/features/metrics/instrument/index.js +1 -3
  102. package/dist/esm/features/page_action/aggregate/index.js +17 -19
  103. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  104. package/dist/esm/features/page_view_event/instrument/index.js +4 -2
  105. package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
  106. package/dist/esm/features/session_replay/aggregate/index.js +4 -2
  107. package/dist/esm/features/session_trace/aggregate/index.js +22 -16
  108. package/dist/esm/features/spa/aggregate/index.js +14 -20
  109. package/dist/esm/features/spa/aggregate/interaction.js +0 -2
  110. package/dist/esm/features/spa/aggregate/serializer.js +1 -1
  111. package/dist/esm/features/utils/aggregate-base.js +4 -0
  112. package/dist/esm/features/utils/handler-cache.js +3 -1
  113. package/dist/esm/features/utils/instrument-base.js +24 -6
  114. package/dist/esm/loaders/agent-base.js +23 -0
  115. package/dist/esm/loaders/agent.js +7 -7
  116. package/dist/esm/loaders/api/api.js +34 -4
  117. package/dist/esm/loaders/api/apiAsync.js +19 -20
  118. package/dist/esm/loaders/api/interaction-types.js +11 -4
  119. package/dist/esm/loaders/configure/configure.js +3 -0
  120. package/dist/esm/loaders/features/enabled-features.js +1 -1
  121. package/dist/esm/loaders/micro-agent.js +21 -4
  122. package/dist/types/common/config/state/init.d.ts.map +1 -1
  123. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  124. package/dist/types/common/constants/runtime.d.ts +1 -1
  125. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  126. package/dist/types/common/event-emitter/contextual-ee.d.ts +22 -2
  127. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
  128. package/dist/types/common/event-emitter/event-context.d.ts +5 -0
  129. package/dist/types/common/event-emitter/event-context.d.ts.map +1 -0
  130. package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
  131. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  132. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  133. package/dist/types/common/ids/bundle-id.d.ts +5 -0
  134. package/dist/types/common/ids/bundle-id.d.ts.map +1 -0
  135. package/dist/types/common/session/session-entity.d.ts +12 -15
  136. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  137. package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
  138. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
  139. package/dist/types/common/storage/local-storage.d.ts.map +1 -1
  140. package/dist/types/common/timer/interaction-timer.d.ts +3 -0
  141. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  142. package/dist/types/common/unload/eol.d.ts +1 -2
  143. package/dist/types/common/unload/eol.d.ts.map +1 -1
  144. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  145. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  146. package/dist/types/common/util/traverse.d.ts.map +1 -1
  147. package/dist/types/common/window/nreum.d.ts +2 -2
  148. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  149. package/dist/types/common/wrap/wrap-events.d.ts.map +1 -1
  150. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  151. package/dist/types/common/wrap/wrap-function.d.ts +1 -19
  152. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
  153. package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
  154. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
  155. package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
  156. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  157. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +1 -1
  158. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
  159. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  160. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
  161. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  162. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  163. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -1
  164. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  165. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  166. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  167. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  168. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  169. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  170. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  171. package/dist/types/features/session_trace/aggregate/index.d.ts +5 -0
  172. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  173. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  174. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  175. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  176. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  177. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  178. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  179. package/dist/types/loaders/agent-base.d.ts +15 -0
  180. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  181. package/dist/types/loaders/agent.d.ts +1 -1
  182. package/dist/types/loaders/agent.d.ts.map +1 -1
  183. package/dist/types/loaders/api/api.d.ts +7 -0
  184. package/dist/types/loaders/api/api.d.ts.map +1 -1
  185. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  186. package/dist/types/loaders/api/interaction-types.d.ts +18 -7
  187. package/dist/types/loaders/api/interaction-types.d.ts.map +1 -1
  188. package/dist/types/loaders/configure/configure.d.ts +2 -0
  189. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  190. package/dist/types/loaders/features/features.d.ts +9 -9
  191. package/dist/types/loaders/micro-agent.d.ts +7 -1
  192. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  193. package/package.json +62 -38
  194. package/src/common/aggregate/aggregator.test.js +107 -0
  195. package/src/common/config/state/configurable.test.js +73 -0
  196. package/src/common/config/state/info.test.js +31 -0
  197. package/src/common/config/state/init.js +13 -12
  198. package/src/common/config/state/init.test.js +28 -0
  199. package/src/common/config/state/loader-config.test.js +21 -0
  200. package/src/common/config/state/runtime.js +0 -2
  201. package/src/common/config/state/runtime.test.js +21 -0
  202. package/src/common/constants/__mocks__/runtime.js +1 -1
  203. package/src/common/constants/runtime.js +1 -1
  204. package/src/common/constants/runtime.test.js +2 -2
  205. package/src/common/constants/shared-channel.js +1 -1
  206. package/src/common/deny-list/deny-list.js +3 -11
  207. package/src/common/deny-list/deny-list.test.js +103 -30
  208. package/src/common/drain/drain.js +1 -1
  209. package/src/common/drain/drain.test.js +74 -0
  210. package/src/common/event-emitter/{contextual-ee.test.js → contextual-ee.component-test.js} +15 -32
  211. package/src/common/event-emitter/contextual-ee.js +26 -37
  212. package/src/common/event-emitter/event-context.js +5 -0
  213. package/src/common/harvest/harvest-scheduler.js +2 -5
  214. package/src/common/harvest/harvest-scheduler.test.js +2 -6
  215. package/src/common/harvest/harvest.js +4 -7
  216. package/src/common/harvest/harvest.test.js +1 -3
  217. package/src/common/ids/__mocks__/bundle-id.js +2 -0
  218. package/src/common/ids/__mocks__/unique-id.js +17 -0
  219. package/src/common/ids/bundle-id.js +13 -0
  220. package/src/common/ids/id.test.js +6 -6
  221. package/src/common/serialize/bel-serializer.js +1 -1
  222. package/src/common/session/session-entity.component-test.js +3 -2
  223. package/src/common/session/session-entity.js +11 -9
  224. package/src/common/storage/first-party-cookies.js +5 -4
  225. package/src/common/storage/local-storage.js +3 -2
  226. package/src/common/timer/interaction-timer.component-test.js +52 -7
  227. package/src/common/timer/interaction-timer.js +15 -6
  228. package/src/common/timer/timer.test.js +0 -1
  229. package/src/common/timing/nav-timing.js +1 -1
  230. package/src/common/unload/eol.js +5 -31
  231. package/src/common/url/__mocks__/parse-url.js +15 -0
  232. package/src/common/url/{encode.component-test.js → encode.test.js} +1 -0
  233. package/src/common/util/__mocks__/get-or-set.js +5 -0
  234. package/src/common/util/__mocks__/invoke.js +1 -0
  235. package/src/common/util/data-size.test.js +0 -1
  236. package/src/common/util/feature-flags.js +15 -17
  237. package/src/common/util/feature-flags.test.js +4 -8
  238. package/src/common/util/invoke.js +1 -1
  239. package/src/common/util/obfuscate.js +3 -5
  240. package/src/common/util/submit-data.test.js +1 -1
  241. package/src/common/util/traverse.js +1 -0
  242. package/src/common/window/__mocks__/nreum.js +12 -0
  243. package/src/common/window/page-visibility.js +1 -2
  244. package/src/common/wrap/wrap-events.js +4 -3
  245. package/src/common/wrap/wrap-fetch.js +2 -4
  246. package/src/common/wrap/wrap-function.js +16 -44
  247. package/src/common/wrap/wrap-jsonp.js +1 -1
  248. package/src/common/wrap/wrap-mutation.js +2 -3
  249. package/src/common/wrap/{wrap-promise.test.js → wrap-promise.component-test.js} +2 -32
  250. package/src/common/wrap/wrap-promise.js +3 -4
  251. package/src/common/wrap/wrap-xhr.js +24 -28
  252. package/src/features/ajax/aggregate/index.js +5 -7
  253. package/src/features/ajax/instrument/distributed-tracing.js +8 -12
  254. package/src/features/ajax/instrument/distributed-tracing.test.js +375 -0
  255. package/src/features/ajax/instrument/index.js +62 -27
  256. package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
  257. package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  258. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  259. package/src/features/jserrors/aggregate/index.js +4 -5
  260. package/src/features/metrics/aggregate/framework-detection.js +129 -8
  261. package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
  262. package/src/features/metrics/aggregate/index.js +22 -45
  263. package/src/features/metrics/instrument/index.js +1 -3
  264. package/src/features/page_action/aggregate/index.js +12 -13
  265. package/src/features/page_view_event/aggregate/index.js +1 -2
  266. package/src/features/page_view_event/instrument/index.js +2 -2
  267. package/src/features/page_view_timing/aggregate/index.js +7 -8
  268. package/src/features/session_replay/aggregate/index.component-test.js +3 -15
  269. package/src/features/session_replay/aggregate/index.js +4 -2
  270. package/src/features/session_trace/aggregate/index.js +22 -16
  271. package/src/features/spa/aggregate/index.js +14 -20
  272. package/src/features/spa/aggregate/interaction.js +0 -2
  273. package/src/features/spa/aggregate/serializer.js +1 -1
  274. package/src/features/utils/aggregate-base.js +5 -0
  275. package/src/features/utils/aggregate-base.test.js +2 -1
  276. package/src/features/utils/handler-cache.js +3 -2
  277. package/src/features/utils/instrument-base.js +25 -6
  278. package/src/features/utils/instrument-base.test.js +2 -2
  279. package/src/loaders/agent-base.js +23 -0
  280. package/src/loaders/agent.js +7 -7
  281. package/src/loaders/api/api.component-test.js +45 -0
  282. package/src/loaders/api/api.js +34 -4
  283. package/src/loaders/api/api.test.js +85 -0
  284. package/src/loaders/api/apiAsync.js +19 -20
  285. package/src/loaders/api/apiAsync.test.js +17 -0
  286. package/src/loaders/api/interaction-types.js +11 -4
  287. package/src/loaders/configure/configure.js +3 -0
  288. package/src/loaders/features/enabled-features.js +1 -1
  289. package/src/loaders/micro-agent.js +22 -4
  290. package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
  291. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
  292. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
  293. package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
  294. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  295. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
  296. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
  297. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
  298. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
  299. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
  300. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
  301. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
  302. package/src/features/metrics/aggregate/endpoint-map.js +0 -7
  303. package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  304. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
  305. package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
  306. package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
  307. /package/src/common/url/{protocol.component-test.js → protocol.test.js} +0 -0
@@ -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.
@@ -56,6 +58,18 @@ class AgentBase {
56
58
  (0, _console.warn)('Call to agent api setUserId failed. The js errors feature is not currently initialized.');
57
59
  }
58
60
 
61
+ /**
62
+ * Adds a user-defined application version string to subsequent events on the page.
63
+ * This decorates all payloads with an attribute of `application.version` which is queryable in NR1.
64
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setapplicationversion/}
65
+ * @param {string|null} value A string identifier for the application version, useful for
66
+ * tying all browser events to a specific release tag. The value parameter does not
67
+ * have to be unique. Passing a null value unsets any existing value.
68
+ */
69
+ setApplicationVersion(value) {
70
+ (0, _console.warn)('Call to agent api setApplicationVersion failed. The agent is not currently initialized.');
71
+ }
72
+
59
73
  /**
60
74
  * Allows selective ignoring and grouping of known errors that the browser agent captures.
61
75
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/seterrorhandler/}
@@ -83,5 +97,14 @@ class AgentBase {
83
97
  addRelease(name, id) {
84
98
  (0, _console.warn)('Call to agent api addRelease failed. The agent is not currently initialized.');
85
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
+ }
86
109
  }
87
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'];
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) {
@@ -115,6 +117,34 @@ function setAPI(agentIdentifier, forceDrain) {
115
117
  }
116
118
  return appendJsAttribute('enduser.id', value, 'setUserId', true);
117
119
  };
120
+
121
+ /**
122
+ * Attach the 'applcation.version' attribute onto agent payloads. This may be used in NR queries to group all browser events by a specific customer-defined release.
123
+ * @param {string|null} value - Application version -- if null, will "unset" the value
124
+ * @returns @see apiCall
125
+ */
126
+ apiInterface.setApplicationVersion = function (value) {
127
+ if (!(typeof value === 'string' || value === null)) {
128
+ (0, _console.warn)("Failed to execute setApplicationVersion. Expected <String | null>, but got <".concat(typeof value, ">."));
129
+ return;
130
+ }
131
+ return appendJsAttribute('application.version', value, 'setApplicationVersion', false);
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
+ };
118
148
  apiInterface.interaction = function () {
119
149
  return new InteractionHandle().get();
120
150
  };
@@ -141,14 +171,14 @@ function setAPI(agentIdentifier, forceDrain) {
141
171
  };
142
172
  }
143
173
  };
144
- void ['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
174
+ ['actionText', 'setName', 'setAttribute', 'save', 'ignore', 'onEnd', 'getContext', 'end', 'get'].forEach(name => {
145
175
  InteractionApiProto[name] = apiCall(spaPrefix, name, undefined, _features.FEATURE_NAMES.spa);
146
176
  });
147
177
  function apiCall(prefix, name, notSpa, bufferGroup) {
148
178
  return function () {
149
179
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/' + name + '/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
150
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
151
- return notSpa ? void 0 : this;
181
+ return notSpa ? undefined : this;
152
182
  };
153
183
  }
154
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
@@ -12,7 +12,7 @@ exports.unused = void 0;
12
12
  * @property {getContext} getContext
13
13
  * @property {ignore} ignore
14
14
  * @property {onEnd} onEnd
15
- * @property {onEnd} save
15
+ * @property {save} save
16
16
  * @property {setAttribute} setAttribute
17
17
  * @property {setName} setName
18
18
  */
@@ -30,8 +30,8 @@ exports.unused = void 0;
30
30
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/createtracer/}
31
31
  * @callback createTracer
32
32
  * @param {string} name This will be used as the name of the tracer.
33
- * @param {string} [callback] A callback that contains the synchronous work to run at the end of the async work. To execute this callback, call the wrapper function returned using createTracer().
34
- * @returns {Function} Returns a method that wraps the original callback. When this method is invoked, it calls the original callback and ends the async timing.
33
+ * @param {(...args: any[]) => any} [callback] A callback that contains the synchronous work to run at the end of the async work. To execute this callback, call the wrapper function returned using createTracer().
34
+ * @returns {(...args: any[]) => any} Returns a method that wraps the original callback. When this method is invoked, it calls the original callback and ends the async timing.
35
35
  */
36
36
 
37
37
  /**
@@ -49,6 +49,13 @@ exports.unused = void 0;
49
49
  * @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
50
50
  */
51
51
 
52
+ /**
53
+ * Overrides other SPA save() calls; ignores an interaction so it is not saved or sent to New Relic.
54
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/ignore/}
55
+ * @callback ignore
56
+ * @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
57
+ */
58
+
52
59
  /**
53
60
  * Change the values associated with a SPA interaction before the interaction is saved.
54
61
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/onend/}
@@ -69,7 +76,7 @@ exports.unused = void 0;
69
76
  * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setattribute/}
70
77
  * @callback setAttribute
71
78
  * @param {string} key Used as the attribute name on the BrowserInteraction event.
72
- * @param {any} key Used as the attribute value on the BrowserInteraction event. This can be a string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string.
79
+ * @param {any} value Used as the attribute value on the BrowserInteraction event. This can be a string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string.
73
80
  * @returns {InteractionInstance} Returns the same interaction object allowing method chaining.
74
81
  */
75
82
 
@@ -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
@@ -9,8 +9,6 @@ const model = () => {
9
9
  }
10
10
  };
11
11
  return {
12
- allow_bfcache: true,
13
- // *cli - temporary feature flag for BFCache work
14
12
  privacy: {
15
13
  cookies_enabled: true
16
14
  },
@@ -19,7 +17,8 @@ const model = () => {
19
17
  deny_list: undefined,
20
18
  block_internal: true,
21
19
  enabled: true,
22
- harvestTimeSeconds: 10
20
+ harvestTimeSeconds: 10,
21
+ autoStart: true
23
22
  },
24
23
  distributed_tracing: {
25
24
  enabled: undefined,
@@ -38,32 +37,39 @@ const model = () => {
38
37
  obfuscate: undefined,
39
38
  jserrors: {
40
39
  enabled: true,
41
- harvestTimeSeconds: 10
40
+ harvestTimeSeconds: 10,
41
+ autoStart: true
42
42
  },
43
43
  metrics: {
44
- enabled: true
44
+ enabled: true,
45
+ autoStart: true
45
46
  },
46
47
  page_action: {
47
48
  enabled: true,
48
- harvestTimeSeconds: 30
49
+ harvestTimeSeconds: 30,
50
+ autoStart: true
49
51
  },
50
52
  page_view_event: {
51
- enabled: true
53
+ enabled: true,
54
+ autoStart: true
52
55
  },
53
56
  page_view_timing: {
54
57
  enabled: true,
55
58
  harvestTimeSeconds: 30,
56
- long_task: false
59
+ long_task: false,
60
+ autoStart: true
57
61
  },
58
62
  session_trace: {
59
63
  enabled: true,
60
- harvestTimeSeconds: 10
64
+ harvestTimeSeconds: 10,
65
+ autoStart: true
61
66
  },
62
67
  harvest: {
63
68
  tooManyRequestsDelay: 60
64
69
  },
65
70
  session_replay: {
66
71
  // feature settings
72
+ autoStart: true,
67
73
  enabled: false,
68
74
  harvestTimeSeconds: 60,
69
75
  sampleRate: 0.1,
@@ -102,23 +108,25 @@ const model = () => {
102
108
  },
103
109
  spa: {
104
110
  enabled: true,
105
- harvestTimeSeconds: 10
111
+ harvestTimeSeconds: 10,
112
+ autoStart: true
106
113
  }
107
114
  };
108
115
  };
109
116
  const _cache = {};
117
+ const missingAgentIdError = 'All configuration objects require an agent identifier!';
110
118
  export function getConfiguration(id) {
111
- if (!id) throw new Error('All configuration objects require an agent identifier!');
119
+ if (!id) throw new Error(missingAgentIdError);
112
120
  if (!_cache[id]) throw new Error("Configuration for ".concat(id, " was never set"));
113
121
  return _cache[id];
114
122
  }
115
123
  export function setConfiguration(id, obj) {
116
- if (!id) throw new Error('All configuration objects require an agent identifier!');
124
+ if (!id) throw new Error(missingAgentIdError);
117
125
  _cache[id] = getModeledObject(obj, model());
118
126
  gosNREUMInitializedAgents(id, _cache[id], 'config');
119
127
  }
120
128
  export function getConfigurationValue(id, path) {
121
- if (!id) throw new Error('All configuration objects require an agent identifier!');
129
+ if (!id) throw new Error(missingAgentIdError);
122
130
  var val = getConfiguration(id);
123
131
  if (val) {
124
132
  var parts = path.split('.');
@@ -4,10 +4,6 @@ import { globalScope } from '../../constants/runtime';
4
4
  import { BUILD_ENV, DIST_METHOD, VERSION } from "../../constants/env.npm";
5
5
  const model = {
6
6
  buildEnv: BUILD_ENV,
7
- bytesSent: {},
8
- // Used for SM to capture body bytes sent per endpoint
9
- queryBytesSent: {},
10
- // Used for SM to capture query parameter bytes sent per endpoint
11
7
  customTransaction: undefined,
12
8
  disabled: false,
13
9
  distMethod: DIST_METHOD,
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.237.1";
9
+ export const VERSION = "1.239.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.237.1";
9
+ export const VERSION = "1.239.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -25,7 +25,7 @@ export const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
25
25
  * did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
26
26
  * This was fixed in v16+.
27
27
  */
28
- export const iOS_below16 = isiOS && typeof SharedWorker === 'undefined';
28
+ export const iOSBelow16 = isiOS && typeof SharedWorker === 'undefined';
29
29
  export const ffVersion = (() => {
30
30
  const match = navigator.userAgent.match(/Firefox[/\s](\d+\.\d+)/);
31
31
  if (Array.isArray(match) && match.length >= 2) {