@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
@@ -7,9 +7,7 @@ exports.debugNR1 = debugNR1;
7
7
  var _nreum = require("../../common/window/nreum");
8
8
  const debugId = 1;
9
9
  const newrelic = (0, _nreum.gosCDN)();
10
- function debugNR1(agentIdentifier, location, event) {
11
- let otherprops = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
12
- let debugName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'SR';
10
+ function debugNR1(agentIdentifier, location, event, otherprops = {}, debugName = 'SR') {
13
11
  const api = agentIdentifier ? newrelic.initializedAgents[agentIdentifier].api.addPageAction : newrelic.addPageAction;
14
12
  let url;
15
13
  try {
@@ -15,8 +15,7 @@ var _uniqueId = require("../common/ids/unique-id");
15
15
 
16
16
  class AgentBase {
17
17
  agentIdentifier;
18
- constructor() {
19
- let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _uniqueId.generateRandomHexString)(16);
18
+ constructor(agentIdentifier = (0, _uniqueId.generateRandomHexString)(16)) {
20
19
  this.agentIdentifier = agentIdentifier;
21
20
  }
22
21
 
@@ -25,10 +24,7 @@ class AgentBase {
25
24
  * @param {string} methodName
26
25
  * @param {...any} args
27
26
  */
28
- #callMethod(methodName) {
29
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
30
- args[_key - 1] = arguments[_key];
31
- }
27
+ #callMethod(methodName, ...args) {
32
28
  if (typeof this.api?.[methodName] !== 'function') (0, _console.warn)(35, methodName);else return this.api[methodName](...args);
33
29
  }
34
30
 
@@ -187,12 +183,12 @@ class AgentBase {
187
183
 
188
184
  /**
189
185
  * Capture a single log.
190
- * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/loginfo/}
186
+ * {@link https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/log/}
191
187
  * @param {string} message String to be captured as log message
192
188
  * @param {{customAttributes?: object, level?: 'ERROR'|'TRACE'|'DEBUG'|'INFO'|'WARN'}} [options] customAttributes defaults to `{}` if not assigned, level defaults to `info` if not assigned.
193
189
  */
194
190
  log(message, options) {
195
- return this.#callMethod('logInfo', message, options);
191
+ return this.#callMethod('log', message, options);
196
192
  }
197
193
 
198
194
  /**
@@ -76,8 +76,13 @@ class Agent extends _agentBase.AgentBase {
76
76
  if (this.runSoftNavOverSpa && InstrumentCtor.featureName === _features.FEATURE_NAMES.spa) return;
77
77
  if (!this.runSoftNavOverSpa && InstrumentCtor.featureName === _features.FEATURE_NAMES.softNav) return;
78
78
  const dependencies = (0, _featureDependencies.getFeatureDependencyNames)(InstrumentCtor.featureName);
79
- 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
80
- if (!hasAllDeps) (0, _console.warn)(36, InstrumentCtor.featureName);
79
+ 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
80
+ if (missingDependencies.length > 0) {
81
+ (0, _console.warn)(36, {
82
+ targetFeature: InstrumentCtor.featureName,
83
+ missingDependencies
84
+ });
85
+ }
81
86
  this.features[InstrumentCtor.featureName] = new InstrumentCtor(this.agentIdentifier, this.sharedAggregator);
82
87
  });
83
88
  } catch (err) {
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.setAPI = setAPI;
7
7
  exports.setTopLevelCallers = setTopLevelCallers;
8
8
  var _features = require("../features/features");
9
- var _config = require("../../common/config/config");
9
+ var _info = require("../../common/config/info");
10
+ var _runtime = require("../../common/config/runtime");
10
11
  var _handle = require("../../common/event-emitter/handle");
11
12
  var _contextualEe = require("../../common/event-emitter/contextual-ee");
12
13
  var _drain = require("../../common/drain/drain");
13
14
  var _load = require("../../common/window/load");
14
- var _runtime = require("../../common/constants/runtime");
15
+ var _runtime2 = require("../../common/constants/runtime");
15
16
  var _console = require("../../common/util/console");
16
17
  var _constants = require("../../features/metrics/constants");
17
18
  var _nreum = require("../../common/window/nreum");
@@ -30,17 +31,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
30
31
  function setTopLevelCallers() {
31
32
  const nr = (0, _nreum.gosCDN)();
32
33
  _apiMethods.apiMethods.forEach(f => {
33
- nr[f] = function () {
34
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
- args[_key] = arguments[_key];
36
- }
37
- return caller(f, ...args);
38
- };
34
+ nr[f] = (...args) => caller(f, ...args);
39
35
  });
40
- function caller(fnName) {
41
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
42
- args[_key2 - 1] = arguments[_key2];
43
- }
36
+ function caller(fnName, ...args) {
44
37
  let returnVals = [];
45
38
  Object.values(nr.initializedAgents).forEach(val => {
46
39
  if (!val || !val.api) {
@@ -53,8 +46,7 @@ function setTopLevelCallers() {
53
46
  }
54
47
  }
55
48
  const replayRunning = {};
56
- function setAPI(agentIdentifier, forceDrain) {
57
- let runSoftNavOverSpa = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
49
+ function setAPI(agentIdentifier, forceDrain, runSoftNavOverSpa = false) {
58
50
  if (!forceDrain) (0, _drain.registerDrain)(agentIdentifier, 'api');
59
51
  const apiInterface = {};
60
52
  var instanceEE = _contextualEe.ee.get(agentIdentifier);
@@ -65,19 +57,17 @@ function setAPI(agentIdentifier, forceDrain) {
65
57
  });
66
58
  var prefix = 'api-';
67
59
  var spaPrefix = prefix + 'ixn-';
68
- apiInterface.log = function (message) {
69
- let {
70
- customAttributes = {},
71
- level = _constants4.LOG_LEVELS.INFO
72
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
+ apiInterface.log = function (message, {
61
+ customAttributes = {},
62
+ level = _constants4.LOG_LEVELS.INFO
63
+ } = {}) {
73
64
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/log/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
74
65
  (0, _utils.bufferLog)(instanceEE, message, customAttributes, level);
75
66
  };
76
- apiInterface.wrapLogger = function (parent, functionName) {
77
- let {
78
- customAttributes = {},
79
- level = _constants4.LOG_LEVELS.INFO
80
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
67
+ apiInterface.wrapLogger = (parent, functionName, {
68
+ customAttributes = {},
69
+ level = _constants4.LOG_LEVELS.INFO
70
+ } = {}) => {
81
71
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['API/wrapLogger/called'], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
82
72
  (0, _wrapLogger.wrapLogger)(instanceEE, parent, functionName, {
83
73
  customAttributes,
@@ -93,7 +83,7 @@ function setAPI(agentIdentifier, forceDrain) {
93
83
  apiInterface.setPageViewName = function (name, host) {
94
84
  if (typeof name !== 'string') return;
95
85
  if (name.charAt(0) !== '/') name = '/' + name;
96
- (0, _config.getRuntime)(agentIdentifier).customTransaction = (host || 'http://custom.transaction') + name;
86
+ (0, _runtime.getRuntime)(agentIdentifier).customTransaction = (host || 'http://custom.transaction') + name;
97
87
  return apiCall(prefix, 'setPageViewName', true)();
98
88
  };
99
89
 
@@ -106,11 +96,11 @@ function setAPI(agentIdentifier, forceDrain) {
106
96
  * @returns @see apiCall
107
97
  */
108
98
  function appendJsAttribute(key, value, apiName, addToBrowserStorage) {
109
- const currentInfo = (0, _config.getInfo)(agentIdentifier);
99
+ const currentInfo = (0, _info.getInfo)(agentIdentifier);
110
100
  if (value === null) {
111
101
  delete currentInfo.jsAttributes[key];
112
102
  } else {
113
- (0, _config.setInfo)(agentIdentifier, {
103
+ (0, _info.setInfo)(agentIdentifier, {
114
104
  ...currentInfo,
115
105
  jsAttributes: {
116
106
  ...currentInfo.jsAttributes,
@@ -120,8 +110,7 @@ function setAPI(agentIdentifier, forceDrain) {
120
110
  }
121
111
  return apiCall(prefix, apiName, true, !!addToBrowserStorage || value === null ? 'session' : undefined)(key, value);
122
112
  }
123
- apiInterface.setCustomAttribute = function (name, value) {
124
- let persistAttribute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
113
+ apiInterface.setCustomAttribute = function (name, value, persistAttribute = false) {
125
114
  if (typeof name !== 'string') {
126
115
  (0, _console.warn)(39, typeof name);
127
116
  return;
@@ -220,14 +209,13 @@ function setAPI(agentIdentifier, forceDrain) {
220
209
  };
221
210
 
222
211
  // theres no window.load event on non-browser scopes, lazy load immediately
223
- if (!_runtime.isBrowserScope) lazyLoad();
212
+ if (!_runtime2.isBrowserScope) lazyLoad();
224
213
  // try to stay out of the way of the window.load event, lazy load once that has finished.
225
214
  else (0, _load.onWindowLoad)(() => lazyLoad(), true);
226
215
  function lazyLoad() {
227
- Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "async-api" */'./apiAsync'))).then(_ref => {
228
- let {
229
- setAPI
230
- } = _ref;
216
+ Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "async-api" */'./apiAsync'))).then(({
217
+ setAPI
218
+ }) => {
231
219
  setAPI(agentIdentifier);
232
220
  (0, _drain.drain)(agentIdentifier, 'api');
233
221
  }).catch(err => {
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.setAPI = setAPI;
7
7
  var _features = require("../features/features");
8
- var _config = require("../../common/config/config");
8
+ var _runtime = require("../../common/config/runtime");
9
9
  var _contextualEe = require("../../common/event-emitter/contextual-ee");
10
10
  var _handle = require("../../common/event-emitter/handle");
11
11
  var _registerHandler = require("../../common/event-emitter/register-handler");
12
12
  var _invoke = require("../../common/util/invoke");
13
13
  var _constants = require("../../features/metrics/constants");
14
- var _runtime = require("../../common/constants/runtime");
14
+ var _runtime2 = require("../../common/constants/runtime");
15
15
  function setAPI(agentIdentifier) {
16
16
  var instanceEE = _contextualEe.ee.get(agentIdentifier);
17
17
  var api = {
@@ -22,22 +22,19 @@ function setAPI(agentIdentifier) {
22
22
  };
23
23
 
24
24
  // Hook all of the api functions up to the queues/stubs created in loader/api.js
25
- Object.entries(api).forEach(_ref => {
26
- let [fnName, fnCall] = _ref;
27
- return (0, _registerHandler.registerHandler)('api-' + fnName, fnCall, 'api', instanceEE);
28
- });
25
+ Object.entries(api).forEach(([fnName, fnCall]) => (0, _registerHandler.registerHandler)('api-' + fnName, fnCall, 'api', instanceEE));
29
26
 
30
27
  // All API functions get passed the time they were called as their
31
28
  // first parameter. These functions can be called asynchronously.
32
29
 
33
30
  function finished(t, providedTime) {
34
- var time = providedTime ? providedTime - _runtime.originTime : t;
31
+ var time = providedTime ? providedTime - _runtime2.originTime : t;
35
32
  (0, _handle.handle)(_constants.CUSTOM_METRIC_CHANNEL, ['finished', {
36
33
  time
37
34
  }], undefined, _features.FEATURE_NAMES.metrics, instanceEE);
38
35
  addToTrace(t, {
39
36
  name: 'finished',
40
- start: time + _runtime.originTime,
37
+ start: time + _runtime2.originTime,
41
38
  origin: 'nr'
42
39
  });
43
40
  (0, _handle.handle)('api-addPageAction', [time, 'finished'], undefined, _features.FEATURE_NAMES.genericEvents, instanceEE);
@@ -46,19 +43,19 @@ function setAPI(agentIdentifier) {
46
43
  if (!(evt && typeof evt === 'object' && evt.name && evt.start)) return;
47
44
  var report = {
48
45
  n: evt.name,
49
- s: evt.start - _runtime.originTime,
50
- e: (evt.end || evt.start) - _runtime.originTime,
46
+ s: evt.start - _runtime2.originTime,
47
+ e: (evt.end || evt.start) - _runtime2.originTime,
51
48
  o: evt.origin || '',
52
49
  t: 'api'
53
50
  };
54
51
  (0, _handle.handle)('bstApi', [report], undefined, _features.FEATURE_NAMES.sessionTrace, instanceEE);
55
52
  }
56
53
  function setErrorHandler(t, handler) {
57
- (0, _config.getRuntime)(agentIdentifier).onerror = handler;
54
+ (0, _runtime.getRuntime)(agentIdentifier).onerror = handler;
58
55
  }
59
56
  var releaseCount = 0;
60
57
  function addRelease(t, name, id) {
61
58
  if (++releaseCount > 10) return;
62
- (0, _config.getRuntime)(agentIdentifier).releaseIds[name.slice(-200)] = ('' + id).slice(-200);
59
+ (0, _runtime.getRuntime)(agentIdentifier).releaseIds[name.slice(-200)] = ('' + id).slice(-200);
63
60
  }
64
61
  }
@@ -6,9 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.configure = configure;
7
7
  var _api = require("../api/api");
8
8
  var _nreum = require("../../common/window/nreum");
9
- var _config = require("../../common/config/config");
9
+ var _info = require("../../common/config/info");
10
+ var _init = require("../../common/config/init");
11
+ var _loaderConfig = require("../../common/config/loader-config");
12
+ var _runtime = require("../../common/config/runtime");
10
13
  var _featureFlags = require("../../common/util/feature-flags");
11
- var _runtime = require("../../common/constants/runtime");
14
+ var _runtime2 = require("../../common/constants/runtime");
12
15
  var _publicPath = require("./public-path");
13
16
  var _contextualEe = require("../../common/event-emitter/contextual-ee");
14
17
  let alreadySetOnce = false; // the configure() function can run multiple times in agent lifecycle
@@ -16,10 +19,7 @@ let alreadySetOnce = false; // the configure() function can run multiple times i
16
19
  /**
17
20
  * Sets or re-sets the agent's configuration values from global settings. This also attach those as properties to the agent instance.
18
21
  */
19
- function configure(agent) {
20
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
21
- let loaderType = arguments.length > 2 ? arguments[2] : undefined;
22
- let forceDrain = arguments.length > 3 ? arguments[3] : undefined;
22
+ function configure(agent, opts = {}, loaderType, forceDrain) {
23
23
  // eslint-disable-next-line camelcase
24
24
  let {
25
25
  init,
@@ -36,16 +36,16 @@ function configure(agent) {
36
36
  // eslint-disable-next-line camelcase
37
37
  loader_config = nr.loader_config;
38
38
  }
39
- (0, _config.setConfiguration)(agent.agentIdentifier, init || {});
39
+ (0, _init.setConfiguration)(agent.agentIdentifier, init || {});
40
40
  // eslint-disable-next-line camelcase
41
- (0, _config.setLoaderConfig)(agent.agentIdentifier, loader_config || {});
41
+ (0, _loaderConfig.setLoaderConfig)(agent.agentIdentifier, loader_config || {});
42
42
  info.jsAttributes ??= {};
43
- if (_runtime.isWorkerScope) {
43
+ if (_runtime2.isWorkerScope) {
44
44
  // add a default attr to all worker payloads
45
45
  info.jsAttributes.isWorker = true;
46
46
  }
47
- (0, _config.setInfo)(agent.agentIdentifier, info);
48
- const updatedInit = (0, _config.getConfiguration)(agent.agentIdentifier);
47
+ (0, _info.setInfo)(agent.agentIdentifier, info);
48
+ const updatedInit = (0, _init.getConfiguration)(agent.agentIdentifier);
49
49
  const internalTrafficList = [info.beacon, info.errorBeacon];
50
50
  if (!alreadySetOnce) {
51
51
  if (updatedInit.proxy.assets) {
@@ -61,7 +61,7 @@ function configure(agent) {
61
61
  }
62
62
  runtime.denyList = [...(updatedInit.ajax.deny_list || []), ...(updatedInit.ajax.block_internal ? internalTrafficList : [])];
63
63
  runtime.ptid = agent.agentIdentifier;
64
- (0, _config.setRuntime)(agent.agentIdentifier, runtime);
64
+ (0, _runtime.setRuntime)(agent.agentIdentifier, runtime);
65
65
  agent.ee = _contextualEe.ee.get(agent.agentIdentifier);
66
66
  if (agent.api === undefined) agent.api = (0, _api.setAPI)(agent.agentIdentifier, forceDrain, agent.runSoftNavOverSpa);
67
67
  if (agent.exposed === undefined) agent.exposed = exposed;
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getEnabledFeatures = getEnabledFeatures;
7
7
  var _features = require("./features");
8
- var _config = require("../../common/config/config");
8
+ var _init = require("../../common/config/init");
9
9
  const featureNames = Object.values(_features.FEATURE_NAMES);
10
10
  function isEnabled(name, agentIdentifier) {
11
- return (0, _config.getConfigurationValue)(agentIdentifier, "".concat(name, ".enabled")) === true;
11
+ return (0, _init.getConfigurationValue)(agentIdentifier, "".concat(name, ".enabled")) === true;
12
12
  }
13
13
  function getEnabledFeatures(agentIdentifier) {
14
14
  const enabledFeatures = {};
@@ -9,7 +9,10 @@ var _enabledFeatures = require("./features/enabled-features");
9
9
  var _configure = require("./configure/configure");
10
10
  var _aggregator = require("../common/aggregate/aggregator");
11
11
  var _nreum = require("../common/window/nreum");
12
- var _config = require("../common/config/config");
12
+ var _info = require("../common/config/info");
13
+ var _init = require("../common/config/init");
14
+ var _loaderConfig = require("../common/config/loader-config");
15
+ var _runtime = require("../common/config/runtime");
13
16
  var _features = require("./features/features");
14
17
  var _console = require("../common/util/console");
15
18
  var _load = require("../common/window/load");
@@ -50,14 +53,14 @@ class MicroAgent extends _agentBase.AgentBase {
50
53
  * @param {string|string[]|undefined} name The feature name(s) to start. If no name(s) are passed, all features will be started
51
54
  */
52
55
  this.start = features => this.run(features);
53
- this.run(nonAutoFeatures.filter(featureName => (0, _config.getConfigurationValue)(this.agentIdentifier, "".concat(featureName, ".autoStart"))));
56
+ this.run(nonAutoFeatures.filter(featureName => (0, _init.getConfigurationValue)(this.agentIdentifier, "".concat(featureName, ".autoStart"))));
54
57
  }
55
58
  get config() {
56
59
  return {
57
- info: (0, _config.getInfo)(this.agentIdentifier),
58
- init: (0, _config.getConfiguration)(this.agentIdentifier),
59
- loader_config: (0, _config.getLoaderConfig)(this.agentIdentifier),
60
- runtime: (0, _config.getRuntime)(this.agentIdentifier)
60
+ info: (0, _info.getInfo)(this.agentIdentifier),
61
+ init: (0, _init.getConfiguration)(this.agentIdentifier),
62
+ loader_config: (0, _loaderConfig.getLoaderConfig)(this.agentIdentifier),
63
+ runtime: (0, _runtime.getRuntime)(this.agentIdentifier)
61
64
  };
62
65
  }
63
66
  run(features) {
@@ -83,15 +86,13 @@ class MicroAgent extends _agentBase.AgentBase {
83
86
  // these features do not import an "instrument" file, meaning they are only hooked up to the API.
84
87
  nonAutoFeatures.forEach(f => {
85
88
  if (enabledFeatures[f] && features.includes(f)) {
86
- Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(_ref => {
87
- let {
88
- lazyFeatureLoader
89
- } = _ref;
89
+ Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(({
90
+ lazyFeatureLoader
91
+ }) => {
90
92
  return lazyFeatureLoader(f, 'aggregate');
91
- }).then(_ref2 => {
92
- let {
93
- Aggregate
94
- } = _ref2;
93
+ }).then(({
94
+ Aggregate
95
+ }) => {
95
96
  this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator);
96
97
  }).catch(err => (0, _console.warn)(25, err));
97
98
  }
@@ -88,8 +88,7 @@ function aggregateMetrics(newMetrics, oldMetrics) {
88
88
  count: 0
89
89
  };
90
90
  oldMetrics.count += 1;
91
- Object.entries(newMetrics || {}).forEach(_ref => {
92
- let [key, value] = _ref;
91
+ Object.entries(newMetrics || {}).forEach(([key, value]) => {
93
92
  oldMetrics[key] = updateMetric(value, oldMetrics[key]);
94
93
  });
95
94
  return oldMetrics;
@@ -1,4 +1,4 @@
1
- import { warn } from '../../util/console';
1
+ import { warn } from '../util/console';
2
2
  export function getModeledObject(obj, model) {
3
3
  try {
4
4
  if (!obj || typeof obj !== 'object') return warn(3);
@@ -1,4 +1,4 @@
1
- import { defaults as nrDefaults, getNREUMInitializedAgent } from '../../window/nreum';
1
+ import { defaults as nrDefaults, getNREUMInitializedAgent } from '../window/nreum';
2
2
  import { getModeledObject } from './configurable';
3
3
  const model = {
4
4
  // preset defaults
@@ -1,8 +1,8 @@
1
- import { LOG_LEVELS } from '../../../features/logging/constants';
2
- import { isValidSelector } from '../../dom/query-selector';
3
- import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS } from '../../session/constants';
4
- import { warn } from '../../util/console';
5
- import { getNREUMInitializedAgent } from '../../window/nreum';
1
+ import { LOG_LEVELS } from '../../features/logging/constants';
2
+ import { isValidSelector } from '../dom/query-selector';
3
+ import { DEFAULT_EXPIRES_MS, DEFAULT_INACTIVE_MS } from '../session/constants';
4
+ import { warn } from '../util/console';
5
+ import { getNREUMInitializedAgent } from '../window/nreum';
6
6
  import { getModeledObject } from './configurable';
7
7
  const nrMask = '[data-nr-mask]';
8
8
  const model = () => {
@@ -1,4 +1,4 @@
1
- import { getNREUMInitializedAgent } from '../../window/nreum';
1
+ import { getNREUMInitializedAgent } from '../window/nreum';
2
2
  import { getModeledObject } from './configurable';
3
3
  const model = {
4
4
  accountID: undefined,
@@ -1,7 +1,13 @@
1
1
  import { getModeledObject } from './configurable';
2
- import { getNREUMInitializedAgent } from '../../window/nreum';
3
- import { globalScope, originTime } from '../../constants/runtime';
4
- import { BUILD_ENV, DIST_METHOD, VERSION } from "../../constants/env.npm";
2
+ import { getNREUMInitializedAgent } from '../window/nreum';
3
+ import { globalScope, originTime } from '../constants/runtime';
4
+ import { BUILD_ENV, DIST_METHOD, VERSION } from "../constants/env.npm";
5
+
6
+ /**
7
+ * Module level count of harvests. This property will auto-increment each time it is accessed.
8
+ * @type {number}
9
+ */
10
+ let harvestCount = 0;
5
11
  const readonly = {
6
12
  buildEnv: BUILD_ENV,
7
13
  distMethod: DIST_METHOD,
@@ -22,8 +28,8 @@ const model = {
22
28
  appMetadata: {},
23
29
  session: undefined,
24
30
  denyList: undefined,
25
- harvestCount: 0,
26
- timeKeeper: undefined
31
+ timeKeeper: undefined,
32
+ obfuscator: undefined
27
33
  };
28
34
  const _cache = {};
29
35
  export function getRuntime(id) {
@@ -37,6 +43,12 @@ export function setRuntime(id, obj) {
37
43
  ...getModeledObject(obj, model),
38
44
  ...readonly
39
45
  };
46
+ if (!Object.hasOwnProperty.call(_cache[id], 'harvestCount')) {
47
+ // Harvest count needs to be added as a getter so the variable is updated each time it is accessed
48
+ Object.defineProperty(_cache[id], 'harvestCount', {
49
+ get: () => ++harvestCount
50
+ });
51
+ }
40
52
  const agentInst = getNREUMInitializedAgent(id);
41
53
  if (agentInst) agentInst.runtime = _cache[id];
42
54
  }
@@ -0,0 +1,2 @@
1
+ export const IDEAL_PAYLOAD_SIZE = 64000;
2
+ export const MAX_PAYLOAD_SIZE = 1000000;
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.264.0";
9
+ export const VERSION = "1.265.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.264.0";
9
+ export const VERSION = "1.265.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -9,8 +9,7 @@ export class SharedContext {
9
9
  if (typeof context !== 'object') return warn(8);
10
10
  this.sharedContext = {};
11
11
  Object.assign(this.sharedContext, model);
12
- Object.entries(context).forEach(_ref => {
13
- let [key, value] = _ref;
12
+ Object.entries(context).forEach(([key, value]) => {
14
13
  if (Object.keys(model).includes(key)) this.sharedContext[key] = value;
15
14
  });
16
15
  } catch (err) {
@@ -1,7 +1,6 @@
1
1
  import { globalScope } from '../constants/runtime';
2
2
  const GLOBAL_EVENT_NAMESPACE = 'newrelic';
3
- export function dispatchGlobalEvent() {
4
- let detail = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3
+ export function dispatchGlobalEvent(detail = {}) {
5
4
  try {
6
5
  globalScope.dispatchEvent(new CustomEvent(GLOBAL_EVENT_NAMESPACE, {
7
6
  detail
@@ -6,6 +6,7 @@
6
6
  import { ee } from '../event-emitter/contextual-ee';
7
7
  import { registerHandler as defaultRegister } from '../event-emitter/register-handler';
8
8
  import { featurePriority } from '../../loaders/features/features';
9
+ import { EventContext } from '../event-emitter/event-context';
9
10
  const registry = {};
10
11
 
11
12
  /**
@@ -56,10 +57,7 @@ function curateRegistry(agentIdentifier) {
56
57
  * @param {string} featureName - A named group into which the feature's buffered events are bucketed.
57
58
  * @param {boolean} force - Whether to force the drain to occur immediately, bypassing the registry and staging logic.
58
59
  */
59
- export function drain() {
60
- let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
61
- let featureName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'feature';
62
- let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
60
+ export function drain(agentIdentifier = '', featureName = 'feature', force = false) {
63
61
  curateRegistry(agentIdentifier);
64
62
  // If the feature for the specified agent is not in the registry, that means the instrument file was bypassed.
65
63
  // This could happen in tests, or loaders that directly import the aggregator. In these cases it is safe to
@@ -76,13 +74,9 @@ function checkCanDrainAll(agentIdentifier) {
76
74
  // Only when the event-groups for all features are ready to drain (staged) do we execute the drain. This has the effect
77
75
  // that the last feature to call drain triggers drain for all features.
78
76
  const items = Array.from(registry[agentIdentifier]);
79
- if (items.every(_ref => {
80
- let [key, values] = _ref;
81
- return values.staged;
82
- })) {
77
+ if (items.every(([key, values]) => values.staged)) {
83
78
  items.sort((a, b) => a[1].priority - b[1].priority);
84
- items.forEach(_ref2 => {
85
- let [group] = _ref2;
79
+ items.forEach(([group]) => {
86
80
  registry[agentIdentifier].delete(group);
87
81
  drainGroup(agentIdentifier, group);
88
82
  });
@@ -94,8 +88,7 @@ function checkCanDrainAll(agentIdentifier) {
94
88
  * the subscribed handlers for the group.
95
89
  * @param {*} group - The name of a particular feature's event "bucket".
96
90
  */
97
- function drainGroup(agentIdentifier, group) {
98
- let activateGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
91
+ function drainGroup(agentIdentifier, group, activateGroup = true) {
99
92
  const baseEE = agentIdentifier ? ee.get(agentIdentifier) : ee;
100
93
  const handlers = defaultRegister.handlers; // other storage in registerHandler
101
94
  if (baseEE.aborted || !baseEE.backlog || !handlers) return;
@@ -110,11 +103,12 @@ function drainGroup(agentIdentifier, group) {
110
103
  // eslint-disable-line no-unmodified-loop-condition
111
104
  emitEvent(bufferedEventsInGroup[i], groupHandlers);
112
105
  }
113
- Object.entries(groupHandlers).forEach(_ref3 => {
114
- let [eventType, handlerRegistrationList] = _ref3;
106
+ Object.entries(groupHandlers).forEach(([eventType, handlerRegistrationList]) => {
115
107
  Object.values(handlerRegistrationList || {}).forEach(registration => {
116
- // registration is an array of: [targetEE, eventHandler]
117
- registration[0].on(eventType, registration[1]);
108
+ // registration *should* be an array of: [targetEE, eventHandler]
109
+ // certain browser polyfills of .values and .entries pass the prototype methods into the callback,
110
+ // which breaks this assumption and throws errors. So we make sure here that we only call .on() if its an actual NR EE
111
+ if (registration[0]?.on && registration[0]?.context() instanceof EventContext) registration[0].on(eventType, registration[1]);
118
112
  });
119
113
  });
120
114
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { gosNREUM } from '../window/nreum';
7
7
  import { getOrSet } from '../util/get-or-set';
8
- import { getRuntime } from '../config/config';
8
+ import { getRuntime } from '../config/runtime';
9
9
  import { EventContext } from './event-context';
10
10
  import { bundleId } from '../ids/bundle-id';
11
11
 
@@ -125,8 +125,7 @@ function ee(old, debugId) {
125
125
 
126
126
  // do not buffer events if agent has been aborted
127
127
  if (emitter.aborted) return;
128
- Object.entries(types || {}).forEach(_ref => {
129
- let [_, type] = _ref;
128
+ Object.entries(types || {}).forEach(([_, type]) => {
130
129
  bufferGroupMap[type] = group;
131
130
  if (!(group in eventBuffer)) {
132
131
  eventBuffer[group] = [];
@@ -30,14 +30,10 @@ export function eventListenerOpts(useCapture, abortSignal) {
30
30
  }
31
31
 
32
32
  /** Do not use this within the worker context. */
33
- export function windowAddEventListener(event, listener) {
34
- let capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
35
- let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
33
+ export function windowAddEventListener(event, listener, capture = false, abortSignal) {
36
34
  window.addEventListener(event, listener, eventListenerOpts(capture, abortSignal));
37
35
  }
38
36
  /** Do not use this within the worker context. */
39
- export function documentAddEventListener(event, listener) {
40
- let capture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
41
- let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
37
+ export function documentAddEventListener(event, listener, capture = false, abortSignal) {
42
38
  document.addEventListener(event, listener, eventListenerOpts(capture, abortSignal));
43
39
  }
@@ -62,8 +62,7 @@ export class HarvestScheduler extends SharedContext {
62
62
  this.started = true;
63
63
  this.scheduleHarvest(initialDelay != null ? initialDelay : this.interval);
64
64
  }
65
- stopTimer() {
66
- let permanently = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
65
+ stopTimer(permanently = false) {
67
66
  this.aborted = permanently; // stopping permanently is same as aborting, but this function also cleans up the setTimeout loop
68
67
  this.started = false;
69
68
  if (this.timeoutHandle) {