@newrelic/browser-agent 1.264.0 → 1.265.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 (407) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/common/aggregate/aggregator.js +1 -2
  3. package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
  4. package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
  5. package/dist/cjs/common/config/{state/init.js → init.js} +5 -5
  6. package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
  7. package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
  8. package/dist/cjs/common/constants/agent-constants.js +8 -0
  9. package/dist/cjs/common/constants/env.cdn.js +1 -1
  10. package/dist/cjs/common/constants/env.npm.js +1 -1
  11. package/dist/cjs/common/context/shared-context.js +1 -2
  12. package/dist/cjs/common/dispatch/global-event.js +1 -2
  13. package/dist/cjs/common/drain/drain.js +10 -16
  14. package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
  15. package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
  16. package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
  17. package/dist/cjs/common/harvest/harvest.js +29 -56
  18. package/dist/cjs/common/serialize/bel-serializer.js +6 -11
  19. package/dist/cjs/common/session/session-entity.js +9 -12
  20. package/dist/cjs/common/timing/nav-timing.js +1 -3
  21. package/dist/cjs/common/timing/time-keeper.js +16 -6
  22. package/dist/cjs/common/url/encode.js +2 -4
  23. package/dist/cjs/common/util/console.js +2 -0
  24. package/dist/cjs/common/util/invoke.js +6 -16
  25. package/dist/cjs/common/util/obfuscate.js +97 -53
  26. package/dist/cjs/common/util/submit-data.js +17 -20
  27. package/dist/cjs/common/util/text.js +9 -0
  28. package/dist/cjs/common/util/traverse.js +1 -3
  29. package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
  30. package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
  31. package/dist/cjs/common/vitals/first-input-delay.js +4 -5
  32. package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
  33. package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
  34. package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
  35. package/dist/cjs/common/vitals/vital-metric.js +6 -8
  36. package/dist/cjs/common/window/nreum.js +2 -1
  37. package/dist/cjs/common/window/page-visibility.js +1 -4
  38. package/dist/cjs/common/wrap/wrap-events.js +1 -4
  39. package/dist/cjs/common/wrap/wrap-promise.js +1 -4
  40. package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
  41. package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
  42. package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
  43. package/dist/cjs/features/ajax/aggregate/index.js +20 -23
  44. package/dist/cjs/features/ajax/constants.js +2 -3
  45. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
  46. package/dist/cjs/features/ajax/instrument/index.js +15 -13
  47. package/dist/cjs/features/generic_events/aggregate/index.js +49 -58
  48. package/dist/cjs/features/generic_events/constants.js +4 -2
  49. package/dist/cjs/features/generic_events/instrument/index.js +7 -7
  50. package/dist/cjs/features/jserrors/aggregate/index.js +24 -44
  51. package/dist/cjs/features/jserrors/instrument/index.js +5 -5
  52. package/dist/cjs/features/logging/aggregate/index.js +34 -37
  53. package/dist/cjs/features/logging/constants.js +2 -3
  54. package/dist/cjs/features/logging/instrument/index.js +6 -7
  55. package/dist/cjs/features/logging/shared/log.js +1 -3
  56. package/dist/cjs/features/logging/shared/utils.js +2 -4
  57. package/dist/cjs/features/metrics/aggregate/index.js +35 -18
  58. package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
  59. package/dist/cjs/features/metrics/constants.js +4 -2
  60. package/dist/cjs/features/metrics/instrument/index.js +13 -5
  61. package/dist/cjs/features/page_action/instrument/index.js +8 -4
  62. package/dist/cjs/features/page_view_event/aggregate/index.js +20 -40
  63. package/dist/cjs/features/page_view_event/instrument/index.js +5 -5
  64. package/dist/cjs/features/page_view_timing/aggregate/index.js +24 -40
  65. package/dist/cjs/features/page_view_timing/instrument/index.js +5 -5
  66. package/dist/cjs/features/session_replay/aggregate/index.js +37 -44
  67. package/dist/cjs/features/session_replay/constants.js +1 -5
  68. package/dist/cjs/features/session_replay/instrument/index.js +6 -10
  69. package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
  70. package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
  71. package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +3 -3
  72. package/dist/cjs/features/session_replay/shared/utils.js +5 -4
  73. package/dist/cjs/features/session_trace/aggregate/index.js +26 -43
  74. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +7 -5
  75. package/dist/cjs/features/session_trace/instrument/index.js +9 -8
  76. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
  77. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -1
  78. package/dist/cjs/features/soft_navigations/aggregate/index.js +23 -31
  79. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
  80. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +9 -10
  81. package/dist/cjs/features/soft_navigations/instrument/index.js +15 -14
  82. package/dist/cjs/features/spa/aggregate/index.js +17 -27
  83. package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
  84. package/dist/cjs/features/spa/aggregate/serializer.js +3 -3
  85. package/dist/cjs/features/spa/constants.js +2 -2
  86. package/dist/cjs/features/spa/instrument/index.js +21 -20
  87. package/dist/cjs/features/utils/agent-session.js +6 -4
  88. package/dist/cjs/features/utils/aggregate-base.js +15 -10
  89. package/dist/cjs/features/utils/event-buffer.js +132 -0
  90. package/dist/cjs/features/utils/feature-gates.js +2 -2
  91. package/dist/cjs/features/utils/instrument-base.js +7 -8
  92. package/dist/cjs/features/utils/lazy-feature-loader.js +11 -11
  93. package/dist/cjs/features/utils/nr1-debugger.js +1 -3
  94. package/dist/cjs/loaders/agent-base.js +4 -8
  95. package/dist/cjs/loaders/agent.js +7 -2
  96. package/dist/cjs/loaders/api/api.js +22 -34
  97. package/dist/cjs/loaders/api/apiAsync.js +9 -12
  98. package/dist/cjs/loaders/configure/configure.js +12 -12
  99. package/dist/cjs/loaders/features/enabled-features.js +2 -2
  100. package/dist/cjs/loaders/micro-agent.js +15 -14
  101. package/dist/esm/common/aggregate/aggregator.js +1 -2
  102. package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
  103. package/dist/esm/common/config/{state/info.js → info.js} +1 -1
  104. package/dist/esm/common/config/{state/init.js → init.js} +5 -5
  105. package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
  106. package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
  107. package/dist/esm/common/constants/agent-constants.js +2 -0
  108. package/dist/esm/common/constants/env.cdn.js +1 -1
  109. package/dist/esm/common/constants/env.npm.js +1 -1
  110. package/dist/esm/common/context/shared-context.js +1 -2
  111. package/dist/esm/common/dispatch/global-event.js +1 -2
  112. package/dist/esm/common/drain/drain.js +10 -16
  113. package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
  114. package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
  115. package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
  116. package/dist/esm/common/harvest/harvest.js +21 -48
  117. package/dist/esm/common/serialize/bel-serializer.js +6 -11
  118. package/dist/esm/common/session/session-entity.js +8 -11
  119. package/dist/esm/common/timing/nav-timing.js +1 -3
  120. package/dist/esm/common/timing/time-keeper.js +15 -5
  121. package/dist/esm/common/url/encode.js +2 -4
  122. package/dist/esm/common/util/console.js +2 -0
  123. package/dist/esm/common/util/invoke.js +6 -16
  124. package/dist/esm/common/util/obfuscate.js +96 -49
  125. package/dist/esm/common/util/submit-data.js +17 -20
  126. package/dist/esm/common/util/text.js +3 -0
  127. package/dist/esm/common/util/traverse.js +1 -3
  128. package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
  129. package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
  130. package/dist/esm/common/vitals/first-input-delay.js +4 -5
  131. package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
  132. package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
  133. package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
  134. package/dist/esm/common/vitals/vital-metric.js +6 -8
  135. package/dist/esm/common/window/nreum.js +2 -1
  136. package/dist/esm/common/window/page-visibility.js +1 -4
  137. package/dist/esm/common/wrap/wrap-events.js +1 -4
  138. package/dist/esm/common/wrap/wrap-promise.js +1 -4
  139. package/dist/esm/common/wrap/wrap-websocket.js +67 -0
  140. package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
  141. package/dist/esm/features/ajax/aggregate/gql.js +4 -5
  142. package/dist/esm/features/ajax/aggregate/index.js +17 -20
  143. package/dist/esm/features/ajax/constants.js +1 -2
  144. package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
  145. package/dist/esm/features/ajax/instrument/index.js +11 -9
  146. package/dist/esm/features/generic_events/aggregate/index.js +41 -50
  147. package/dist/esm/features/generic_events/constants.js +3 -1
  148. package/dist/esm/features/generic_events/instrument/index.js +5 -5
  149. package/dist/esm/features/jserrors/aggregate/index.js +19 -39
  150. package/dist/esm/features/jserrors/instrument/index.js +4 -4
  151. package/dist/esm/features/logging/aggregate/index.js +32 -35
  152. package/dist/esm/features/logging/constants.js +1 -2
  153. package/dist/esm/features/logging/instrument/index.js +5 -6
  154. package/dist/esm/features/logging/shared/log.js +1 -3
  155. package/dist/esm/features/logging/shared/utils.js +2 -4
  156. package/dist/esm/features/metrics/aggregate/index.js +29 -12
  157. package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
  158. package/dist/esm/features/metrics/constants.js +3 -1
  159. package/dist/esm/features/metrics/instrument/index.js +13 -5
  160. package/dist/esm/features/page_action/instrument/index.js +7 -3
  161. package/dist/esm/features/page_view_event/aggregate/index.js +18 -38
  162. package/dist/esm/features/page_view_event/instrument/index.js +4 -4
  163. package/dist/esm/features/page_view_timing/aggregate/index.js +21 -37
  164. package/dist/esm/features/page_view_timing/instrument/index.js +4 -4
  165. package/dist/esm/features/session_replay/aggregate/index.js +27 -34
  166. package/dist/esm/features/session_replay/constants.js +0 -4
  167. package/dist/esm/features/session_replay/index.js +1 -7
  168. package/dist/esm/features/session_replay/instrument/index.js +6 -9
  169. package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
  170. package/dist/esm/features/session_replay/shared/recorder.js +14 -10
  171. package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +3 -3
  172. package/dist/esm/features/session_replay/shared/utils.js +3 -2
  173. package/dist/esm/features/session_trace/aggregate/index.js +21 -38
  174. package/dist/esm/features/session_trace/aggregate/trace/storage.js +7 -5
  175. package/dist/esm/features/session_trace/instrument/index.js +6 -5
  176. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
  177. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -1
  178. package/dist/esm/features/soft_navigations/aggregate/index.js +22 -30
  179. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
  180. package/dist/esm/features/soft_navigations/aggregate/interaction.js +7 -8
  181. package/dist/esm/features/soft_navigations/instrument/index.js +12 -11
  182. package/dist/esm/features/spa/aggregate/index.js +11 -21
  183. package/dist/esm/features/spa/aggregate/interaction.js +6 -5
  184. package/dist/esm/features/spa/aggregate/serializer.js +1 -1
  185. package/dist/esm/features/spa/constants.js +2 -2
  186. package/dist/esm/features/spa/instrument/index.js +13 -12
  187. package/dist/esm/features/utils/agent-session.js +3 -1
  188. package/dist/esm/features/utils/aggregate-base.js +13 -8
  189. package/dist/esm/features/utils/event-buffer.js +126 -0
  190. package/dist/esm/features/utils/feature-gates.js +1 -1
  191. package/dist/esm/features/utils/instrument-base.js +6 -7
  192. package/dist/esm/features/utils/lazy-feature-loader.js +11 -11
  193. package/dist/esm/features/utils/nr1-debugger.js +1 -3
  194. package/dist/esm/loaders/agent-base.js +4 -8
  195. package/dist/esm/loaders/agent.js +7 -2
  196. package/dist/esm/loaders/api/api.js +17 -29
  197. package/dist/esm/loaders/api/apiAsync.js +2 -5
  198. package/dist/esm/loaders/configure/configure.js +5 -5
  199. package/dist/esm/loaders/features/enabled-features.js +1 -1
  200. package/dist/esm/loaders/micro-agent.js +10 -9
  201. package/dist/types/common/config/configurable.d.ts.map +1 -0
  202. package/dist/types/common/config/info.d.ts.map +1 -0
  203. package/dist/types/common/config/init.d.ts.map +1 -0
  204. package/dist/types/common/config/loader-config.d.ts.map +1 -0
  205. package/dist/types/common/config/runtime.d.ts.map +1 -0
  206. package/dist/types/common/constants/agent-constants.d.ts +3 -0
  207. package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
  208. package/dist/types/common/drain/drain.d.ts.map +1 -1
  209. package/dist/types/common/harvest/harvest.d.ts +1 -7
  210. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  211. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
  212. package/dist/types/common/timing/time-keeper.d.ts +9 -2
  213. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  214. package/dist/types/common/util/console.d.ts.map +1 -1
  215. package/dist/types/common/util/obfuscate.d.ts +78 -6
  216. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  217. package/dist/types/common/util/text.d.ts +2 -0
  218. package/dist/types/common/util/text.d.ts.map +1 -0
  219. package/dist/types/common/window/nreum.d.ts.map +1 -1
  220. package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
  221. package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
  222. package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
  223. package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
  224. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  225. package/dist/types/features/ajax/constants.d.ts +0 -1
  226. package/dist/types/features/ajax/constants.d.ts.map +1 -1
  227. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
  228. package/dist/types/features/ajax/instrument/index.d.ts +1 -0
  229. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  230. package/dist/types/features/generic_events/aggregate/index.d.ts +6 -8
  231. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  232. package/dist/types/features/generic_events/constants.d.ts +2 -0
  233. package/dist/types/features/generic_events/constants.d.ts.map +1 -1
  234. package/dist/types/features/generic_events/instrument/index.d.ts +1 -0
  235. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
  236. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  237. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  238. package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
  239. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  240. package/dist/types/features/logging/aggregate/index.d.ts +4 -7
  241. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  242. package/dist/types/features/logging/constants.d.ts +0 -1
  243. package/dist/types/features/logging/constants.d.ts.map +1 -1
  244. package/dist/types/features/logging/instrument/index.d.ts +1 -0
  245. package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
  246. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  247. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
  248. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
  249. package/dist/types/features/metrics/constants.d.ts +1 -0
  250. package/dist/types/features/metrics/constants.d.ts.map +1 -1
  251. package/dist/types/features/metrics/instrument/index.d.ts +1 -0
  252. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  253. package/dist/types/features/page_action/instrument/index.d.ts +4 -0
  254. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
  255. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  256. package/dist/types/features/page_view_event/instrument/index.d.ts +1 -0
  257. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
  258. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  259. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  260. package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
  261. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
  262. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  263. package/dist/types/features/session_replay/constants.d.ts +0 -4
  264. package/dist/types/features/session_replay/constants.d.ts.map +1 -1
  265. package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
  266. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  267. package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
  268. package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
  269. package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
  270. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  271. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
  272. package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
  273. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  274. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
  275. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
  276. package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
  277. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  278. package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
  279. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  280. package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
  281. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
  282. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  283. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  284. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  285. package/dist/types/features/spa/constants.d.ts.map +1 -1
  286. package/dist/types/features/spa/instrument/index.d.ts +1 -0
  287. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  288. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  289. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  290. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  291. package/dist/types/features/utils/event-buffer.d.ts +72 -0
  292. package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
  293. package/dist/types/features/utils/instrument-base.d.ts +1 -0
  294. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  295. package/dist/types/loaders/agent-base.d.ts +1 -1
  296. package/dist/types/loaders/agent.d.ts.map +1 -1
  297. package/dist/types/loaders/api/api.d.ts.map +1 -1
  298. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  299. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  300. package/package.json +55 -59
  301. package/src/common/config/__mocks__/info.js +3 -0
  302. package/src/common/config/__mocks__/init.js +3 -0
  303. package/src/common/config/__mocks__/loader-config.js +2 -0
  304. package/src/common/config/__mocks__/runtime.js +2 -0
  305. package/src/common/config/{state/configurable.js → configurable.js} +1 -1
  306. package/src/common/config/{state/info.js → info.js} +1 -1
  307. package/src/common/config/{state/init.js → init.js} +5 -5
  308. package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
  309. package/src/common/config/{state/runtime.js → runtime.js} +19 -5
  310. package/src/common/constants/agent-constants.js +2 -0
  311. package/src/common/drain/drain.js +5 -2
  312. package/src/common/event-emitter/contextual-ee.js +1 -1
  313. package/src/common/harvest/harvest.js +7 -21
  314. package/src/common/serialize/bel-serializer.js +5 -7
  315. package/src/common/session/session-entity.js +2 -2
  316. package/src/common/timing/__mocks__/time-keeper.js +6 -2
  317. package/src/common/timing/time-keeper.js +15 -5
  318. package/src/common/util/__mocks__/console.js +1 -0
  319. package/src/common/util/__mocks__/obfuscate.js +5 -8
  320. package/src/common/util/console.js +2 -0
  321. package/src/common/util/obfuscate.js +94 -50
  322. package/src/common/util/text.js +6 -0
  323. package/src/common/window/__mocks__/nreum.js +1 -1
  324. package/src/common/window/nreum.js +2 -1
  325. package/src/common/wrap/wrap-websocket.js +73 -0
  326. package/src/features/ajax/aggregate/chunk.js +3 -2
  327. package/src/features/ajax/aggregate/index.js +20 -19
  328. package/src/features/ajax/constants.js +0 -2
  329. package/src/features/ajax/instrument/distributed-tracing.js +2 -1
  330. package/src/features/ajax/instrument/index.js +9 -5
  331. package/src/features/generic_events/aggregate/index.js +43 -37
  332. package/src/features/generic_events/constants.js +2 -0
  333. package/src/features/generic_events/instrument/index.js +3 -1
  334. package/src/features/jserrors/aggregate/index.js +14 -4
  335. package/src/features/jserrors/instrument/index.js +2 -0
  336. package/src/features/logging/aggregate/index.js +39 -31
  337. package/src/features/logging/constants.js +0 -2
  338. package/src/features/logging/instrument/index.js +2 -0
  339. package/src/features/logging/shared/utils.js +1 -1
  340. package/src/features/metrics/aggregate/index.js +24 -9
  341. package/src/features/metrics/aggregate/websocket-detection.js +31 -0
  342. package/src/features/metrics/constants.js +3 -0
  343. package/src/features/metrics/instrument/index.js +13 -1
  344. package/src/features/page_action/instrument/index.js +5 -0
  345. package/src/features/page_view_event/aggregate/index.js +8 -23
  346. package/src/features/page_view_event/instrument/index.js +2 -0
  347. package/src/features/page_view_timing/aggregate/index.js +14 -16
  348. package/src/features/page_view_timing/instrument/index.js +2 -0
  349. package/src/features/session_replay/aggregate/index.js +13 -9
  350. package/src/features/session_replay/constants.js +0 -4
  351. package/src/features/session_replay/index.js +1 -7
  352. package/src/features/session_replay/instrument/index.js +3 -4
  353. package/src/features/session_replay/shared/recorder-events.js +27 -20
  354. package/src/features/session_replay/shared/recorder.js +13 -6
  355. package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
  356. package/src/features/session_replay/shared/utils.js +3 -2
  357. package/src/features/session_trace/aggregate/index.js +16 -7
  358. package/src/features/session_trace/aggregate/trace/storage.js +6 -1
  359. package/src/features/session_trace/instrument/index.js +4 -1
  360. package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
  361. package/src/features/soft_navigations/aggregate/index.js +13 -15
  362. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
  363. package/src/features/soft_navigations/aggregate/interaction.js +1 -1
  364. package/src/features/soft_navigations/instrument/index.js +9 -5
  365. package/src/features/spa/aggregate/index.js +11 -18
  366. package/src/features/spa/aggregate/interaction.js +5 -3
  367. package/src/features/spa/aggregate/serializer.js +1 -1
  368. package/src/features/spa/constants.js +2 -2
  369. package/src/features/spa/instrument/index.js +9 -3
  370. package/src/features/utils/agent-session.js +3 -1
  371. package/src/features/utils/aggregate-base.js +10 -2
  372. package/src/features/utils/event-buffer.js +126 -0
  373. package/src/features/utils/feature-gates.js +1 -1
  374. package/src/features/utils/instrument-base.js +2 -1
  375. package/src/loaders/agent-base.js +2 -2
  376. package/src/loaders/agent.js +7 -2
  377. package/src/loaders/api/api.js +2 -1
  378. package/src/loaders/api/apiAsync.js +1 -1
  379. package/src/loaders/configure/configure.js +4 -1
  380. package/src/loaders/features/enabled-features.js +1 -1
  381. package/src/loaders/micro-agent.js +4 -1
  382. package/dist/cjs/common/config/config.js +0 -76
  383. package/dist/cjs/common/config/state/originals.js +0 -8
  384. package/dist/cjs/common/wrap/index.js +0 -61
  385. package/dist/esm/common/config/config.js +0 -11
  386. package/dist/esm/common/config/state/originals.js +0 -2
  387. package/dist/esm/common/wrap/index.js +0 -13
  388. package/dist/types/common/config/config.d.ts +0 -13
  389. package/dist/types/common/config/config.d.ts.map +0 -1
  390. package/dist/types/common/config/state/configurable.d.ts.map +0 -1
  391. package/dist/types/common/config/state/info.d.ts.map +0 -1
  392. package/dist/types/common/config/state/init.d.ts.map +0 -1
  393. package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
  394. package/dist/types/common/config/state/originals.d.ts +0 -2
  395. package/dist/types/common/config/state/originals.d.ts.map +0 -1
  396. package/dist/types/common/config/state/runtime.d.ts.map +0 -1
  397. package/dist/types/common/wrap/index.d.ts +0 -10
  398. package/dist/types/common/wrap/index.d.ts.map +0 -1
  399. package/src/common/config/__mocks__/config.js +0 -11
  400. package/src/common/config/config.js +0 -12
  401. package/src/common/config/state/originals.js +0 -3
  402. package/src/common/wrap/index.js +0 -16
  403. /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
  404. /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
  405. /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
  406. /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
  407. /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
@@ -2,13 +2,19 @@
2
2
  * Copyright 2020 New Relic Corporation. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { wrapMutation, wrapPromise, wrapHistory, wrapTimer, wrapFetch, wrapXhr, wrapJsonP } from '../../../common/wrap';
6
5
  import { eventListenerOpts } from '../../../common/event-listener/event-listener-opts';
7
6
  import { InstrumentBase } from '../../utils/instrument-base';
8
7
  import * as CONSTANTS from '../constants';
9
8
  import { isBrowserScope } from '../../../common/constants/runtime';
10
9
  import { now } from '../../../common/timing/now';
11
10
  import { handle } from '../../../common/event-emitter/handle';
11
+ import { wrapJsonP } from '../../../common/wrap/wrap-jsonp';
12
+ import { wrapPromise } from '../../../common/wrap/wrap-promise';
13
+ import { wrapTimer } from '../../../common/wrap/wrap-timer';
14
+ import { wrapXhr } from '../../../common/wrap/wrap-xhr';
15
+ import { wrapFetch } from '../../../common/wrap/wrap-fetch';
16
+ import { wrapHistory } from '../../../common/wrap/wrap-history';
17
+ import { wrapMutation } from '../../../common/wrap/wrap-mutation';
12
18
  const {
13
19
  FEATURE_NAME,
14
20
  START,
@@ -22,12 +28,9 @@ const {
22
28
  FN_END
23
29
  } = CONSTANTS;
24
30
  export class Instrument extends InstrumentBase {
25
- static featureName = (() => FEATURE_NAME)();
26
- constructor(agentIdentifier, aggregator) {
27
- var _this;
28
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
31
+ static featureName = FEATURE_NAME;
32
+ constructor(agentIdentifier, aggregator, auto = true) {
29
33
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
30
- _this = this;
31
34
  if (!isBrowserScope) return; // SPA not supported outside web env
32
35
 
33
36
  try {
@@ -50,11 +53,8 @@ export class Instrument extends InstrumentBase {
50
53
  this.ee.on(FN_END, endTimestamp);
51
54
  promiseEE.on(CB_END, endTimestamp);
52
55
  jsonpEE.on(CB_END, endTimestamp);
53
- this.ee.on('fn-err', function () {
54
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
55
- args[_key] = arguments[_key];
56
- }
57
- if (!args[2]?.__newrelic?.[agentIdentifier]) handle('function-err', [...args], undefined, _this.featureName, _this.ee);
56
+ this.ee.on('fn-err', (...args) => {
57
+ if (!args[2]?.__newrelic?.[agentIdentifier]) handle('function-err', [...args], undefined, this.featureName, this.ee);
58
58
  });
59
59
  this.ee.buffer([FN_START, FN_END, 'xhr-resolved'], this.featureName);
60
60
  eventsEE.buffer([FN_START], this.featureName);
@@ -109,4 +109,5 @@ export class Instrument extends InstrumentBase {
109
109
  this.removeOnAbort?.abort();
110
110
  this.abortHandler = undefined; // weakly allow this abort op to run only once
111
111
  }
112
- }
112
+ }
113
+ export const Spa = Instrument;
@@ -1,4 +1,6 @@
1
- import { getConfiguration, getInfo, getRuntime } from '../../common/config/config';
1
+ import { getInfo } from '../../common/config/info';
2
+ import { getConfiguration } from '../../common/config/init';
3
+ import { getRuntime } from '../../common/config/runtime';
2
4
  import { drain } from '../../common/drain/drain';
3
5
  import { ee } from '../../common/event-emitter/contextual-ee';
4
6
  import { registerHandler } from '../../common/event-emitter/register-handler';
@@ -1,13 +1,16 @@
1
1
  import { FeatureBase } from './feature-base';
2
- import { getInfo, isConfigured, getRuntime } from '../../common/config/config';
2
+ import { getInfo, isValid } from '../../common/config/info';
3
+ import { getRuntime } from '../../common/config/runtime';
3
4
  import { configure } from '../../loaders/configure/configure';
4
5
  import { gosCDN } from '../../common/window/nreum';
5
6
  import { deregisterDrain, drain } from '../../common/drain/drain';
6
7
  import { activatedFeatures } from '../../common/util/feature-flags';
8
+ import { Obfuscator } from '../../common/util/obfuscate';
7
9
  export class AggregateBase extends FeatureBase {
8
- constructor() {
9
- super(...arguments);
10
+ constructor(...args) {
11
+ super(...args);
10
12
  this.checkConfiguration();
13
+ this.obfuscator = getRuntime(this.agentIdentifier).obfuscator;
11
14
  }
12
15
 
13
16
  /**
@@ -15,14 +18,12 @@ export class AggregateBase extends FeatureBase {
15
18
  * @param {string[]} flagNames
16
19
  * @returns {Promise}
17
20
  */
18
- waitForFlags() {
19
- let flagNames = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
21
+ waitForFlags(flagNames = []) {
20
22
  const flagsPromise = new Promise((resolve, reject) => {
21
23
  if (activatedFeatures[this.agentIdentifier]) {
22
24
  resolve(buildOutput(activatedFeatures[this.agentIdentifier]));
23
25
  } else {
24
- this.ee.on('rumresp', function () {
25
- let resp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ this.ee.on('rumresp', (resp = {}) => {
26
27
  resolve(buildOutput(resp));
27
28
  });
28
29
  }
@@ -50,7 +51,7 @@ export class AggregateBase extends FeatureBase {
50
51
  */
51
52
  checkConfiguration() {
52
53
  // NOTE: This check has to happen at aggregator load time
53
- if (!isConfigured(this.agentIdentifier)) {
54
+ if (!isValid(this.agentIdentifier)) {
54
55
  const cdn = gosCDN();
55
56
  let jsAttributes = {
56
57
  ...cdn.info?.jsAttributes
@@ -74,5 +75,9 @@ export class AggregateBase extends FeatureBase {
74
75
  runtime: getRuntime(this.agentIdentifier)
75
76
  });
76
77
  }
78
+ const runtime = getRuntime(this.agentIdentifier);
79
+ if (!runtime.obfuscator) {
80
+ runtime.obfuscator = new Obfuscator(this.agentIdentifier);
81
+ }
77
82
  }
78
83
  }
@@ -0,0 +1,126 @@
1
+ import { stringify } from '../../common/util/stringify';
2
+ import { MAX_PAYLOAD_SIZE } from '../../common/constants/agent-constants';
3
+
4
+ /**
5
+ * A container that keeps an event buffer and size with helper methods
6
+ * @typedef {Object} EventBuffer
7
+ * @property {number} size
8
+ * @property {*[]} buffer
9
+ */
10
+
11
+ /**
12
+ * A container that holds, evaluates, and merges event objects for harvesting
13
+ */
14
+ export class EventBuffer {
15
+ /** @type {Object[]} */
16
+ #buffer = [];
17
+ /** @type {number} */
18
+ #bytes = 0;
19
+ /** @type {EventBuffer} */
20
+ #held;
21
+
22
+ /**
23
+ *
24
+ * @param {number=} maxPayloadSize
25
+ */
26
+ constructor(maxPayloadSize = MAX_PAYLOAD_SIZE) {
27
+ this.maxPayloadSize = maxPayloadSize;
28
+ }
29
+
30
+ /**
31
+ * buffer is read only, use the helper methods to add or clear buffer data
32
+ */
33
+ get buffer() {
34
+ return this.#buffer;
35
+ }
36
+
37
+ /**
38
+ * bytes is read only, use the helper methods to add or clear buffer data
39
+ */
40
+ get bytes() {
41
+ return this.#bytes;
42
+ }
43
+
44
+ /**
45
+ * held is another event buffer
46
+ */
47
+ get held() {
48
+ this.#held ??= new EventBuffer(this.maxPayloadSize);
49
+ return this.#held;
50
+ }
51
+
52
+ /**
53
+ * Returns a boolean indicating whether the current size and buffer contain valid data
54
+ * @returns {boolean}
55
+ */
56
+ get hasData() {
57
+ return this.buffer.length > 0 && this.bytes > 0;
58
+ }
59
+
60
+ /**
61
+ * Adds an event object to the buffer while tallying size
62
+ * @param {Object} event the event object to add to the buffer
63
+ * @returns {EventBuffer} returns the event buffer for chaining
64
+ */
65
+ add(event) {
66
+ const size = stringify(event).length;
67
+ if (!this.canMerge(size)) return this;
68
+ this.#buffer.push(event);
69
+ this.#bytes += size;
70
+ return this;
71
+ }
72
+
73
+ /**
74
+ * clear the buffer data
75
+ * @returns {EventBuffer}
76
+ */
77
+ clear() {
78
+ this.#bytes = 0;
79
+ this.#buffer = [];
80
+ return this;
81
+ }
82
+
83
+ /**
84
+ * Hold the buffer data in a new (child) EventBuffer (.held) to unblock the main buffer.
85
+ * This action clears the main buffer
86
+ * @returns {EventBuffer}
87
+ */
88
+ hold() {
89
+ this.held.merge(this);
90
+ this.clear();
91
+ return this;
92
+ }
93
+
94
+ /**
95
+ * Prepend the held EventBuffer (.held) back into the main buffer
96
+ * This action clears the held buffer
97
+ * @returns {EventBuffer}
98
+ */
99
+ unhold() {
100
+ this.merge(this.held, true);
101
+ this.held.clear();
102
+ return this;
103
+ }
104
+
105
+ /**
106
+ * Merges an EventBuffer into this EventBuffer
107
+ * @param {EventBuffer} events an EventBuffer intended to merge with this EventBuffer
108
+ * @param {boolean} prepend if true, the supplied events will be prepended before the events of this class
109
+ * @returns {EventBuffer} returns the event buffer for chaining
110
+ */
111
+ merge(eventBuffer, prepend = false) {
112
+ if (!this.canMerge(eventBuffer.bytes)) return this;
113
+ this.#buffer = prepend ? [...eventBuffer.buffer, ...this.#buffer] : [...this.#buffer, ...eventBuffer.buffer];
114
+ this.#bytes += eventBuffer.#bytes;
115
+ return this;
116
+ }
117
+
118
+ /**
119
+ * Returns a boolean indicating the resulting size of a merge would be valid. Compares against the maxPayloadSize provided at initialization time.
120
+ * @param {number} size
121
+ * @returns {boolean}
122
+ */
123
+ canMerge(size) {
124
+ return this.bytes + (size || Infinity) < this.maxPayloadSize;
125
+ }
126
+ }
@@ -1,4 +1,4 @@
1
- import { getConfigurationValue } from '../../common/config/config';
1
+ import { getConfigurationValue } from '../../common/config/init';
2
2
  import { isBrowserScope } from '../../common/constants/runtime';
3
3
 
4
4
  /**
@@ -10,7 +10,7 @@ import { onWindowLoad } from '../../common/window/load';
10
10
  import { isBrowserScope } from '../../common/constants/runtime';
11
11
  import { warn } from '../../common/util/console';
12
12
  import { FEATURE_NAMES } from '../../loaders/features/features';
13
- import { getConfigurationValue } from '../../common/config/config';
13
+ import { getConfigurationValue } from '../../common/config/init';
14
14
  import { hasReplayPrerequisite } from '../session_replay/shared/utils';
15
15
  import { canEnableSessionTracking } from './feature-gates';
16
16
  import { single } from '../../common/util/invoke';
@@ -29,8 +29,7 @@ export class InstrumentBase extends FeatureBase {
29
29
  * of its pooled instrumentation data handled by the agent's centralized drain functionality, rather than draining
30
30
  * immediately. Primarily useful for fine-grained control in tests.
31
31
  */
32
- constructor(agentIdentifier, aggregator, featureName) {
33
- let auto = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
32
+ constructor(agentIdentifier, aggregator, featureName, auto = true) {
34
33
  super(agentIdentifier, aggregator, featureName);
35
34
  this.auto = auto;
36
35
 
@@ -46,6 +45,7 @@ export class InstrumentBase extends FeatureBase {
46
45
  /**
47
46
  * @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
47
  * one another if there are inter-features dependencies.
48
+ * TODO: This is only used for the SPA feature component tests and should be refactored out.
49
49
  */
50
50
  this.onAggregateImported = undefined;
51
51
 
@@ -69,8 +69,7 @@ export class InstrumentBase extends FeatureBase {
69
69
  * @param {Object} [argsObjFromInstrument] - any values or references to pass down to aggregate
70
70
  * @returns void
71
71
  */
72
- importAggregator() {
73
- let argsObjFromInstrument = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
72
+ importAggregator(argsObjFromInstrument = {}) {
74
73
  if (this.featAggregate || !this.auto) return;
75
74
  let loadedSuccessfully;
76
75
  this.onAggregateImported = new Promise(resolve => {
@@ -83,7 +82,7 @@ export class InstrumentBase extends FeatureBase {
83
82
  // would require some setup before certain features start
84
83
  const {
85
84
  setupAgentSession
86
- } = await import( /* webpackChunkName: "session-manager" */'./agent-session');
85
+ } = await import(/* webpackChunkName: "session-manager" */'./agent-session');
87
86
  session = setupAgentSession(this.agentIdentifier);
88
87
  }
89
88
  } catch (e) {
@@ -104,7 +103,7 @@ export class InstrumentBase extends FeatureBase {
104
103
  }
105
104
  const {
106
105
  lazyFeatureLoader
107
- } = await import( /* webpackChunkName: "lazy-feature-loader" */'./lazy-feature-loader');
106
+ } = await import(/* webpackChunkName: "lazy-feature-loader" */'./lazy-feature-loader');
108
107
  const {
109
108
  Aggregate
110
109
  } = await lazyFeatureLoader(this.featureName, 'aggregate');
@@ -15,27 +15,27 @@ export function lazyFeatureLoader(featureName, featurePart) {
15
15
  if (featurePart === 'aggregate') {
16
16
  switch (featureName) {
17
17
  case FEATURE_NAMES.ajax:
18
- return import( /* webpackChunkName: "ajax-aggregate" */'../ajax/aggregate');
18
+ return import(/* webpackChunkName: "ajax-aggregate" */'../ajax/aggregate');
19
19
  case FEATURE_NAMES.jserrors:
20
- return import( /* webpackChunkName: "jserrors-aggregate" */'../jserrors/aggregate');
20
+ return import(/* webpackChunkName: "jserrors-aggregate" */'../jserrors/aggregate');
21
21
  case FEATURE_NAMES.genericEvents:
22
- return import( /* webpackChunkName: "generic_events-aggregate" */'../generic_events/aggregate');
22
+ return import(/* webpackChunkName: "generic_events-aggregate" */'../generic_events/aggregate');
23
23
  case FEATURE_NAMES.logging:
24
- return import( /* webpackChunkName: "logging-aggregate" */'../logging/aggregate');
24
+ return import(/* webpackChunkName: "logging-aggregate" */'../logging/aggregate');
25
25
  case FEATURE_NAMES.metrics:
26
- return import( /* webpackChunkName: "metrics-aggregate" */'../metrics/aggregate');
26
+ return import(/* webpackChunkName: "metrics-aggregate" */'../metrics/aggregate');
27
27
  case FEATURE_NAMES.pageViewEvent:
28
- return import( /* webpackChunkName: "page_view_event-aggregate" */'../page_view_event/aggregate');
28
+ return import(/* webpackChunkName: "page_view_event-aggregate" */'../page_view_event/aggregate');
29
29
  case FEATURE_NAMES.pageViewTiming:
30
- return import( /* webpackChunkName: "page_view_timing-aggregate" */'../page_view_timing/aggregate');
30
+ return import(/* webpackChunkName: "page_view_timing-aggregate" */'../page_view_timing/aggregate');
31
31
  case FEATURE_NAMES.sessionReplay:
32
- return import( /* webpackChunkName: "session_replay-aggregate" */'../session_replay/aggregate');
32
+ return import(/* webpackChunkName: "session_replay-aggregate" */'../session_replay/aggregate');
33
33
  case FEATURE_NAMES.sessionTrace:
34
- return import( /* webpackChunkName: "session_trace-aggregate" */'../session_trace/aggregate');
34
+ return import(/* webpackChunkName: "session_trace-aggregate" */'../session_trace/aggregate');
35
35
  case FEATURE_NAMES.spa:
36
- return import( /* webpackChunkName: "spa-aggregate" */'../spa/aggregate');
36
+ return import(/* webpackChunkName: "spa-aggregate" */'../spa/aggregate');
37
37
  case FEATURE_NAMES.softNav:
38
- return import( /* webpackChunkName: "basic-spa-aggregate" */'../soft_navigations/aggregate');
38
+ return import(/* webpackChunkName: "basic-spa-aggregate" */'../soft_navigations/aggregate');
39
39
  default:
40
40
  throw new Error("Attempted to load unsupported agent feature: ".concat(featureName, " ").concat(featurePart));
41
41
  }
@@ -1,9 +1,7 @@
1
1
  import { gosCDN } from '../../common/window/nreum';
2
2
  const debugId = 1;
3
3
  const newrelic = gosCDN();
4
- export function debugNR1(agentIdentifier, location, event) {
5
- let otherprops = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
6
- let debugName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'SR';
4
+ export function debugNR1(agentIdentifier, location, event, otherprops = {}, debugName = 'SR') {
7
5
  const api = agentIdentifier ? newrelic.initializedAgents[agentIdentifier].api.addPageAction : newrelic.addPageAction;
8
6
  let url;
9
7
  try {
@@ -10,8 +10,7 @@ import { generateRandomHexString } from '../common/ids/unique-id';
10
10
 
11
11
  export class AgentBase {
12
12
  agentIdentifier;
13
- constructor() {
14
- let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : generateRandomHexString(16);
13
+ constructor(agentIdentifier = generateRandomHexString(16)) {
15
14
  this.agentIdentifier = agentIdentifier;
16
15
  }
17
16
 
@@ -20,10 +19,7 @@ export class AgentBase {
20
19
  * @param {string} methodName
21
20
  * @param {...any} args
22
21
  */
23
- #callMethod(methodName) {
24
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
25
- args[_key - 1] = arguments[_key];
26
- }
22
+ #callMethod(methodName, ...args) {
27
23
  if (typeof this.api?.[methodName] !== 'function') warn(35, methodName);else return this.api[methodName](...args);
28
24
  }
29
25
 
@@ -182,12 +178,12 @@ export class AgentBase {
182
178
 
183
179
  /**
184
180
  * Capture a single log.
185
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/loginfo/}
181
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
186
182
  * @param {string} message String to be captured as log message
187
183
  * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
188
184
  */
189
185
  log(message, options) {
190
- return this.#callMethod('logInfo', message, options);
186
+ return this.#callMethod('log', message, options);
191
187
  }
192
188
 
193
189
  /**
@@ -67,8 +67,13 @@ export class Agent extends AgentBase {
67
67
  if (this.runSoftNavOverSpa && InstrumentCtor.featureName === FEATURE_NAMES.spa) return;
68
68
  if (!this.runSoftNavOverSpa && InstrumentCtor.featureName === FEATURE_NAMES.softNav) return;
69
69
  const dependencies = getFeatureDependencyNames(InstrumentCtor.featureName);
70
- const hasAllDeps = dependencies.every(featName => featName in this.features); // any other feature(s) this depends on should've been initialized on prior iterations by priority order
71
- if (!hasAllDeps) warn(36, InstrumentCtor.featureName);
70
+ const missingDependencies = dependencies.filter(featName => !(featName in this.features)); // any other feature(s) this depends on should've been initialized on prior iterations by priority order
71
+ if (missingDependencies.length > 0) {
72
+ warn(36, {
73
+ targetFeature: InstrumentCtor.featureName,
74
+ missingDependencies
75
+ });
76
+ }
72
77
  this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator);
73
78
  });
74
79
  } catch (err) {
@@ -3,7 +3,8 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { FEATURE_NAMES } from '../features/features';
6
- import { getRuntime, setInfo, getInfo } from '../../common/config/config';
6
+ import { getInfo, setInfo } from '../../common/config/info';
7
+ import { getRuntime } from '../../common/config/runtime';
7
8
  import { handle } from '../../common/event-emitter/handle';
8
9
  import { ee } from '../../common/event-emitter/contextual-ee';
9
10
  import { drain, registerDrain } from '../../common/drain/drain';
@@ -22,17 +23,9 @@ import { wrapLogger } from '../../common/wrap/wrap-logger';
22
23
  export function setTopLevelCallers() {
23
24
  const nr = gosCDN();
24
25
  apiMethods.forEach(f => {
25
- nr[f] = function () {
26
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
- args[_key] = arguments[_key];
28
- }
29
- return caller(f, ...args);
30
- };
26
+ nr[f] = (...args) => caller(f, ...args);
31
27
  });
32
- function caller(fnName) {
33
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
34
- args[_key2 - 1] = arguments[_key2];
35
- }
28
+ function caller(fnName, ...args) {
36
29
  let returnVals = [];
37
30
  Object.values(nr.initializedAgents).forEach(val => {
38
31
  if (!val || !val.api) {
@@ -45,8 +38,7 @@ export function setTopLevelCallers() {
45
38
  }
46
39
  }
47
40
  const replayRunning = {};
48
- export function setAPI(agentIdentifier, forceDrain) {
49
- let runSoftNavOverSpa = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
41
+ export function setAPI(agentIdentifier, forceDrain, runSoftNavOverSpa = false) {
50
42
  if (!forceDrain) registerDrain(agentIdentifier, 'api');
51
43
  const apiInterface = {};
52
44
  var instanceEE = ee.get(agentIdentifier);
@@ -57,19 +49,17 @@ export function setAPI(agentIdentifier, forceDrain) {
57
49
  });
58
50
  var prefix = 'api-';
59
51
  var spaPrefix = prefix + 'ixn-';
60
- apiInterface.log = function (message) {
61
- let {
62
- customAttributes = {},
63
- level = LOG_LEVELS.INFO
64
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
52
+ apiInterface.log = function (message, {
53
+ customAttributes = {},
54
+ level = LOG_LEVELS.INFO
55
+ } = {}) {
65
56
  handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/log/called'], undefined, FEATURE_NAMES.metrics, instanceEE);
66
57
  bufferLog(instanceEE, message, customAttributes, level);
67
58
  };
68
- apiInterface.wrapLogger = function (parent, functionName) {
69
- let {
70
- customAttributes = {},
71
- level = LOG_LEVELS.INFO
72
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
59
+ apiInterface.wrapLogger = (parent, functionName, {
60
+ customAttributes = {},
61
+ level = LOG_LEVELS.INFO
62
+ } = {}) => {
73
63
  handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/wrapLogger/called'], undefined, FEATURE_NAMES.metrics, instanceEE);
74
64
  wrapLogger(instanceEE, parent, functionName, {
75
65
  customAttributes,
@@ -112,8 +102,7 @@ export function setAPI(agentIdentifier, forceDrain) {
112
102
  }
113
103
  return apiCall(prefix, apiName, true, !!addToBrowserStorage || value === null ? 'session' : undefined)(key, value);
114
104
  }
115
- apiInterface.setCustomAttribute = function (name, value) {
116
- let persistAttribute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
105
+ apiInterface.setCustomAttribute = function (name, value, persistAttribute = false) {
117
106
  if (typeof name !== 'string') {
118
107
  warn(39, typeof name);
119
108
  return;
@@ -216,10 +205,9 @@ export function setAPI(agentIdentifier, forceDrain) {
216
205
  // try to stay out of the way of the window.load event, lazy load once that has finished.
217
206
  else onWindowLoad(() => lazyLoad(), true);
218
207
  function lazyLoad() {
219
- import( /* webpackChunkName: "async-api" */'./apiAsync').then(_ref => {
220
- let {
221
- setAPI
222
- } = _ref;
208
+ import(/* webpackChunkName: "async-api" */'./apiAsync').then(({
209
+ setAPI
210
+ }) => {
223
211
  setAPI(agentIdentifier);
224
212
  drain(agentIdentifier, 'api');
225
213
  }).catch(err => {
@@ -1,5 +1,5 @@
1
1
  import { FEATURE_NAMES } from '../features/features';
2
- import { getRuntime } from '../../common/config/config';
2
+ import { getRuntime } from '../../common/config/runtime';
3
3
  import { ee } from '../../common/event-emitter/contextual-ee';
4
4
  import { handle } from '../../common/event-emitter/handle';
5
5
  import { registerHandler } from '../../common/event-emitter/register-handler';
@@ -16,10 +16,7 @@ export function setAPI(agentIdentifier) {
16
16
  };
17
17
 
18
18
  // Hook all of the api functions up to the queues/stubs created in loader/api.js
19
- Object.entries(api).forEach(_ref => {
20
- let [fnName, fnCall] = _ref;
21
- return registerHandler('api-' + fnName, fnCall, 'api', instanceEE);
22
- });
19
+ Object.entries(api).forEach(([fnName, fnCall]) => registerHandler('api-' + fnName, fnCall, 'api', instanceEE));
23
20
 
24
21
  // All API functions get passed the time they were called as their
25
22
  // first parameter. These functions can be called asynchronously.
@@ -1,6 +1,9 @@
1
1
  import { setAPI, setTopLevelCallers } from '../api/api';
2
2
  import { addToNREUM, gosCDN } from '../../common/window/nreum';
3
- import { getConfiguration, setConfiguration, setInfo, setLoaderConfig, setRuntime } from '../../common/config/config';
3
+ import { setInfo } from '../../common/config/info';
4
+ import { getConfiguration, setConfiguration } from '../../common/config/init';
5
+ import { setLoaderConfig } from '../../common/config/loader-config';
6
+ import { setRuntime } from '../../common/config/runtime';
4
7
  import { activatedFeatures } from '../../common/util/feature-flags';
5
8
  import { isWorkerScope } from '../../common/constants/runtime';
6
9
  import { redefinePublicPath } from './public-path';
@@ -10,10 +13,7 @@ let alreadySetOnce = false; // the configure() function can run multiple times i
10
13
  /**
11
14
  * Sets or re-sets the agent's configuration values from global settings. This also attach those as properties to the agent instance.
12
15
  */
13
- export function configure(agent) {
14
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
- let loaderType = arguments.length > 2 ? arguments[2] : undefined;
16
- let forceDrain = arguments.length > 3 ? arguments[3] : undefined;
16
+ export function configure(agent, opts = {}, loaderType, forceDrain) {
17
17
  // eslint-disable-next-line camelcase
18
18
  let {
19
19
  init,
@@ -1,5 +1,5 @@
1
1
  import { FEATURE_NAMES } from './features';
2
- import { getConfigurationValue } from '../../common/config/config';
2
+ import { getConfigurationValue } from '../../common/config/init';
3
3
  const featureNames = Object.values(FEATURE_NAMES);
4
4
  function isEnabled(name, agentIdentifier) {
5
5
  return getConfigurationValue(agentIdentifier, "".concat(name, ".enabled")) === true;
@@ -5,7 +5,10 @@ import { configure } from './configure/configure';
5
5
  // core files
6
6
  import { Aggregator } from '../common/aggregate/aggregator';
7
7
  import { setNREUMInitializedAgent } from '../common/window/nreum';
8
- import { getConfiguration, getConfigurationValue, getInfo, getLoaderConfig, getRuntime } from '../common/config/config';
8
+ import { getInfo } from '../common/config/info';
9
+ import { getConfiguration, getConfigurationValue } from '../common/config/init';
10
+ import { getLoaderConfig } from '../common/config/loader-config';
11
+ import { getRuntime } from '../common/config/runtime';
9
12
  import { FEATURE_NAMES } from './features/features';
10
13
  import { warn } from '../common/util/console';
11
14
  import { onWindowLoad } from '../common/window/load';
@@ -76,15 +79,13 @@ export class MicroAgent extends AgentBase {
76
79
  // these features do not import an "instrument" file, meaning they are only hooked up to the API.
77
80
  nonAutoFeatures.forEach(f => {
78
81
  if (enabledFeatures[f] && features.includes(f)) {
79
- import( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader').then(_ref => {
80
- let {
81
- lazyFeatureLoader
82
- } = _ref;
82
+ import(/* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader').then(({
83
+ lazyFeatureLoader
84
+ }) => {
83
85
  return lazyFeatureLoader(f, 'aggregate');
84
- }).then(_ref2 => {
85
- let {
86
- Aggregate
87
- } = _ref2;
86
+ }).then(({
87
+ Aggregate
88
+ }) => {
88
89
  this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator);
89
90
  }).catch(err => warn(25, err));
90
91
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurable.d.ts","sourceRoot":"","sources":["../../../../src/common/config/configurable.js"],"names":[],"mappings":"AAEA,4DA0BC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../../src/common/config/info.js"],"names":[],"mappings":"AA6BA,0CAOC;AAED,sCAIC;AAED,iDAKC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/common/config/init.js"],"names":[],"mappings":"AAkHA,+CAIC;AAED,0DAKC;AAED,+DAYC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-config.d.ts","sourceRoot":"","sources":["../../../../src/common/config/loader-config.js"],"names":[],"mappings":"AAcA,8CAIC;AAED,yDAKC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/common/config/runtime.js"],"names":[],"mappings":"AAsCA,yCAIC;AAED,oDAgBC"}
@@ -0,0 +1,3 @@
1
+ export const IDEAL_PAYLOAD_SIZE: 64000;
2
+ export const MAX_PAYLOAD_SIZE: 1000000;
3
+ //# sourceMappingURL=agent-constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-constants.d.ts","sourceRoot":"","sources":["../../../../src/common/constants/agent-constants.js"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,uCAAuC"}
@@ -1 +1 @@
1
- {"version":3,"file":"drain.d.ts","sourceRoot":"","sources":["../../../../src/common/drain/drain.js"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,+CAHW,MAAM,SACN,MAAM,QAQhB;AAED;;;;GAIG;AACH,iDAHW,GAAC,SACD,GAAC,QAOX;AAYD;;;;;;GAMG;AACH,wCAJW,MAAM,gBACN,MAAM,UACN,OAAO,QAajB"}
1
+ {"version":3,"file":"drain.d.ts","sourceRoot":"","sources":["../../../../src/common/drain/drain.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,+CAHW,MAAM,SACN,MAAM,QAQhB;AAED;;;;GAIG;AACH,iDAHW,GAAC,SACD,GAAC,QAOX;AAYD;;;;;;GAMG;AACH,wCAJW,MAAM,gBACN,MAAM,UACN,OAAO,QAajB"}