@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
@@ -12,15 +12,17 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
12
12
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
13
13
  var _stringify = require("../../../common/util/stringify");
14
14
  var _handle = require("../../../common/event-emitter/handle");
15
- var _mapOwn = require("../../../common/util/map-own");
16
- var _config = require("../../../common/config/config");
17
- var _runtime = require("../../../common/constants/runtime");
15
+ var _info = require("../../../common/config/info");
16
+ var _init = require("../../../common/config/init");
17
+ var _runtime = require("../../../common/config/runtime");
18
+ var _runtime2 = require("../../../common/constants/runtime");
18
19
  var _constants = require("../constants");
19
20
  var _features = require("../../../loaders/features/features");
20
21
  var _aggregateBase = require("../../utils/aggregate-base");
21
22
  var _nreum = require("../../../common/window/nreum");
22
23
  var _drain = require("../../../common/drain/drain");
23
24
  var _now = require("../../../common/timing/now");
25
+ var _traverse = require("../../../common/util/traverse");
24
26
  /*
25
27
  * Copyright 2020 New Relic Corporation. All rights reserved.
26
28
  * SPDX-License-Identifier: Apache-2.0
@@ -33,9 +35,7 @@ var _now = require("../../../common/timing/now");
33
35
  class Aggregate extends _aggregateBase.AggregateBase {
34
36
  static featureName = _constants.FEATURE_NAME;
35
37
  constructor(agentIdentifier, aggregator) {
36
- var _this;
37
38
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
38
- _this = this;
39
39
  this.stackReported = {};
40
40
  this.observedAt = {};
41
41
  this.pageviewReported = {};
@@ -45,28 +45,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
45
45
 
46
46
  // this will need to change to match whatever ee we use in the instrument
47
47
  this.ee.on('interactionDone', (interaction, wasSaved) => this.onInteractionDone(interaction, wasSaved));
48
- (0, _registerHandler.registerHandler)('err', function () {
49
- return _this.storeError(...arguments);
50
- }, this.featureName, this.ee);
51
- (0, _registerHandler.registerHandler)('ierr', function () {
52
- return _this.storeError(...arguments);
53
- }, this.featureName, this.ee);
48
+ (0, _registerHandler.registerHandler)('err', (...args) => this.storeError(...args), this.featureName, this.ee);
49
+ (0, _registerHandler.registerHandler)('ierr', (...args) => this.storeError(...args), this.featureName, this.ee);
54
50
  (0, _registerHandler.registerHandler)('softNavFlush', (interactionId, wasFinished, softNavAttrs) => this.onSoftNavNotification(interactionId, wasFinished, softNavAttrs), this.featureName, this.ee); // when an ixn is done or cancelled
55
51
 
56
- const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
52
+ const harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
57
53
 
58
54
  // 0 == off, 1 == on
59
- this.waitForFlags(['err']).then(_ref => {
60
- let [errFlag] = _ref;
55
+ this.waitForFlags(['err']).then(([errFlag]) => {
61
56
  if (errFlag) {
62
57
  const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
63
- onFinished: function () {
64
- return _this.onHarvestFinished(...arguments);
65
- }
58
+ onFinished: (...args) => this.onHarvestFinished(...args)
66
59
  }, this);
67
- scheduler.harvest.on('jserrors', function () {
68
- return _this.onHarvestStarted(...arguments);
69
- });
60
+ scheduler.harvest.on('jserrors', (...args) => this.onHarvestStarted(...args));
70
61
  scheduler.startTimer(harvestTimeSeconds);
71
62
  this.drain();
72
63
  } else {
@@ -77,7 +68,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
77
68
  }
78
69
  onHarvestStarted(options) {
79
70
  // this gets rid of dependency in AJAX module
80
- var body = this.aggregator.take(['err', 'ierr', 'xhr']);
71
+ var body = (0, _traverse.applyFnToProps)(this.aggregator.take(['err', 'ierr', 'xhr']), this.obfuscator.obfuscateString.bind(this.obfuscator), 'string');
81
72
  if (options.retry) {
82
73
  this.currentBody = body;
83
74
  }
@@ -85,7 +76,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
85
76
  body,
86
77
  qs: {}
87
78
  };
88
- var releaseIds = (0, _stringify.stringify)((0, _config.getRuntime)(this.agentIdentifier).releaseIds);
79
+ var releaseIds = (0, _stringify.stringify)((0, _runtime.getRuntime)(this.agentIdentifier).releaseIds);
89
80
  if (releaseIds !== '{}') {
90
81
  payload.qs.ri = releaseIds;
91
82
  }
@@ -100,7 +91,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
100
91
  }
101
92
  onHarvestFinished(result) {
102
93
  if (result.retry && this.currentBody) {
103
- (0, _mapOwn.mapOwn)(this.currentBody, (key, value) => {
94
+ Object.entries(this.currentBody || {}).forEach(([key, value]) => {
104
95
  for (var i = 0; i < value.length; i++) {
105
96
  var bucket = value[i];
106
97
  var name = this.getBucketName(key, bucket.params, bucket.custom);
@@ -143,7 +134,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
143
134
  if (!err) return;
144
135
  // are we in an interaction
145
136
  time = time || (0, _now.now)();
146
- const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
137
+ const agentRuntime = (0, _runtime.getRuntime)(this.agentIdentifier);
147
138
  let filterOutput;
148
139
  if (!internal && agentRuntime.onerror) {
149
140
  filterOutput = agentRuntime.onerror(err);
@@ -159,7 +150,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
159
150
  const params = {
160
151
  stackHash: (0, _stringHashCode.stringHashCode)(canonicalStackString),
161
152
  exceptionClass: stackInfo.name,
162
- request_uri: _runtime.globalScope?.location.pathname
153
+ request_uri: _runtime2.globalScope?.location.pathname
163
154
  };
164
155
  if (stackInfo.message) params.message = '' + stackInfo.message;
165
156
  // Notice if filterOutput isn't false|undefined OR our specified object, this func would've returned already (so it's unnecessary to req-check group).
@@ -176,7 +167,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
176
167
  if (!this.stackReported[bucketHash]) {
177
168
  this.stackReported[bucketHash] = true;
178
169
  params.stack_trace = (0, _formatStackTrace.truncateSize)(stackInfo.stackString);
179
- this.observedAt[bucketHash] = agentRuntime.timeKeeper.convertRelativeTimestamp(time);
170
+ this.observedAt[bucketHash] = Math.floor(agentRuntime.timeKeeper.correctAbsoluteTimestamp(agentRuntime.timeKeeper.convertRelativeTimestamp(time)));
180
171
  } else {
181
172
  params.browser_stack_hash = (0, _stringHashCode.stringHashCode)(stackInfo.stackString);
182
173
  }
@@ -192,7 +183,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
192
183
  this.pageviewReported[bucketHash] = true;
193
184
  }
194
185
  params.firstOccurrenceTimestamp = this.observedAt[bucketHash];
195
- params.timestamp = agentRuntime.timeKeeper.convertRelativeTimestamp(time);
186
+ params.timestamp = Math.floor(agentRuntime.timeKeeper.correctAbsoluteTimestamp(agentRuntime.timeKeeper.convertRelativeTimestamp(time)));
196
187
  var type = internal ? 'ierr' : 'err';
197
188
  var newMetrics = {
198
189
  time
@@ -225,30 +216,20 @@ class Aggregate extends _aggregateBase.AggregateBase {
225
216
  this.#storeJserrorForHarvest(jsErrorEvent, params.browserInteractionId !== undefined, params._softNavAttributes);
226
217
  }
227
218
  }
228
- #storeJserrorForHarvest(errorInfoArr, softNavOccurredFinished) {
229
- let softNavCustomAttrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
219
+ #storeJserrorForHarvest(errorInfoArr, softNavOccurredFinished, softNavCustomAttrs = {}) {
230
220
  let [type, bucketHash, params, newMetrics, localAttrs] = errorInfoArr;
231
221
  const allCustomAttrs = {};
232
222
  if (softNavOccurredFinished) {
233
- Object.entries(softNavCustomAttrs).forEach(_ref2 => {
234
- let [k, v] = _ref2;
235
- return setCustom(k, v);
236
- }); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
223
+ Object.entries(softNavCustomAttrs).forEach(([k, v]) => setCustom(k, v)); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
237
224
  bucketHash += params.browserInteractionId;
238
225
  delete params._softNavAttributes; // cleanup temp properties from synchronous evaluation; this is harmless when async from soft nav (properties DNE)
239
226
  delete params._softNavFinished;
240
227
  } else {
241
228
  // interaction was cancelled -> error should not be associated OR there was no interaction
242
- Object.entries((0, _config.getInfo)(this.agentIdentifier).jsAttributes).forEach(_ref3 => {
243
- let [k, v] = _ref3;
244
- return setCustom(k, v);
245
- });
229
+ Object.entries((0, _info.getInfo)(this.agentIdentifier).jsAttributes).forEach(([k, v]) => setCustom(k, v));
246
230
  delete params.browserInteractionId;
247
231
  }
248
- if (localAttrs) Object.entries(localAttrs).forEach(_ref4 => {
249
- let [k, v] = _ref4;
250
- return setCustom(k, v);
251
- }); // local custom attrs are applied in either case with the highest precedence
232
+ if (localAttrs) Object.entries(localAttrs).forEach(([k, v]) => setCustom(k, v)); // local custom attrs are applied in either case with the highest precedence
252
233
 
253
234
  const jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
254
235
  const aggregateHash = bucketHash + ':' + jsAttributesHash;
@@ -264,8 +245,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
264
245
  this.bufferedErrorsUnderSpa[interaction.id].forEach(item => {
265
246
  var allCustomAttrs = {};
266
247
  const localCustomAttrs = item[4];
267
- (0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom); // tack on custom attrs from the interaction
268
- (0, _mapOwn.mapOwn)(localCustomAttrs, setCustom);
248
+ Object.entries(interaction.root.attrs.custom || {}).forEach(setCustom); // tack on custom attrs from the interaction
249
+ Object.entries(localCustomAttrs || {}).forEach(setCustom);
269
250
  var params = item[2];
270
251
  if (wasSaved) {
271
252
  params.browserInteractionId = interaction.root.attrs.id;
@@ -277,7 +258,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
277
258
  var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
278
259
  var aggregateHash = hash + ':' + jsAttributesHash;
279
260
  this.aggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs);
280
- function setCustom(key, val) {
261
+ function setCustom([key, val]) {
281
262
  allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
282
263
  }
283
264
  });
@@ -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");
@@ -20,8 +20,7 @@ var _castError = require("../shared/cast-error");
20
20
  class Instrument extends _instrumentBase.InstrumentBase {
21
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,6 +17,9 @@ 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
24
  static featureName = _constants2.FEATURE_NAME;
20
25
  #agentRuntime;
@@ -23,14 +28,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
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
11
  static featureName = _constants.FEATURE_NAME;
12
- constructor(agentIdentifier, aggregator) {
13
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
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
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
12
  static featureName = _constants.FEATURE_NAME;
11
- constructor(agentIdentifier, aggregator) {
12
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
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;