@newrelic/browser-agent 1.263.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 (478) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/cdn/experimental.js +3 -7
  4. package/dist/cjs/cdn/pro.js +2 -2
  5. package/dist/cjs/cdn/spa.js +2 -2
  6. package/dist/cjs/common/aggregate/aggregator.js +2 -3
  7. package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
  8. package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
  9. package/dist/cjs/common/config/{state/init.js → init.js} +11 -8
  10. package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
  11. package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
  12. package/dist/cjs/common/constants/agent-constants.js +8 -0
  13. package/dist/cjs/common/constants/env.cdn.js +1 -1
  14. package/dist/cjs/common/constants/env.npm.js +1 -1
  15. package/dist/cjs/common/constants/runtime.js +1 -3
  16. package/dist/cjs/common/context/shared-context.js +1 -2
  17. package/dist/cjs/common/dispatch/global-event.js +1 -2
  18. package/dist/cjs/common/drain/drain.js +12 -18
  19. package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
  20. package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
  21. package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
  22. package/dist/cjs/common/harvest/harvest.js +30 -57
  23. package/dist/cjs/common/serialize/bel-serializer.js +6 -11
  24. package/dist/cjs/common/session/session-entity.js +10 -13
  25. package/dist/cjs/common/timing/nav-timing.js +1 -3
  26. package/dist/cjs/common/timing/time-keeper.js +16 -6
  27. package/dist/cjs/common/url/encode.js +3 -7
  28. package/dist/cjs/common/util/console.js +2 -0
  29. package/dist/cjs/common/util/invoke.js +6 -16
  30. package/dist/cjs/common/util/obfuscate.js +97 -53
  31. package/dist/cjs/common/util/submit-data.js +17 -21
  32. package/dist/cjs/common/util/text.js +9 -0
  33. package/dist/cjs/common/util/traverse.js +1 -3
  34. package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
  35. package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
  36. package/dist/cjs/common/vitals/first-input-delay.js +4 -5
  37. package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
  38. package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
  39. package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
  40. package/dist/cjs/common/vitals/vital-metric.js +5 -7
  41. package/dist/cjs/common/window/nreum.js +2 -1
  42. package/dist/cjs/common/window/page-visibility.js +1 -4
  43. package/dist/cjs/common/wrap/wrap-events.js +1 -4
  44. package/dist/cjs/common/wrap/wrap-promise.js +1 -4
  45. package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
  46. package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
  47. package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
  48. package/dist/cjs/features/ajax/aggregate/index.js +19 -22
  49. package/dist/cjs/features/ajax/constants.js +2 -3
  50. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
  51. package/dist/cjs/features/ajax/instrument/index.js +14 -12
  52. package/dist/cjs/features/generic_events/aggregate/index.js +128 -0
  53. package/dist/cjs/features/generic_events/constants.js +10 -0
  54. package/dist/cjs/features/generic_events/index.js +12 -0
  55. package/dist/cjs/features/generic_events/instrument/index.js +27 -0
  56. package/dist/cjs/features/jserrors/aggregate/index.js +25 -44
  57. package/dist/cjs/features/jserrors/instrument/index.js +4 -4
  58. package/dist/cjs/features/logging/aggregate/index.js +33 -36
  59. package/dist/cjs/features/logging/constants.js +2 -3
  60. package/dist/cjs/features/logging/instrument/index.js +5 -6
  61. package/dist/cjs/features/logging/shared/log.js +1 -3
  62. package/dist/cjs/features/logging/shared/utils.js +2 -4
  63. package/dist/cjs/features/metrics/aggregate/index.js +34 -17
  64. package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
  65. package/dist/cjs/features/metrics/constants.js +4 -2
  66. package/dist/cjs/features/metrics/instrument/index.js +12 -4
  67. package/dist/cjs/features/page_action/instrument/index.js +14 -10
  68. package/dist/cjs/features/page_view_event/aggregate/index.js +19 -39
  69. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -1
  70. package/dist/cjs/features/page_view_event/instrument/index.js +4 -4
  71. package/dist/cjs/features/page_view_timing/aggregate/index.js +23 -39
  72. package/dist/cjs/features/page_view_timing/instrument/index.js +4 -4
  73. package/dist/cjs/features/session_replay/aggregate/index.js +35 -42
  74. package/dist/cjs/features/session_replay/constants.js +1 -5
  75. package/dist/cjs/features/session_replay/instrument/index.js +5 -9
  76. package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
  77. package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
  78. package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +2 -2
  79. package/dist/cjs/features/session_replay/shared/utils.js +5 -4
  80. package/dist/cjs/features/session_trace/aggregate/index.js +25 -42
  81. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +5 -3
  82. package/dist/cjs/features/session_trace/instrument/index.js +8 -7
  83. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
  84. package/dist/cjs/features/soft_navigations/aggregate/index.js +22 -30
  85. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
  86. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +4 -5
  87. package/dist/cjs/features/soft_navigations/instrument/index.js +14 -13
  88. package/dist/cjs/features/spa/aggregate/index.js +17 -28
  89. package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
  90. package/dist/cjs/features/spa/aggregate/serializer.js +4 -5
  91. package/dist/cjs/features/spa/constants.js +2 -2
  92. package/dist/cjs/features/spa/instrument/index.js +20 -19
  93. package/dist/cjs/features/utils/agent-session.js +6 -4
  94. package/dist/cjs/features/utils/aggregate-base.js +17 -10
  95. package/dist/cjs/features/utils/event-buffer.js +132 -0
  96. package/dist/cjs/features/utils/feature-gates.js +2 -2
  97. package/dist/cjs/features/utils/instrument-base.js +7 -8
  98. package/dist/cjs/features/utils/lazy-feature-loader.js +12 -12
  99. package/dist/cjs/features/utils/nr1-debugger.js +1 -3
  100. package/dist/cjs/index.js +21 -0
  101. package/dist/cjs/loaders/agent-base.js +4 -12
  102. package/dist/cjs/loaders/agent.js +7 -2
  103. package/dist/cjs/loaders/api/api.js +23 -35
  104. package/dist/cjs/loaders/api/apiAsync.js +10 -13
  105. package/dist/cjs/loaders/browser-agent.js +4 -3
  106. package/dist/cjs/loaders/configure/configure.js +16 -15
  107. package/dist/cjs/loaders/features/enabled-features.js +2 -2
  108. package/dist/cjs/loaders/features/features.js +8 -4
  109. package/dist/cjs/loaders/micro-agent.js +16 -15
  110. package/dist/esm/cdn/experimental.js +2 -5
  111. package/dist/esm/cdn/pro.js +2 -2
  112. package/dist/esm/cdn/spa.js +2 -2
  113. package/dist/esm/common/aggregate/aggregator.js +2 -3
  114. package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
  115. package/dist/esm/common/config/{state/info.js → info.js} +1 -1
  116. package/dist/esm/common/config/{state/init.js → init.js} +11 -8
  117. package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
  118. package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
  119. package/dist/esm/common/constants/agent-constants.js +2 -0
  120. package/dist/esm/common/constants/env.cdn.js +1 -1
  121. package/dist/esm/common/constants/env.npm.js +1 -1
  122. package/dist/esm/common/constants/runtime.js +0 -2
  123. package/dist/esm/common/context/shared-context.js +1 -2
  124. package/dist/esm/common/dispatch/global-event.js +1 -2
  125. package/dist/esm/common/drain/drain.js +12 -18
  126. package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
  127. package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
  128. package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
  129. package/dist/esm/common/harvest/harvest.js +24 -51
  130. package/dist/esm/common/serialize/bel-serializer.js +6 -11
  131. package/dist/esm/common/session/session-entity.js +10 -13
  132. package/dist/esm/common/timing/nav-timing.js +1 -3
  133. package/dist/esm/common/timing/time-keeper.js +15 -5
  134. package/dist/esm/common/url/encode.js +3 -7
  135. package/dist/esm/common/util/console.js +2 -0
  136. package/dist/esm/common/util/invoke.js +6 -16
  137. package/dist/esm/common/util/obfuscate.js +96 -49
  138. package/dist/esm/common/util/submit-data.js +17 -21
  139. package/dist/esm/common/util/text.js +3 -0
  140. package/dist/esm/common/util/traverse.js +1 -3
  141. package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
  142. package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
  143. package/dist/esm/common/vitals/first-input-delay.js +4 -5
  144. package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
  145. package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
  146. package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
  147. package/dist/esm/common/vitals/vital-metric.js +5 -7
  148. package/dist/esm/common/window/nreum.js +2 -1
  149. package/dist/esm/common/window/page-visibility.js +1 -4
  150. package/dist/esm/common/wrap/wrap-events.js +1 -4
  151. package/dist/esm/common/wrap/wrap-promise.js +1 -4
  152. package/dist/esm/common/wrap/wrap-websocket.js +67 -0
  153. package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
  154. package/dist/esm/features/ajax/aggregate/gql.js +4 -5
  155. package/dist/esm/features/ajax/aggregate/index.js +16 -19
  156. package/dist/esm/features/ajax/constants.js +1 -2
  157. package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
  158. package/dist/esm/features/ajax/instrument/index.js +10 -8
  159. package/dist/esm/features/generic_events/aggregate/index.js +120 -0
  160. package/dist/esm/features/generic_events/constants.js +4 -0
  161. package/dist/esm/features/generic_events/index.js +1 -0
  162. package/dist/esm/features/generic_events/instrument/index.js +20 -0
  163. package/dist/esm/features/jserrors/aggregate/index.js +20 -39
  164. package/dist/esm/features/jserrors/instrument/index.js +3 -3
  165. package/dist/esm/features/logging/aggregate/index.js +31 -34
  166. package/dist/esm/features/logging/constants.js +1 -2
  167. package/dist/esm/features/logging/instrument/index.js +4 -5
  168. package/dist/esm/features/logging/shared/log.js +1 -3
  169. package/dist/esm/features/logging/shared/utils.js +2 -4
  170. package/dist/esm/features/metrics/aggregate/index.js +28 -11
  171. package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
  172. package/dist/esm/features/metrics/constants.js +3 -1
  173. package/dist/esm/features/metrics/instrument/index.js +12 -4
  174. package/dist/esm/features/page_action/instrument/index.js +14 -9
  175. package/dist/esm/features/page_view_event/aggregate/index.js +17 -37
  176. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -1
  177. package/dist/esm/features/page_view_event/instrument/index.js +3 -3
  178. package/dist/esm/features/page_view_timing/aggregate/index.js +20 -36
  179. package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
  180. package/dist/esm/features/session_replay/aggregate/index.js +25 -32
  181. package/dist/esm/features/session_replay/constants.js +0 -4
  182. package/dist/esm/features/session_replay/index.js +1 -7
  183. package/dist/esm/features/session_replay/instrument/index.js +5 -8
  184. package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
  185. package/dist/esm/features/session_replay/shared/recorder.js +14 -10
  186. package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +2 -2
  187. package/dist/esm/features/session_replay/shared/utils.js +3 -2
  188. package/dist/esm/features/session_trace/aggregate/index.js +20 -37
  189. package/dist/esm/features/session_trace/aggregate/trace/storage.js +5 -3
  190. package/dist/esm/features/session_trace/instrument/index.js +5 -4
  191. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
  192. package/dist/esm/features/soft_navigations/aggregate/index.js +21 -29
  193. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
  194. package/dist/esm/features/soft_navigations/aggregate/interaction.js +2 -3
  195. package/dist/esm/features/soft_navigations/instrument/index.js +11 -10
  196. package/dist/esm/features/spa/aggregate/index.js +11 -22
  197. package/dist/esm/features/spa/aggregate/interaction.js +6 -5
  198. package/dist/esm/features/spa/aggregate/serializer.js +2 -3
  199. package/dist/esm/features/spa/constants.js +2 -2
  200. package/dist/esm/features/spa/instrument/index.js +12 -11
  201. package/dist/esm/features/utils/agent-session.js +3 -1
  202. package/dist/esm/features/utils/aggregate-base.js +16 -9
  203. package/dist/esm/features/utils/event-buffer.js +126 -0
  204. package/dist/esm/features/utils/feature-gates.js +1 -1
  205. package/dist/esm/features/utils/instrument-base.js +6 -7
  206. package/dist/esm/features/utils/lazy-feature-loader.js +12 -12
  207. package/dist/esm/features/utils/nr1-debugger.js +1 -3
  208. package/dist/esm/index.js +3 -0
  209. package/dist/esm/loaders/agent-base.js +4 -12
  210. package/dist/esm/loaders/agent.js +7 -2
  211. package/dist/esm/loaders/api/api.js +18 -30
  212. package/dist/esm/loaders/api/apiAsync.js +3 -6
  213. package/dist/esm/loaders/browser-agent.js +3 -2
  214. package/dist/esm/loaders/configure/configure.js +9 -8
  215. package/dist/esm/loaders/features/enabled-features.js +1 -1
  216. package/dist/esm/loaders/features/features.js +8 -4
  217. package/dist/esm/loaders/micro-agent.js +11 -10
  218. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
  219. package/dist/types/common/config/configurable.d.ts.map +1 -0
  220. package/dist/types/common/config/info.d.ts.map +1 -0
  221. package/dist/types/common/config/init.d.ts.map +1 -0
  222. package/dist/types/common/config/loader-config.d.ts.map +1 -0
  223. package/dist/types/common/config/runtime.d.ts.map +1 -0
  224. package/dist/types/common/constants/agent-constants.d.ts +3 -0
  225. package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
  226. package/dist/types/common/constants/runtime.d.ts +0 -1
  227. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  228. package/dist/types/common/harvest/harvest.d.ts +1 -7
  229. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  230. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
  231. package/dist/types/common/timing/time-keeper.d.ts +9 -2
  232. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  233. package/dist/types/common/url/encode.d.ts.map +1 -1
  234. package/dist/types/common/util/console.d.ts.map +1 -1
  235. package/dist/types/common/util/obfuscate.d.ts +78 -6
  236. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  237. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  238. package/dist/types/common/util/text.d.ts +2 -0
  239. package/dist/types/common/util/text.d.ts.map +1 -0
  240. package/dist/types/common/window/nreum.d.ts.map +1 -1
  241. package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
  242. package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
  243. package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
  244. package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
  245. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  246. package/dist/types/features/ajax/constants.d.ts +0 -1
  247. package/dist/types/features/ajax/constants.d.ts.map +1 -1
  248. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
  249. package/dist/types/features/ajax/instrument/index.d.ts +1 -0
  250. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  251. package/dist/types/features/{page_action → generic_events}/aggregate/index.d.ts +10 -10
  252. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -0
  253. package/dist/types/features/generic_events/constants.d.ts +4 -0
  254. package/dist/types/features/generic_events/constants.d.ts.map +1 -0
  255. package/dist/types/features/generic_events/index.d.ts +2 -0
  256. package/dist/types/features/generic_events/index.d.ts.map +1 -0
  257. package/dist/types/features/generic_events/instrument/index.d.ts +7 -0
  258. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -0
  259. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  260. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  261. package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
  262. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  263. package/dist/types/features/logging/aggregate/index.d.ts +4 -7
  264. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  265. package/dist/types/features/logging/constants.d.ts +0 -1
  266. package/dist/types/features/logging/constants.d.ts.map +1 -1
  267. package/dist/types/features/logging/instrument/index.d.ts +1 -0
  268. package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
  269. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  270. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
  271. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
  272. package/dist/types/features/metrics/constants.d.ts +1 -0
  273. package/dist/types/features/metrics/constants.d.ts.map +1 -1
  274. package/dist/types/features/metrics/instrument/index.d.ts +1 -0
  275. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  276. package/dist/types/features/page_action/instrument/index.d.ts +9 -4
  277. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
  278. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  279. package/dist/types/features/page_view_event/instrument/index.d.ts +1 -0
  280. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
  281. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  282. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  283. package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
  284. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
  285. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  286. package/dist/types/features/session_replay/constants.d.ts +0 -4
  287. package/dist/types/features/session_replay/constants.d.ts.map +1 -1
  288. package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
  289. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  290. package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
  291. package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
  292. package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
  293. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  294. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
  295. package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
  296. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  297. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
  298. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
  299. package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
  300. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  301. package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
  302. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  303. package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
  304. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
  305. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  306. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  307. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  308. package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -1
  309. package/dist/types/features/spa/constants.d.ts.map +1 -1
  310. package/dist/types/features/spa/instrument/index.d.ts +1 -0
  311. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  312. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  313. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  314. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  315. package/dist/types/features/utils/event-buffer.d.ts +72 -0
  316. package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
  317. package/dist/types/features/utils/instrument-base.d.ts +1 -0
  318. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  319. package/dist/types/index.d.ts +3 -0
  320. package/dist/types/loaders/agent-base.d.ts +1 -2
  321. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  322. package/dist/types/loaders/agent.d.ts.map +1 -1
  323. package/dist/types/loaders/api/api.d.ts.map +1 -1
  324. package/dist/types/loaders/browser-agent.d.ts.map +1 -1
  325. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  326. package/dist/types/loaders/features/features.d.ts +1 -0
  327. package/dist/types/loaders/features/features.d.ts.map +1 -1
  328. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  329. package/package.json +67 -52
  330. package/src/cdn/experimental.js +2 -4
  331. package/src/cdn/pro.js +2 -2
  332. package/src/cdn/spa.js +2 -2
  333. package/src/common/aggregate/aggregator.js +2 -3
  334. package/src/common/config/__mocks__/info.js +3 -0
  335. package/src/common/config/__mocks__/init.js +3 -0
  336. package/src/common/config/__mocks__/loader-config.js +2 -0
  337. package/src/common/config/__mocks__/runtime.js +2 -0
  338. package/src/common/config/{state/configurable.js → configurable.js} +1 -1
  339. package/src/common/config/{state/info.js → info.js} +1 -1
  340. package/src/common/config/{state/init.js → init.js} +7 -6
  341. package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
  342. package/src/common/config/{state/runtime.js → runtime.js} +19 -5
  343. package/src/common/constants/agent-constants.js +2 -0
  344. package/src/common/constants/runtime.js +0 -2
  345. package/src/common/drain/drain.js +8 -6
  346. package/src/common/event-emitter/contextual-ee.js +1 -1
  347. package/src/common/harvest/harvest.js +10 -24
  348. package/src/common/serialize/bel-serializer.js +6 -9
  349. package/src/common/session/session-entity.js +4 -4
  350. package/src/common/timing/__mocks__/time-keeper.js +6 -2
  351. package/src/common/timing/time-keeper.js +15 -5
  352. package/src/common/url/encode.js +2 -3
  353. package/src/common/util/__mocks__/console.js +1 -0
  354. package/src/common/util/__mocks__/obfuscate.js +5 -8
  355. package/src/common/util/console.js +2 -0
  356. package/src/common/util/obfuscate.js +94 -50
  357. package/src/common/util/submit-data.js +0 -1
  358. package/src/common/util/text.js +6 -0
  359. package/src/common/window/__mocks__/nreum.js +1 -1
  360. package/src/common/window/nreum.js +2 -1
  361. package/src/common/wrap/wrap-websocket.js +73 -0
  362. package/src/features/ajax/aggregate/chunk.js +3 -2
  363. package/src/features/ajax/aggregate/index.js +20 -19
  364. package/src/features/ajax/constants.js +0 -2
  365. package/src/features/ajax/instrument/distributed-tracing.js +2 -1
  366. package/src/features/ajax/instrument/index.js +9 -5
  367. package/src/features/generic_events/aggregate/index.js +139 -0
  368. package/src/features/generic_events/constants.js +5 -0
  369. package/src/features/generic_events/index.js +1 -0
  370. package/src/features/generic_events/instrument/index.js +24 -0
  371. package/src/features/jserrors/aggregate/index.js +18 -9
  372. package/src/features/jserrors/instrument/index.js +2 -0
  373. package/src/features/logging/aggregate/index.js +39 -31
  374. package/src/features/logging/constants.js +0 -2
  375. package/src/features/logging/instrument/index.js +2 -0
  376. package/src/features/logging/shared/utils.js +1 -1
  377. package/src/features/metrics/aggregate/index.js +24 -9
  378. package/src/features/metrics/aggregate/websocket-detection.js +31 -0
  379. package/src/features/metrics/constants.js +3 -0
  380. package/src/features/metrics/instrument/index.js +13 -1
  381. package/src/features/page_action/instrument/index.js +11 -6
  382. package/src/features/page_view_event/aggregate/index.js +8 -23
  383. package/src/features/page_view_event/aggregate/initialized-features.js +1 -1
  384. package/src/features/page_view_event/instrument/index.js +2 -0
  385. package/src/features/page_view_timing/aggregate/index.js +15 -18
  386. package/src/features/page_view_timing/instrument/index.js +2 -0
  387. package/src/features/session_replay/aggregate/index.js +13 -9
  388. package/src/features/session_replay/constants.js +0 -4
  389. package/src/features/session_replay/index.js +1 -7
  390. package/src/features/session_replay/instrument/index.js +3 -4
  391. package/src/features/session_replay/shared/recorder-events.js +27 -20
  392. package/src/features/session_replay/shared/recorder.js +13 -6
  393. package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
  394. package/src/features/session_replay/shared/utils.js +3 -2
  395. package/src/features/session_trace/aggregate/index.js +16 -7
  396. package/src/features/session_trace/aggregate/trace/storage.js +6 -1
  397. package/src/features/session_trace/instrument/index.js +4 -1
  398. package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
  399. package/src/features/soft_navigations/aggregate/index.js +13 -15
  400. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
  401. package/src/features/soft_navigations/aggregate/interaction.js +1 -1
  402. package/src/features/soft_navigations/instrument/index.js +9 -5
  403. package/src/features/spa/aggregate/index.js +12 -20
  404. package/src/features/spa/aggregate/interaction.js +6 -5
  405. package/src/features/spa/aggregate/serializer.js +2 -3
  406. package/src/features/spa/constants.js +2 -2
  407. package/src/features/spa/instrument/index.js +9 -3
  408. package/src/features/utils/agent-session.js +3 -1
  409. package/src/features/utils/aggregate-base.js +13 -3
  410. package/src/features/utils/event-buffer.js +126 -0
  411. package/src/features/utils/feature-gates.js +1 -1
  412. package/src/features/utils/instrument-base.js +2 -1
  413. package/src/features/utils/lazy-feature-loader.js +2 -2
  414. package/src/index.js +3 -0
  415. package/src/loaders/agent-base.js +2 -6
  416. package/src/loaders/agent.js +7 -2
  417. package/src/loaders/api/api.js +3 -2
  418. package/src/loaders/api/apiAsync.js +2 -2
  419. package/src/loaders/browser-agent.js +5 -3
  420. package/src/loaders/configure/configure.js +9 -2
  421. package/src/loaders/features/enabled-features.js +1 -1
  422. package/src/loaders/features/features.js +8 -4
  423. package/src/loaders/micro-agent.js +5 -2
  424. package/dist/cjs/cdn/polyfills/lite.js +0 -16
  425. package/dist/cjs/cdn/polyfills/pro.js +0 -21
  426. package/dist/cjs/cdn/polyfills/spa.js +0 -22
  427. package/dist/cjs/cdn/polyfills.js +0 -24
  428. package/dist/cjs/common/config/config.js +0 -76
  429. package/dist/cjs/common/config/state/originals.js +0 -8
  430. package/dist/cjs/common/util/map-own.js +0 -31
  431. package/dist/cjs/common/wrap/index.js +0 -61
  432. package/dist/cjs/features/page_action/aggregate/index.js +0 -121
  433. package/dist/esm/cdn/polyfills/lite.js +0 -14
  434. package/dist/esm/cdn/polyfills/pro.js +0 -19
  435. package/dist/esm/cdn/polyfills/spa.js +0 -20
  436. package/dist/esm/cdn/polyfills.js +0 -27
  437. package/dist/esm/common/config/config.js +0 -11
  438. package/dist/esm/common/config/state/originals.js +0 -2
  439. package/dist/esm/common/util/map-own.js +0 -24
  440. package/dist/esm/common/wrap/index.js +0 -13
  441. package/dist/esm/features/page_action/aggregate/index.js +0 -114
  442. package/dist/types/cdn/polyfills/lite.d.ts +0 -2
  443. package/dist/types/cdn/polyfills/lite.d.ts.map +0 -1
  444. package/dist/types/cdn/polyfills/pro.d.ts +0 -2
  445. package/dist/types/cdn/polyfills/pro.d.ts.map +0 -1
  446. package/dist/types/cdn/polyfills/spa.d.ts +0 -2
  447. package/dist/types/cdn/polyfills/spa.d.ts.map +0 -1
  448. package/dist/types/cdn/polyfills.d.ts +0 -2
  449. package/dist/types/cdn/polyfills.d.ts.map +0 -1
  450. package/dist/types/common/config/config.d.ts +0 -13
  451. package/dist/types/common/config/config.d.ts.map +0 -1
  452. package/dist/types/common/config/state/configurable.d.ts.map +0 -1
  453. package/dist/types/common/config/state/info.d.ts.map +0 -1
  454. package/dist/types/common/config/state/init.d.ts.map +0 -1
  455. package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
  456. package/dist/types/common/config/state/originals.d.ts +0 -2
  457. package/dist/types/common/config/state/originals.d.ts.map +0 -1
  458. package/dist/types/common/config/state/runtime.d.ts.map +0 -1
  459. package/dist/types/common/util/map-own.d.ts +0 -3
  460. package/dist/types/common/util/map-own.d.ts.map +0 -1
  461. package/dist/types/common/wrap/index.d.ts +0 -10
  462. package/dist/types/common/wrap/index.d.ts.map +0 -1
  463. package/dist/types/features/page_action/aggregate/index.d.ts.map +0 -1
  464. package/src/cdn/polyfills/lite.js +0 -20
  465. package/src/cdn/polyfills/pro.js +0 -30
  466. package/src/cdn/polyfills/spa.js +0 -32
  467. package/src/cdn/polyfills.js +0 -27
  468. package/src/common/config/__mocks__/config.js +0 -11
  469. package/src/common/config/config.js +0 -12
  470. package/src/common/config/state/originals.js +0 -3
  471. package/src/common/util/map-own.js +0 -22
  472. package/src/common/wrap/index.js +0 -16
  473. package/src/features/page_action/aggregate/index.js +0 -114
  474. /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
  475. /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
  476. /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
  477. /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
  478. /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
@@ -1,27 +1,34 @@
1
+ import { EventBuffer } from '../../utils/event-buffer'
2
+
1
3
  export class RecorderEvents {
2
- constructor () {
3
- /** The buffer to hold recorder event nodes */
4
- this.events = []
5
- /** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
4
+ /** The buffer to hold recorder event nodes */
5
+ #events = new EventBuffer(Infinity)
6
+ /** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
6
7
  * cycle timestamps are used as fallbacks if event timestamps cannot be used
7
8
  */
8
- this.cycleTimestamp = Date.now()
9
- /** A value which increments with every new mutation node reported. Resets after a harvest is sent */
10
- this.payloadBytesEstimation = 0
11
- /** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
12
- * -- When the recording library begins recording, it starts by taking a DOM snapshot
13
- * -- When visibility changes from "hidden" -> "visible", it must capture a full snapshot for the replay to work correctly across tabs
14
- */
15
- this.hasSnapshot = false
16
- /** Payload metadata -- Should indicate that the payload being sent has a meta node. The meta node should always precede a snapshot node. */
17
- this.hasMeta = false
18
- /** Payload metadata -- Should indicate that the payload being sent contains an error. Used for query/filter purposes in UI */
19
- this.hasError = false
20
- /** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
21
- this.inlinedAllStylesheets = true
22
- }
9
+ cycleTimestamp = Date.now()
10
+ /** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
11
+ * -- When the recording library begins recording, it starts by taking a DOM snapshot
12
+ * -- When visibility changes from "hidden" -> "visible", it must capture a full snapshot for the replay to work correctly across tabs
13
+ */
14
+ hasSnapshot = false
15
+ /** Payload metadata -- Should indicate that the payload being sent has a meta node. The meta node should always precede a snapshot node. */
16
+ hasMeta = false
17
+ /** Payload metadata -- Should indicate that the payload being sent contains an error. Used for query/filter purposes in UI */
18
+ hasError = false
19
+ /** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
20
+ inlinedAllStylesheets = true
23
21
 
24
22
  add (event) {
25
- this.events.push(event)
23
+ this.#events.add(event)
24
+ }
25
+
26
+ get events () {
27
+ return this.#events.buffer
28
+ }
29
+
30
+ /** A value which increments with every new mutation node reported. Resets after a harvest is sent */
31
+ get payloadBytesEstimation () {
32
+ return this.#events.bytes
26
33
  }
27
34
  }
@@ -1,7 +1,7 @@
1
1
  import { record as recorder } from 'rrweb'
2
2
  import { stringify } from '../../../common/util/stringify'
3
- import { AVG_COMPRESSION, CHECKOUT_MS, IDEAL_PAYLOAD_SIZE, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES } from '../constants'
4
- import { getConfigurationValue } from '../../../common/config/config'
3
+ import { AVG_COMPRESSION, CHECKOUT_MS, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES } from '../constants'
4
+ import { getConfigurationValue } from '../../../common/config/init'
5
5
  import { RecorderEvents } from './recorder-events'
6
6
  import { MODE } from '../../../common/session/constants'
7
7
  import { stylesheetEvaluator } from './stylesheet-evaluator'
@@ -9,6 +9,7 @@ import { handle } from '../../../common/event-emitter/handle'
9
9
  import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
10
10
  import { FEATURE_NAMES } from '../../../loaders/features/features'
11
11
  import { buildNRMetaNode } from './utils'
12
+ import { IDEAL_PAYLOAD_SIZE } from '../../../common/constants/agent-constants'
12
13
 
13
14
  export class Recorder {
14
15
  /** Each page mutation or event will be stored (raw) in this array. This array will be cleared on each harvest */
@@ -41,7 +42,14 @@ export class Recorder {
41
42
  }
42
43
 
43
44
  getEvents () {
44
- if (this.#preloaded[0]?.events.length) return { ...this.#preloaded[0], type: 'preloaded' }
45
+ if (this.#preloaded[0]?.events.length) {
46
+ return {
47
+ ...this.#preloaded[0],
48
+ events: this.#preloaded[0].events,
49
+ payloadBytesEstimation: this.#preloaded[0].payloadBytesEstimation,
50
+ type: 'preloaded'
51
+ }
52
+ }
45
53
  return {
46
54
  events: [...this.#backloggedEvents.events, ...this.#events.events].filter(x => x),
47
55
  type: 'standard',
@@ -93,7 +101,8 @@ export class Recorder {
93
101
  this.parent.ee.emit('internal-error', [err])
94
102
  /** returning true informs rrweb to swallow the error instead of throwing it to the window */
95
103
  return true
96
- }
104
+ },
105
+ recordAfter: 'DOMContentLoaded'
97
106
  })
98
107
 
99
108
  this.stopRecording = () => {
@@ -176,9 +185,7 @@ export class Recorder {
176
185
  if (event.type === RRWEB_EVENT_TYPES.FullSnapshot) {
177
186
  this.currentBufferTarget.hasSnapshot = true
178
187
  }
179
-
180
188
  this.currentBufferTarget.add(event)
181
- this.currentBufferTarget.payloadBytesEstimation += eventBytes
182
189
 
183
190
  // We are making an effort to try to keep payloads manageable for unloading. If they reach the unload limit before their interval,
184
191
  // it will send immediately. This often happens on the first snapshot, which can be significantly larger than the other payloads.
@@ -1,4 +1,4 @@
1
- import { originals } from '../../../common/config/config'
1
+ import { gosNREUMOriginals } from '../../../common/window/nreum'
2
2
  import { isBrowserScope } from '../../../common/constants/runtime'
3
3
 
4
4
  class StylesheetEvaluator {
@@ -57,7 +57,7 @@ class StylesheetEvaluator {
57
57
  async #fetchAndOverride (target) {
58
58
  if (!target?.href) return
59
59
  try {
60
- const stylesheetContents = await originals.FETCH.bind(window)(target.href)
60
+ const stylesheetContents = await gosNREUMOriginals().o.FETCH.bind(window)(target.href)
61
61
  if (!stylesheetContents.ok) {
62
62
  this.failedToFix++
63
63
  return
@@ -1,9 +1,10 @@
1
- import { getConfigurationValue, originals } from '../../../common/config/config'
1
+ import { gosNREUMOriginals } from '../../../common/window/nreum'
2
+ import { getConfigurationValue } from '../../../common/config/init'
2
3
  import { canEnableSessionTracking } from '../../utils/feature-gates'
3
4
  import { originTime } from '../../../common/constants/runtime'
4
5
 
5
6
  export function hasReplayPrerequisite (agentId) {
6
- return !!originals.MO && // Session Replay cannot work without Mutation Observer
7
+ return !!gosNREUMOriginals().o.MO && // Session Replay cannot work without Mutation Observer
7
8
  canEnableSessionTracking(agentId) && // requires session tracking to be running (hence "session" replay...)
8
9
  getConfigurationValue(agentId, 'session_trace.enabled') === true // Session Replay as of now is tightly coupled with Session Trace in the UI
9
10
  }
@@ -1,6 +1,8 @@
1
1
  import { registerHandler } from '../../../common/event-emitter/register-handler'
2
2
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
3
- import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config'
3
+ import { getInfo } from '../../../common/config/info'
4
+ import { getConfigurationValue } from '../../../common/config/init'
5
+ import { getRuntime } from '../../../common/config/runtime'
4
6
  import { FEATURE_NAME } from '../constants'
5
7
  import { AggregateBase } from '../../utils/aggregate-base'
6
8
  import { TraceStorage } from './trace/storage'
@@ -8,6 +10,7 @@ import { obj as encodeObj } from '../../../common/url/encode'
8
10
  import { deregisterDrain } from '../../../common/drain/drain'
9
11
  import { globalScope } from '../../../common/constants/runtime'
10
12
  import { MODE, SESSION_EVENTS } from '../../../common/session/constants'
13
+ import { applyFnToProps } from '../../../common/util/traverse'
11
14
 
12
15
  const ERROR_MODE_SECONDS_WINDOW = 30 * 1000 // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
13
16
  /** Reserved room for query param attrs */
@@ -92,7 +95,7 @@ export class Aggregate extends AggregateBase {
92
95
  if (typeof PerformanceNavigationTiming !== 'undefined') {
93
96
  this.traceStorage.storeTiming(globalScope.performance?.getEntriesByType?.('navigation')[0])
94
97
  } else {
95
- this.traceStorage.storeTiming(globalScope.performance?.timing)
98
+ this.traceStorage.storeTiming(globalScope.performance?.timing, true)
96
99
  }
97
100
 
98
101
  /** Only start actually harvesting if running in full mode at init time */
@@ -151,15 +154,21 @@ export class Aggregate extends AggregateBase {
151
154
  type: 'BrowserSessionChunk',
152
155
  app_id: this.agentInfo.applicationID,
153
156
  protocol_version: '0',
154
- timestamp: this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
157
+ timestamp: Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
158
+ this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp)
159
+ )),
155
160
  attributes: encodeObj({
156
161
  ...(agentMetadata.entityGuid && { entityGuid: agentMetadata.entityGuid }),
157
162
  harvestId: `${this.agentRuntime.session?.state.value}_${this.agentRuntime.ptid}_${this.agentRuntime.harvestCount}`,
158
163
  // this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
159
164
  // if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
160
165
  // trace payload metadata
161
- 'trace.firstTimestamp': this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
162
- 'trace.lastTimestamp': this.timeKeeper.convertRelativeTimestamp(latestTimeStamp),
166
+ 'trace.firstTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
167
+ this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp)
168
+ )),
169
+ 'trace.lastTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(
170
+ this.timeKeeper.convertRelativeTimestamp(latestTimeStamp)
171
+ )),
163
172
  'trace.nodes': stns.length,
164
173
  'trace.originTimestamp': this.timeKeeper.correctedOriginTime,
165
174
  // other payload metadata
@@ -169,11 +178,11 @@ export class Aggregate extends AggregateBase {
169
178
  ptid: `${this.ptid}`,
170
179
  session: `${this.sessionId}`,
171
180
  // customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
172
- ...(endUserId && { 'enduser.id': endUserId })
181
+ ...(endUserId && { 'enduser.id': this.obfuscator.obfuscateString(endUserId) })
173
182
  // The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
174
183
  }, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
175
184
  },
176
- body: stns
185
+ body: applyFnToProps(stns, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
177
186
  }
178
187
  }
179
188
 
@@ -148,7 +148,7 @@ export class TraceStorage {
148
148
  }
149
149
  }
150
150
 
151
- storeTiming (timingEntry) {
151
+ storeTiming (timingEntry, isAbsoluteTimestamp = false) {
152
152
  if (!timingEntry) return
153
153
 
154
154
  // loop iterates through prototype also (for FF)
@@ -164,6 +164,11 @@ export class TraceStorage {
164
164
  if (!(typeof val === 'number' && val >= 0)) continue
165
165
 
166
166
  val = Math.round(val)
167
+ if (this.parent.timeKeeper && this.parent.timeKeeper.ready && isAbsoluteTimestamp) {
168
+ val = this.parent.timeKeeper.convertAbsoluteTimestamp(
169
+ Math.floor(this.parent.timeKeeper.correctAbsoluteTimestamp(val))
170
+ )
171
+ }
167
172
  this.storeSTN(new TraceNode(key, val, val, 'document', 'timing'))
168
173
  }
169
174
  }
@@ -3,7 +3,8 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { handle } from '../../../common/event-emitter/handle'
6
- import { wrapHistory, wrapEvents } from '../../../common/wrap'
6
+ import { wrapHistory } from '../../../common/wrap/wrap-history'
7
+ import { wrapEvents } from '../../../common/wrap/wrap-events'
7
8
  import { InstrumentBase } from '../../utils/instrument-base'
8
9
  import * as CONSTANTS from '../constants'
9
10
  import { FEATURE_NAMES } from '../../../loaders/features/features'
@@ -61,3 +62,5 @@ export class Instrument extends InstrumentBase {
61
62
  this.importAggregator({ resourceObserver: observer })
62
63
  }
63
64
  }
65
+
66
+ export const SessionTrace = Instrument
@@ -18,7 +18,7 @@ export class AjaxNode extends BelNode {
18
18
  this.spanTimestamp = ajaxEvent.spanTimestamp
19
19
  this.gql = ajaxEvent.gql
20
20
 
21
- this.start = ajaxEvent.startTime
21
+ this.start = ajaxEvent.startTime // 5000 --- 5500 --> 10500
22
22
  this.end = ajaxEvent.endTime
23
23
  }
24
24
 
@@ -1,4 +1,4 @@
1
- import { getConfigurationValue } from '../../../common/config/config'
1
+ import { getConfigurationValue } from '../../../common/config/init'
2
2
  import { deregisterDrain } from '../../../common/drain/drain'
3
3
  import { handle } from '../../../common/event-emitter/handle'
4
4
  import { registerHandler } from '../../../common/event-emitter/register-handler'
@@ -8,6 +8,7 @@ import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte'
8
8
  import { FEATURE_NAMES } from '../../../loaders/features/features'
9
9
  import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
10
10
  import { AggregateBase } from '../../utils/aggregate-base'
11
+ import { EventBuffer } from '../../utils/event-buffer'
11
12
  import { API_TRIGGER_NAME, FEATURE_NAME, INTERACTION_STATUS } from '../constants'
12
13
  import { AjaxNode } from './ajax-node'
13
14
  import { InitialPageLoadInteraction } from './initial-page-load-interaction'
@@ -19,8 +20,7 @@ export class Aggregate extends AggregateBase {
19
20
  super(agentIdentifier, aggregator, FEATURE_NAME)
20
21
 
21
22
  const harvestTimeSeconds = getConfigurationValue(agentIdentifier, 'soft_navigations.harvestTimeSeconds') || 10
22
- this.interactionsToHarvest = []
23
- this.interactionsAwaitingRetry = []
23
+ this.interactionsToHarvest = new EventBuffer()
24
24
  this.domObserver = domObserver
25
25
 
26
26
  this.initialPageLoadInteraction = new InitialPageLoadInteraction(agentIdentifier)
@@ -28,7 +28,7 @@ export class Aggregate extends AggregateBase {
28
28
  const loadEventTime = attrs.navigationEntry.loadEventEnd
29
29
  this.initialPageLoadInteraction.forceSave = true
30
30
  this.initialPageLoadInteraction.done(loadEventTime)
31
- this.interactionsToHarvest.push(this.initialPageLoadInteraction)
31
+ this.interactionsToHarvest.add(this.initialPageLoadInteraction)
32
32
  this.initialPageLoadInteraction = null
33
33
  // Report metric on the initial page load time
34
34
  handle(SUPPORTABILITY_METRIC_CHANNEL, ['SoftNav/Interaction/InitialPageLoad/Duration/Ms', Math.round(loadEventTime)], undefined, FEATURE_NAMES.metrics, this.ee)
@@ -69,28 +69,26 @@ export class Aggregate extends AggregateBase {
69
69
  }
70
70
 
71
71
  onHarvestStarted (options) {
72
- if (this.interactionsToHarvest.length === 0 || this.blocked) return
72
+ if (!this.interactionsToHarvest.hasData || this.blocked) return
73
73
  // 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.
74
74
  // 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.
75
75
  let firstIxnStartTime = 0 // the very 1st ixn does not require any offsetting
76
76
  const serializedIxnList = []
77
- for (const interaction of this.interactionsToHarvest) {
77
+ for (const interaction of this.interactionsToHarvest.buffer) {
78
78
  serializedIxnList.push(interaction.serialize(firstIxnStartTime))
79
79
  if (!firstIxnStartTime) firstIxnStartTime = Math.floor(interaction.start)
80
80
  }
81
81
  const payload = `bel.7;${serializedIxnList.join(';')}`
82
82
 
83
- if (options.retry) this.interactionsAwaitingRetry = this.interactionsToHarvest
84
- this.interactionsToHarvest = []
83
+ if (options.retry) this.interactionsToHarvest.hold()
84
+ else this.interactionsToHarvest.clear()
85
85
 
86
86
  return { body: { e: payload } }
87
87
  }
88
88
 
89
89
  onHarvestFinished (result) {
90
- if (result.sent && result.retry && this.interactionsAwaitingRetry.length > 0) {
91
- this.interactionsToHarvest = [...this.interactionsAwaitingRetry, ...this.interactionsToHarvest]
92
- }
93
- this.interactionsAwaitingRetry = []
90
+ if (result.sent && result.retry && this.interactionsToHarvest.held.hasData) this.interactionsToHarvest.unhold()
91
+ else this.interactionsToHarvest.held.clear()
94
92
  }
95
93
 
96
94
  startUIInteraction (eventName, startedAt, sourceElem) { // this is throttled by instrumentation so that it isn't excessively called
@@ -113,7 +111,7 @@ export class Aggregate extends AggregateBase {
113
111
  setClosureHandlers () {
114
112
  this.interactionInProgress.on('finished', () => {
115
113
  const ref = this.interactionInProgress
116
- this.interactionsToHarvest.push(this.interactionInProgress)
114
+ this.interactionsToHarvest.add(this.interactionInProgress)
117
115
  this.interactionInProgress = null
118
116
  this.domObserver.disconnect() // can stop observing whenever our interaction logic completes a cycle
119
117
 
@@ -143,8 +141,8 @@ export class Aggregate extends AggregateBase {
143
141
  */
144
142
  if (this.interactionInProgress?.isActiveDuring(timestamp)) return this.interactionInProgress
145
143
  let saveIxn
146
- for (let idx = this.interactionsToHarvest.length - 1; idx >= 0; idx--) { // reverse search for the latest completed interaction for efficiency
147
- const finishedInteraction = this.interactionsToHarvest[idx]
144
+ for (let idx = this.interactionsToHarvest.buffer.length - 1; idx >= 0; idx--) { // reverse search for the latest completed interaction for efficiency
145
+ const finishedInteraction = this.interactionsToHarvest.buffer[idx]
148
146
  if (finishedInteraction.isActiveDuring(timestamp)) {
149
147
  if (finishedInteraction.trigger !== 'initialPageLoad') return finishedInteraction
150
148
  // 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
@@ -3,7 +3,7 @@ import { Interaction } from './interaction'
3
3
  import { numeric } from '../../../common/serialize/bel-serializer'
4
4
  import { firstPaint } from '../../../common/vitals/first-paint'
5
5
  import { firstContentfulPaint } from '../../../common/vitals/first-contentful-paint'
6
- import { getInfo } from '../../../common/config/config'
6
+ import { getInfo } from '../../../common/config/info'
7
7
 
8
8
  export class InitialPageLoadInteraction extends Interaction {
9
9
  constructor (agentIdentifier) {
@@ -1,4 +1,4 @@
1
- import { getInfo } from '../../../common/config/config'
1
+ import { getInfo } from '../../../common/config/info'
2
2
  import { globalScope, initialLocation } from '../../../common/constants/runtime'
3
3
  import { generateUuid } from '../../../common/ids/unique-id'
4
4
  import { addCustomAttributes, getAddStringContext, nullable, numeric } from '../../../common/serialize/bel-serializer'
@@ -1,14 +1,16 @@
1
- import { originals } from '../../../common/config/config'
1
+ import { gosNREUMOriginals } from '../../../common/window/nreum'
2
2
  import { isBrowserScope } from '../../../common/constants/runtime'
3
3
  import { handle } from '../../../common/event-emitter/handle'
4
4
  import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts'
5
5
  import { debounce } from '../../../common/util/invoke'
6
- import { wrapEvents, wrapHistory } from '../../../common/wrap'
6
+ import { wrapEvents } from '../../../common/wrap/wrap-events'
7
+ import { wrapHistory } from '../../../common/wrap/wrap-history'
7
8
  import { InstrumentBase } from '../../utils/instrument-base'
8
9
  import { FEATURE_NAME, INTERACTION_TRIGGERS } from '../constants'
9
10
  import { now } from '../../../common/timing/now'
10
11
 
11
- /** The minimal time after a UI event for which no further events will be processed - i.e. a throttling rate to reduce spam.
12
+ /**
13
+ * The minimal time after a UI event for which no further events will be processed - i.e. a throttling rate to reduce spam.
12
14
  * This also give some time for the new interaction to complete without being discarded by a subsequent UI event and wrongly attributed.
13
15
  * This value is still subject to change and critique, as it is derived from beyond worst case time to next frame of a page.
14
16
  */
@@ -18,7 +20,7 @@ export class Instrument extends InstrumentBase {
18
20
  static featureName = FEATURE_NAME
19
21
  constructor (agentIdentifier, aggregator, auto = true) {
20
22
  super(agentIdentifier, aggregator, FEATURE_NAME, auto)
21
- if (!isBrowserScope || !originals.MO) return // soft navigations is not supported outside web env or browsers without the mutation observer API
23
+ if (!isBrowserScope || !gosNREUMOriginals().o.MO) return // soft navigations is not supported outside web env or browsers without the mutation observer API
22
24
 
23
25
  const historyEE = wrapHistory(this.ee)
24
26
  const eventsEE = wrapEvents(this.ee)
@@ -34,7 +36,7 @@ export class Instrument extends InstrumentBase {
34
36
  windowAddEventListener('popstate', trackURLChangeEvent, true, this.removeOnAbort?.signal)
35
37
 
36
38
  let oncePerFrame = false // attempt to reduce dom noice since the observer runs very frequently with below options
37
- const domObserver = new originals.MO((domChanges, observer) => {
39
+ const domObserver = new (gosNREUMOriginals().o).MO((domChanges, observer) => {
38
40
  if (oncePerFrame) return
39
41
  oncePerFrame = true
40
42
  requestAnimationFrame(() => { // waiting for next frame to time when any visuals are supposedly updated
@@ -65,3 +67,5 @@ export class Instrument extends InstrumentBase {
65
67
  }
66
68
  }
67
69
  }
70
+
71
+ export const SoftNav = Instrument
@@ -6,11 +6,11 @@
6
6
  import { registerHandler as register } from '../../../common/event-emitter/register-handler'
7
7
  import { parseUrl } from '../../../common/url/parse-url'
8
8
  import { shouldCollectEvent } from '../../../common/deny-list/deny-list'
9
- import { mapOwn } from '../../../common/util/map-own'
10
9
  import { navTimingValues as navTiming } from '../../../common/timing/nav-timing'
11
10
  import { generateUuid } from '../../../common/ids/unique-id'
12
11
  import { Interaction } from './interaction'
13
- import { getConfigurationValue, getRuntime } from '../../../common/config/config'
12
+ import { getConfigurationValue } from '../../../common/config/init'
13
+ import { getRuntime } from '../../../common/config/runtime'
14
14
  import { eventListenerOpts } from '../../../common/event-listener/event-listener-opts'
15
15
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
16
16
  import { Serializer } from './serializer'
@@ -26,6 +26,7 @@ import { handle } from '../../../common/event-emitter/handle'
26
26
  import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
27
27
  import { deregisterDrain } from '../../../common/drain/drain'
28
28
  import { warn } from '../../../common/util/console'
29
+ import { EventBuffer } from '../../utils/event-buffer'
29
30
 
30
31
  const {
31
32
  FEATURE_NAME, INTERACTION_EVENTS, MAX_TIMER_BUDGET, FN_START, FN_END, CB_START, INTERACTION_API, REMAINING,
@@ -51,8 +52,7 @@ export class Aggregate extends AggregateBase {
51
52
  childTime: 0,
52
53
  depth: 0,
53
54
  harvestTimeSeconds: getConfigurationValue(agentIdentifier, 'spa.harvestTimeSeconds') || 10,
54
- interactionsToHarvest: [],
55
- interactionsSent: [],
55
+ interactionsToHarvest: new EventBuffer(),
56
56
  // The below feature flag is used to disable the SPA ajax fix for specific customers, see https://new-relic.atlassian.net/browse/NR-172169
57
57
  disableSpaFix: (getConfigurationValue(agentIdentifier, 'feature_flags') || []).indexOf('disable-spa-fix') > -1
58
58
  }
@@ -668,7 +668,7 @@ export class Aggregate extends AggregateBase {
668
668
 
669
669
  // make sure that newrelic[INTERACTION]() works in end handler
670
670
  state.currentNode = root
671
- mapOwn(interaction.handlers, function (i, cb) {
671
+ Object.values(interaction.handlers || {}).forEach(function (cb) {
672
672
  cb(attrs.store)
673
673
  })
674
674
  setCurrentNode(null)
@@ -676,26 +676,18 @@ export class Aggregate extends AggregateBase {
676
676
 
677
677
  const classThis = this
678
678
  function onHarvestStarted (options) {
679
- if (state.interactionsToHarvest.length === 0 || classThis.blocked) return {}
680
- var payload = serializer.serializeMultiple(state.interactionsToHarvest, 0, navTiming)
679
+ if (!state.interactionsToHarvest.hasData || classThis.blocked) return {}
680
+ var payload = serializer.serializeMultiple(state.interactionsToHarvest.buffer, 0, navTiming)
681
681
 
682
- if (options.retry) {
683
- state.interactionsToHarvest.forEach(function (interaction) {
684
- state.interactionsSent.push(interaction)
685
- })
686
- }
687
- state.interactionsToHarvest = []
682
+ if (options.retry) state.interactionsToHarvest.hold()
683
+ else state.interactionsToHarvest.clear()
688
684
 
689
685
  return { body: { e: payload } }
690
686
  }
691
687
 
692
688
  function onHarvestFinished (result) {
693
- if (result.sent && result.retry && state.interactionsSent.length > 0) {
694
- state.interactionsSent.forEach(function (interaction) {
695
- state.interactionsToHarvest.unshift(interaction)
696
- })
697
- state.interactionsSent = []
698
- }
689
+ if (result.sent && result.retry && state.interactionsToHarvest.held.hasData) state.interactionsToHarvest.unhold()
690
+ else state.interactionsToHarvest.held.clear()
699
691
  }
700
692
 
701
693
  baseEE.on('spa-jserror', function (type, name, params, metrics) {
@@ -748,7 +740,7 @@ export class Aggregate extends AggregateBase {
748
740
  interaction.root.attrs.firstContentfulPaint = firstContentfulPaint.current.value
749
741
  }
750
742
  baseEE.emit('interactionDone', [interaction, true])
751
- state.interactionsToHarvest.push(interaction)
743
+ state.interactionsToHarvest.add(interaction)
752
744
 
753
745
  let smCategory
754
746
  if (interaction.root?.attrs?.trigger === 'initialPageLoad') smCategory = 'InitialPageLoad'
@@ -3,13 +3,14 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { getInfo, getRuntime, originals } from '../../../common/config/config'
7
- import { mapOwn } from '../../../common/util/map-own'
6
+ import { getInfo } from '../../../common/config/info'
7
+ import { getRuntime } from '../../../common/config/runtime'
8
+ import { gosNREUMOriginals } from '../../../common/window/nreum'
8
9
  import { ee } from '../../../common/event-emitter/contextual-ee'
9
10
  import { InteractionNode } from './interaction-node'
10
11
 
11
- var originalSetTimeout = originals.ST
12
- var originalClearTimeout = originals.CT
12
+ var originalSetTimeout = gosNREUMOriginals().o.ST
13
+ var originalClearTimeout = gosNREUMOriginals().o.CT
13
14
 
14
15
  var lastId = {}
15
16
 
@@ -101,7 +102,7 @@ InteractionPrototype.finish = function finishInteraction () {
101
102
  this.onFinished(this)
102
103
  }
103
104
 
104
- mapOwn(getInfo(interaction.agentIdentifier).jsAttributes, function (attr, value) {
105
+ Object.entries(getInfo(interaction.agentIdentifier).jsAttributes || {}).forEach(([attr, value]) => {
105
106
  if (!(attr in customAttrs)) customAttrs[attr] = value
106
107
  })
107
108
 
@@ -3,10 +3,9 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { cleanURL } from '../../../common/url/clean-url'
6
- import { mapOwn } from '../../../common/util/map-own'
7
6
  import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer'
8
7
  import { SharedContext } from '../../../common/context/shared-context'
9
- import { getInfo } from '../../../common/config/config'
8
+ import { getInfo } from '../../../common/config/info'
10
9
 
11
10
  export class Serializer extends SharedContext {
12
11
  constructor (parent) {
@@ -181,7 +180,7 @@ export class Serializer extends SharedContext {
181
180
  // get all navTiming values except navigationStart
182
181
  // (since its the same as interaction.start)
183
182
  // and limit to just the first 20 values we know about
184
- mapOwn(navTiming.slice(1, 21), function (i, v) {
183
+ Object.values(navTiming.slice(1, 21) || {}).forEach((v) => {
185
184
  if (v !== undefined) {
186
185
  navTimingNode += seperator + numeric(v - prev)
187
186
  seperator = ','
@@ -1,4 +1,4 @@
1
- import { originals } from '../../common/config/config'
1
+ import { gosNREUMOriginals } from '../../common/window/nreum'
2
2
  import { FEATURE_NAMES } from '../../loaders/features/features'
3
3
 
4
4
  export const FEATURE_NAME = FEATURE_NAMES.spa
@@ -25,7 +25,7 @@ export const FETCH_DONE = 'fetch-done'
25
25
  export const FETCH_BODY = 'fetch-body-'
26
26
  export const JSONP_END = 'jsonp-end'
27
27
 
28
- export const originalSetTimeout = originals.ST
28
+ export const originalSetTimeout = gosNREUMOriginals().o.ST
29
29
 
30
30
  export const START = '-start'
31
31
  export const END = '-end'
@@ -2,15 +2,19 @@
2
2
  * Copyright 2020 New Relic Corporation. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import {
6
- wrapMutation, wrapPromise, wrapHistory, wrapTimer, wrapFetch, wrapXhr, wrapJsonP
7
- } from '../../../common/wrap'
8
5
  import { eventListenerOpts } from '../../../common/event-listener/event-listener-opts'
9
6
  import { InstrumentBase } from '../../utils/instrument-base'
10
7
  import * as CONSTANTS from '../constants'
11
8
  import { isBrowserScope } from '../../../common/constants/runtime'
12
9
  import { now } from '../../../common/timing/now'
13
10
  import { handle } from '../../../common/event-emitter/handle'
11
+ import { wrapJsonP } from '../../../common/wrap/wrap-jsonp'
12
+ import { wrapPromise } from '../../../common/wrap/wrap-promise'
13
+ import { wrapTimer } from '../../../common/wrap/wrap-timer'
14
+ import { wrapXhr } from '../../../common/wrap/wrap-xhr'
15
+ import { wrapFetch } from '../../../common/wrap/wrap-fetch'
16
+ import { wrapHistory } from '../../../common/wrap/wrap-history'
17
+ import { wrapMutation } from '../../../common/wrap/wrap-mutation'
14
18
 
15
19
  const {
16
20
  FEATURE_NAME, START, END, BODY, CB_END, JS_TIME, FETCH, FN_START, CB_START, FN_END
@@ -112,3 +116,5 @@ export class Instrument extends InstrumentBase {
112
116
  this.abortHandler = undefined // weakly allow this abort op to run only once
113
117
  }
114
118
  }
119
+
120
+ export const Spa = Instrument
@@ -1,4 +1,6 @@
1
- import { getConfiguration, getInfo, getRuntime } from '../../common/config/config'
1
+ import { getInfo } from '../../common/config/info'
2
+ import { getConfiguration } from '../../common/config/init'
3
+ import { getRuntime } from '../../common/config/runtime'
2
4
  import { drain } from '../../common/drain/drain'
3
5
  import { ee } from '../../common/event-emitter/contextual-ee'
4
6
  import { registerHandler } from '../../common/event-emitter/register-handler'