@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
@@ -6,27 +6,30 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Aggregate = void 0;
7
7
  var _registerHandler = require("../../../common/event-emitter/register-handler");
8
8
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
9
- var _config = require("../../../common/config/config");
9
+ var _info = require("../../../common/config/info");
10
+ var _init = require("../../../common/config/init");
11
+ var _runtime = require("../../../common/config/runtime");
10
12
  var _constants = require("../constants");
11
13
  var _aggregateBase = require("../../utils/aggregate-base");
12
14
  var _storage = require("./trace/storage");
13
15
  var _encode = require("../../../common/url/encode");
14
16
  var _drain = require("../../../common/drain/drain");
15
- var _runtime = require("../../../common/constants/runtime");
17
+ var _runtime2 = require("../../../common/constants/runtime");
16
18
  var _constants2 = require("../../../common/session/constants");
19
+ var _traverse = require("../../../common/util/traverse");
17
20
  const ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
18
21
  /** Reserved room for query param attrs */
19
22
  const QUERY_PARAM_PADDING = 5000;
20
23
  class Aggregate extends _aggregateBase.AggregateBase {
21
- static featureName = (() => _constants.FEATURE_NAME)();
24
+ static featureName = _constants.FEATURE_NAME;
22
25
  constructor(agentIdentifier, aggregator) {
23
26
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
24
- this.agentRuntime = (0, _config.getRuntime)(agentIdentifier);
25
- this.agentInfo = (0, _config.getInfo)(agentIdentifier);
27
+ this.agentRuntime = (0, _runtime.getRuntime)(agentIdentifier);
28
+ this.agentInfo = (0, _info.getInfo)(agentIdentifier);
26
29
 
27
30
  /** A buffer to hold on to harvested traces in the case that a retry must be made later */
28
31
  this.sentTrace = null;
29
- this.harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.harvestTimeSeconds') || 30;
32
+ this.harvestTimeSeconds = (0, _init.getConfigurationValue)(agentIdentifier, 'session_trace.harvestTimeSeconds') || 30;
30
33
  /** Tied to the entitlement flag response from BCS. Will short circuit operations of the agg if false */
31
34
  this.entitled = undefined;
32
35
  /** A flag used to decide if the 30 node threshold should be ignored on the first harvest to ensure sending on the first payload */
@@ -36,15 +39,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
36
39
  /** TraceStorage is the mechanism that holds, normalizes and aggregates ST nodes. It will be accessed and purged when harvests occur */
37
40
  this.traceStorage = new _storage.TraceStorage(this);
38
41
  /** This agg needs information about sampling (sts) and entitlements (st) to make the appropriate decisions on running */
39
- this.waitForFlags(['sts', 'st']).then(_ref => {
40
- let [stMode, stEntitled] = _ref;
41
- return this.initialize(stMode, stEntitled);
42
- });
42
+ this.waitForFlags(['sts', 'st']).then(([stMode, stEntitled]) => this.initialize(stMode, stEntitled));
43
43
  }
44
44
 
45
45
  /** Sets up event listeners, and initializes this module to run in the correct "mode". Can be triggered from a few places, but makes an effort to only set up listeners once */
46
46
  initialize(stMode, stEntitled, ignoreSession) {
47
- var _this = this;
48
47
  this.entitled ??= stEntitled;
49
48
  if (this.blocked || !this.entitled) return (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
50
49
  if (!this.initialized) {
@@ -84,31 +83,17 @@ class Aggregate extends _aggregateBase.AggregateBase {
84
83
  }, this);
85
84
 
86
85
  /** The handlers set up by the Inst file */
87
- (0, _registerHandler.registerHandler)('bst', function () {
88
- return _this.traceStorage.storeEvent(...arguments);
89
- }, this.featureName, this.ee);
90
- (0, _registerHandler.registerHandler)('bstResource', function () {
91
- return _this.traceStorage.storeResources(...arguments);
92
- }, this.featureName, this.ee);
93
- (0, _registerHandler.registerHandler)('bstHist', function () {
94
- return _this.traceStorage.storeHist(...arguments);
95
- }, this.featureName, this.ee);
96
- (0, _registerHandler.registerHandler)('bstXhrAgg', function () {
97
- return _this.traceStorage.storeXhrAgg(...arguments);
98
- }, this.featureName, this.ee);
99
- (0, _registerHandler.registerHandler)('bstApi', function () {
100
- return _this.traceStorage.storeSTN(...arguments);
101
- }, this.featureName, this.ee);
102
- (0, _registerHandler.registerHandler)('trace-jserror', function () {
103
- return _this.traceStorage.storeErrorAgg(...arguments);
104
- }, this.featureName, this.ee);
105
- (0, _registerHandler.registerHandler)('pvtAdded', function () {
106
- return _this.traceStorage.processPVT(...arguments);
107
- }, this.featureName, this.ee);
86
+ (0, _registerHandler.registerHandler)('bst', (...args) => this.traceStorage.storeEvent(...args), this.featureName, this.ee);
87
+ (0, _registerHandler.registerHandler)('bstResource', (...args) => this.traceStorage.storeResources(...args), this.featureName, this.ee);
88
+ (0, _registerHandler.registerHandler)('bstHist', (...args) => this.traceStorage.storeHist(...args), this.featureName, this.ee);
89
+ (0, _registerHandler.registerHandler)('bstXhrAgg', (...args) => this.traceStorage.storeXhrAgg(...args), this.featureName, this.ee);
90
+ (0, _registerHandler.registerHandler)('bstApi', (...args) => this.traceStorage.storeSTN(...args), this.featureName, this.ee);
91
+ (0, _registerHandler.registerHandler)('trace-jserror', (...args) => this.traceStorage.storeErrorAgg(...args), this.featureName, this.ee);
92
+ (0, _registerHandler.registerHandler)('pvtAdded', (...args) => this.traceStorage.processPVT(...args), this.featureName, this.ee);
108
93
  if (typeof PerformanceNavigationTiming !== 'undefined') {
109
- this.traceStorage.storeTiming(_runtime.globalScope.performance?.getEntriesByType?.('navigation')[0]);
94
+ this.traceStorage.storeTiming(_runtime2.globalScope.performance?.getEntriesByType?.('navigation')[0]);
110
95
  } else {
111
- this.traceStorage.storeTiming(_runtime.globalScope.performance?.timing);
96
+ this.traceStorage.storeTiming(_runtime2.globalScope.performance?.timing, true);
112
97
  }
113
98
 
114
99
  /** Only start actually harvesting if running in full mode at init time */
@@ -132,8 +117,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
132
117
  }
133
118
 
134
119
  /** Called by the harvest scheduler at harvest time to retrieve the payload. This will only actually return a payload if running in full mode */
135
- prepareHarvest() {
136
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
120
+ prepareHarvest(options = {}) {
137
121
  this.traceStorage.prevStoredEvents.clear(); // release references to past events for GC
138
122
  if (!this.timeKeeper?.ready) return; // this should likely never happen, but just to be safe, we should never harvest if we cant correct time
139
123
  if (this.blocked || this.mode !== _constants2.MODE.FULL || this.traceStorage.nodeCount === 0) return;
@@ -172,7 +156,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
172
156
  type: 'BrowserSessionChunk',
173
157
  app_id: this.agentInfo.applicationID,
174
158
  protocol_version: '0',
175
- timestamp: this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
159
+ timestamp: Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp))),
176
160
  attributes: (0, _encode.obj)({
177
161
  ...(agentMetadata.entityGuid && {
178
162
  entityGuid: agentMetadata.entityGuid
@@ -181,8 +165,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
181
165
  // this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
182
166
  // if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
183
167
  // trace payload metadata
184
- 'trace.firstTimestamp': this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
185
- 'trace.lastTimestamp': this.timeKeeper.convertRelativeTimestamp(latestTimeStamp),
168
+ 'trace.firstTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp))),
169
+ 'trace.lastTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(latestTimeStamp))),
186
170
  'trace.nodes': stns.length,
187
171
  'trace.originTimestamp': this.timeKeeper.correctedOriginTime,
188
172
  // other payload metadata
@@ -197,12 +181,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
197
181
  session: "".concat(this.sessionId),
198
182
  // customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
199
183
  ...(endUserId && {
200
- 'enduser.id': endUserId
184
+ 'enduser.id': this.obfuscator.obfuscateString(endUserId)
201
185
  })
202
186
  // The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
203
187
  }, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
204
188
  },
205
- body: stns
189
+ body: (0, _traverse.applyFnToProps)(stns, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
206
190
  };
207
191
  }
208
192
 
@@ -212,8 +196,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
212
196
  onHarvestFinished(result) {
213
197
  if (result.sent && result.retry && this.sentTrace) {
214
198
  // merge previous trace back into buffer to retry for next harvest
215
- Object.entries(this.sentTrace).forEach(_ref2 => {
216
- let [name, listOfSTNodes] = _ref2;
199
+ Object.entries(this.sentTrace).forEach(([name, listOfSTNodes]) => {
217
200
  this.traceStorage.restoreNode(name, listOfSTNodes);
218
201
  });
219
202
  this.sentTrace = null;
@@ -39,10 +39,10 @@ const toAggregate = {
39
39
  class TraceStorage {
40
40
  nodeCount = 0;
41
41
  trace = {};
42
- earliestTimeStamp = (() => Infinity)();
42
+ earliestTimeStamp = Infinity;
43
43
  latestTimeStamp = 0;
44
44
  tempStorage = [];
45
- prevStoredEvents = (() => new Set())();
45
+ prevStoredEvents = new Set();
46
46
  constructor(parent) {
47
47
  this.parent = parent;
48
48
  }
@@ -97,8 +97,7 @@ class TraceStorage {
97
97
  // if PO isn't supported, this checks resourcetiming buffer every harvest.
98
98
  this.storeResources(_runtime.globalScope.performance?.getEntriesByType?.('resource'));
99
99
  }
100
- const stns = Object.entries(this.trace).flatMap(_ref => {
101
- let [name, listOfSTNodes] = _ref;
100
+ const stns = Object.entries(this.trace).flatMap(([name, listOfSTNodes]) => {
102
101
  // basically take the "this.trace" map-obj and concat all the list-type values
103
102
  if (!(name in toAggregate)) return listOfSTNodes;
104
103
  // Special processing for event nodes dealing with user inputs:
@@ -156,7 +155,7 @@ class TraceStorage {
156
155
  return name === 'fi' && !!attrs && typeof attrs.fid === 'number';
157
156
  }
158
157
  }
159
- storeTiming(timingEntry) {
158
+ storeTiming(timingEntry, isAbsoluteTimestamp = false) {
160
159
  if (!timingEntry) return;
161
160
 
162
161
  // loop iterates through prototype also (for FF)
@@ -171,6 +170,9 @@ class TraceStorage {
171
170
  // that are in the future (Microsoft Edge seems to sometimes produce these)
172
171
  if (!(typeof val === 'number' && val >= 0)) continue;
173
172
  val = Math.round(val);
173
+ if (this.parent.timeKeeper && this.parent.timeKeeper.ready && isAbsoluteTimestamp) {
174
+ val = this.parent.timeKeeper.convertAbsoluteTimestamp(Math.floor(this.parent.timeKeeper.correctAbsoluteTimestamp(val)));
175
+ }
174
176
  this.storeSTN(new _node.TraceNode(key, val, val, 'document', 'timing'));
175
177
  }
176
178
  }
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
6
+ exports.SessionTrace = exports.Instrument = void 0;
7
7
  var _handle = require("../../../common/event-emitter/handle");
8
- var _wrap = require("../../../common/wrap");
8
+ var _wrapHistory = require("../../../common/wrap/wrap-history");
9
+ var _wrapEvents = require("../../../common/wrap/wrap-events");
9
10
  var _instrumentBase = require("../../utils/instrument-base");
10
11
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
11
12
  var _features = require("../../../loaders/features/features");
@@ -30,9 +31,8 @@ const {
30
31
  PUSH_STATE
31
32
  } = CONSTANTS;
32
33
  class Instrument extends _instrumentBase.InstrumentBase {
33
- static featureName = (() => FEATURE_NAME)();
34
- constructor(agentIdentifier, aggregator) {
35
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
34
+ static featureName = FEATURE_NAME;
35
+ constructor(agentIdentifier, aggregator, auto = true) {
36
36
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
37
37
  const canTrackSession = (0, _featureGates.canEnableSessionTracking)(this.agentIdentifier);
38
38
  if (!canTrackSession) {
@@ -40,8 +40,8 @@ class Instrument extends _instrumentBase.InstrumentBase {
40
40
  return;
41
41
  }
42
42
  const thisInstrumentEE = this.ee;
43
- (0, _wrap.wrapHistory)(thisInstrumentEE);
44
- this.eventsEE = (0, _wrap.wrapEvents)(thisInstrumentEE);
43
+ (0, _wrapHistory.wrapHistory)(thisInstrumentEE);
44
+ this.eventsEE = (0, _wrapEvents.wrapEvents)(thisInstrumentEE);
45
45
  this.eventsEE.on(FN_START, function (args, target) {
46
46
  this.bstStart = (0, _now.now)();
47
47
  });
@@ -77,4 +77,5 @@ class Instrument extends _instrumentBase.InstrumentBase {
77
77
  });
78
78
  }
79
79
  }
80
- exports.Instrument = Instrument;
80
+ exports.Instrument = Instrument;
81
+ const SessionTrace = exports.SessionTrace = Instrument;
@@ -22,7 +22,7 @@ class AjaxNode extends _belNode.BelNode {
22
22
  this.traceId = ajaxEvent.traceId;
23
23
  this.spanTimestamp = ajaxEvent.spanTimestamp;
24
24
  this.gql = ajaxEvent.gql;
25
- this.start = ajaxEvent.startTime;
25
+ this.start = ajaxEvent.startTime; // 5000 --- 5500 --> 10500
26
26
  this.end = ajaxEvent.endTime;
27
27
  }
28
28
  serialize(parentStartTimestamp) {
@@ -13,7 +13,7 @@ class BelNode {
13
13
  end;
14
14
  callbackEnd = 0;
15
15
  callbackDuration = 0;
16
- nodeId = (() => ++nodesSeen)();
16
+ nodeId = ++nodesSeen;
17
17
  constructor(agentIdentifier) {
18
18
  if (!agentIdentifier) throw new Error('Interaction is missing core attributes');
19
19
  this.agentIdentifier = agentIdentifier;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Aggregate = void 0;
7
- var _config = require("../../../common/config/config");
7
+ var _init = require("../../../common/config/init");
8
8
  var _drain = require("../../../common/drain/drain");
9
9
  var _handle = require("../../../common/event-emitter/handle");
10
10
  var _registerHandler = require("../../../common/event-emitter/register-handler");
@@ -14,30 +14,28 @@ var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
14
14
  var _features = require("../../../loaders/features/features");
15
15
  var _constants = require("../../metrics/constants");
16
16
  var _aggregateBase = require("../../utils/aggregate-base");
17
+ var _eventBuffer = require("../../utils/event-buffer");
17
18
  var _constants2 = require("../constants");
18
19
  var _ajaxNode = require("./ajax-node");
19
20
  var _initialPageLoadInteraction = require("./initial-page-load-interaction");
20
21
  var _interaction = require("./interaction");
21
22
  class Aggregate extends _aggregateBase.AggregateBase {
22
- static featureName = (() => _constants2.FEATURE_NAME)();
23
- constructor(agentIdentifier, aggregator, _ref) {
24
- let {
25
- domObserver
26
- } = _ref;
23
+ static featureName = _constants2.FEATURE_NAME;
24
+ constructor(agentIdentifier, aggregator, {
25
+ domObserver
26
+ }) {
27
27
  super(agentIdentifier, aggregator, _constants2.FEATURE_NAME);
28
- const harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'soft_navigations.harvestTimeSeconds') || 10;
29
- this.interactionsToHarvest = [];
30
- this.interactionsAwaitingRetry = [];
28
+ const harvestTimeSeconds = (0, _init.getConfigurationValue)(agentIdentifier, 'soft_navigations.harvestTimeSeconds') || 10;
29
+ this.interactionsToHarvest = new _eventBuffer.EventBuffer();
31
30
  this.domObserver = domObserver;
32
31
  this.initialPageLoadInteraction = new _initialPageLoadInteraction.InitialPageLoadInteraction(agentIdentifier);
33
- _timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
34
- let {
35
- attrs
36
- } = _ref2;
32
+ _timeToFirstByte.timeToFirstByte.subscribe(({
33
+ attrs
34
+ }) => {
37
35
  const loadEventTime = attrs.navigationEntry.loadEventEnd;
38
36
  this.initialPageLoadInteraction.forceSave = true;
39
37
  this.initialPageLoadInteraction.done(loadEventTime);
40
- this.interactionsToHarvest.push(this.initialPageLoadInteraction);
38
+ this.interactionsToHarvest.add(this.initialPageLoadInteraction);
41
39
  this.initialPageLoadInteraction = null;
42
40
  // Report metric on the initial page load time
43
41
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['SoftNav/Interaction/InitialPageLoad/Duration/Ms', Math.round(loadEventTime)], undefined, _features.FEATURE_NAMES.metrics, this.ee);
@@ -46,8 +44,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
46
44
  this.interactionInProgress = null; // aside from the "page load" interaction, there can only ever be 1 ongoing at a time
47
45
 
48
46
  this.blocked = false;
49
- this.waitForFlags(['spa']).then(_ref3 => {
50
- let [spaOn] = _ref3;
47
+ this.waitForFlags(['spa']).then(([spaOn]) => {
51
48
  if (spaOn) {
52
49
  this.drain();
53
50
  const scheduler = new _harvestScheduler.HarvestScheduler('events', {
@@ -78,18 +75,17 @@ class Aggregate extends _aggregateBase.AggregateBase {
78
75
  (0, _registerHandler.registerHandler)('jserror', this.#handleJserror.bind(this), this.featureName, this.ee);
79
76
  }
80
77
  onHarvestStarted(options) {
81
- if (this.interactionsToHarvest.length === 0 || this.blocked) return;
78
+ if (!this.interactionsToHarvest.hasData || this.blocked) return;
82
79
  // The payload depacker takes the first ixn of a payload (if there are multiple ixns) and positively offset the subsequent ixns timestamps by that amount.
83
80
  // In order to accurately portray the real start & end times of the 2nd & onward ixns, we hence need to negatively offset their start timestamps with that of the 1st ixn.
84
81
  let firstIxnStartTime = 0; // the very 1st ixn does not require any offsetting
85
82
  const serializedIxnList = [];
86
- for (const interaction of this.interactionsToHarvest) {
83
+ for (const interaction of this.interactionsToHarvest.buffer) {
87
84
  serializedIxnList.push(interaction.serialize(firstIxnStartTime));
88
85
  if (!firstIxnStartTime) firstIxnStartTime = Math.floor(interaction.start);
89
86
  }
90
87
  const payload = "bel.7;".concat(serializedIxnList.join(';'));
91
- if (options.retry) this.interactionsAwaitingRetry = this.interactionsToHarvest;
92
- this.interactionsToHarvest = [];
88
+ if (options.retry) this.interactionsToHarvest.hold();else this.interactionsToHarvest.clear();
93
89
  return {
94
90
  body: {
95
91
  e: payload
@@ -97,10 +93,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
97
93
  };
98
94
  }
99
95
  onHarvestFinished(result) {
100
- if (result.sent && result.retry && this.interactionsAwaitingRetry.length > 0) {
101
- this.interactionsToHarvest = [...this.interactionsAwaitingRetry, ...this.interactionsToHarvest];
102
- }
103
- this.interactionsAwaitingRetry = [];
96
+ if (result.sent && result.retry && this.interactionsToHarvest.held.hasData) this.interactionsToHarvest.unhold();else this.interactionsToHarvest.held.clear();
104
97
  }
105
98
  startUIInteraction(eventName, startedAt, sourceElem) {
106
99
  // this is throttled by instrumentation so that it isn't excessively called
@@ -121,7 +114,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
121
114
  setClosureHandlers() {
122
115
  this.interactionInProgress.on('finished', () => {
123
116
  const ref = this.interactionInProgress;
124
- this.interactionsToHarvest.push(this.interactionInProgress);
117
+ this.interactionsToHarvest.add(this.interactionInProgress);
125
118
  this.interactionInProgress = null;
126
119
  this.domObserver.disconnect(); // can stop observing whenever our interaction logic completes a cycle
127
120
 
@@ -148,9 +141,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
148
141
  */
149
142
  if (this.interactionInProgress?.isActiveDuring(timestamp)) return this.interactionInProgress;
150
143
  let saveIxn;
151
- for (let idx = this.interactionsToHarvest.length - 1; idx >= 0; idx--) {
144
+ for (let idx = this.interactionsToHarvest.buffer.length - 1; idx >= 0; idx--) {
152
145
  // reverse search for the latest completed interaction for efficiency
153
- const finishedInteraction = this.interactionsToHarvest[idx];
146
+ const finishedInteraction = this.interactionsToHarvest.buffer[idx];
154
147
  if (finishedInteraction.isActiveDuring(timestamp)) {
155
148
  if (finishedInteraction.trigger !== 'initialPageLoad') return finishedInteraction;
156
149
  // It's possible that a complete interaction occurs before page is fully loaded, so we need to consider if a route-change ixn may have overlapped this iPL
@@ -210,10 +203,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
210
203
  #registerApiHandlers() {
211
204
  const INTERACTION_API = 'api-ixn-';
212
205
  const thisClass = this;
213
- (0, _registerHandler.registerHandler)(INTERACTION_API + 'get', function (time) {
214
- let {
215
- waitForEnd
216
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
206
+ (0, _registerHandler.registerHandler)(INTERACTION_API + 'get', function (time, {
207
+ waitForEnd
208
+ } = {}) {
217
209
  // In here, 'this' refers to the EventContext specific to per InteractionHandle instance spawned by each .interaction() api call.
218
210
  // Each api call aka IH instance would therefore retain a reference to either the in-progress interaction *at the time of the call* OR a new api-started interaction.
219
211
  this.associatedInteraction = thisClass.getInteractionFor(time);
@@ -9,11 +9,11 @@ var _interaction = require("./interaction");
9
9
  var _belSerializer = require("../../../common/serialize/bel-serializer");
10
10
  var _firstPaint = require("../../../common/vitals/first-paint");
11
11
  var _firstContentfulPaint = require("../../../common/vitals/first-contentful-paint");
12
- var _config = require("../../../common/config/config");
12
+ var _info = require("../../../common/config/info");
13
13
  class InitialPageLoadInteraction extends _interaction.Interaction {
14
14
  constructor(agentIdentifier) {
15
15
  super(agentIdentifier, 'initialPageLoad', 0, null);
16
- const agentInfo = (0, _config.getInfo)(agentIdentifier);
16
+ const agentInfo = (0, _info.getInfo)(agentIdentifier);
17
17
  this.queueTime = agentInfo.queueTime;
18
18
  this.appTime = agentInfo.applicationTime;
19
19
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Interaction = void 0;
7
- var _config = require("../../../common/config/config");
7
+ var _info = require("../../../common/config/info");
8
8
  var _runtime = require("../../../common/constants/runtime");
9
9
  var _uniqueId = require("../../../common/ids/unique-id");
10
10
  var _belSerializer = require("../../../common/serialize/bel-serializer");
@@ -16,10 +16,10 @@ var _belNode = require("./bel-node");
16
16
  * link https://github.com/newrelic/nr-querypack/blob/main/schemas/bel/7.qpschema
17
17
  **/
18
18
  class Interaction extends _belNode.BelNode {
19
- id = (() => (0, _uniqueId.generateUuid)())(); // unique id that is serialized and used to link interactions with errors
20
- initialPageURL = (() => _runtime.initialLocation)();
21
- oldURL = (() => '' + _runtime.globalScope?.location)();
22
- newURL = (() => '' + _runtime.globalScope?.location)();
19
+ id = (0, _uniqueId.generateUuid)(); // unique id that is serialized and used to link interactions with errors
20
+ initialPageURL = _runtime.initialLocation;
21
+ oldURL = '' + _runtime.globalScope?.location;
22
+ newURL = '' + _runtime.globalScope?.location;
23
23
  customName;
24
24
  customAttributes = {};
25
25
  customDataByApi = {};
@@ -27,7 +27,7 @@ class Interaction extends _belNode.BelNode {
27
27
  appTime; // only used by initialPageLoad interactions
28
28
  newRoute;
29
29
  /** Internal state of this interaction: in-progress, finished, or cancelled. */
30
- status = (() => _constants.INTERACTION_STATUS.IP)();
30
+ status = _constants.INTERACTION_STATUS.IP;
31
31
  domTimestamp = 0;
32
32
  historyTimestamp = 0;
33
33
  createdByApi = false;
@@ -70,13 +70,12 @@ class Interaction extends _belNode.BelNode {
70
70
  else this.#cancel();
71
71
  return true;
72
72
  }
73
- #finish() {
74
- let customEndTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
73
+ #finish(customEndTime = 0) {
75
74
  if (this.status !== _constants.INTERACTION_STATUS.IP) return; // disallow this call if the ixn is already done aka not in-progress
76
75
  clearTimeout(this.cancellationTimer);
77
76
  this.end = Math.max(this.domTimestamp, this.historyTimestamp, customEndTime);
78
77
  this.customAttributes = {
79
- ...(0, _config.getInfo)(this.agentIdentifier).jsAttributes,
78
+ ...(0, _info.getInfo)(this.agentIdentifier).jsAttributes,
80
79
  ...this.customAttributes
81
80
  }; // attrs specific to this interaction should have precedence over the general custom attrs
82
81
  this.status = _constants.INTERACTION_STATUS.FIN;
@@ -129,7 +128,7 @@ class Interaction extends _belNode.BelNode {
129
128
  // not relative
130
129
  addString(this.trigger), addString((0, _cleanUrl.cleanURL)(this.initialPageURL, true)), addString((0, _cleanUrl.cleanURL)(this.oldURL, true)), addString((0, _cleanUrl.cleanURL)(this.newURL, true)), addString(this.customName), ixnType, (0, _belSerializer.nullable)(this.queueTime, _belSerializer.numeric, true) + (0, _belSerializer.nullable)(this.appTime, _belSerializer.numeric, true) + (0, _belSerializer.nullable)(this.oldRoute, addString, true) + (0, _belSerializer.nullable)(this.newRoute, addString, true) + addString(this.id), addString(this.nodeId), (0, _belSerializer.nullable)(this.firstPaint, _belSerializer.numeric, true) + (0, _belSerializer.nullable)(this.firstContentfulPaint, _belSerializer.numeric)];
131
130
  const allAttachedNodes = (0, _belSerializer.addCustomAttributes)(this.customAttributes || {}, addString); // start with all custom attributes
132
- if ((0, _config.getInfo)(this.agentIdentifier).atts) allAttachedNodes.push('a,' + addString((0, _config.getInfo)(this.agentIdentifier).atts)); // add apm provided attributes
131
+ if ((0, _info.getInfo)(this.agentIdentifier).atts) allAttachedNodes.push('a,' + addString((0, _info.getInfo)(this.agentIdentifier).atts)); // add apm provided attributes
133
132
  /* Querypack encoder+decoder quirkiness:
134
133
  - If first ixn node of payload is being processed, we use this node's start to offset. (firstStartTime should be 0--or undefined.)
135
134
  - Else for subsequent ixn nodes, we use the first ixn node's start to offset. */
@@ -3,31 +3,32 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
7
- var _config = require("../../../common/config/config");
6
+ exports.SoftNav = exports.Instrument = void 0;
7
+ var _nreum = require("../../../common/window/nreum");
8
8
  var _runtime = require("../../../common/constants/runtime");
9
9
  var _handle = require("../../../common/event-emitter/handle");
10
10
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
11
11
  var _invoke = require("../../../common/util/invoke");
12
- var _wrap = require("../../../common/wrap");
12
+ var _wrapEvents = require("../../../common/wrap/wrap-events");
13
+ var _wrapHistory = require("../../../common/wrap/wrap-history");
13
14
  var _instrumentBase = require("../../utils/instrument-base");
14
15
  var _constants = require("../constants");
15
16
  var _now = require("../../../common/timing/now");
16
- /** The minimal time after a UI event for which no further events will be processed - i.e. a throttling rate to reduce spam.
17
+ /**
18
+ * The minimal time after a UI event for which no further events will be processed - i.e. a throttling rate to reduce spam.
17
19
  * This also give some time for the new interaction to complete without being discarded by a subsequent UI event and wrongly attributed.
18
20
  * This value is still subject to change and critique, as it is derived from beyond worst case time to next frame of a page.
19
21
  */
20
22
  const UI_WAIT_INTERVAL = 1 / 10 * 1000; // assume 10 fps
21
23
 
22
24
  class Instrument extends _instrumentBase.InstrumentBase {
23
- static featureName = (() => _constants.FEATURE_NAME)();
24
- constructor(agentIdentifier, aggregator) {
25
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
25
+ static featureName = _constants.FEATURE_NAME;
26
+ constructor(agentIdentifier, aggregator, auto = true) {
26
27
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
27
- if (!_runtime.isBrowserScope || !_config.originals.MO) return; // soft navigations is not supported outside web env or browsers without the mutation observer API
28
+ if (!_runtime.isBrowserScope || !(0, _nreum.gosNREUMOriginals)().o.MO) return; // soft navigations is not supported outside web env or browsers without the mutation observer API
28
29
 
29
- const historyEE = (0, _wrap.wrapHistory)(this.ee);
30
- const eventsEE = (0, _wrap.wrapEvents)(this.ee);
30
+ const historyEE = (0, _wrapHistory.wrapHistory)(this.ee);
31
+ const eventsEE = (0, _wrapEvents.wrapEvents)(this.ee);
31
32
  const trackURLChange = () => (0, _handle.handle)('newURL', [(0, _now.now)(), '' + window.location], undefined, this.featureName, this.ee);
32
33
  historyEE.on('pushState-end', trackURLChange);
33
34
  historyEE.on('replaceState-end', trackURLChange);
@@ -37,7 +38,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
37
38
  const trackURLChangeEvent = evt => (0, _handle.handle)('newURL', [evt.timeStamp, '' + window.location], undefined, this.featureName, this.ee);
38
39
  (0, _eventListenerOpts.windowAddEventListener)('popstate', trackURLChangeEvent, true, this.removeOnAbort?.signal);
39
40
  let oncePerFrame = false; // attempt to reduce dom noice since the observer runs very frequently with below options
40
- const domObserver = new _config.originals.MO((domChanges, observer) => {
41
+ const domObserver = new ((0, _nreum.gosNREUMOriginals)().o.MO)((domChanges, observer) => {
41
42
  if (oncePerFrame) return;
42
43
  oncePerFrame = true;
43
44
  requestAnimationFrame(() => {
@@ -57,8 +58,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
57
58
  }, UI_WAIT_INTERVAL, {
58
59
  leading: true
59
60
  });
60
- eventsEE.on('fn-start', _ref => {
61
- let [evt] = _ref;
61
+ eventsEE.on('fn-start', ([evt]) => {
62
62
  // set up a new user ixn before the callback for the triggering event executes
63
63
  if (_constants.INTERACTION_TRIGGERS.includes(evt?.type)) {
64
64
  processUserInteraction(evt);
@@ -76,4 +76,5 @@ class Instrument extends _instrumentBase.InstrumentBase {
76
76
  }
77
77
  }
78
78
  }
79
- exports.Instrument = Instrument;
79
+ exports.Instrument = Instrument;
80
+ const SoftNav = exports.SoftNav = Instrument;