@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
@@ -3,13 +3,11 @@ import { FEATURE_NAME } from '../constants';
3
3
  import { bufferLog } from '../shared/utils';
4
4
  export class Instrument extends InstrumentBase {
5
5
  static featureName = FEATURE_NAME;
6
- constructor(agentIdentifier, aggregator) {
7
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
6
+ constructor(agentIdentifier, aggregator, auto = true) {
8
7
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
9
8
  const instanceEE = this.ee;
10
9
  /** emitted by wrap-logger function */
11
- this.ee.on('wrap-logger-end', function handleLog(_ref) {
12
- let [message] = _ref;
10
+ this.ee.on('wrap-logger-end', function handleLog([message]) {
13
11
  const {
14
12
  level,
15
13
  customAttributes
@@ -18,4 +16,5 @@ export class Instrument extends InstrumentBase {
18
16
  });
19
17
  this.importAggregator();
20
18
  }
21
- }
19
+ }
20
+ export const Logging = Instrument;
@@ -17,9 +17,7 @@ export class Log {
17
17
  * @param {object} attributes - other log event attributes
18
18
  * @param {enum} level - Log level
19
19
  */
20
- constructor(timestamp, message) {
21
- let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
22
- let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : LOG_LEVELS.INFO;
20
+ constructor(timestamp, message, attributes = {}, level = LOG_LEVELS.INFO) {
23
21
  /** @type {long} */
24
22
  this.timestamp = timestamp;
25
23
  this.message = message;
@@ -10,9 +10,7 @@ import { LOGGING_EVENT_EMITTER_CHANNEL, LOG_LEVELS } from '../constants';
10
10
  * @param {{[key: string]: *}} customAttributes - The log's custom attributes if any
11
11
  * @param {enum} level - the log level enum
12
12
  */
13
- export function bufferLog(ee, message) {
14
- let customAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15
- let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : LOG_LEVELS.INFO;
13
+ export function bufferLog(ee, message, customAttributes = {}, level = LOG_LEVELS.INFO) {
16
14
  handle(SUPPORTABILITY_METRIC_CHANNEL, ["API/logging/".concat(level.toLowerCase(), "/called")], undefined, FEATURE_NAMES.metrics, ee);
17
15
  handle(LOGGING_EVENT_EMITTER_CHANNEL, [now(), message, customAttributes, level], undefined, FEATURE_NAMES.logging, ee);
18
16
  }
@@ -24,5 +22,5 @@ export function bufferLog(ee, message) {
24
22
  */
25
23
  export function isValidLogLevel(level) {
26
24
  if (typeof level !== 'string') return false;
27
- return Object.values(LOG_LEVELS).some(logLevel => logLevel === level);
25
+ return Object.values(LOG_LEVELS).some(logLevel => logLevel === level.toUpperCase().trim());
28
26
  }
@@ -1,21 +1,22 @@
1
- import { getRuntime, getConfiguration } from '../../../common/config/config';
1
+ import { getConfiguration } from '../../../common/config/init';
2
+ import { getRuntime } from '../../../common/config/runtime';
2
3
  import { registerHandler } from '../../../common/event-emitter/register-handler';
3
4
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
4
- import { FEATURE_NAME, SUPPORTABILITY_METRIC, CUSTOM_METRIC, SUPPORTABILITY_METRIC_CHANNEL, CUSTOM_METRIC_CHANNEL } from '../constants';
5
+ import { FEATURE_NAME, SUPPORTABILITY_METRIC, CUSTOM_METRIC, SUPPORTABILITY_METRIC_CHANNEL, CUSTOM_METRIC_CHANNEL, WATCHABLE_WEB_SOCKET_EVENTS } from '../constants';
5
6
  import { getFrameworks } from './framework-detection';
6
7
  import { isFileProtocol } from '../../../common/url/protocol';
7
- import { getRules, validateRules } from '../../../common/util/obfuscate';
8
8
  import { onDOMContentLoaded } from '../../../common/window/load';
9
9
  import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts';
10
10
  import { isBrowserScope, isWorkerScope } from '../../../common/constants/runtime';
11
11
  import { AggregateBase } from '../../utils/aggregate-base';
12
12
  import { deregisterDrain } from '../../../common/drain/drain';
13
+ import { WEBSOCKET_TAG } from '../../../common/wrap/wrap-websocket';
14
+ import { handleWebsocketEvents } from './websocket-detection';
13
15
  export class Aggregate extends AggregateBase {
14
16
  static featureName = FEATURE_NAME;
15
17
  constructor(agentIdentifier, aggregator) {
16
18
  super(agentIdentifier, aggregator, FEATURE_NAME);
17
- this.waitForFlags(['err']).then(_ref => {
18
- let [errFlag] = _ref;
19
+ this.waitForFlags(['err']).then(([errFlag]) => {
19
20
  if (errFlag) {
20
21
  // *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
21
22
  const scheduler = new HarvestScheduler('jserrors', {
@@ -95,21 +96,32 @@ export class Aggregate extends AggregateBase {
95
96
  }
96
97
 
97
98
  // Capture SMs to assess customer engagement with the obfuscation config
98
- const rules = getRules(this.agentIdentifier);
99
- if (rules.length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
100
- if (rules.length > 0 && !validateRules(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
99
+ const ruleValidations = this.obfuscator.ruleValidationCache;
100
+ if (ruleValidations.length > 0) {
101
+ this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
102
+ if (ruleValidations.filter(ruleValidation => !ruleValidation.isValid).length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
103
+ }
101
104
 
102
105
  // Check if proxy for either chunks or beacon is being used
103
106
  if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
104
107
  if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
105
108
  if (isBrowserScope && window.MutationObserver) {
106
- this.storeSupportabilityMetrics('Generic/VideoElement/Added', window.document.querySelectorAll('video').length);
109
+ if (window.self !== window.top) {
110
+ this.storeSupportabilityMetrics('Generic/Runtime/IFrame/Detected');
111
+ }
112
+ const preExistingVideos = window.document.querySelectorAll('video').length;
113
+ if (preExistingVideos) this.storeSupportabilityMetrics('Generic/VideoElement/Added', preExistingVideos);
114
+ const preExistingIframes = window.document.querySelectorAll('iframe').length;
115
+ if (preExistingIframes) this.storeSupportabilityMetrics('Generic/IFrame/Added', preExistingIframes);
107
116
  const mo = new MutationObserver(records => {
108
117
  records.forEach(record => {
109
118
  record.addedNodes.forEach(addedNode => {
110
119
  if (addedNode instanceof HTMLVideoElement) {
111
120
  this.storeSupportabilityMetrics('Generic/VideoElement/Added', 1);
112
121
  }
122
+ if (addedNode instanceof HTMLIFrameElement) {
123
+ this.storeSupportabilityMetrics('Generic/IFrame/Added', 1);
124
+ }
113
125
  });
114
126
  });
115
127
  });
@@ -118,6 +130,11 @@ export class Aggregate extends AggregateBase {
118
130
  subtree: true
119
131
  });
120
132
  }
133
+ WATCHABLE_WEB_SOCKET_EVENTS.forEach(tag => {
134
+ registerHandler('buffered-' + WEBSOCKET_TAG + tag, (...args) => {
135
+ handleWebsocketEvents(this.storeSupportabilityMetrics.bind(this), tag, ...args);
136
+ }, this.featureName, this.ee);
137
+ });
121
138
  }
122
139
  eachSessionChecks() {
123
140
  if (!isBrowserScope) return;
@@ -159,8 +176,8 @@ export class Aggregate extends AggregateBase {
159
176
  if (typeof performance !== 'undefined') {
160
177
  const markers = performance.getEntriesByType('mark');
161
178
  const measures = performance.getEntriesByType('measure');
162
- this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
163
- this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
179
+ if (markers.length) this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
180
+ if (measures.length) this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
164
181
  }
165
182
  } catch (e) {
166
183
  // do nothing
@@ -0,0 +1,29 @@
1
+ import { dataSize } from '../../../common/util/data-size';
2
+ import { toTitleCase } from '../../../common/util/text';
3
+ import { ADD_EVENT_LISTENER_TAG } from '../../../common/wrap/wrap-websocket';
4
+
5
+ /**
6
+ * A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
7
+ * @param {Function} reporter a function that reports data as a supportability metric
8
+ * @param {string} tag the unique tag to assign to the sm
9
+ * @param {number} timestamp ms from page origin
10
+ * @param {number} timeSinceInit ms from class init
11
+ * @param {boolean} isLoaded whether the even was observed before the page load event
12
+ * @param {string} socketId a unique id assigned to the observed socket
13
+ * @param {*} data the data reported alongside the socket event
14
+ */
15
+ export function handleWebsocketEvents(reporter, tag, timestamp, timeSinceInit, isLoaded, socketId, data) {
16
+ // socketId is unused in the SMs
17
+ const useDataType = tag === ADD_EVENT_LISTENER_TAG;
18
+ let metricTag = toTitleCase(useDataType ? data.eventType : tag);
19
+ if (metricTag === 'Close') {
20
+ if (data?.event.code === 1000 || data?.event.wasClean) metricTag += '-Clean';else metricTag += '-Dirty';
21
+ }
22
+ const bytes = metricTag === 'Message' && dataSize(data?.event?.data) || metricTag === 'Send' && dataSize(data);
23
+ reporter(buildSMTag(metricTag, 'Ms'), timestamp);
24
+ reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit);
25
+ if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes);
26
+ }
27
+ function buildSMTag(tag, category) {
28
+ return 'WebSocket/' + tag + '/' + category;
29
+ }
@@ -1,6 +1,8 @@
1
+ import { ADD_EVENT_LISTENER_TAG } from '../../common/wrap/wrap-websocket';
1
2
  import { FEATURE_NAMES } from '../../loaders/features/features';
2
3
  export const FEATURE_NAME = FEATURE_NAMES.metrics;
3
4
  export const SUPPORTABILITY_METRIC = 'sm';
4
5
  export const CUSTOM_METRIC = 'cm';
5
6
  export const SUPPORTABILITY_METRIC_CHANNEL = 'storeSupportabilityMetrics';
6
- export const CUSTOM_METRIC_CHANNEL = 'storeEventMetrics';
7
+ export const CUSTOM_METRIC_CHANNEL = 'storeEventMetrics';
8
+ export const WATCHABLE_WEB_SOCKET_EVENTS = ['new', 'send', 'close', ADD_EVENT_LISTENER_TAG];
@@ -1,10 +1,18 @@
1
+ import { handle } from '../../../common/event-emitter/handle';
2
+ import { WEBSOCKET_TAG, wrapWebSocket } from '../../../common/wrap/wrap-websocket';
1
3
  import { InstrumentBase } from '../../utils/instrument-base';
2
- import { FEATURE_NAME } from '../constants';
4
+ import { FEATURE_NAME, WATCHABLE_WEB_SOCKET_EVENTS } from '../constants';
3
5
  export class Instrument extends InstrumentBase {
4
6
  static featureName = FEATURE_NAME;
5
- constructor(agentIdentifier, aggregator) {
6
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7
+ constructor(agentIdentifier, aggregator, auto = true) {
7
8
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
9
+ wrapWebSocket(this.ee);
10
+ WATCHABLE_WEB_SOCKET_EVENTS.forEach(suffix => {
11
+ this.ee.on(WEBSOCKET_TAG + suffix, (...args) => {
12
+ handle('buffered-' + WEBSOCKET_TAG + suffix, [...args], undefined, this.featureName, this.ee);
13
+ });
14
+ });
8
15
  this.importAggregator();
9
16
  }
10
- }
17
+ }
18
+ export const Metrics = Instrument;
@@ -3,13 +3,18 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { InstrumentBase } from '../../utils/instrument-base';
7
- import { FEATURE_NAME } from '../constants';
8
- export class Instrument extends InstrumentBase {
9
- static featureName = FEATURE_NAME;
10
- constructor(agentIdentifier, aggregator) {
11
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
- super(agentIdentifier, aggregator, FEATURE_NAME, auto);
13
- this.importAggregator();
6
+ import { GenericEvents } from '../../generic_events';
7
+
8
+ /**
9
+ * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
10
+ */
11
+ export class Instrument extends GenericEvents {
12
+ constructor(agentIdentifier, aggregator, auto = true) {
13
+ super(agentIdentifier, aggregator, auto);
14
14
  }
15
- }
15
+ }
16
+
17
+ /**
18
+ * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
19
+ */
20
+ export const PageAction = Instrument;
@@ -1,7 +1,8 @@
1
1
  import { globalScope, isBrowserScope, originTime } from '../../../common/constants/runtime';
2
2
  import { addPT, addPN } from '../../../common/timing/nav-timing';
3
3
  import { stringify } from '../../../common/util/stringify';
4
- import { getInfo, getRuntime, isConfigured } from '../../../common/config/config';
4
+ import { getInfo, isValid } from '../../../common/config/info';
5
+ import { getRuntime } from '../../../common/config/runtime';
5
6
  import { Harvest } from '../../../common/harvest/harvest';
6
7
  import * as CONSTANTS from '../constants';
7
8
  import { getActivatedFeaturesFlags } from './initialized-features';
@@ -11,12 +12,9 @@ import { AggregateBase } from '../../utils/aggregate-base';
11
12
  import { firstContentfulPaint } from '../../../common/vitals/first-contentful-paint';
12
13
  import { firstPaint } from '../../../common/vitals/first-paint';
13
14
  import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte';
14
- import { drain } from '../../../common/drain/drain';
15
- import { FEATURE_NAMES } from '../../../loaders/features/features';
16
- import { handle } from '../../../common/event-emitter/handle';
17
- import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
18
15
  import { now } from '../../../common/timing/now';
19
16
  import { TimeKeeper } from '../../../common/timing/time-keeper';
17
+ import { applyFnToProps } from '../../../common/util/traverse';
20
18
  export class Aggregate extends AggregateBase {
21
19
  static featureName = CONSTANTS.FEATURE_NAME;
22
20
  constructor(agentIdentifier, aggregator) {
@@ -25,16 +23,15 @@ export class Aggregate extends AggregateBase {
25
23
  this.firstByteToWindowLoad = 0; // our "frontend" duration
26
24
  this.firstByteToDomContent = 0; // our "dom processing" duration
27
25
  this.timeKeeper = new TimeKeeper(this.agentIdentifier);
28
- if (!isConfigured(agentIdentifier)) {
26
+ if (!isValid(agentIdentifier)) {
29
27
  this.ee.abort();
30
28
  return warn(43);
31
29
  }
32
30
  if (isBrowserScope) {
33
- timeToFirstByte.subscribe(_ref => {
34
- let {
35
- value,
36
- attrs
37
- } = _ref;
31
+ timeToFirstByte.subscribe(({
32
+ value,
33
+ attrs
34
+ }) => {
38
35
  const navEntry = attrs.navigationEntry;
39
36
  this.timeToFirstByte = Math.max(value, this.timeToFirstByte);
40
37
  this.firstByteToWindowLoad = Math.max(Math.round(navEntry.loadEventEnd - this.timeToFirstByte), this.firstByteToWindowLoad); // our "frontend" duration
@@ -76,8 +73,7 @@ export class Aggregate extends AggregateBase {
76
73
  ac: info.account,
77
74
  pr: info.product,
78
75
  af: getActivatedFeaturesFlags(this.agentIdentifier).join(','),
79
- ...Object.entries(this.aggregator.get('measures') || {}).reduce((aggregator, _ref2) => {
80
- let [metricName, measure] = _ref2;
76
+ ...Object.entries(this.aggregator.get('measures') || {}).reduce((aggregator, [metricName, measure]) => {
81
77
  aggregator[metricName] = measure.params?.value;
82
78
  return aggregator;
83
79
  }, {}),
@@ -89,9 +85,9 @@ export class Aggregate extends AggregateBase {
89
85
 
90
86
  let body;
91
87
  if (typeof info.jsAttributes === 'object' && Object.keys(info.jsAttributes).length > 0) {
92
- body = {
88
+ body = applyFnToProps({
93
89
  ja: info.jsAttributes
94
- };
90
+ }, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string');
95
91
  }
96
92
  if (globalScope.performance) {
97
93
  if (typeof PerformanceNavigationTiming !== 'undefined') {
@@ -114,7 +110,7 @@ export class Aggregate extends AggregateBase {
114
110
  queryParameters.fp = firstPaint.current.value;
115
111
  queryParameters.fcp = firstContentfulPaint.current.value;
116
112
  if (this.timeKeeper?.ready) {
117
- queryParameters.timestamp = this.timeKeeper.convertRelativeTimestamp(now());
113
+ queryParameters.timestamp = Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(now())));
118
114
  }
119
115
  const rumStartTime = now();
120
116
  harvester.send({
@@ -127,12 +123,11 @@ export class Aggregate extends AggregateBase {
127
123
  needResponse: true,
128
124
  sendEmptyBody: true
129
125
  },
130
- cbFinished: _ref3 => {
131
- let {
132
- status,
133
- responseText,
134
- xhr
135
- } = _ref3;
126
+ cbFinished: ({
127
+ status,
128
+ responseText,
129
+ xhr
130
+ }) => {
136
131
  const rumEndTime = now();
137
132
  if (status >= 400 || status === 0) {
138
133
  // Adding retry logic for the rum call will be a separate change
@@ -143,22 +138,7 @@ export class Aggregate extends AggregateBase {
143
138
  this.timeKeeper.processRumRequest(xhr, rumStartTime, rumEndTime);
144
139
  if (!this.timeKeeper.ready) throw new Error('TimeKeeper not ready');
145
140
  agentRuntime.timeKeeper = this.timeKeeper;
146
-
147
- // Check if the time diff is such that we need to capture a supportability metric
148
- if (this.timeKeeper.localTimeDiff >= 12 * 60 * 60 * 1000) {
149
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed12Hrs'], undefined, FEATURE_NAMES.metrics, this.ee);
150
- } else if (this.timeKeeper.localTimeDiff >= 6 * 60 * 60 * 1000) {
151
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed6Hrs'], undefined, FEATURE_NAMES.metrics, this.ee);
152
- } else if (this.timeKeeper.localTimeDiff >= 60 * 60 * 1000) {
153
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed1Hrs'], undefined, FEATURE_NAMES.metrics, this.ee);
154
- }
155
141
  } catch (error) {
156
- if (error?.message?.indexOf('invalid format') > 0) {
157
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/InvalidFormat'], undefined, FEATURE_NAMES.metrics, this.ee);
158
- } else {
159
- handle(SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, FEATURE_NAMES.metrics, this.ee);
160
- }
161
- drain(this.agentIdentifier, FEATURE_NAMES.metrics, true);
162
142
  this.ee.abort();
163
143
  warn(17, error);
164
144
  return;
@@ -19,7 +19,7 @@ export function getActivatedFeaturesFlags(agentId) {
19
19
  case FEATURE_NAMES.jserrors:
20
20
  flagArr.push('err');
21
21
  break;
22
- case FEATURE_NAMES.pageAction:
22
+ case FEATURE_NAMES.genericEvents:
23
23
  flagArr.push('ins');
24
24
  break;
25
25
  case FEATURE_NAMES.sessionTrace:
@@ -2,9 +2,9 @@ import { InstrumentBase } from '../../utils/instrument-base';
2
2
  import * as CONSTANTS from '../constants';
3
3
  export class Instrument extends InstrumentBase {
4
4
  static featureName = CONSTANTS.FEATURE_NAME;
5
- constructor(agentIdentifier, aggregator) {
6
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
5
+ constructor(agentIdentifier, aggregator, auto = true) {
7
6
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
8
7
  this.importAggregator();
9
8
  }
10
- }
9
+ }
10
+ export const PageViewEvent = Instrument;
@@ -4,11 +4,11 @@
4
4
  */
5
5
 
6
6
  import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
7
- import { mapOwn } from '../../../common/util/map-own';
8
7
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
9
8
  import { registerHandler } from '../../../common/event-emitter/register-handler';
10
9
  import { handle } from '../../../common/event-emitter/handle';
11
- import { getInfo, getConfigurationValue } from '../../../common/config/config';
10
+ import { getInfo } from '../../../common/config/info';
11
+ import { getConfigurationValue } from '../../../common/config/init';
12
12
  import { FEATURE_NAME } from '../constants';
13
13
  import { FEATURE_NAMES } from '../../../loaders/features/features';
14
14
  import { AggregateBase } from '../../utils/aggregate-base';
@@ -22,22 +22,19 @@ import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte';
22
22
  import { longTask } from '../../../common/vitals/long-task';
23
23
  import { subscribeToVisibilityChange } from '../../../common/window/page-visibility';
24
24
  import { VITAL_NAMES } from '../../../common/vitals/constants';
25
+ import { EventBuffer } from '../../utils/event-buffer';
25
26
  export class Aggregate extends AggregateBase {
26
27
  static featureName = FEATURE_NAME;
27
- #handleVitalMetric = _ref => {
28
- let {
29
- name,
30
- value,
31
- attrs
32
- } = _ref;
28
+ #handleVitalMetric = ({
29
+ name,
30
+ value,
31
+ attrs
32
+ }) => {
33
33
  this.addTiming(name, value, attrs);
34
34
  };
35
35
  constructor(agentIdentifier, aggregator) {
36
- var _this;
37
36
  super(agentIdentifier, aggregator, FEATURE_NAME);
38
- _this = this;
39
- this.timings = [];
40
- this.timingsSent = [];
37
+ this.timings = new EventBuffer();
41
38
  this.curSessEndRecorded = false;
42
39
  if (getConfigurationValue(this.agentIdentifier, 'page_view_timing.long_task') === true) longTask.subscribe(this.#handleVitalMetric);
43
40
  registerHandler('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
@@ -51,10 +48,9 @@ export class Aggregate extends AggregateBase {
51
48
  firstInputDelay.subscribe(this.#handleVitalMetric);
52
49
  largestContentfulPaint.subscribe(this.#handleVitalMetric);
53
50
  interactionToNextPaint.subscribe(this.#handleVitalMetric);
54
- timeToFirstByte.subscribe(_ref2 => {
55
- let {
56
- attrs
57
- } = _ref2;
51
+ timeToFirstByte.subscribe(({
52
+ attrs
53
+ }) => {
58
54
  this.addTiming('load', Math.round(attrs.navigationEntry.loadEventEnd));
59
55
  });
60
56
  subscribeToVisibilityChange(() => {
@@ -71,12 +67,8 @@ export class Aggregate extends AggregateBase {
71
67
  }, true); // CLS node should only reports on vis change rather than on every change
72
68
 
73
69
  const scheduler = new HarvestScheduler('events', {
74
- onFinished: function () {
75
- return _this.onHarvestFinished(...arguments);
76
- },
77
- getPayload: function () {
78
- return _this.prepareHarvest(...arguments);
79
- }
70
+ onFinished: (...args) => this.onHarvestFinished(...args),
71
+ getPayload: (...args) => this.prepareHarvest(...args)
80
72
  }, this);
81
73
  scheduler.startTimer(harvestTimeSeconds);
82
74
  this.drain();
@@ -124,7 +116,7 @@ export class Aggregate extends AggregateBase {
124
116
  if (name !== VITAL_NAMES.CUMULATIVE_LAYOUT_SHIFT && cumulativeLayoutShift.current.value >= 0) {
125
117
  attrs.cls = cumulativeLayoutShift.current.value;
126
118
  }
127
- this.timings.push({
119
+ this.timings.add({
128
120
  name,
129
121
  value,
130
122
  attrs
@@ -132,16 +124,13 @@ export class Aggregate extends AggregateBase {
132
124
  handle('pvtAdded', [name, value, attrs], undefined, FEATURE_NAMES.sessionTrace, this.ee);
133
125
  }
134
126
  onHarvestFinished(result) {
135
- if (result.retry && this.timingsSent.length > 0) {
136
- this.timings.unshift(...this.timingsSent);
137
- this.timingsSent = [];
138
- }
127
+ if (result.retry && this.timings.held.hasData) this.timings.unhold();else this.timings.held.clear();
139
128
  }
140
129
  appendGlobalCustomAttributes(timing) {
141
130
  var timingAttributes = timing.attrs || {};
142
131
  var customAttributes = getInfo(this.agentIdentifier).jsAttributes || {};
143
132
  var reservedAttributes = ['size', 'eid', 'cls', 'type', 'fid', 'elTag', 'elUrl', 'net-type', 'net-etype', 'net-rtt', 'net-dlink'];
144
- mapOwn(customAttributes, function (key, val) {
133
+ Object.entries(customAttributes || {}).forEach(([key, val]) => {
145
134
  if (reservedAttributes.indexOf(key) < 0) {
146
135
  timingAttributes[key] = val;
147
136
  }
@@ -150,14 +139,9 @@ export class Aggregate extends AggregateBase {
150
139
 
151
140
  // serialize and return current timing data, clear and save current data for retry
152
141
  prepareHarvest(options) {
153
- if (this.timings.length === 0) return;
154
- var payload = this.getPayload(this.timings);
155
- if (options.retry) {
156
- for (var i = 0; i < this.timings.length; i++) {
157
- this.timingsSent.push(this.timings[i]);
158
- }
159
- }
160
- this.timings = [];
142
+ if (!this.timings.hasData) return;
143
+ var payload = this.getPayload(this.timings.buffer);
144
+ if (options.retry) this.timings.hold();else this.timings.clear();
161
145
  return {
162
146
  body: {
163
147
  e: payload
@@ -11,8 +11,7 @@ import { isBrowserScope } from '../../../common/constants/runtime';
11
11
  import { now } from '../../../common/timing/now';
12
12
  export class Instrument extends InstrumentBase {
13
13
  static featureName = FEATURE_NAME;
14
- constructor(agentIdentifier, aggregator) {
15
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
14
+ constructor(agentIdentifier, aggregator, auto = true) {
16
15
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
17
16
  if (!isBrowserScope) return; // CWV is irrelevant outside web context
18
17
 
@@ -23,4 +22,5 @@ export class Instrument extends InstrumentBase {
23
22
  windowAddEventListener('pagehide', () => handle('winPagehide', [now()], undefined, FEATURE_NAME, this.ee));
24
23
  this.importAggregator();
25
24
  }
26
- }
25
+ }
26
+ export const PageViewTiming = Instrument;