@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
@@ -4,16 +4,14 @@
4
4
  */
5
5
  /**
6
6
  * @file Records, aggregates, and harvests session replay data.
7
- *
8
- * NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
9
- * It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
10
- * functionality is validated and a full user experience is curated.
11
7
  */
12
8
 
13
9
  import { registerHandler } from '../../../common/event-emitter/register-handler';
14
10
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
15
- import { ABORT_REASONS, FEATURE_NAME, MAX_PAYLOAD_SIZE, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants';
16
- import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config';
11
+ import { ABORT_REASONS, FEATURE_NAME, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants';
12
+ import { getInfo } from '../../../common/config/info';
13
+ import { getConfigurationValue } from '../../../common/config/init';
14
+ import { getRuntime } from '../../../common/config/runtime';
17
15
  import { AggregateBase } from '../../utils/aggregate-base';
18
16
  import { sharedChannel } from '../../../common/constants/shared-channel';
19
17
  import { obj as encodeObj } from '../../../common/url/encode';
@@ -29,6 +27,7 @@ import { stylesheetEvaluator } from '../shared/stylesheet-evaluator';
29
27
  import { deregisterDrain } from '../../../common/drain/drain';
30
28
  import { now } from '../../../common/timing/now';
31
29
  import { buildNRMetaNode } from '../shared/utils';
30
+ import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
32
31
  export class Aggregate extends AggregateBase {
33
32
  static featureName = FEATURE_NAME;
34
33
  mode = MODE.OFF;
@@ -108,8 +107,7 @@ export class Aggregate extends AggregateBase {
108
107
  inline_images,
109
108
  collect_fonts
110
109
  } = getConfigurationValue(this.agentIdentifier, 'session_replay');
111
- this.waitForFlags(['srs', 'sr']).then(_ref => {
112
- let [srMode, entitled] = _ref;
110
+ this.waitForFlags(['srs', 'sr']).then(([srMode, entitled]) => {
113
111
  this.entitled = !!entitled;
114
112
  if (!this.entitled) {
115
113
  deregisterDrain(this.agentIdentifier, this.featureName);
@@ -201,7 +199,7 @@ export class Aggregate extends AggregateBase {
201
199
  // Do not change the webpackChunkName or it will break the webpack nrba-chunking plugin
202
200
  const {
203
201
  Recorder
204
- } = await import( /* webpackChunkName: "recorder" */'../shared/recorder');
202
+ } = await import(/* webpackChunkName: "recorder" */'../shared/recorder');
205
203
  this.recorder = new Recorder(this);
206
204
  this.recorder.currentBufferTarget.hasError = this.errorNoticed;
207
205
  } catch (err) {
@@ -240,17 +238,16 @@ export class Aggregate extends AggregateBase {
240
238
  const {
241
239
  gzipSync,
242
240
  strToU8
243
- } = await import( /* webpackChunkName: "compressor" */'fflate');
241
+ } = await import(/* webpackChunkName: "compressor" */'fflate');
244
242
  this.gzipper = gzipSync;
245
243
  this.u8 = strToU8;
246
244
  } catch (err) {
247
245
  // compressor failed to load, but we can still record without compression as a last ditch effort
248
246
  }
249
247
  }
250
- prepareHarvest() {
251
- let {
252
- opts
253
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
248
+ prepareHarvest({
249
+ opts
250
+ } = {}) {
254
251
  if (!this.recorder || !this.timeKeeper?.ready) return;
255
252
  const recorderEvents = this.recorder.getEvents();
256
253
  // get the event type and use that to trigger another harvest if needed
@@ -263,11 +260,10 @@ export class Aggregate extends AggregateBase {
263
260
  handle(SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/Harvest/Attempts'], undefined, FEATURE_NAMES.metrics, this.ee);
264
261
  let len = 0;
265
262
  if (!!this.gzipper && !!this.u8) {
266
- payload.body = this.gzipper(this.u8("[".concat(payload.body.map(_ref2 => {
267
- let {
268
- __serialized,
269
- ...e
270
- } = _ref2;
263
+ payload.body = this.gzipper(this.u8("[".concat(payload.body.map(({
264
+ __serialized,
265
+ ...e
266
+ }) => {
271
267
  if (e.__newrelic && __serialized) return __serialized;
272
268
  const output = {
273
269
  ...e
@@ -281,11 +277,10 @@ export class Aggregate extends AggregateBase {
281
277
  len = payload.body.length;
282
278
  this.scheduler.opts.gzip = true;
283
279
  } else {
284
- payload.body = payload.body.map(_ref3 => {
285
- let {
286
- __serialized,
287
- ...node
288
- } = _ref3;
280
+ payload.body = payload.body.map(({
281
+ __serialized,
282
+ ...node
283
+ }) => {
289
284
  if (node.__newrelic) return node;
290
285
  const output = {
291
286
  ...node
@@ -344,8 +339,9 @@ export class Aggregate extends AggregateBase {
344
339
  const relativeNow = now();
345
340
  const firstEventTimestamp = this.getCorrectedTimestamp(events[0]); // from rrweb node
346
341
  const lastEventTimestamp = this.getCorrectedTimestamp(events[events.length - 1]); // from rrweb node
347
- const firstTimestamp = firstEventTimestamp || this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp); // from rrweb node || from when the harvest cycle started
348
- const lastTimestamp = lastEventTimestamp || this.timeKeeper.convertRelativeTimestamp(relativeNow);
342
+ // from rrweb node || from when the harvest cycle started
343
+ const firstTimestamp = firstEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp)));
344
+ const lastTimestamp = lastEventTimestamp || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(relativeNow)));
349
345
  const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
350
346
  return {
351
347
  qs: {
@@ -382,7 +378,7 @@ export class Aggregate extends AggregateBase {
382
378
  'payload.type': recorderEvents.type,
383
379
  // customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
384
380
  ...(endUserId && {
385
- 'enduser.id': endUserId
381
+ 'enduser.id': this.obfuscator.obfuscateString(endUserId)
386
382
  })
387
383
  // The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
388
384
  }, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
@@ -413,9 +409,7 @@ export class Aggregate extends AggregateBase {
413
409
  }
414
410
 
415
411
  /** Abort the feature, once aborted it will not resume */
416
- abort() {
417
- let reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
418
- let data = arguments.length > 1 ? arguments[1] : undefined;
412
+ abort(reason = {}, data) {
419
413
  warn(33, reason.message);
420
414
  handle(SUPPORTABILITY_METRIC_CHANNEL, ["SessionReplay/Abort/".concat(reason.sm), data], undefined, FEATURE_NAMES.metrics, this.ee);
421
415
  this.blocked = true;
@@ -428,8 +422,7 @@ export class Aggregate extends AggregateBase {
428
422
  this.ee.emit('REPLAY_ABORTED');
429
423
  while (this.recorder?.getEvents().events.length) this.recorder?.clearBuffer?.();
430
424
  }
431
- syncWithSessionManager() {
432
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
425
+ syncWithSessionManager(state = {}) {
433
426
  const {
434
427
  session
435
428
  } = getRuntime(this.agentIdentifier);
@@ -16,10 +16,6 @@ export const RRWEB_EVENT_TYPES = {
16
16
  Meta: 4,
17
17
  Custom: 5
18
18
  };
19
- /** Vortex caps payload sizes at 1MB */
20
- export const MAX_PAYLOAD_SIZE = 1000000;
21
- /** Unloading caps around 64kb */
22
- export const IDEAL_PAYLOAD_SIZE = 64000;
23
19
  /** Interval between forcing new full snapshots -- 15 seconds in error mode (x2), 5 minutes in full mode */
24
20
  export const CHECKOUT_MS = {
25
21
  [MODE.ERROR]: 15000,
@@ -2,11 +2,5 @@
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- /**
6
- * @file The top-level entry point for the eventual Session Replay feature.
7
- *
8
- * NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
9
- * It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
10
- * functionality is validated and a full user experience is curated.
11
- */
5
+
12
6
  export { Instrument as SessionReplay } from './instrument/index';
@@ -4,11 +4,8 @@
4
4
  */
5
5
  /**
6
6
  * @file Primes the Session Replay feature for lazy loading.
7
- *
8
- * NOTE: This code is under development and dormant. It will not download to instrumented pages or record any data.
9
- * It is not production ready, and is not intended to be imported or implemented in any build of the browser agent until
10
- * functionality is validated and a full user experience is curated.
11
7
  */
8
+
12
9
  import { handle } from '../../../common/event-emitter/handle';
13
10
  import { DEFAULT_KEY, MODE, PREFIX } from '../../../common/session/constants';
14
11
  import { InstrumentBase } from '../../utils/instrument-base';
@@ -17,8 +14,7 @@ import { FEATURE_NAME, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants';
17
14
  export class Instrument extends InstrumentBase {
18
15
  static featureName = FEATURE_NAME;
19
16
  #mode;
20
- constructor(agentIdentifier, aggregator) {
21
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
17
+ constructor(agentIdentifier, aggregator, auto = true) {
22
18
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
23
19
  let session;
24
20
  this.replayRunning = false;
@@ -73,7 +69,7 @@ export class Instrument extends InstrumentBase {
73
69
  try {
74
70
  const {
75
71
  Recorder
76
- } = await import( /* webpackChunkName: "recorder" */'../shared/recorder');
72
+ } = await import(/* webpackChunkName: "recorder" */'../shared/recorder');
77
73
 
78
74
  // If startReplay() has been used by this point, we must record in full mode regardless of session preload:
79
75
  // Note: recorder starts here with w/e the mode is at this time, but this may be changed later (see #apiStartOrRestartReplay else-case)
@@ -114,4 +110,5 @@ export class Instrument extends InstrumentBase {
114
110
  }
115
111
  }
116
112
  }
117
- }
113
+ }
114
+ export const SessionReplay = Instrument;
@@ -1,26 +1,31 @@
1
+ import { EventBuffer } from '../../utils/event-buffer';
1
2
  export class RecorderEvents {
2
- constructor() {
3
- /** The buffer to hold recorder event nodes */
4
- this.events = [];
5
- /** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
3
+ /** The buffer to hold recorder event nodes */
4
+ #events = new EventBuffer(Infinity);
5
+ /** Payload metadata -- Should indicate when a replay blob started recording. Resets each time a harvest occurs.
6
6
  * cycle timestamps are used as fallbacks if event timestamps cannot be used
7
7
  */
8
- this.cycleTimestamp = Date.now();
9
- /** A value which increments with every new mutation node reported. Resets after a harvest is sent */
10
- this.payloadBytesEstimation = 0;
11
- /** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
12
- * -- When the recording library begins recording, it starts by taking a DOM snapshot
13
- * -- When visibility changes from "hidden" -> "visible", it must capture a full snapshot for the replay to work correctly across tabs
14
- */
15
- this.hasSnapshot = false;
16
- /** Payload metadata -- Should indicate that the payload being sent has a meta node. The meta node should always precede a snapshot node. */
17
- this.hasMeta = false;
18
- /** Payload metadata -- Should indicate that the payload being sent contains an error. Used for query/filter purposes in UI */
19
- this.hasError = false;
20
- /** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
21
- this.inlinedAllStylesheets = true;
22
- }
8
+ cycleTimestamp = Date.now();
9
+ /** Payload metadata -- Should indicate that the payload being sent has a full DOM snapshot. This can happen
10
+ * -- When the recording library begins recording, it starts by taking a DOM snapshot
11
+ * -- When visibility changes from "hidden" -> "visible", it must capture a full snapshot for the replay to work correctly across tabs
12
+ */
13
+ hasSnapshot = false;
14
+ /** Payload metadata -- Should indicate that the payload being sent has a meta node. The meta node should always precede a snapshot node. */
15
+ hasMeta = false;
16
+ /** Payload metadata -- Should indicate that the payload being sent contains an error. Used for query/filter purposes in UI */
17
+ hasError = false;
18
+ /** Payload metadata -- Denotes whether all stylesheet elements were able to be inlined */
19
+ inlinedAllStylesheets = true;
23
20
  add(event) {
24
- this.events.push(event);
21
+ this.#events.add(event);
22
+ }
23
+ get events() {
24
+ return this.#events.buffer;
25
+ }
26
+
27
+ /** A value which increments with every new mutation node reported. Resets after a harvest is sent */
28
+ get payloadBytesEstimation() {
29
+ return this.#events.bytes;
25
30
  }
26
31
  }
@@ -1,7 +1,7 @@
1
1
  import { record as recorder } from 'rrweb';
2
2
  import { stringify } from '../../../common/util/stringify';
3
- import { AVG_COMPRESSION, CHECKOUT_MS, IDEAL_PAYLOAD_SIZE, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES } from '../constants';
4
- import { getConfigurationValue } from '../../../common/config/config';
3
+ import { AVG_COMPRESSION, CHECKOUT_MS, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES } from '../constants';
4
+ import { getConfigurationValue } from '../../../common/config/init';
5
5
  import { RecorderEvents } from './recorder-events';
6
6
  import { MODE } from '../../../common/session/constants';
7
7
  import { stylesheetEvaluator } from './stylesheet-evaluator';
@@ -9,6 +9,7 @@ import { handle } from '../../../common/event-emitter/handle';
9
9
  import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
10
10
  import { FEATURE_NAMES } from '../../../loaders/features/features';
11
11
  import { buildNRMetaNode } from './utils';
12
+ import { IDEAL_PAYLOAD_SIZE } from '../../../common/constants/agent-constants';
12
13
  export class Recorder {
13
14
  /** Each page mutation or event will be stored (raw) in this array. This array will be cleared on each harvest */
14
15
  #events;
@@ -38,10 +39,14 @@ export class Recorder {
38
39
  this.stopRecording = () => {/* no-op until set by rrweb initializer */};
39
40
  }
40
41
  getEvents() {
41
- if (this.#preloaded[0]?.events.length) return {
42
- ...this.#preloaded[0],
43
- type: 'preloaded'
44
- };
42
+ if (this.#preloaded[0]?.events.length) {
43
+ return {
44
+ ...this.#preloaded[0],
45
+ events: this.#preloaded[0].events,
46
+ payloadBytesEstimation: this.#preloaded[0].payloadBytesEstimation,
47
+ type: 'preloaded'
48
+ };
49
+ }
45
50
  return {
46
51
  events: [...this.#backloggedEvents.events, ...this.#events.events].filter(x => x),
47
52
  type: 'standard',
@@ -102,7 +107,8 @@ export class Recorder {
102
107
  this.parent.ee.emit('internal-error', [err]);
103
108
  /** returning true informs rrweb to swallow the error instead of throwing it to the window */
104
109
  return true;
105
- }
110
+ },
111
+ recordAfter: 'DOMContentLoaded'
106
112
  });
107
113
  this.stopRecording = () => {
108
114
  this.recording = false;
@@ -180,7 +186,6 @@ export class Recorder {
180
186
  this.currentBufferTarget.hasSnapshot = true;
181
187
  }
182
188
  this.currentBufferTarget.add(event);
183
- this.currentBufferTarget.payloadBytesEstimation += eventBytes;
184
189
 
185
190
  // We are making an effort to try to keep payloads manageable for unloading. If they reach the unload limit before their interval,
186
191
  // it will send immediately. This often happens on the first snapshot, which can be significantly larger than the other payloads.
@@ -209,8 +214,7 @@ export class Recorder {
209
214
  }
210
215
 
211
216
  /** Estimate the payload size */
212
- getPayloadSize() {
213
- let newBytes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
217
+ getPayloadSize(newBytes = 0) {
214
218
  // the query param padding constant gives us some padding for the other metadata to be safely injected
215
219
  return this.estimateCompression(this.currentBufferTarget.payloadBytesEstimation + newBytes) + QUERY_PARAM_PADDING;
216
220
  }
@@ -1,4 +1,4 @@
1
- import { originals } from '../../../common/config/config';
1
+ import { gosNREUMOriginals } from '../../../common/window/nreum';
2
2
  import { isBrowserScope } from '../../../common/constants/runtime';
3
3
  class StylesheetEvaluator {
4
4
  #evaluated = new WeakSet();
@@ -56,7 +56,7 @@ class StylesheetEvaluator {
56
56
  async #fetchAndOverride(target) {
57
57
  if (!target?.href) return;
58
58
  try {
59
- const stylesheetContents = await originals.FETCH.bind(window)(target.href);
59
+ const stylesheetContents = await gosNREUMOriginals().o.FETCH.bind(window)(target.href);
60
60
  if (!stylesheetContents.ok) {
61
61
  this.failedToFix++;
62
62
  return;
@@ -1,8 +1,9 @@
1
- import { getConfigurationValue, originals } from '../../../common/config/config';
1
+ import { gosNREUMOriginals } from '../../../common/window/nreum';
2
+ import { getConfigurationValue } from '../../../common/config/init';
2
3
  import { canEnableSessionTracking } from '../../utils/feature-gates';
3
4
  import { originTime } from '../../../common/constants/runtime';
4
5
  export function hasReplayPrerequisite(agentId) {
5
- return !!originals.MO &&
6
+ return !!gosNREUMOriginals().o.MO &&
6
7
  // Session Replay cannot work without Mutation Observer
7
8
  canEnableSessionTracking(agentId) &&
8
9
  // requires session tracking to be running (hence "session" replay...)
@@ -1,6 +1,8 @@
1
1
  import { registerHandler } from '../../../common/event-emitter/register-handler';
2
2
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
3
- import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config';
3
+ import { getInfo } from '../../../common/config/info';
4
+ import { getConfigurationValue } from '../../../common/config/init';
5
+ import { getRuntime } from '../../../common/config/runtime';
4
6
  import { FEATURE_NAME } from '../constants';
5
7
  import { AggregateBase } from '../../utils/aggregate-base';
6
8
  import { TraceStorage } from './trace/storage';
@@ -8,6 +10,7 @@ import { obj as encodeObj } from '../../../common/url/encode';
8
10
  import { deregisterDrain } from '../../../common/drain/drain';
9
11
  import { globalScope } from '../../../common/constants/runtime';
10
12
  import { MODE, SESSION_EVENTS } from '../../../common/session/constants';
13
+ import { applyFnToProps } from '../../../common/util/traverse';
11
14
  const ERROR_MODE_SECONDS_WINDOW = 30 * 1000; // sliding window of nodes to track when simply monitoring (but not harvesting) in error mode
12
15
  /** Reserved room for query param attrs */
13
16
  const QUERY_PARAM_PADDING = 5000;
@@ -30,15 +33,11 @@ export class Aggregate extends AggregateBase {
30
33
  /** TraceStorage is the mechanism that holds, normalizes and aggregates ST nodes. It will be accessed and purged when harvests occur */
31
34
  this.traceStorage = new TraceStorage(this);
32
35
  /** This agg needs information about sampling (sts) and entitlements (st) to make the appropriate decisions on running */
33
- this.waitForFlags(['sts', 'st']).then(_ref => {
34
- let [stMode, stEntitled] = _ref;
35
- return this.initialize(stMode, stEntitled);
36
- });
36
+ this.waitForFlags(['sts', 'st']).then(([stMode, stEntitled]) => this.initialize(stMode, stEntitled));
37
37
  }
38
38
 
39
39
  /** Sets up event listeners, and initializes this module to run in the correct "mode". Can be triggered from a few places, but makes an effort to only set up listeners once */
40
40
  initialize(stMode, stEntitled, ignoreSession) {
41
- var _this = this;
42
41
  this.entitled ??= stEntitled;
43
42
  if (this.blocked || !this.entitled) return deregisterDrain(this.agentIdentifier, this.featureName);
44
43
  if (!this.initialized) {
@@ -78,31 +77,17 @@ export class Aggregate extends AggregateBase {
78
77
  }, this);
79
78
 
80
79
  /** The handlers set up by the Inst file */
81
- registerHandler('bst', function () {
82
- return _this.traceStorage.storeEvent(...arguments);
83
- }, this.featureName, this.ee);
84
- registerHandler('bstResource', function () {
85
- return _this.traceStorage.storeResources(...arguments);
86
- }, this.featureName, this.ee);
87
- registerHandler('bstHist', function () {
88
- return _this.traceStorage.storeHist(...arguments);
89
- }, this.featureName, this.ee);
90
- registerHandler('bstXhrAgg', function () {
91
- return _this.traceStorage.storeXhrAgg(...arguments);
92
- }, this.featureName, this.ee);
93
- registerHandler('bstApi', function () {
94
- return _this.traceStorage.storeSTN(...arguments);
95
- }, this.featureName, this.ee);
96
- registerHandler('trace-jserror', function () {
97
- return _this.traceStorage.storeErrorAgg(...arguments);
98
- }, this.featureName, this.ee);
99
- registerHandler('pvtAdded', function () {
100
- return _this.traceStorage.processPVT(...arguments);
101
- }, this.featureName, this.ee);
80
+ registerHandler('bst', (...args) => this.traceStorage.storeEvent(...args), this.featureName, this.ee);
81
+ registerHandler('bstResource', (...args) => this.traceStorage.storeResources(...args), this.featureName, this.ee);
82
+ registerHandler('bstHist', (...args) => this.traceStorage.storeHist(...args), this.featureName, this.ee);
83
+ registerHandler('bstXhrAgg', (...args) => this.traceStorage.storeXhrAgg(...args), this.featureName, this.ee);
84
+ registerHandler('bstApi', (...args) => this.traceStorage.storeSTN(...args), this.featureName, this.ee);
85
+ registerHandler('trace-jserror', (...args) => this.traceStorage.storeErrorAgg(...args), this.featureName, this.ee);
86
+ registerHandler('pvtAdded', (...args) => this.traceStorage.processPVT(...args), this.featureName, this.ee);
102
87
  if (typeof PerformanceNavigationTiming !== 'undefined') {
103
88
  this.traceStorage.storeTiming(globalScope.performance?.getEntriesByType?.('navigation')[0]);
104
89
  } else {
105
- this.traceStorage.storeTiming(globalScope.performance?.timing);
90
+ this.traceStorage.storeTiming(globalScope.performance?.timing, true);
106
91
  }
107
92
 
108
93
  /** Only start actually harvesting if running in full mode at init time */
@@ -126,8 +111,7 @@ export class Aggregate extends AggregateBase {
126
111
  }
127
112
 
128
113
  /** Called by the harvest scheduler at harvest time to retrieve the payload. This will only actually return a payload if running in full mode */
129
- prepareHarvest() {
130
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
114
+ prepareHarvest(options = {}) {
131
115
  this.traceStorage.prevStoredEvents.clear(); // release references to past events for GC
132
116
  if (!this.timeKeeper?.ready) return; // this should likely never happen, but just to be safe, we should never harvest if we cant correct time
133
117
  if (this.blocked || this.mode !== MODE.FULL || this.traceStorage.nodeCount === 0) return;
@@ -166,7 +150,7 @@ export class Aggregate extends AggregateBase {
166
150
  type: 'BrowserSessionChunk',
167
151
  app_id: this.agentInfo.applicationID,
168
152
  protocol_version: '0',
169
- timestamp: this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
153
+ timestamp: Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp))),
170
154
  attributes: encodeObj({
171
155
  ...(agentMetadata.entityGuid && {
172
156
  entityGuid: agentMetadata.entityGuid
@@ -175,8 +159,8 @@ export class Aggregate extends AggregateBase {
175
159
  // this section of attributes must be controllable and stay below the query param padding limit -- see QUERY_PARAM_PADDING
176
160
  // if not, data could be lost to truncation at time of sending, potentially breaking parsing / API behavior in NR1
177
161
  // trace payload metadata
178
- 'trace.firstTimestamp': this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp),
179
- 'trace.lastTimestamp': this.timeKeeper.convertRelativeTimestamp(latestTimeStamp),
162
+ 'trace.firstTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(earliestTimeStamp))),
163
+ 'trace.lastTimestamp': Math.floor(this.timeKeeper.correctAbsoluteTimestamp(this.timeKeeper.convertRelativeTimestamp(latestTimeStamp))),
180
164
  'trace.nodes': stns.length,
181
165
  'trace.originTimestamp': this.timeKeeper.correctedOriginTime,
182
166
  // other payload metadata
@@ -191,12 +175,12 @@ export class Aggregate extends AggregateBase {
191
175
  session: "".concat(this.sessionId),
192
176
  // customer-defined data should go last so that if it exceeds the query param padding limit it will be truncated instead of important attrs
193
177
  ...(endUserId && {
194
- 'enduser.id': endUserId
178
+ 'enduser.id': this.obfuscator.obfuscateString(endUserId)
195
179
  })
196
180
  // The Query Param is being arbitrarily limited in length here. It is also applied when estimating the size of the payload in getPayloadSize()
197
181
  }, QUERY_PARAM_PADDING).substring(1) // remove the leading '&'
198
182
  },
199
- body: stns
183
+ body: applyFnToProps(stns, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')
200
184
  };
201
185
  }
202
186
 
@@ -206,8 +190,7 @@ export class Aggregate extends AggregateBase {
206
190
  onHarvestFinished(result) {
207
191
  if (result.sent && result.retry && this.sentTrace) {
208
192
  // merge previous trace back into buffer to retry for next harvest
209
- Object.entries(this.sentTrace).forEach(_ref2 => {
210
- let [name, listOfSTNodes] = _ref2;
193
+ Object.entries(this.sentTrace).forEach(([name, listOfSTNodes]) => {
211
194
  this.traceStorage.restoreNode(name, listOfSTNodes);
212
195
  });
213
196
  this.sentTrace = null;
@@ -91,8 +91,7 @@ export class TraceStorage {
91
91
  // if PO isn't supported, this checks resourcetiming buffer every harvest.
92
92
  this.storeResources(globalScope.performance?.getEntriesByType?.('resource'));
93
93
  }
94
- const stns = Object.entries(this.trace).flatMap(_ref => {
95
- let [name, listOfSTNodes] = _ref;
94
+ const stns = Object.entries(this.trace).flatMap(([name, listOfSTNodes]) => {
96
95
  // basically take the "this.trace" map-obj and concat all the list-type values
97
96
  if (!(name in toAggregate)) return listOfSTNodes;
98
97
  // Special processing for event nodes dealing with user inputs:
@@ -150,7 +149,7 @@ export class TraceStorage {
150
149
  return name === 'fi' && !!attrs && typeof attrs.fid === 'number';
151
150
  }
152
151
  }
153
- storeTiming(timingEntry) {
152
+ storeTiming(timingEntry, isAbsoluteTimestamp = false) {
154
153
  if (!timingEntry) return;
155
154
 
156
155
  // loop iterates through prototype also (for FF)
@@ -165,6 +164,9 @@ export class TraceStorage {
165
164
  // that are in the future (Microsoft Edge seems to sometimes produce these)
166
165
  if (!(typeof val === 'number' && val >= 0)) continue;
167
166
  val = Math.round(val);
167
+ if (this.parent.timeKeeper && this.parent.timeKeeper.ready && isAbsoluteTimestamp) {
168
+ val = this.parent.timeKeeper.convertAbsoluteTimestamp(Math.floor(this.parent.timeKeeper.correctAbsoluteTimestamp(val)));
169
+ }
168
170
  this.storeSTN(new TraceNode(key, val, val, 'document', 'timing'));
169
171
  }
170
172
  }
@@ -3,7 +3,8 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { handle } from '../../../common/event-emitter/handle';
6
- import { wrapHistory, wrapEvents } from '../../../common/wrap';
6
+ import { wrapHistory } from '../../../common/wrap/wrap-history';
7
+ import { wrapEvents } from '../../../common/wrap/wrap-events';
7
8
  import { InstrumentBase } from '../../utils/instrument-base';
8
9
  import * as CONSTANTS from '../constants';
9
10
  import { FEATURE_NAMES } from '../../../loaders/features/features';
@@ -22,8 +23,7 @@ const {
22
23
  } = CONSTANTS;
23
24
  export class Instrument extends InstrumentBase {
24
25
  static featureName = FEATURE_NAME;
25
- constructor(agentIdentifier, aggregator) {
26
- let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
26
+ constructor(agentIdentifier, aggregator, auto = true) {
27
27
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
28
28
  const canTrackSession = canEnableSessionTracking(this.agentIdentifier);
29
29
  if (!canTrackSession) {
@@ -67,4 +67,5 @@ export class Instrument extends InstrumentBase {
67
67
  resourceObserver: observer
68
68
  });
69
69
  }
70
- }
70
+ }
71
+ export const SessionTrace = Instrument;
@@ -16,7 +16,7 @@ export class AjaxNode extends BelNode {
16
16
  this.traceId = ajaxEvent.traceId;
17
17
  this.spanTimestamp = ajaxEvent.spanTimestamp;
18
18
  this.gql = ajaxEvent.gql;
19
- this.start = ajaxEvent.startTime;
19
+ this.start = ajaxEvent.startTime; // 5000 --- 5500 --> 10500
20
20
  this.end = ajaxEvent.endTime;
21
21
  }
22
22
  serialize(parentStartTimestamp) {