@newrelic/browser-agent 1.264.0 → 1.265.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/common/aggregate/aggregator.js +1 -2
  3. package/dist/cjs/common/config/{state/configurable.js → configurable.js} +1 -1
  4. package/dist/cjs/common/config/{state/info.js → info.js} +1 -1
  5. package/dist/cjs/common/config/{state/init.js → init.js} +5 -5
  6. package/dist/cjs/common/config/{state/loader-config.js → loader-config.js} +1 -1
  7. package/dist/cjs/common/config/{state/runtime.js → runtime.js} +16 -5
  8. package/dist/cjs/common/constants/agent-constants.js +8 -0
  9. package/dist/cjs/common/constants/env.cdn.js +1 -1
  10. package/dist/cjs/common/constants/env.npm.js +1 -1
  11. package/dist/cjs/common/context/shared-context.js +1 -2
  12. package/dist/cjs/common/dispatch/global-event.js +1 -2
  13. package/dist/cjs/common/drain/drain.js +10 -16
  14. package/dist/cjs/common/event-emitter/contextual-ee.js +3 -4
  15. package/dist/cjs/common/event-listener/event-listener-opts.js +2 -6
  16. package/dist/cjs/common/harvest/harvest-scheduler.js +1 -2
  17. package/dist/cjs/common/harvest/harvest.js +29 -56
  18. package/dist/cjs/common/serialize/bel-serializer.js +6 -11
  19. package/dist/cjs/common/session/session-entity.js +9 -12
  20. package/dist/cjs/common/timing/nav-timing.js +1 -3
  21. package/dist/cjs/common/timing/time-keeper.js +16 -6
  22. package/dist/cjs/common/url/encode.js +2 -4
  23. package/dist/cjs/common/util/console.js +2 -0
  24. package/dist/cjs/common/util/invoke.js +6 -16
  25. package/dist/cjs/common/util/obfuscate.js +97 -53
  26. package/dist/cjs/common/util/submit-data.js +17 -20
  27. package/dist/cjs/common/util/text.js +9 -0
  28. package/dist/cjs/common/util/traverse.js +1 -3
  29. package/dist/cjs/common/vitals/cumulative-layout-shift.js +5 -6
  30. package/dist/cjs/common/vitals/first-contentful-paint.js +4 -5
  31. package/dist/cjs/common/vitals/first-input-delay.js +4 -5
  32. package/dist/cjs/common/vitals/interaction-to-next-paint.js +5 -6
  33. package/dist/cjs/common/vitals/largest-contentful-paint.js +4 -5
  34. package/dist/cjs/common/vitals/time-to-first-byte.js +4 -5
  35. package/dist/cjs/common/vitals/vital-metric.js +6 -8
  36. package/dist/cjs/common/window/nreum.js +2 -1
  37. package/dist/cjs/common/window/page-visibility.js +1 -4
  38. package/dist/cjs/common/wrap/wrap-events.js +1 -4
  39. package/dist/cjs/common/wrap/wrap-promise.js +1 -4
  40. package/dist/cjs/common/wrap/wrap-websocket.js +74 -0
  41. package/dist/cjs/features/ajax/aggregate/chunk.js +4 -3
  42. package/dist/cjs/features/ajax/aggregate/gql.js +4 -5
  43. package/dist/cjs/features/ajax/aggregate/index.js +20 -23
  44. package/dist/cjs/features/ajax/constants.js +2 -3
  45. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +9 -8
  46. package/dist/cjs/features/ajax/instrument/index.js +15 -13
  47. package/dist/cjs/features/generic_events/aggregate/index.js +49 -58
  48. package/dist/cjs/features/generic_events/constants.js +4 -2
  49. package/dist/cjs/features/generic_events/instrument/index.js +7 -7
  50. package/dist/cjs/features/jserrors/aggregate/index.js +24 -44
  51. package/dist/cjs/features/jserrors/instrument/index.js +5 -5
  52. package/dist/cjs/features/logging/aggregate/index.js +34 -37
  53. package/dist/cjs/features/logging/constants.js +2 -3
  54. package/dist/cjs/features/logging/instrument/index.js +6 -7
  55. package/dist/cjs/features/logging/shared/log.js +1 -3
  56. package/dist/cjs/features/logging/shared/utils.js +2 -4
  57. package/dist/cjs/features/metrics/aggregate/index.js +35 -18
  58. package/dist/cjs/features/metrics/aggregate/websocket-detection.js +34 -0
  59. package/dist/cjs/features/metrics/constants.js +4 -2
  60. package/dist/cjs/features/metrics/instrument/index.js +13 -5
  61. package/dist/cjs/features/page_action/instrument/index.js +8 -4
  62. package/dist/cjs/features/page_view_event/aggregate/index.js +20 -40
  63. package/dist/cjs/features/page_view_event/instrument/index.js +5 -5
  64. package/dist/cjs/features/page_view_timing/aggregate/index.js +24 -40
  65. package/dist/cjs/features/page_view_timing/instrument/index.js +5 -5
  66. package/dist/cjs/features/session_replay/aggregate/index.js +37 -44
  67. package/dist/cjs/features/session_replay/constants.js +1 -5
  68. package/dist/cjs/features/session_replay/instrument/index.js +6 -10
  69. package/dist/cjs/features/session_replay/shared/recorder-events.js +25 -20
  70. package/dist/cjs/features/session_replay/shared/recorder.js +17 -13
  71. package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +3 -3
  72. package/dist/cjs/features/session_replay/shared/utils.js +5 -4
  73. package/dist/cjs/features/session_trace/aggregate/index.js +26 -43
  74. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +7 -5
  75. package/dist/cjs/features/session_trace/instrument/index.js +9 -8
  76. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +1 -1
  77. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -1
  78. package/dist/cjs/features/soft_navigations/aggregate/index.js +23 -31
  79. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +2 -2
  80. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +9 -10
  81. package/dist/cjs/features/soft_navigations/instrument/index.js +15 -14
  82. package/dist/cjs/features/spa/aggregate/index.js +17 -27
  83. package/dist/cjs/features/spa/aggregate/interaction.js +7 -6
  84. package/dist/cjs/features/spa/aggregate/serializer.js +3 -3
  85. package/dist/cjs/features/spa/constants.js +2 -2
  86. package/dist/cjs/features/spa/instrument/index.js +21 -20
  87. package/dist/cjs/features/utils/agent-session.js +6 -4
  88. package/dist/cjs/features/utils/aggregate-base.js +15 -10
  89. package/dist/cjs/features/utils/event-buffer.js +132 -0
  90. package/dist/cjs/features/utils/feature-gates.js +2 -2
  91. package/dist/cjs/features/utils/instrument-base.js +7 -8
  92. package/dist/cjs/features/utils/lazy-feature-loader.js +11 -11
  93. package/dist/cjs/features/utils/nr1-debugger.js +1 -3
  94. package/dist/cjs/loaders/agent-base.js +4 -8
  95. package/dist/cjs/loaders/agent.js +7 -2
  96. package/dist/cjs/loaders/api/api.js +22 -34
  97. package/dist/cjs/loaders/api/apiAsync.js +9 -12
  98. package/dist/cjs/loaders/configure/configure.js +12 -12
  99. package/dist/cjs/loaders/features/enabled-features.js +2 -2
  100. package/dist/cjs/loaders/micro-agent.js +15 -14
  101. package/dist/esm/common/aggregate/aggregator.js +1 -2
  102. package/dist/esm/common/config/{state/configurable.js → configurable.js} +1 -1
  103. package/dist/esm/common/config/{state/info.js → info.js} +1 -1
  104. package/dist/esm/common/config/{state/init.js → init.js} +5 -5
  105. package/dist/esm/common/config/{state/loader-config.js → loader-config.js} +1 -1
  106. package/dist/esm/common/config/{state/runtime.js → runtime.js} +17 -5
  107. package/dist/esm/common/constants/agent-constants.js +2 -0
  108. package/dist/esm/common/constants/env.cdn.js +1 -1
  109. package/dist/esm/common/constants/env.npm.js +1 -1
  110. package/dist/esm/common/context/shared-context.js +1 -2
  111. package/dist/esm/common/dispatch/global-event.js +1 -2
  112. package/dist/esm/common/drain/drain.js +10 -16
  113. package/dist/esm/common/event-emitter/contextual-ee.js +2 -3
  114. package/dist/esm/common/event-listener/event-listener-opts.js +2 -6
  115. package/dist/esm/common/harvest/harvest-scheduler.js +1 -2
  116. package/dist/esm/common/harvest/harvest.js +21 -48
  117. package/dist/esm/common/serialize/bel-serializer.js +6 -11
  118. package/dist/esm/common/session/session-entity.js +8 -11
  119. package/dist/esm/common/timing/nav-timing.js +1 -3
  120. package/dist/esm/common/timing/time-keeper.js +15 -5
  121. package/dist/esm/common/url/encode.js +2 -4
  122. package/dist/esm/common/util/console.js +2 -0
  123. package/dist/esm/common/util/invoke.js +6 -16
  124. package/dist/esm/common/util/obfuscate.js +96 -49
  125. package/dist/esm/common/util/submit-data.js +17 -20
  126. package/dist/esm/common/util/text.js +3 -0
  127. package/dist/esm/common/util/traverse.js +1 -3
  128. package/dist/esm/common/vitals/cumulative-layout-shift.js +5 -6
  129. package/dist/esm/common/vitals/first-contentful-paint.js +4 -5
  130. package/dist/esm/common/vitals/first-input-delay.js +4 -5
  131. package/dist/esm/common/vitals/interaction-to-next-paint.js +5 -6
  132. package/dist/esm/common/vitals/largest-contentful-paint.js +4 -5
  133. package/dist/esm/common/vitals/time-to-first-byte.js +4 -5
  134. package/dist/esm/common/vitals/vital-metric.js +6 -8
  135. package/dist/esm/common/window/nreum.js +2 -1
  136. package/dist/esm/common/window/page-visibility.js +1 -4
  137. package/dist/esm/common/wrap/wrap-events.js +1 -4
  138. package/dist/esm/common/wrap/wrap-promise.js +1 -4
  139. package/dist/esm/common/wrap/wrap-websocket.js +67 -0
  140. package/dist/esm/features/ajax/aggregate/chunk.js +3 -2
  141. package/dist/esm/features/ajax/aggregate/gql.js +4 -5
  142. package/dist/esm/features/ajax/aggregate/index.js +17 -20
  143. package/dist/esm/features/ajax/constants.js +1 -2
  144. package/dist/esm/features/ajax/instrument/distributed-tracing.js +2 -1
  145. package/dist/esm/features/ajax/instrument/index.js +11 -9
  146. package/dist/esm/features/generic_events/aggregate/index.js +41 -50
  147. package/dist/esm/features/generic_events/constants.js +3 -1
  148. package/dist/esm/features/generic_events/instrument/index.js +5 -5
  149. package/dist/esm/features/jserrors/aggregate/index.js +19 -39
  150. package/dist/esm/features/jserrors/instrument/index.js +4 -4
  151. package/dist/esm/features/logging/aggregate/index.js +32 -35
  152. package/dist/esm/features/logging/constants.js +1 -2
  153. package/dist/esm/features/logging/instrument/index.js +5 -6
  154. package/dist/esm/features/logging/shared/log.js +1 -3
  155. package/dist/esm/features/logging/shared/utils.js +2 -4
  156. package/dist/esm/features/metrics/aggregate/index.js +29 -12
  157. package/dist/esm/features/metrics/aggregate/websocket-detection.js +29 -0
  158. package/dist/esm/features/metrics/constants.js +3 -1
  159. package/dist/esm/features/metrics/instrument/index.js +13 -5
  160. package/dist/esm/features/page_action/instrument/index.js +7 -3
  161. package/dist/esm/features/page_view_event/aggregate/index.js +18 -38
  162. package/dist/esm/features/page_view_event/instrument/index.js +4 -4
  163. package/dist/esm/features/page_view_timing/aggregate/index.js +21 -37
  164. package/dist/esm/features/page_view_timing/instrument/index.js +4 -4
  165. package/dist/esm/features/session_replay/aggregate/index.js +27 -34
  166. package/dist/esm/features/session_replay/constants.js +0 -4
  167. package/dist/esm/features/session_replay/index.js +1 -7
  168. package/dist/esm/features/session_replay/instrument/index.js +6 -9
  169. package/dist/esm/features/session_replay/shared/recorder-events.js +25 -20
  170. package/dist/esm/features/session_replay/shared/recorder.js +14 -10
  171. package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +3 -3
  172. package/dist/esm/features/session_replay/shared/utils.js +3 -2
  173. package/dist/esm/features/session_trace/aggregate/index.js +21 -38
  174. package/dist/esm/features/session_trace/aggregate/trace/storage.js +7 -5
  175. package/dist/esm/features/session_trace/instrument/index.js +6 -5
  176. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +1 -1
  177. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -1
  178. package/dist/esm/features/soft_navigations/aggregate/index.js +22 -30
  179. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
  180. package/dist/esm/features/soft_navigations/aggregate/interaction.js +7 -8
  181. package/dist/esm/features/soft_navigations/instrument/index.js +12 -11
  182. package/dist/esm/features/spa/aggregate/index.js +11 -21
  183. package/dist/esm/features/spa/aggregate/interaction.js +6 -5
  184. package/dist/esm/features/spa/aggregate/serializer.js +1 -1
  185. package/dist/esm/features/spa/constants.js +2 -2
  186. package/dist/esm/features/spa/instrument/index.js +13 -12
  187. package/dist/esm/features/utils/agent-session.js +3 -1
  188. package/dist/esm/features/utils/aggregate-base.js +13 -8
  189. package/dist/esm/features/utils/event-buffer.js +126 -0
  190. package/dist/esm/features/utils/feature-gates.js +1 -1
  191. package/dist/esm/features/utils/instrument-base.js +6 -7
  192. package/dist/esm/features/utils/lazy-feature-loader.js +11 -11
  193. package/dist/esm/features/utils/nr1-debugger.js +1 -3
  194. package/dist/esm/loaders/agent-base.js +4 -8
  195. package/dist/esm/loaders/agent.js +7 -2
  196. package/dist/esm/loaders/api/api.js +17 -29
  197. package/dist/esm/loaders/api/apiAsync.js +2 -5
  198. package/dist/esm/loaders/configure/configure.js +5 -5
  199. package/dist/esm/loaders/features/enabled-features.js +1 -1
  200. package/dist/esm/loaders/micro-agent.js +10 -9
  201. package/dist/types/common/config/configurable.d.ts.map +1 -0
  202. package/dist/types/common/config/info.d.ts.map +1 -0
  203. package/dist/types/common/config/init.d.ts.map +1 -0
  204. package/dist/types/common/config/loader-config.d.ts.map +1 -0
  205. package/dist/types/common/config/runtime.d.ts.map +1 -0
  206. package/dist/types/common/constants/agent-constants.d.ts +3 -0
  207. package/dist/types/common/constants/agent-constants.d.ts.map +1 -0
  208. package/dist/types/common/drain/drain.d.ts.map +1 -1
  209. package/dist/types/common/harvest/harvest.d.ts +1 -7
  210. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  211. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
  212. package/dist/types/common/timing/time-keeper.d.ts +9 -2
  213. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  214. package/dist/types/common/util/console.d.ts.map +1 -1
  215. package/dist/types/common/util/obfuscate.d.ts +78 -6
  216. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  217. package/dist/types/common/util/text.d.ts +2 -0
  218. package/dist/types/common/util/text.d.ts.map +1 -0
  219. package/dist/types/common/window/nreum.d.ts.map +1 -1
  220. package/dist/types/common/wrap/wrap-websocket.d.ts +4 -0
  221. package/dist/types/common/wrap/wrap-websocket.d.ts.map +1 -0
  222. package/dist/types/features/ajax/aggregate/chunk.d.ts.map +1 -1
  223. package/dist/types/features/ajax/aggregate/index.d.ts +2 -3
  224. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  225. package/dist/types/features/ajax/constants.d.ts +0 -1
  226. package/dist/types/features/ajax/constants.d.ts.map +1 -1
  227. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
  228. package/dist/types/features/ajax/instrument/index.d.ts +1 -0
  229. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  230. package/dist/types/features/generic_events/aggregate/index.d.ts +6 -8
  231. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  232. package/dist/types/features/generic_events/constants.d.ts +2 -0
  233. package/dist/types/features/generic_events/constants.d.ts.map +1 -1
  234. package/dist/types/features/generic_events/instrument/index.d.ts +1 -0
  235. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
  236. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  237. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  238. package/dist/types/features/jserrors/instrument/index.d.ts +1 -0
  239. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  240. package/dist/types/features/logging/aggregate/index.d.ts +4 -7
  241. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  242. package/dist/types/features/logging/constants.d.ts +0 -1
  243. package/dist/types/features/logging/constants.d.ts.map +1 -1
  244. package/dist/types/features/logging/instrument/index.d.ts +1 -0
  245. package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
  246. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  247. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts +12 -0
  248. package/dist/types/features/metrics/aggregate/websocket-detection.d.ts.map +1 -0
  249. package/dist/types/features/metrics/constants.d.ts +1 -0
  250. package/dist/types/features/metrics/constants.d.ts.map +1 -1
  251. package/dist/types/features/metrics/instrument/index.d.ts +1 -0
  252. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  253. package/dist/types/features/page_action/instrument/index.d.ts +4 -0
  254. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
  255. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  256. package/dist/types/features/page_view_event/instrument/index.d.ts +1 -0
  257. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
  258. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  259. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  260. package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -0
  261. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
  262. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  263. package/dist/types/features/session_replay/constants.d.ts +0 -4
  264. package/dist/types/features/session_replay/constants.d.ts.map +1 -1
  265. package/dist/types/features/session_replay/instrument/index.d.ts +1 -0
  266. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  267. package/dist/types/features/session_replay/shared/recorder-events.d.ts +6 -6
  268. package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
  269. package/dist/types/features/session_replay/shared/recorder.d.ts +2 -2
  270. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  271. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
  272. package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
  273. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  274. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +1 -1
  275. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
  276. package/dist/types/features/session_trace/instrument/index.d.ts +1 -0
  277. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  278. package/dist/types/features/soft_navigations/aggregate/index.d.ts +3 -3
  279. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  280. package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -0
  281. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
  282. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  283. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  284. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  285. package/dist/types/features/spa/constants.d.ts.map +1 -1
  286. package/dist/types/features/spa/instrument/index.d.ts +1 -0
  287. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  288. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  289. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  290. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  291. package/dist/types/features/utils/event-buffer.d.ts +72 -0
  292. package/dist/types/features/utils/event-buffer.d.ts.map +1 -0
  293. package/dist/types/features/utils/instrument-base.d.ts +1 -0
  294. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  295. package/dist/types/loaders/agent-base.d.ts +1 -1
  296. package/dist/types/loaders/agent.d.ts.map +1 -1
  297. package/dist/types/loaders/api/api.d.ts.map +1 -1
  298. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  299. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  300. package/package.json +55 -59
  301. package/src/common/config/__mocks__/info.js +3 -0
  302. package/src/common/config/__mocks__/init.js +3 -0
  303. package/src/common/config/__mocks__/loader-config.js +2 -0
  304. package/src/common/config/__mocks__/runtime.js +2 -0
  305. package/src/common/config/{state/configurable.js → configurable.js} +1 -1
  306. package/src/common/config/{state/info.js → info.js} +1 -1
  307. package/src/common/config/{state/init.js → init.js} +5 -5
  308. package/src/common/config/{state/loader-config.js → loader-config.js} +1 -1
  309. package/src/common/config/{state/runtime.js → runtime.js} +19 -5
  310. package/src/common/constants/agent-constants.js +2 -0
  311. package/src/common/drain/drain.js +5 -2
  312. package/src/common/event-emitter/contextual-ee.js +1 -1
  313. package/src/common/harvest/harvest.js +7 -21
  314. package/src/common/serialize/bel-serializer.js +5 -7
  315. package/src/common/session/session-entity.js +2 -2
  316. package/src/common/timing/__mocks__/time-keeper.js +6 -2
  317. package/src/common/timing/time-keeper.js +15 -5
  318. package/src/common/util/__mocks__/console.js +1 -0
  319. package/src/common/util/__mocks__/obfuscate.js +5 -8
  320. package/src/common/util/console.js +2 -0
  321. package/src/common/util/obfuscate.js +94 -50
  322. package/src/common/util/text.js +6 -0
  323. package/src/common/window/__mocks__/nreum.js +1 -1
  324. package/src/common/window/nreum.js +2 -1
  325. package/src/common/wrap/wrap-websocket.js +73 -0
  326. package/src/features/ajax/aggregate/chunk.js +3 -2
  327. package/src/features/ajax/aggregate/index.js +20 -19
  328. package/src/features/ajax/constants.js +0 -2
  329. package/src/features/ajax/instrument/distributed-tracing.js +2 -1
  330. package/src/features/ajax/instrument/index.js +9 -5
  331. package/src/features/generic_events/aggregate/index.js +43 -37
  332. package/src/features/generic_events/constants.js +2 -0
  333. package/src/features/generic_events/instrument/index.js +3 -1
  334. package/src/features/jserrors/aggregate/index.js +14 -4
  335. package/src/features/jserrors/instrument/index.js +2 -0
  336. package/src/features/logging/aggregate/index.js +39 -31
  337. package/src/features/logging/constants.js +0 -2
  338. package/src/features/logging/instrument/index.js +2 -0
  339. package/src/features/logging/shared/utils.js +1 -1
  340. package/src/features/metrics/aggregate/index.js +24 -9
  341. package/src/features/metrics/aggregate/websocket-detection.js +31 -0
  342. package/src/features/metrics/constants.js +3 -0
  343. package/src/features/metrics/instrument/index.js +13 -1
  344. package/src/features/page_action/instrument/index.js +5 -0
  345. package/src/features/page_view_event/aggregate/index.js +8 -23
  346. package/src/features/page_view_event/instrument/index.js +2 -0
  347. package/src/features/page_view_timing/aggregate/index.js +14 -16
  348. package/src/features/page_view_timing/instrument/index.js +2 -0
  349. package/src/features/session_replay/aggregate/index.js +13 -9
  350. package/src/features/session_replay/constants.js +0 -4
  351. package/src/features/session_replay/index.js +1 -7
  352. package/src/features/session_replay/instrument/index.js +3 -4
  353. package/src/features/session_replay/shared/recorder-events.js +27 -20
  354. package/src/features/session_replay/shared/recorder.js +13 -6
  355. package/src/features/session_replay/shared/stylesheet-evaluator.js +2 -2
  356. package/src/features/session_replay/shared/utils.js +3 -2
  357. package/src/features/session_trace/aggregate/index.js +16 -7
  358. package/src/features/session_trace/aggregate/trace/storage.js +6 -1
  359. package/src/features/session_trace/instrument/index.js +4 -1
  360. package/src/features/soft_navigations/aggregate/ajax-node.js +1 -1
  361. package/src/features/soft_navigations/aggregate/index.js +13 -15
  362. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +1 -1
  363. package/src/features/soft_navigations/aggregate/interaction.js +1 -1
  364. package/src/features/soft_navigations/instrument/index.js +9 -5
  365. package/src/features/spa/aggregate/index.js +11 -18
  366. package/src/features/spa/aggregate/interaction.js +5 -3
  367. package/src/features/spa/aggregate/serializer.js +1 -1
  368. package/src/features/spa/constants.js +2 -2
  369. package/src/features/spa/instrument/index.js +9 -3
  370. package/src/features/utils/agent-session.js +3 -1
  371. package/src/features/utils/aggregate-base.js +10 -2
  372. package/src/features/utils/event-buffer.js +126 -0
  373. package/src/features/utils/feature-gates.js +1 -1
  374. package/src/features/utils/instrument-base.js +2 -1
  375. package/src/loaders/agent-base.js +2 -2
  376. package/src/loaders/agent.js +7 -2
  377. package/src/loaders/api/api.js +2 -1
  378. package/src/loaders/api/apiAsync.js +1 -1
  379. package/src/loaders/configure/configure.js +4 -1
  380. package/src/loaders/features/enabled-features.js +1 -1
  381. package/src/loaders/micro-agent.js +4 -1
  382. package/dist/cjs/common/config/config.js +0 -76
  383. package/dist/cjs/common/config/state/originals.js +0 -8
  384. package/dist/cjs/common/wrap/index.js +0 -61
  385. package/dist/esm/common/config/config.js +0 -11
  386. package/dist/esm/common/config/state/originals.js +0 -2
  387. package/dist/esm/common/wrap/index.js +0 -13
  388. package/dist/types/common/config/config.d.ts +0 -13
  389. package/dist/types/common/config/config.d.ts.map +0 -1
  390. package/dist/types/common/config/state/configurable.d.ts.map +0 -1
  391. package/dist/types/common/config/state/info.d.ts.map +0 -1
  392. package/dist/types/common/config/state/init.d.ts.map +0 -1
  393. package/dist/types/common/config/state/loader-config.d.ts.map +0 -1
  394. package/dist/types/common/config/state/originals.d.ts +0 -2
  395. package/dist/types/common/config/state/originals.d.ts.map +0 -1
  396. package/dist/types/common/config/state/runtime.d.ts.map +0 -1
  397. package/dist/types/common/wrap/index.d.ts +0 -10
  398. package/dist/types/common/wrap/index.d.ts.map +0 -1
  399. package/src/common/config/__mocks__/config.js +0 -11
  400. package/src/common/config/config.js +0 -12
  401. package/src/common/config/state/originals.js +0 -3
  402. package/src/common/wrap/index.js +0 -16
  403. /package/dist/types/common/config/{state/configurable.d.ts → configurable.d.ts} +0 -0
  404. /package/dist/types/common/config/{state/info.d.ts → info.d.ts} +0 -0
  405. /package/dist/types/common/config/{state/init.d.ts → init.d.ts} +0 -0
  406. /package/dist/types/common/config/{state/loader-config.d.ts → loader-config.d.ts} +0 -0
  407. /package/dist/types/common/config/{state/runtime.d.ts → runtime.d.ts} +0 -0
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
6
+ exports.JSErrors = exports.Instrument = void 0;
7
7
  var _handle = require("../../../common/event-emitter/handle");
8
8
  var _instrumentBase = require("../../utils/instrument-base");
9
9
  var _constants = require("../constants");
@@ -18,10 +18,9 @@ var _castError = require("../shared/cast-error");
18
18
  */
19
19
 
20
20
  class Instrument extends _instrumentBase.InstrumentBase {
21
- static featureName = (() => _constants.FEATURE_NAME)();
21
+ static featureName = _constants.FEATURE_NAME;
22
22
  #replayRunning = false;
23
- constructor(agentIdentifier, aggregator) {
24
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
23
+ constructor(agentIdentifier, aggregator, auto = true) {
25
24
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
26
25
  try {
27
26
  // this try-catch can be removed when IE11 is completely unsupported & gone
@@ -54,4 +53,5 @@ class Instrument extends _instrumentBase.InstrumentBase {
54
53
  this.abortHandler = undefined; // weakly allow this abort op to run only once
55
54
  }
56
55
  }
57
- exports.Instrument = Instrument;
56
+ exports.Instrument = Instrument;
57
+ const JSErrors = exports.JSErrors = Instrument;
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Aggregate = void 0;
7
- var _config = require("../../../common/config/config");
7
+ var _info = require("../../../common/config/info");
8
+ var _init = require("../../../common/config/init");
9
+ var _runtime = require("../../../common/config/runtime");
8
10
  var _handle = require("../../../common/event-emitter/handle");
9
11
  var _registerHandler = require("../../../common/event-emitter/register-handler");
10
12
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
@@ -15,22 +17,21 @@ var _aggregateBase = require("../../utils/aggregate-base");
15
17
  var _constants2 = require("../constants");
16
18
  var _log = require("../shared/log");
17
19
  var _utils = require("../shared/utils");
20
+ var _traverse = require("../../../common/util/traverse");
21
+ var _agentConstants = require("../../../common/constants/agent-constants");
22
+ var _eventBuffer = require("../../utils/event-buffer");
18
23
  class Aggregate extends _aggregateBase.AggregateBase {
19
- static featureName = (() => _constants2.FEATURE_NAME)();
24
+ static featureName = _constants2.FEATURE_NAME;
20
25
  #agentRuntime;
21
26
  #agentInfo;
22
27
  constructor(agentIdentifier, aggregator) {
23
28
  super(agentIdentifier, aggregator, _constants2.FEATURE_NAME);
24
29
 
25
30
  /** held logs before sending */
26
- this.bufferedLogs = [];
27
- /** held logs during sending, for retries */
28
- this.outgoingLogs = [];
29
- /** the estimated bytes of log data waiting to be sent -- triggers a harvest if adding a new log will exceed limit */
30
- this.estimatedBytes = 0;
31
- this.#agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
32
- this.#agentInfo = (0, _config.getInfo)(this.agentIdentifier);
33
- this.harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'logging.harvestTimeSeconds');
31
+ this.bufferedLogs = new _eventBuffer.EventBuffer();
32
+ this.#agentRuntime = (0, _runtime.getRuntime)(this.agentIdentifier);
33
+ this.#agentInfo = (0, _info.getInfo)(this.agentIdentifier);
34
+ this.harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'logging.harvestTimeSeconds');
34
35
  this.waitForFlags([]).then(() => {
35
36
  this.scheduler = new _harvestScheduler.HarvestScheduler('browser/logs', {
36
37
  onFinished: this.onHarvestFinished.bind(this),
@@ -38,16 +39,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
38
39
  getPayload: this.prepareHarvest.bind(this),
39
40
  raw: true
40
41
  }, this);
41
- /** harvest immediately once started to purge pre-load logs collected */
42
- this.scheduler.startTimer(this.harvestTimeSeconds, 0);
43
42
  /** emitted by instrument class (wrapped loggers) or the api methods directly */
44
43
  (0, _registerHandler.registerHandler)(_constants2.LOGGING_EVENT_EMITTER_CHANNEL, this.handleLog.bind(this), this.featureName, this.ee);
45
44
  this.drain();
45
+ /** harvest immediately once started to purge pre-load logs collected */
46
+ this.scheduler.startTimer(this.harvestTimeSeconds, 0);
46
47
  });
47
48
  }
48
- handleLog(timestamp, message) {
49
- let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
50
- let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants2.LOG_LEVELS.INFO;
49
+ handleLog(timestamp, message, attributes = {}, level = _constants2.LOG_LEVELS.INFO) {
51
50
  if (this.blocked) return;
52
51
  if (!attributes || typeof attributes !== 'object') attributes = {};
53
52
  if (typeof level === 'string') level = level.toUpperCase();
@@ -67,30 +66,26 @@ class Aggregate extends _aggregateBase.AggregateBase {
67
66
  return;
68
67
  }
69
68
  if (typeof message !== 'string' || !message) return (0, _console.warn)(32);
70
- if (message.length > _constants2.MAX_PAYLOAD_SIZE) {
71
- (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', message.length]);
72
- return (0, _console.warn)(31, message.slice(0, 25) + '...');
73
- }
74
- const log = new _log.Log(this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp), message, attributes, level);
69
+ const log = new _log.Log(Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(this.#agentRuntime.timeKeeper.convertRelativeTimestamp(timestamp))), message, attributes, level);
75
70
  const logBytes = log.message.length + (0, _stringify.stringify)(log.attributes).length + log.level.length + 10; // timestamp == 10 chars
76
- if (logBytes > _constants2.MAX_PAYLOAD_SIZE) {
77
- (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', logBytes]);
78
- return (0, _console.warn)(31, log.message.slice(0, 25) + '...');
79
- }
80
- if (this.estimatedBytes + logBytes >= _constants2.MAX_PAYLOAD_SIZE) {
81
- (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Early/Seen', this.estimatedBytes + logBytes]);
82
- this.scheduler.runHarvest({});
71
+
72
+ if (!this.bufferedLogs.canMerge(logBytes)) {
73
+ if (this.bufferedLogs.hasData) {
74
+ (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Early/Seen', this.bufferedLogs.bytes + logBytes]);
75
+ this.scheduler.runHarvest({});
76
+ if (logBytes < _agentConstants.MAX_PAYLOAD_SIZE) this.bufferedLogs.add(log);
77
+ } else {
78
+ (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ['Logging/Harvest/Failed/Seen', logBytes]);
79
+ (0, _console.warn)(31, log.message.slice(0, 25) + '...');
80
+ }
81
+ return;
83
82
  }
84
- this.estimatedBytes += logBytes;
85
- this.bufferedLogs.push(log);
83
+ this.bufferedLogs.add(log);
86
84
  }
87
- prepareHarvest() {
88
- if (this.blocked || !(this.bufferedLogs.length || this.outgoingLogs.length)) return;
89
- /** populate outgoing array while also clearing main buffer */
90
- this.outgoingLogs.push(...this.bufferedLogs.splice(0));
91
- this.estimatedBytes = 0;
85
+ prepareHarvest(options = {}) {
86
+ if (this.blocked || !this.bufferedLogs.hasData) return;
92
87
  /** see https://source.datanerd.us/agents/rum-specs/blob/main/browser/Log for logging spec */
93
- return {
88
+ const payload = {
94
89
  qs: {
95
90
  browser_monitoring_key: this.#agentInfo.licenseKey
96
91
  },
@@ -116,12 +111,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
116
111
  }
117
112
  },
118
113
  /** logs section contains individual unique log entries */
119
- logs: this.outgoingLogs
114
+ logs: (0, _traverse.applyFnToProps)(this.bufferedLogs.buffer, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
120
115
  }]
121
116
  };
117
+ if (options.retry) this.bufferedLogs.hold();else this.bufferedLogs.clear();
118
+ return payload;
122
119
  }
123
120
  onHarvestFinished(result) {
124
- if (!result.retry) this.outgoingLogs = [];
121
+ if (result.retry) this.bufferedLogs.unhold();else this.bufferedLogs.held.clear();
125
122
  }
126
123
  }
127
124
  exports.Aggregate = Aggregate;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.MAX_PAYLOAD_SIZE = exports.LOG_LEVELS = exports.LOGGING_EVENT_EMITTER_CHANNEL = exports.FEATURE_NAME = void 0;
6
+ exports.LOG_LEVELS = exports.LOGGING_EVENT_EMITTER_CHANNEL = exports.FEATURE_NAME = void 0;
7
7
  var _features = require("../../loaders/features/features");
8
8
  const LOG_LEVELS = exports.LOG_LEVELS = {
9
9
  ERROR: 'ERROR',
@@ -13,5 +13,4 @@ const LOG_LEVELS = exports.LOG_LEVELS = {
13
13
  TRACE: 'TRACE'
14
14
  };
15
15
  const LOGGING_EVENT_EMITTER_CHANNEL = exports.LOGGING_EVENT_EMITTER_CHANNEL = 'log';
16
- const FEATURE_NAME = exports.FEATURE_NAME = _features.FEATURE_NAMES.logging;
17
- const MAX_PAYLOAD_SIZE = exports.MAX_PAYLOAD_SIZE = 1000000;
16
+ const FEATURE_NAME = exports.FEATURE_NAME = _features.FEATURE_NAMES.logging;
@@ -3,19 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
6
+ exports.Logging = exports.Instrument = void 0;
7
7
  var _instrumentBase = require("../../utils/instrument-base");
8
8
  var _constants = require("../constants");
9
9
  var _utils = require("../shared/utils");
10
10
  class Instrument extends _instrumentBase.InstrumentBase {
11
- static featureName = (() => _constants.FEATURE_NAME)();
12
- constructor(agentIdentifier, aggregator) {
13
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11
+ static featureName = _constants.FEATURE_NAME;
12
+ constructor(agentIdentifier, aggregator, auto = true) {
14
13
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
15
14
  const instanceEE = this.ee;
16
15
  /** emitted by wrap-logger function */
17
- this.ee.on('wrap-logger-end', function handleLog(_ref) {
18
- let [message] = _ref;
16
+ this.ee.on('wrap-logger-end', function handleLog([message]) {
19
17
  const {
20
18
  level,
21
19
  customAttributes
@@ -25,4 +23,5 @@ class Instrument extends _instrumentBase.InstrumentBase {
25
23
  this.importAggregator();
26
24
  }
27
25
  }
28
- exports.Instrument = Instrument;
26
+ exports.Instrument = Instrument;
27
+ const Logging = exports.Logging = Instrument;
@@ -23,9 +23,7 @@ class Log {
23
23
  * @param {object} attributes - other log event attributes
24
24
  * @param {enum} level - Log level
25
25
  */
26
- constructor(timestamp, message) {
27
- let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
28
- let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants.LOG_LEVELS.INFO;
26
+ constructor(timestamp, message, attributes = {}, level = _constants.LOG_LEVELS.INFO) {
29
27
  /** @type {long} */
30
28
  this.timestamp = timestamp;
31
29
  this.message = message;
@@ -16,9 +16,7 @@ var _constants2 = require("../constants");
16
16
  * @param {{[key: string]: *}} customAttributes - The log's custom attributes if any
17
17
  * @param {enum} level - the log level enum
18
18
  */
19
- function bufferLog(ee, message) {
20
- let customAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
21
- let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants2.LOG_LEVELS.INFO;
19
+ function bufferLog(ee, message, customAttributes = {}, level = _constants2.LOG_LEVELS.INFO) {
22
20
  (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, ["API/logging/".concat(level.toLowerCase(), "/called")], undefined, _features.FEATURE_NAMES.metrics, ee);
23
21
  (0, _handle.handle)(_constants2.LOGGING_EVENT_EMITTER_CHANNEL, [(0, _now.now)(), message, customAttributes, level], undefined, _features.FEATURE_NAMES.logging, ee);
24
22
  }
@@ -30,5 +28,5 @@ function bufferLog(ee, message) {
30
28
  */
31
29
  function isValidLogLevel(level) {
32
30
  if (typeof level !== 'string') return false;
33
- return Object.values(_constants2.LOG_LEVELS).some(logLevel => logLevel === level);
31
+ return Object.values(_constants2.LOG_LEVELS).some(logLevel => logLevel === level.toUpperCase().trim());
34
32
  }
@@ -4,24 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Aggregate = void 0;
7
- var _config = require("../../../common/config/config");
7
+ var _init = require("../../../common/config/init");
8
+ var _runtime = require("../../../common/config/runtime");
8
9
  var _registerHandler = require("../../../common/event-emitter/register-handler");
9
10
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
10
11
  var _constants = require("../constants");
11
12
  var _frameworkDetection = require("./framework-detection");
12
13
  var _protocol = require("../../../common/url/protocol");
13
- var _obfuscate = require("../../../common/util/obfuscate");
14
14
  var _load = require("../../../common/window/load");
15
15
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
16
- var _runtime = require("../../../common/constants/runtime");
16
+ var _runtime2 = require("../../../common/constants/runtime");
17
17
  var _aggregateBase = require("../../utils/aggregate-base");
18
18
  var _drain = require("../../../common/drain/drain");
19
+ var _wrapWebsocket = require("../../../common/wrap/wrap-websocket");
20
+ var _websocketDetection = require("./websocket-detection");
19
21
  class Aggregate extends _aggregateBase.AggregateBase {
20
- static featureName = (() => _constants.FEATURE_NAME)();
22
+ static featureName = _constants.FEATURE_NAME;
21
23
  constructor(agentIdentifier, aggregator) {
22
24
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
23
- this.waitForFlags(['err']).then(_ref => {
24
- let [errFlag] = _ref;
25
+ this.waitForFlags(['err']).then(([errFlag]) => {
25
26
  if (errFlag) {
26
27
  // *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
27
28
  const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
@@ -65,15 +66,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
65
66
  const {
66
67
  distMethod,
67
68
  loaderType
68
- } = (0, _config.getRuntime)(this.agentIdentifier);
69
+ } = (0, _runtime.getRuntime)(this.agentIdentifier);
69
70
  const {
70
71
  proxy,
71
72
  privacy,
72
73
  page_view_timing
73
- } = (0, _config.getConfiguration)(this.agentIdentifier);
74
+ } = (0, _init.getConfiguration)(this.agentIdentifier);
74
75
  if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
75
76
  if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
76
- if (_runtime.isBrowserScope) {
77
+ if (_runtime2.isBrowserScope) {
77
78
  this.storeSupportabilityMetrics('Generic/Runtime/Browser/Detected');
78
79
  const nonce = document?.currentScript?.nonce;
79
80
  if (nonce && nonce !== '') {
@@ -88,7 +89,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
88
89
  });
89
90
  if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
90
91
  if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled');
91
- } else if (_runtime.isWorkerScope) {
92
+ } else if (_runtime2.isWorkerScope) {
92
93
  this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
93
94
  } else {
94
95
  this.storeSupportabilityMetrics('Generic/Runtime/Unknown/Detected');
@@ -101,21 +102,32 @@ class Aggregate extends _aggregateBase.AggregateBase {
101
102
  }
102
103
 
103
104
  // Capture SMs to assess customer engagement with the obfuscation config
104
- const rules = (0, _obfuscate.getRules)(this.agentIdentifier);
105
- if (rules.length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
106
- if (rules.length > 0 && !(0, _obfuscate.validateRules)(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
105
+ const ruleValidations = this.obfuscator.ruleValidationCache;
106
+ if (ruleValidations.length > 0) {
107
+ this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
108
+ if (ruleValidations.filter(ruleValidation => !ruleValidation.isValid).length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
109
+ }
107
110
 
108
111
  // Check if proxy for either chunks or beacon is being used
109
112
  if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
110
113
  if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
111
- if (_runtime.isBrowserScope && window.MutationObserver) {
112
- this.storeSupportabilityMetrics('Generic/VideoElement/Added', window.document.querySelectorAll('video').length);
114
+ if (_runtime2.isBrowserScope && window.MutationObserver) {
115
+ if (window.self !== window.top) {
116
+ this.storeSupportabilityMetrics('Generic/Runtime/IFrame/Detected');
117
+ }
118
+ const preExistingVideos = window.document.querySelectorAll('video').length;
119
+ if (preExistingVideos) this.storeSupportabilityMetrics('Generic/VideoElement/Added', preExistingVideos);
120
+ const preExistingIframes = window.document.querySelectorAll('iframe').length;
121
+ if (preExistingIframes) this.storeSupportabilityMetrics('Generic/IFrame/Added', preExistingIframes);
113
122
  const mo = new MutationObserver(records => {
114
123
  records.forEach(record => {
115
124
  record.addedNodes.forEach(addedNode => {
116
125
  if (addedNode instanceof HTMLVideoElement) {
117
126
  this.storeSupportabilityMetrics('Generic/VideoElement/Added', 1);
118
127
  }
128
+ if (addedNode instanceof HTMLIFrameElement) {
129
+ this.storeSupportabilityMetrics('Generic/IFrame/Added', 1);
130
+ }
119
131
  });
120
132
  });
121
133
  });
@@ -124,9 +136,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
124
136
  subtree: true
125
137
  });
126
138
  }
139
+ _constants.WATCHABLE_WEB_SOCKET_EVENTS.forEach(tag => {
140
+ (0, _registerHandler.registerHandler)('buffered-' + _wrapWebsocket.WEBSOCKET_TAG + tag, (...args) => {
141
+ (0, _websocketDetection.handleWebsocketEvents)(this.storeSupportabilityMetrics.bind(this), tag, ...args);
142
+ }, this.featureName, this.ee);
143
+ });
127
144
  }
128
145
  eachSessionChecks() {
129
- if (!_runtime.isBrowserScope) return;
146
+ if (!_runtime2.isBrowserScope) return;
130
147
 
131
148
  // [Temporary] Report restores from BFCache to NR1 while feature flag is in place in lieu of sending pageshow events.
132
149
  (0, _eventListenerOpts.windowAddEventListener)('pageshow', evt => {
@@ -165,8 +182,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
165
182
  if (typeof performance !== 'undefined') {
166
183
  const markers = performance.getEntriesByType('mark');
167
184
  const measures = performance.getEntriesByType('measure');
168
- this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
169
- this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
185
+ if (markers.length) this.storeSupportabilityMetrics('Generic/Performance/Mark/Seen', markers.length);
186
+ if (measures.length) this.storeSupportabilityMetrics('Generic/Performance/Measure/Seen', measures.length);
170
187
  }
171
188
  } catch (e) {
172
189
  // do nothing
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleWebsocketEvents = handleWebsocketEvents;
7
+ var _dataSize = require("../../../common/util/data-size");
8
+ var _text = require("../../../common/util/text");
9
+ var _wrapWebsocket = require("../../../common/wrap/wrap-websocket");
10
+ /**
11
+ * A SM handler for web socket events, which converts them to a shape suitable for SMs and reports them.
12
+ * @param {Function} reporter a function that reports data as a supportability metric
13
+ * @param {string} tag the unique tag to assign to the sm
14
+ * @param {number} timestamp ms from page origin
15
+ * @param {number} timeSinceInit ms from class init
16
+ * @param {boolean} isLoaded whether the even was observed before the page load event
17
+ * @param {string} socketId a unique id assigned to the observed socket
18
+ * @param {*} data the data reported alongside the socket event
19
+ */
20
+ function handleWebsocketEvents(reporter, tag, timestamp, timeSinceInit, isLoaded, socketId, data) {
21
+ // socketId is unused in the SMs
22
+ const useDataType = tag === _wrapWebsocket.ADD_EVENT_LISTENER_TAG;
23
+ let metricTag = (0, _text.toTitleCase)(useDataType ? data.eventType : tag);
24
+ if (metricTag === 'Close') {
25
+ if (data?.event.code === 1000 || data?.event.wasClean) metricTag += '-Clean';else metricTag += '-Dirty';
26
+ }
27
+ const bytes = metricTag === 'Message' && (0, _dataSize.dataSize)(data?.event?.data) || metricTag === 'Send' && (0, _dataSize.dataSize)(data);
28
+ reporter(buildSMTag(metricTag, 'Ms'), timestamp);
29
+ reporter(buildSMTag(metricTag, 'MsSinceClassInit'), timeSinceInit);
30
+ if (bytes) reporter(buildSMTag(metricTag, 'Bytes'), bytes);
31
+ }
32
+ function buildSMTag(tag, category) {
33
+ return 'WebSocket/' + tag + '/' + category;
34
+ }
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SUPPORTABILITY_METRIC_CHANNEL = exports.SUPPORTABILITY_METRIC = exports.FEATURE_NAME = exports.CUSTOM_METRIC_CHANNEL = exports.CUSTOM_METRIC = void 0;
6
+ exports.WATCHABLE_WEB_SOCKET_EVENTS = exports.SUPPORTABILITY_METRIC_CHANNEL = exports.SUPPORTABILITY_METRIC = exports.FEATURE_NAME = exports.CUSTOM_METRIC_CHANNEL = exports.CUSTOM_METRIC = void 0;
7
+ var _wrapWebsocket = require("../../common/wrap/wrap-websocket");
7
8
  var _features = require("../../loaders/features/features");
8
9
  const FEATURE_NAME = exports.FEATURE_NAME = _features.FEATURE_NAMES.metrics;
9
10
  const SUPPORTABILITY_METRIC = exports.SUPPORTABILITY_METRIC = 'sm';
10
11
  const CUSTOM_METRIC = exports.CUSTOM_METRIC = 'cm';
11
12
  const SUPPORTABILITY_METRIC_CHANNEL = exports.SUPPORTABILITY_METRIC_CHANNEL = 'storeSupportabilityMetrics';
12
- const CUSTOM_METRIC_CHANNEL = exports.CUSTOM_METRIC_CHANNEL = 'storeEventMetrics';
13
+ const CUSTOM_METRIC_CHANNEL = exports.CUSTOM_METRIC_CHANNEL = 'storeEventMetrics';
14
+ const WATCHABLE_WEB_SOCKET_EVENTS = exports.WATCHABLE_WEB_SOCKET_EVENTS = ['new', 'send', 'close', _wrapWebsocket.ADD_EVENT_LISTENER_TAG];
@@ -3,15 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
6
+ exports.Metrics = exports.Instrument = void 0;
7
+ var _handle = require("../../../common/event-emitter/handle");
8
+ var _wrapWebsocket = require("../../../common/wrap/wrap-websocket");
7
9
  var _instrumentBase = require("../../utils/instrument-base");
8
10
  var _constants = require("../constants");
9
11
  class Instrument extends _instrumentBase.InstrumentBase {
10
- static featureName = (() => _constants.FEATURE_NAME)();
11
- constructor(agentIdentifier, aggregator) {
12
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
+ static featureName = _constants.FEATURE_NAME;
13
+ constructor(agentIdentifier, aggregator, auto = true) {
13
14
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
15
+ (0, _wrapWebsocket.wrapWebSocket)(this.ee);
16
+ _constants.WATCHABLE_WEB_SOCKET_EVENTS.forEach(suffix => {
17
+ this.ee.on(_wrapWebsocket.WEBSOCKET_TAG + suffix, (...args) => {
18
+ (0, _handle.handle)('buffered-' + _wrapWebsocket.WEBSOCKET_TAG + suffix, [...args], undefined, this.featureName, this.ee);
19
+ });
20
+ });
14
21
  this.importAggregator();
15
22
  }
16
23
  }
17
- exports.Instrument = Instrument;
24
+ exports.Instrument = Instrument;
25
+ const Metrics = exports.Metrics = Instrument;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
6
+ exports.PageAction = exports.Instrument = void 0;
7
7
  var _generic_events = require("../../generic_events");
8
8
  /*
9
9
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -14,9 +14,13 @@ var _generic_events = require("../../generic_events");
14
14
  * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
15
15
  */
16
16
  class Instrument extends _generic_events.GenericEvents {
17
- constructor(agentIdentifier, aggregator) {
18
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
17
+ constructor(agentIdentifier, aggregator, auto = true) {
19
18
  super(agentIdentifier, aggregator, auto);
20
19
  }
21
20
  }
22
- exports.Instrument = Instrument;
21
+
22
+ /**
23
+ * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
24
+ */
25
+ exports.Instrument = Instrument;
26
+ const PageAction = exports.PageAction = Instrument;
@@ -7,7 +7,8 @@ exports.Aggregate = void 0;
7
7
  var _runtime = require("../../../common/constants/runtime");
8
8
  var _navTiming = require("../../../common/timing/nav-timing");
9
9
  var _stringify = require("../../../common/util/stringify");
10
- var _config = require("../../../common/config/config");
10
+ var _info = require("../../../common/config/info");
11
+ var _runtime2 = require("../../../common/config/runtime");
11
12
  var _harvest = require("../../../common/harvest/harvest");
12
13
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
13
14
  var _initializedFeatures = require("./initialized-features");
@@ -17,32 +18,28 @@ var _aggregateBase = require("../../utils/aggregate-base");
17
18
  var _firstContentfulPaint = require("../../../common/vitals/first-contentful-paint");
18
19
  var _firstPaint = require("../../../common/vitals/first-paint");
19
20
  var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
20
- var _drain = require("../../../common/drain/drain");
21
- var _features = require("../../../loaders/features/features");
22
- var _handle = require("../../../common/event-emitter/handle");
23
- var _constants2 = require("../../metrics/constants");
24
21
  var _now = require("../../../common/timing/now");
25
22
  var _timeKeeper = require("../../../common/timing/time-keeper");
23
+ var _traverse = require("../../../common/util/traverse");
26
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
27
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
28
26
  class Aggregate extends _aggregateBase.AggregateBase {
29
- static featureName = (() => CONSTANTS.FEATURE_NAME)();
27
+ static featureName = CONSTANTS.FEATURE_NAME;
30
28
  constructor(agentIdentifier, aggregator) {
31
29
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
32
30
  this.timeToFirstByte = 0;
33
31
  this.firstByteToWindowLoad = 0; // our "frontend" duration
34
32
  this.firstByteToDomContent = 0; // our "dom processing" duration
35
33
  this.timeKeeper = new _timeKeeper.TimeKeeper(this.agentIdentifier);
36
- if (!(0, _config.isConfigured)(agentIdentifier)) {
34
+ if (!(0, _info.isValid)(agentIdentifier)) {
37
35
  this.ee.abort();
38
36
  return (0, _console.warn)(43);
39
37
  }
40
38
  if (_runtime.isBrowserScope) {
41
- _timeToFirstByte.timeToFirstByte.subscribe(_ref => {
42
- let {
43
- value,
44
- attrs
45
- } = _ref;
39
+ _timeToFirstByte.timeToFirstByte.subscribe(({
40
+ value,
41
+ attrs
42
+ }) => {
46
43
  const navEntry = attrs.navigationEntry;
47
44
  this.timeToFirstByte = Math.max(value, this.timeToFirstByte);
48
45
  this.firstByteToWindowLoad = Math.max(Math.round(navEntry.loadEventEnd - this.timeToFirstByte), this.firstByteToWindowLoad); // our "frontend" duration
@@ -56,8 +53,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
56
53
  }
57
54
  }
58
55
  sendRum() {
59
- const info = (0, _config.getInfo)(this.agentIdentifier);
60
- const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
56
+ const info = (0, _info.getInfo)(this.agentIdentifier);
57
+ const agentRuntime = (0, _runtime2.getRuntime)(this.agentIdentifier);
61
58
  const harvester = new _harvest.Harvest(this);
62
59
  if (info.queueTime) this.aggregator.store('measures', 'qt', {
63
60
  value: info.queueTime
@@ -84,8 +81,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
84
81
  ac: info.account,
85
82
  pr: info.product,
86
83
  af: (0, _initializedFeatures.getActivatedFeaturesFlags)(this.agentIdentifier).join(','),
87
- ...Object.entries(this.aggregator.get('measures') || {}).reduce((aggregator, _ref2) => {
88
- let [metricName, measure] = _ref2;
84
+ ...Object.entries(this.aggregator.get('measures') || {}).reduce((aggregator, [metricName, measure]) => {
89
85
  aggregator[metricName] = measure.params?.value;
90
86
  return aggregator;
91
87
  }, {}),
@@ -97,9 +93,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
97
93
 
98
94
  let body;
99
95
  if (typeof info.jsAttributes === 'object' && Object.keys(info.jsAttributes).length > 0) {
100
- body = {
96
+ body = (0, _traverse.applyFnToProps)({
101
97
  ja: info.jsAttributes
102
- };
98
+ }, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string');
103
99
  }
104
100
  if (_runtime.globalScope.performance) {
105
101
  if (typeof PerformanceNavigationTiming !== 'undefined') {
@@ -122,7 +118,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
122
118
  queryParameters.fp = _firstPaint.firstPaint.current.value;
123
119
  queryParameters.fcp = _firstContentfulPaint.firstContentfulPaint.current.value;
124
120
  if (this.timeKeeper?.ready) {
125
- queryParameters.timestamp = this.timeKeeper.convertRelativeTimestamp((0, _now.now)());
121
+ queryParameters.timestamp = Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp((0, _now.now)())));
126
122
  }
127
123
  const rumStartTime = (0, _now.now)();
128
124
  harvester.send({
@@ -135,12 +131,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
135
131
  needResponse: true,
136
132
  sendEmptyBody: true
137
133
  },
138
- cbFinished: _ref3 => {
139
- let {
140
- status,
141
- responseText,
142
- xhr
143
- } = _ref3;
134
+ cbFinished: ({
135
+ status,
136
+ responseText,
137
+ xhr
138
+ }) => {
144
139
  const rumEndTime = (0, _now.now)();
145
140
  if (status >= 400 || status === 0) {
146
141
  // Adding retry logic for the rum call will be a separate change
@@ -151,22 +146,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
151
146
  this.timeKeeper.processRumRequest(xhr, rumStartTime, rumEndTime);
152
147
  if (!this.timeKeeper.ready) throw new Error('TimeKeeper not ready');
153
148
  agentRuntime.timeKeeper = this.timeKeeper;
154
-
155
- // Check if the time diff is such that we need to capture a supportability metric
156
- if (this.timeKeeper.localTimeDiff >= 12 * 60 * 60 * 1000) {
157
- (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed12Hrs'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
158
- } else if (this.timeKeeper.localTimeDiff >= 6 * 60 * 60 * 1000) {
159
- (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed6Hrs'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
160
- } else if (this.timeKeeper.localTimeDiff >= 60 * 60 * 1000) {
161
- (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/DiffExceed1Hrs'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
162
- }
163
149
  } catch (error) {
164
- if (error?.message?.indexOf('invalid format') > 0) {
165
- (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/InvalidFormat'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
166
- } else {
167
- (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
168
- }
169
- (0, _drain.drain)(this.agentIdentifier, _features.FEATURE_NAMES.metrics, true);
170
150
  this.ee.abort();
171
151
  (0, _console.warn)(17, error);
172
152
  return;
@@ -3,17 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Instrument = void 0;
6
+ exports.PageViewEvent = exports.Instrument = void 0;
7
7
  var _instrumentBase = require("../../utils/instrument-base");
8
8
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
9
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
10
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
11
  class Instrument extends _instrumentBase.InstrumentBase {
12
- static featureName = (() => CONSTANTS.FEATURE_NAME)();
13
- constructor(agentIdentifier, aggregator) {
14
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
+ static featureName = CONSTANTS.FEATURE_NAME;
13
+ constructor(agentIdentifier, aggregator, auto = true) {
15
14
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
16
15
  this.importAggregator();
17
16
  }
18
17
  }
19
- exports.Instrument = Instrument;
18
+ exports.Instrument = Instrument;
19
+ const PageViewEvent = exports.PageViewEvent = Instrument;