@newrelic/browser-agent 0.1.229 → 0.1.230

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 (509) hide show
  1. package/README.md +40 -1
  2. package/dist/cjs/common/config/state/configurable.js +2 -1
  3. package/dist/cjs/common/config/state/runtime.js +1 -0
  4. package/dist/cjs/common/constants/environment-variables.js +1 -1
  5. package/dist/cjs/common/context/shared-context.js +2 -1
  6. package/dist/cjs/common/drain/drain.js +9 -3
  7. package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
  8. package/dist/cjs/common/harvest/harvest-scheduler.js +2 -1
  9. package/dist/cjs/common/harvest/harvest.js +13 -2
  10. package/dist/cjs/common/util/console.js +1 -1
  11. package/dist/cjs/common/util/map-own.js +21 -14
  12. package/dist/cjs/common/util/map-own.test.js +49 -0
  13. package/dist/cjs/common/util/submit-data.js +11 -3
  14. package/dist/cjs/common/window/page-visibility.js +2 -1
  15. package/dist/cjs/common/window/session-storage.js +56 -11
  16. package/dist/cjs/common/wrap/index.js +11 -4
  17. package/dist/cjs/common/wrap/wrap-console.js +54 -0
  18. package/dist/cjs/common/wrap/wrap-events.js +4 -1
  19. package/dist/cjs/common/wrap/wrap-fetch.js +0 -2
  20. package/dist/cjs/common/wrap/wrap-function.js +4 -18
  21. package/dist/cjs/common/wrap/wrap-promise.js +4 -1
  22. package/dist/cjs/features/ajax/instrument/index.js +2 -1
  23. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +5 -4
  24. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -2
  25. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +5 -4
  26. package/dist/cjs/features/jserrors/aggregate/index.js +32 -11
  27. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +5 -4
  28. package/dist/cjs/features/jserrors/instrument/index.js +7 -10
  29. package/dist/cjs/features/metrics/aggregate/index.js +11 -0
  30. package/dist/cjs/features/metrics/instrument/index.js +27 -1
  31. package/dist/cjs/features/metrics/instrument/workers-helper.js +4 -1
  32. package/dist/cjs/features/page_action/aggregate/index.js +11 -3
  33. package/dist/cjs/features/page_action/instrument/index.js +2 -1
  34. package/dist/cjs/features/page_view_event/aggregate/index.js +8 -4
  35. package/dist/cjs/features/page_view_event/instrument/index.js +2 -1
  36. package/dist/cjs/features/page_view_timing/aggregate/index.js +54 -35
  37. package/dist/cjs/features/page_view_timing/instrument/index.js +2 -1
  38. package/dist/cjs/features/session_trace/aggregate/index.js +53 -13
  39. package/dist/cjs/features/session_trace/instrument/index.js +2 -1
  40. package/dist/cjs/features/spa/instrument/index.js +2 -1
  41. package/dist/cjs/features/utils/instrument-base.js +2 -1
  42. package/dist/cjs/index.js +9 -9
  43. package/dist/cjs/loaders/agent.js +2 -1
  44. package/dist/cjs/loaders/api/api.js +86 -21
  45. package/dist/cjs/loaders/api/apiAsync.js +3 -3
  46. package/dist/cjs/loaders/configure/configure.js +13 -7
  47. package/dist/cjs/loaders/micro-agent.js +18 -13
  48. package/dist/esm/common/config/state/configurable.js +2 -1
  49. package/dist/esm/common/config/state/runtime.js +1 -0
  50. package/dist/esm/common/constants/environment-variables.js +1 -1
  51. package/dist/esm/common/context/shared-context.js +2 -1
  52. package/dist/esm/common/drain/drain.js +9 -3
  53. package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
  54. package/dist/esm/common/harvest/harvest-scheduler.js +2 -1
  55. package/dist/esm/common/harvest/harvest.js +13 -2
  56. package/dist/esm/common/util/console.js +1 -1
  57. package/dist/esm/common/util/map-own.js +19 -13
  58. package/dist/esm/common/util/map-own.test.js +47 -0
  59. package/dist/esm/common/util/submit-data.js +11 -3
  60. package/dist/esm/common/window/page-visibility.js +2 -1
  61. package/dist/esm/common/window/session-storage.js +54 -13
  62. package/dist/esm/common/wrap/index.js +5 -4
  63. package/dist/esm/common/wrap/wrap-console.js +46 -0
  64. package/dist/esm/common/wrap/wrap-events.js +5 -2
  65. package/dist/esm/common/wrap/wrap-fetch.js +1 -3
  66. package/dist/esm/common/wrap/wrap-function.js +4 -17
  67. package/dist/esm/common/wrap/wrap-history.js +1 -1
  68. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  69. package/dist/esm/common/wrap/wrap-promise.js +4 -1
  70. package/dist/esm/common/wrap/wrap-raf.js +1 -1
  71. package/dist/esm/common/wrap/wrap-timer.js +1 -1
  72. package/dist/esm/common/wrap/wrap-xhr.js +2 -2
  73. package/dist/esm/features/ajax/instrument/index.js +2 -1
  74. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +5 -4
  75. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -2
  76. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +5 -4
  77. package/dist/esm/features/jserrors/aggregate/index.js +32 -11
  78. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +5 -4
  79. package/dist/esm/features/jserrors/instrument/index.js +7 -10
  80. package/dist/esm/features/metrics/aggregate/index.js +11 -0
  81. package/dist/esm/features/metrics/instrument/index.js +27 -1
  82. package/dist/esm/features/metrics/instrument/workers-helper.js +4 -1
  83. package/dist/esm/features/page_action/aggregate/index.js +11 -3
  84. package/dist/esm/features/page_action/instrument/index.js +2 -1
  85. package/dist/esm/features/page_view_event/aggregate/index.js +8 -4
  86. package/dist/esm/features/page_view_event/instrument/index.js +2 -1
  87. package/dist/esm/features/page_view_timing/aggregate/index.js +54 -35
  88. package/dist/esm/features/page_view_timing/instrument/index.js +2 -1
  89. package/dist/esm/features/session_trace/aggregate/index.js +53 -13
  90. package/dist/esm/features/session_trace/instrument/index.js +2 -1
  91. package/dist/esm/features/spa/instrument/index.js +2 -1
  92. package/dist/esm/features/utils/instrument-base.js +2 -1
  93. package/dist/esm/index.js +4 -4
  94. package/dist/esm/loaders/agent.js +2 -1
  95. package/dist/esm/loaders/api/api.js +85 -21
  96. package/dist/esm/loaders/api/apiAsync.js +3 -3
  97. package/dist/esm/loaders/configure/configure.js +14 -8
  98. package/dist/esm/loaders/micro-agent.js +18 -13
  99. package/dist/types/cdn/lite.d.ts +2 -0
  100. package/dist/types/cdn/lite.d.ts.map +1 -0
  101. package/dist/types/cdn/polyfills/lite.d.ts +2 -0
  102. package/dist/types/cdn/polyfills/lite.d.ts.map +1 -0
  103. package/dist/types/cdn/polyfills/pro.d.ts +2 -0
  104. package/dist/types/cdn/polyfills/pro.d.ts.map +1 -0
  105. package/dist/types/cdn/polyfills/spa.d.ts +2 -0
  106. package/dist/types/cdn/polyfills/spa.d.ts.map +1 -0
  107. package/dist/types/cdn/polyfills.d.ts +2 -0
  108. package/dist/types/cdn/polyfills.d.ts.map +1 -0
  109. package/dist/types/cdn/pro.d.ts +2 -0
  110. package/dist/types/cdn/pro.d.ts.map +1 -0
  111. package/dist/types/cdn/spa.d.ts +2 -0
  112. package/dist/types/cdn/spa.d.ts.map +1 -0
  113. package/dist/types/cdn/worker.d.ts +2 -0
  114. package/dist/types/cdn/worker.d.ts.map +1 -0
  115. package/dist/types/common/aggregate/aggregator.d.ts +11 -0
  116. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -0
  117. package/dist/types/common/browser-version/firefox-version.d.ts +2 -0
  118. package/dist/types/common/browser-version/firefox-version.d.ts.map +1 -0
  119. package/dist/types/common/browser-version/ios-version.d.ts +3 -0
  120. package/dist/types/common/browser-version/ios-version.d.ts.map +1 -0
  121. package/dist/types/common/config/config.d.ts +13 -0
  122. package/dist/types/common/config/config.d.ts.map +1 -0
  123. package/dist/types/common/config/state/configurable.d.ts +4 -0
  124. package/dist/types/common/config/state/configurable.d.ts.map +1 -0
  125. package/dist/types/common/config/state/info.d.ts +4 -0
  126. package/dist/types/common/config/state/info.d.ts.map +1 -0
  127. package/dist/types/common/config/state/init.d.ts +4 -0
  128. package/dist/types/common/config/state/init.d.ts.map +1 -0
  129. package/dist/types/common/config/state/loader-config.d.ts +3 -0
  130. package/dist/types/common/config/state/loader-config.d.ts.map +1 -0
  131. package/dist/types/common/config/state/originals.d.ts +2 -0
  132. package/dist/types/common/config/state/originals.d.ts.map +1 -0
  133. package/dist/types/common/config/state/runtime.d.ts +3 -0
  134. package/dist/types/common/config/state/runtime.d.ts.map +1 -0
  135. package/dist/types/common/constants/environment-variables.d.ts +4 -0
  136. package/dist/types/common/constants/environment-variables.d.ts.map +1 -0
  137. package/dist/types/common/context/shared-context.d.ts +5 -0
  138. package/dist/types/common/context/shared-context.d.ts.map +1 -0
  139. package/dist/types/common/deny-list/deny-list.d.ts +12 -0
  140. package/dist/types/common/deny-list/deny-list.d.ts.map +1 -0
  141. package/dist/types/common/drain/drain.d.ts +17 -0
  142. package/dist/types/common/drain/drain.d.ts.map +1 -0
  143. package/dist/types/common/event-emitter/contextual-ee.d.ts +4 -0
  144. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -0
  145. package/dist/types/common/event-emitter/handle.d.ts +3 -0
  146. package/dist/types/common/event-emitter/handle.d.ts.map +1 -0
  147. package/dist/types/common/event-emitter/register-handler.d.ts +8 -0
  148. package/dist/types/common/event-emitter/register-handler.d.ts.map +1 -0
  149. package/dist/types/common/event-listener/event-listener-opts.d.ts +10 -0
  150. package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -0
  151. package/dist/types/common/harvest/harvest-scheduler.d.ts +21 -0
  152. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -0
  153. package/dist/types/common/harvest/harvest.d.ts +58 -0
  154. package/dist/types/common/harvest/harvest.d.ts.map +1 -0
  155. package/dist/types/common/ids/id.d.ts +2 -0
  156. package/dist/types/common/ids/id.d.ts.map +1 -0
  157. package/dist/types/common/ids/unique-id.d.ts +5 -0
  158. package/dist/types/common/ids/unique-id.d.ts.map +1 -0
  159. package/dist/types/common/metrics/framework-detection.d.ts +2 -0
  160. package/dist/types/common/metrics/framework-detection.d.ts.map +1 -0
  161. package/dist/types/common/metrics/paint-metrics.d.ts +2 -0
  162. package/dist/types/common/metrics/paint-metrics.d.ts.map +1 -0
  163. package/dist/types/common/serialize/bel-serializer.d.ts +5 -0
  164. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -0
  165. package/dist/types/common/timing/nav-timing.d.ts +5 -0
  166. package/dist/types/common/timing/nav-timing.d.ts.map +1 -0
  167. package/dist/types/common/timing/now.d.ts +2 -0
  168. package/dist/types/common/timing/now.d.ts.map +1 -0
  169. package/dist/types/common/unload/eol.d.ts +8 -0
  170. package/dist/types/common/unload/eol.d.ts.map +1 -0
  171. package/dist/types/common/url/clean-url.d.ts +2 -0
  172. package/dist/types/common/url/clean-url.d.ts.map +1 -0
  173. package/dist/types/common/url/encode.d.ts +5 -0
  174. package/dist/types/common/url/encode.d.ts.map +1 -0
  175. package/dist/types/common/url/location.d.ts +2 -0
  176. package/dist/types/common/url/location.d.ts.map +1 -0
  177. package/dist/types/common/url/parse-url.d.ts +2 -0
  178. package/dist/types/common/url/parse-url.d.ts.map +1 -0
  179. package/dist/types/common/url/protocol.d.ts +7 -0
  180. package/dist/types/common/url/protocol.d.ts.map +1 -0
  181. package/dist/types/common/util/console.d.ts +8 -0
  182. package/dist/types/common/util/console.d.ts.map +1 -0
  183. package/dist/types/common/util/data-size.d.ts +2 -0
  184. package/dist/types/common/util/data-size.d.ts.map +1 -0
  185. package/dist/types/common/util/feature-flags.d.ts +3 -0
  186. package/dist/types/common/util/feature-flags.d.ts.map +1 -0
  187. package/dist/types/common/util/get-or-set.d.ts +2 -0
  188. package/dist/types/common/util/get-or-set.d.ts.map +1 -0
  189. package/dist/types/common/util/global-scope.d.ts +13 -0
  190. package/dist/types/common/util/global-scope.d.ts.map +1 -0
  191. package/dist/types/common/util/map-own.d.ts +3 -0
  192. package/dist/types/common/util/map-own.d.ts.map +1 -0
  193. package/dist/types/common/util/obfuscate.d.ts +8 -0
  194. package/dist/types/common/util/obfuscate.d.ts.map +1 -0
  195. package/dist/types/common/util/s-hash.d.ts +2 -0
  196. package/dist/types/common/util/s-hash.d.ts.map +1 -0
  197. package/dist/types/common/util/single.d.ts +2 -0
  198. package/dist/types/common/util/single.d.ts.map +1 -0
  199. package/dist/types/common/util/stringify.d.ts +8 -0
  200. package/dist/types/common/util/stringify.d.ts.map +1 -0
  201. package/dist/types/common/util/submit-data.d.ts +35 -0
  202. package/dist/types/common/util/submit-data.d.ts.map +1 -0
  203. package/dist/types/common/util/traverse.d.ts +2 -0
  204. package/dist/types/common/util/traverse.d.ts.map +1 -0
  205. package/dist/types/common/util/user-agent.d.ts +5 -0
  206. package/dist/types/common/util/user-agent.d.ts.map +1 -0
  207. package/dist/types/common/window/load.d.ts +3 -0
  208. package/dist/types/common/window/load.d.ts.map +1 -0
  209. package/dist/types/common/window/nreum.d.ts +14 -0
  210. package/dist/types/common/window/nreum.d.ts.map +1 -0
  211. package/dist/types/common/window/page-visibility.d.ts +7 -0
  212. package/dist/types/common/window/page-visibility.d.ts.map +1 -0
  213. package/dist/types/common/window/session-storage.d.ts +18 -0
  214. package/dist/types/common/window/session-storage.d.ts.map +1 -0
  215. package/dist/types/common/window/supports-performance-observer.d.ts +2 -0
  216. package/dist/types/common/window/supports-performance-observer.d.ts.map +1 -0
  217. package/dist/types/common/wrap/index.d.ts +12 -0
  218. package/dist/types/common/wrap/index.d.ts.map +1 -0
  219. package/dist/types/common/wrap/wrap-console.d.ts +16 -0
  220. package/dist/types/common/wrap/wrap-console.d.ts.map +1 -0
  221. package/dist/types/common/wrap/wrap-events.d.ts +17 -0
  222. package/dist/types/common/wrap/wrap-events.d.ts.map +1 -0
  223. package/dist/types/common/wrap/wrap-fetch.d.ts +18 -0
  224. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -0
  225. package/dist/types/common/wrap/wrap-function.d.ts +28 -0
  226. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -0
  227. package/dist/types/common/wrap/wrap-history.d.ts +16 -0
  228. package/dist/types/common/wrap/wrap-history.d.ts.map +1 -0
  229. package/dist/types/common/wrap/wrap-jsonp.d.ts +16 -0
  230. package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -0
  231. package/dist/types/common/wrap/wrap-mutation.d.ts +16 -0
  232. package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -0
  233. package/dist/types/common/wrap/wrap-promise.d.ts +17 -0
  234. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -0
  235. package/dist/types/common/wrap/wrap-raf.d.ts +16 -0
  236. package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -0
  237. package/dist/types/common/wrap/wrap-timer.d.ts +17 -0
  238. package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -0
  239. package/dist/types/common/wrap/wrap-xhr.d.ts +16 -0
  240. package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -0
  241. package/dist/types/features/ajax/aggregate/index.d.ts +16 -0
  242. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -0
  243. package/dist/types/features/ajax/constants.d.ts +2 -0
  244. package/dist/types/features/ajax/constants.d.ts.map +1 -0
  245. package/dist/types/features/ajax/index.d.ts +2 -0
  246. package/dist/types/features/ajax/index.d.ts.map +1 -0
  247. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +19 -0
  248. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -0
  249. package/dist/types/features/ajax/instrument/index.d.ts +9 -0
  250. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -0
  251. package/dist/types/features/ajax/instrument/response-size.d.ts +2 -0
  252. package/dist/types/features/ajax/instrument/response-size.d.ts.map +1 -0
  253. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts +2 -0
  254. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -0
  255. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts +22 -0
  256. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -0
  257. package/dist/types/features/jserrors/aggregate/format-stack-trace.d.ts +3 -0
  258. package/dist/types/features/jserrors/aggregate/format-stack-trace.d.ts.map +1 -0
  259. package/dist/types/features/jserrors/aggregate/index.d.ts +24 -0
  260. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -0
  261. package/dist/types/features/jserrors/aggregate/string-hash-code.d.ts +2 -0
  262. package/dist/types/features/jserrors/aggregate/string-hash-code.d.ts.map +1 -0
  263. package/dist/types/features/jserrors/constants.d.ts +3 -0
  264. package/dist/types/features/jserrors/constants.d.ts.map +1 -0
  265. package/dist/types/features/jserrors/index.d.ts +2 -0
  266. package/dist/types/features/jserrors/index.d.ts.map +1 -0
  267. package/dist/types/features/jserrors/instrument/debug.d.ts +2 -0
  268. package/dist/types/features/jserrors/instrument/debug.d.ts.map +1 -0
  269. package/dist/types/features/jserrors/instrument/index.d.ts +22 -0
  270. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -0
  271. package/dist/types/features/metrics/aggregate/index.d.ts +12 -0
  272. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -0
  273. package/dist/types/features/metrics/constants.d.ts +6 -0
  274. package/dist/types/features/metrics/constants.d.ts.map +1 -0
  275. package/dist/types/features/metrics/index.d.ts +2 -0
  276. package/dist/types/features/metrics/index.d.ts.map +1 -0
  277. package/dist/types/features/metrics/instrument/index.d.ts +7 -0
  278. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -0
  279. package/dist/types/features/metrics/instrument/workers-helper.d.ts +7 -0
  280. package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -0
  281. package/dist/types/features/page_action/aggregate/index.d.ts +24 -0
  282. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -0
  283. package/dist/types/features/page_action/constants.d.ts +2 -0
  284. package/dist/types/features/page_action/constants.d.ts.map +1 -0
  285. package/dist/types/features/page_action/index.d.ts +2 -0
  286. package/dist/types/features/page_action/index.d.ts.map +1 -0
  287. package/dist/types/features/page_action/instrument/index.d.ts +6 -0
  288. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -0
  289. package/dist/types/features/page_view_event/aggregate/index.d.ts +9 -0
  290. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -0
  291. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts +8 -0
  292. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -0
  293. package/dist/types/features/page_view_event/constants.d.ts +5 -0
  294. package/dist/types/features/page_view_event/constants.d.ts.map +1 -0
  295. package/dist/types/features/page_view_event/index.d.ts +2 -0
  296. package/dist/types/features/page_view_event/index.d.ts.map +1 -0
  297. package/dist/types/features/page_view_event/instrument/index.d.ts +6 -0
  298. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -0
  299. package/dist/types/features/page_view_timing/aggregate/index.d.ts +33 -0
  300. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -0
  301. package/dist/types/features/page_view_timing/constants.d.ts +2 -0
  302. package/dist/types/features/page_view_timing/constants.d.ts.map +1 -0
  303. package/dist/types/features/page_view_timing/first-paint.d.ts +2 -0
  304. package/dist/types/features/page_view_timing/first-paint.d.ts.map +1 -0
  305. package/dist/types/features/page_view_timing/index.d.ts +2 -0
  306. package/dist/types/features/page_view_timing/index.d.ts.map +1 -0
  307. package/dist/types/features/page_view_timing/instrument/index.d.ts +6 -0
  308. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -0
  309. package/dist/types/features/page_view_timing/long-tasks.d.ts +2 -0
  310. package/dist/types/features/page_view_timing/long-tasks.d.ts.map +1 -0
  311. package/dist/types/features/session_trace/aggregate/index.d.ts +77 -0
  312. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -0
  313. package/dist/types/features/session_trace/constants.d.ts +13 -0
  314. package/dist/types/features/session_trace/constants.d.ts.map +1 -0
  315. package/dist/types/features/session_trace/index.d.ts +2 -0
  316. package/dist/types/features/session_trace/index.d.ts.map +1 -0
  317. package/dist/types/features/session_trace/instrument/index.d.ts +11 -0
  318. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -0
  319. package/dist/types/features/spa/aggregate/index.d.ts +25 -0
  320. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -0
  321. package/dist/types/features/spa/aggregate/interaction-node.d.ts +15 -0
  322. package/dist/types/features/spa/aggregate/interaction-node.d.ts.map +1 -0
  323. package/dist/types/features/spa/aggregate/interaction.d.ts +20 -0
  324. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -0
  325. package/dist/types/features/spa/aggregate/serializer.d.ts +15 -0
  326. package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -0
  327. package/dist/types/features/spa/constants.d.ts +23 -0
  328. package/dist/types/features/spa/constants.d.ts.map +1 -0
  329. package/dist/types/features/spa/index.d.ts +2 -0
  330. package/dist/types/features/spa/index.d.ts.map +1 -0
  331. package/dist/types/features/spa/instrument/index.d.ts +8 -0
  332. package/dist/types/features/spa/instrument/index.d.ts.map +1 -0
  333. package/dist/types/features/utils/aggregate-base.d.ts +4 -0
  334. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
  335. package/dist/types/features/utils/feature-base.d.ts +23 -0
  336. package/dist/types/features/utils/feature-base.d.ts.map +1 -0
  337. package/dist/types/features/utils/handler-cache.d.ts +22 -0
  338. package/dist/types/features/utils/handler-cache.d.ts.map +1 -0
  339. package/dist/types/features/utils/instrument-base.d.ts +27 -0
  340. package/dist/types/features/utils/instrument-base.d.ts.map +1 -0
  341. package/dist/types/features/utils/lazy-loader.d.ts +13 -0
  342. package/dist/types/features/utils/lazy-loader.d.ts.map +1 -0
  343. package/dist/types/index.d.ts +12 -0
  344. package/dist/types/index.d.ts.map +1 -0
  345. package/dist/types/loaders/agent.d.ts +20 -0
  346. package/dist/types/loaders/agent.d.ts.map +1 -0
  347. package/dist/types/loaders/api/api.d.ts +17 -0
  348. package/dist/types/loaders/api/api.d.ts.map +1 -0
  349. package/dist/types/loaders/api/apiAsync.d.ts +2 -0
  350. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -0
  351. package/dist/types/loaders/browser-agent.d.ts +9 -0
  352. package/dist/types/loaders/browser-agent.d.ts.map +1 -0
  353. package/dist/types/loaders/configure/configure.d.ts +10 -0
  354. package/dist/types/loaders/configure/configure.d.ts.map +1 -0
  355. package/dist/types/loaders/features/enabled-features.d.ts +2 -0
  356. package/dist/types/loaders/features/enabled-features.d.ts.map +1 -0
  357. package/dist/types/loaders/features/featureDependencies.d.ts +3 -0
  358. package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -0
  359. package/dist/types/loaders/features/features.d.ts +18 -0
  360. package/dist/types/loaders/features/features.d.ts.map +1 -0
  361. package/dist/types/loaders/micro-agent.d.ts +25 -0
  362. package/dist/types/loaders/micro-agent.d.ts.map +1 -0
  363. package/dist/types/loaders/worker-agent.d.ts +8 -0
  364. package/dist/types/loaders/worker-agent.d.ts.map +1 -0
  365. package/package.json +61 -32
  366. package/src/cdn/lite.js +18 -0
  367. package/src/cdn/polyfills/lite.js +7 -0
  368. package/src/cdn/polyfills/pro.js +7 -0
  369. package/src/cdn/polyfills/spa.js +7 -0
  370. package/src/cdn/polyfills.js +17 -0
  371. package/src/cdn/pro.js +27 -0
  372. package/src/cdn/spa.js +28 -0
  373. package/src/cdn/worker.js +21 -0
  374. package/src/common/aggregate/aggregator.js +171 -0
  375. package/src/common/browser-version/firefox-version.js +10 -0
  376. package/src/common/browser-version/ios-version.js +10 -0
  377. package/src/common/config/config.js +12 -0
  378. package/src/common/config/state/configurable.js +26 -0
  379. package/src/common/config/state/info.js +49 -0
  380. package/src/common/config/state/init.js +56 -0
  381. package/src/common/config/state/loader-config.js +25 -0
  382. package/src/common/config/state/originals.js +3 -0
  383. package/src/common/config/state/runtime.js +45 -0
  384. package/src/common/constants/environment-variables.js +11 -0
  385. package/src/common/context/shared-context.js +21 -0
  386. package/src/common/deny-list/deny-list.js +116 -0
  387. package/src/common/drain/drain.js +119 -0
  388. package/src/common/event-emitter/contextual-ee.js +159 -0
  389. package/src/common/event-emitter/handle.js +17 -0
  390. package/src/common/event-emitter/register-handler.js +25 -0
  391. package/src/common/event-listener/event-listener-opts.js +41 -0
  392. package/src/common/harvest/harvest-scheduler.js +112 -0
  393. package/src/common/harvest/harvest.js +248 -0
  394. package/src/common/ids/id.js +23 -0
  395. package/src/common/ids/unique-id.js +81 -0
  396. package/src/common/metrics/framework-detection.js +71 -0
  397. package/src/common/metrics/paint-metrics.js +6 -0
  398. package/src/common/serialize/bel-serializer.js +93 -0
  399. package/src/common/timing/nav-timing.js +70 -0
  400. package/src/common/timing/now.js +9 -0
  401. package/src/common/unload/eol.js +63 -0
  402. package/src/common/url/clean-url.js +10 -0
  403. package/src/common/url/encode.js +75 -0
  404. package/src/common/url/location.js +8 -0
  405. package/src/common/url/parse-url.js +71 -0
  406. package/src/common/url/protocol.js +19 -0
  407. package/src/common/util/console.js +11 -0
  408. package/src/common/util/data-size.js +21 -0
  409. package/src/common/util/feature-flags.js +38 -0
  410. package/src/common/util/get-or-set.js +34 -0
  411. package/src/common/util/global-scope.js +48 -0
  412. package/src/common/util/map-own.js +22 -0
  413. package/src/common/util/map-own.test.js +52 -0
  414. package/src/common/util/obfuscate.js +73 -0
  415. package/src/common/util/s-hash.js +14 -0
  416. package/src/common/util/single.js +18 -0
  417. package/src/common/util/stringify.js +42 -0
  418. package/src/common/util/submit-data.js +101 -0
  419. package/src/common/util/traverse.js +36 -0
  420. package/src/common/util/user-agent.js +56 -0
  421. package/src/common/window/load.js +15 -0
  422. package/src/common/window/nreum.js +110 -0
  423. package/src/common/window/page-visibility.js +24 -0
  424. package/src/common/window/session-storage.js +75 -0
  425. package/src/common/window/supports-performance-observer.js +10 -0
  426. package/src/common/wrap/index.js +18 -0
  427. package/src/common/wrap/wrap-console.js +47 -0
  428. package/src/common/wrap/wrap-events.js +106 -0
  429. package/src/common/wrap/wrap-fetch.js +109 -0
  430. package/src/common/wrap/wrap-function.js +248 -0
  431. package/src/common/wrap/wrap-history.js +48 -0
  432. package/src/common/wrap/wrap-jsonp.js +134 -0
  433. package/src/common/wrap/wrap-mutation.js +55 -0
  434. package/src/common/wrap/wrap-promise.js +165 -0
  435. package/src/common/wrap/wrap-raf.js +50 -0
  436. package/src/common/wrap/wrap-timer.js +67 -0
  437. package/src/common/wrap/wrap-xhr.js +213 -0
  438. package/src/features/ajax/aggregate/index.js +248 -0
  439. package/src/features/ajax/constants.js +3 -0
  440. package/src/features/ajax/index.js +1 -0
  441. package/src/features/ajax/instrument/distributed-tracing.js +166 -0
  442. package/src/features/ajax/instrument/index.js +380 -0
  443. package/src/features/ajax/instrument/response-size.js +18 -0
  444. package/src/features/jserrors/aggregate/canonical-function-name.js +14 -0
  445. package/src/features/jserrors/aggregate/canonical-function-name.test.js +13 -0
  446. package/src/features/jserrors/aggregate/compute-stack-trace.js +231 -0
  447. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +297 -0
  448. package/src/features/jserrors/aggregate/format-stack-trace.js +30 -0
  449. package/src/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
  450. package/src/features/jserrors/aggregate/index.js +310 -0
  451. package/src/features/jserrors/aggregate/string-hash-code.js +17 -0
  452. package/src/features/jserrors/aggregate/string-hash-code.test.js +12 -0
  453. package/src/features/jserrors/constants.js +4 -0
  454. package/src/features/jserrors/index.js +1 -0
  455. package/src/features/jserrors/instrument/debug.js +36 -0
  456. package/src/features/jserrors/instrument/index.js +149 -0
  457. package/src/features/metrics/aggregate/index.js +134 -0
  458. package/src/features/metrics/constants.js +7 -0
  459. package/src/features/metrics/index.js +1 -0
  460. package/src/features/metrics/instrument/index.js +44 -0
  461. package/src/features/metrics/instrument/workers-helper.js +110 -0
  462. package/src/features/page_action/aggregate/index.js +113 -0
  463. package/src/features/page_action/constants.js +3 -0
  464. package/src/features/page_action/index.js +1 -0
  465. package/src/features/page_action/instrument/index.js +15 -0
  466. package/src/features/page_view_event/aggregate/index.js +134 -0
  467. package/src/features/page_view_event/aggregate/initialized-features.js +31 -0
  468. package/src/features/page_view_event/constants.js +6 -0
  469. package/src/features/page_view_event/index.js +1 -0
  470. package/src/features/page_view_event/instrument/index.js +33 -0
  471. package/src/features/page_view_timing/aggregate/index.js +246 -0
  472. package/src/features/page_view_timing/constants.js +3 -0
  473. package/src/features/page_view_timing/first-paint.js +41 -0
  474. package/src/features/page_view_timing/index.js +1 -0
  475. package/src/features/page_view_timing/instrument/index.js +30 -0
  476. package/src/features/page_view_timing/long-tasks.js +60 -0
  477. package/src/features/session_trace/aggregate/index.js +410 -0
  478. package/src/features/session_trace/constants.js +15 -0
  479. package/src/features/session_trace/index.js +1 -0
  480. package/src/features/session_trace/instrument/index.js +126 -0
  481. package/src/features/spa/aggregate/index.js +738 -0
  482. package/src/features/spa/aggregate/interaction-node.js +85 -0
  483. package/src/features/spa/aggregate/interaction-node.test.js +17 -0
  484. package/src/features/spa/aggregate/interaction.js +112 -0
  485. package/src/features/spa/aggregate/serializer.js +198 -0
  486. package/src/features/spa/constants.js +36 -0
  487. package/src/features/spa/index.js +1 -0
  488. package/src/features/spa/instrument/index.js +112 -0
  489. package/src/features/utils/aggregate-base.js +7 -0
  490. package/src/features/utils/feature-base.js +51 -0
  491. package/src/features/utils/handler-cache.js +60 -0
  492. package/src/features/utils/instrument-base.js +68 -0
  493. package/src/features/utils/lazy-loader.js +37 -0
  494. package/src/index.js +15 -0
  495. package/src/loaders/agent.js +80 -0
  496. package/src/loaders/api/api.js +175 -0
  497. package/src/loaders/api/apiAsync.js +92 -0
  498. package/src/loaders/browser-agent.js +33 -0
  499. package/src/loaders/configure/configure.js +39 -0
  500. package/src/loaders/features/enabled-features.js +16 -0
  501. package/src/loaders/features/featureDependencies.js +26 -0
  502. package/src/loaders/features/features.js +25 -0
  503. package/src/loaders/micro-agent.js +84 -0
  504. package/src/loaders/worker-agent.js +24 -0
  505. package/dist/cjs/common/util/reduce.js +0 -22
  506. package/dist/cjs/common/window/top-level-callers.js +0 -23
  507. package/dist/esm/common/util/reduce.js +0 -16
  508. package/dist/esm/common/window/top-level-callers.js +0 -17
  509. package/types.ts +0 -221
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.computeStackTrace = computeStackTrace;
7
- var _reduce = require("../../../common/util/reduce");
8
7
  var _formatStackTrace = require("./format-stack-trace");
9
8
  /*
10
9
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -120,7 +119,7 @@ function computeStackTraceFromStackProp(ex) {
120
119
  if (!ex.stack) {
121
120
  return null;
122
121
  }
123
- var errorInfo = (0, _reduce.reduce)(ex.stack.split('\n'), parseStackProp, {
122
+ var errorInfo = ex.stack.split('\n').reduce(parseStackProp, {
124
123
  frames: [],
125
124
  stackLines: [],
126
125
  wrapperSeen: false
@@ -15,10 +15,11 @@ describe('formatStackTrace', () => {
15
15
  input: ['line 1', 'line 2', ''],
16
16
  expected: 'line 1\nline 2',
17
17
  title: 'Strips ending empty stack frame'
18
- }])('$title', ({
19
- input,
20
- expected
21
- }) => {
18
+ }])('$title', _ref => {
19
+ let {
20
+ input,
21
+ expected
22
+ } = _ref;
22
23
  const result = (0, _formatStackTrace.formatStackTrace)(input);
23
24
  expect(result).toEqual(expected);
24
25
  });
@@ -21,7 +21,6 @@ var _aggregateBase = require("../../utils/aggregate-base");
21
21
  var _constants = require("../constants");
22
22
  var _drain = require("../../../common/drain/drain");
23
23
  var _features = require("../../../loaders/features/features");
24
- var _load = require("../../../common/window/load");
25
24
  /*
26
25
  * Copyright 2020 New Relic Corporation. All rights reserved.
27
26
  * SPDX-License-Identifier: Apache-2.0
@@ -30,7 +29,9 @@ var _load = require("../../../common/window/load");
30
29
  class Aggregate extends _aggregateBase.AggregateBase {
31
30
  static featureName = _constants.FEATURE_NAME;
32
31
  constructor(agentIdentifier, aggregator) {
32
+ var _this;
33
33
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
34
+ _this = this;
34
35
  this.stackReported = {};
35
36
  this.pageviewReported = {};
36
37
  this.errorCache = {};
@@ -42,13 +43,21 @@ class Aggregate extends _aggregateBase.AggregateBase {
42
43
 
43
44
  // this will need to change to match whatever ee we use in the instrument
44
45
  this.ee.on('interactionDiscarded', interaction => this.onInteractionDiscarded(interaction));
45
- (0, _registerHandler.registerHandler)('err', (...args) => this.storeError(...args), this.featureName, this.ee);
46
- (0, _registerHandler.registerHandler)('ierr', (...args) => this.storeError(...args), this.featureName, this.ee);
46
+ (0, _registerHandler.registerHandler)('err', function () {
47
+ return _this.storeError(...arguments);
48
+ }, this.featureName, this.ee);
49
+ (0, _registerHandler.registerHandler)('ierr', function () {
50
+ return _this.storeError(...arguments);
51
+ }, this.featureName, this.ee);
47
52
  const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
48
53
  const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
49
- onFinished: (...args) => this.onHarvestFinished(...args)
54
+ onFinished: function () {
55
+ return _this.onHarvestFinished(...arguments);
56
+ }
50
57
  }, this);
51
- scheduler.harvest.on('jserrors', (...args) => this.onHarvestStarted(...args));
58
+ scheduler.harvest.on('jserrors', function () {
59
+ return _this.onHarvestStarted(...arguments);
60
+ });
52
61
 
53
62
  // Don't start harvesting until "drain" for this feat has been called (which currently requires RUM response).
54
63
  this.ee.on(`drain-${this.featureName}`, () => {
@@ -147,17 +156,29 @@ class Aggregate extends _aggregateBase.AggregateBase {
147
156
  storeError(err, time, internal, customAttributes) {
148
157
  // are we in an interaction
149
158
  time = time || (0, _now.now)();
150
- if (!internal && (0, _config.getRuntime)(this.agentIdentifier).onerror && (0, _config.getRuntime)(this.agentIdentifier).onerror(err)) return;
159
+ const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
160
+ let filterOutput;
161
+ if (!internal && agentRuntime.onerror) {
162
+ filterOutput = agentRuntime.onerror(err);
163
+ if (filterOutput && !(typeof filterOutput.group === 'string' && filterOutput.group.length)) {
164
+ // All truthy values mean don't report (store) the error, per backwards-compatible usage,
165
+ // - EXCEPT if a fingerprinting label is returned, via an object with key of 'group' and value of non-empty string
166
+ return;
167
+ }
168
+ // Again as with previous usage, all falsey values would include the error.
169
+ }
170
+
151
171
  var stackInfo = this.canonicalizeStackURLs((0, _computeStackTrace.computeStackTrace)(err));
152
172
  var canonicalStack = this.buildCanonicalStackString(stackInfo);
153
- var params = {
173
+ const params = {
154
174
  stackHash: (0, _stringHashCode.stringHashCode)(canonicalStack),
155
175
  exceptionClass: stackInfo.name,
156
176
  request_uri: _globalScope.globalScope?.location.pathname
157
177
  };
158
- if (stackInfo.message) {
159
- params.message = '' + stackInfo.message;
160
- }
178
+ if (stackInfo.message) params.message = '' + stackInfo.message;
179
+ // 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).
180
+ // Do not modify the name ('errorGroup') of params without DEM approval!
181
+ if (filterOutput?.group) params.errorGroup = filterOutput.group;
161
182
 
162
183
  /**
163
184
  * The bucketHash is different from the params.stackHash because the params.stackHash is based on the canonicalized
@@ -172,7 +193,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
172
193
  } else {
173
194
  params.browser_stack_hash = (0, _stringHashCode.stringHashCode)(stackInfo.stackString);
174
195
  }
175
- params.releaseIds = (0, _stringify.stringify)((0, _config.getRuntime)(this.agentIdentifier).releaseIds);
196
+ params.releaseIds = (0, _stringify.stringify)(agentRuntime.releaseIds);
176
197
 
177
198
  // When debugging stack canonicalization/hashing, uncomment these lines for
178
199
  // more output in the test logs
@@ -17,10 +17,11 @@ test.each([{
17
17
  input: 'lksjdflksjdf',
18
18
  expected: 32668720,
19
19
  title: 'Return valid hash of string'
20
- }])('$title', ({
21
- input,
22
- expected
23
- }) => {
20
+ }])('$title', _ref => {
21
+ let {
22
+ input,
23
+ expected
24
+ } = _ref;
24
25
  const result = (0, _stringHashCode.stringHashCode)(input);
25
26
  expect(result).toEqual(expected);
26
27
  });
@@ -25,12 +25,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
25
 
26
26
  class Instrument extends _instrumentBase.InstrumentBase {
27
27
  static featureName = _constants.FEATURE_NAME;
28
- constructor(agentIdentifier, aggregator, auto = true) {
28
+ constructor(agentIdentifier, aggregator) {
29
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
29
30
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
30
31
  // skipNext counter to keep track of uncaught
31
32
  // errors that will be the same as caught errors.
32
33
  this.skipNext = 0;
33
- this.origOnerror = _globalScope.globalScope.onerror;
34
34
  try {
35
35
  this.removeOnAbort = new AbortController();
36
36
  } // this try-catch can be removed when IE11 is completely unsupported & gone
@@ -56,12 +56,9 @@ class Instrument extends _instrumentBase.InstrumentBase {
56
56
  (0, _handle.handle)('ierr', [e, (0, _now.now)(), true], undefined, _features.FEATURE_NAMES.jserrors, thisInstrument.ee);
57
57
  });
58
58
 
59
- // Tack on our error handler onto the existing global one.
60
- _globalScope.globalScope.onerror = (...args) => {
61
- if (this.origOnerror) this.origOnerror(...args);
62
- this.onerrorHandler(...args);
63
- return false;
64
- };
59
+ // Replace global error handler with our own.
60
+ this.origOnerror = _globalScope.globalScope.onerror;
61
+ _globalScope.globalScope.onerror = this.onerrorHandler.bind(this);
65
62
  _globalScope.globalScope.addEventListener('unhandledrejection', e => {
66
63
  /** rejections can contain data of any type -- this is an effort to keep the message human readable */
67
64
  const err = castReasonToError(e.reason);
@@ -94,6 +91,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
94
91
  * @returns
95
92
  */
96
93
  onerrorHandler(message, filename, lineno, column, errorObj) {
94
+ if (typeof this.origOnerror === 'function') this.origOnerror(...arguments);
97
95
  try {
98
96
  if (this.skipNext) this.skipNext -= 1;else notice(errorObj || new UncaughtException(message, filename, lineno), true, this.ee);
99
97
  } catch (e) {
@@ -103,8 +101,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
103
101
  // do nothing
104
102
  }
105
103
  }
106
- if (typeof this.origOnerror === 'function') return this.origOnerror.apply(this, (0, _lodash.default)(arguments));
107
- return false;
104
+ return false; // maintain default behavior of the error event of Window
108
105
  }
109
106
  }
110
107
 
@@ -109,6 +109,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
109
109
  // TODO - these SMs are to be removed when we implement the actual resources feature
110
110
  try {
111
111
  if (this.resourcesSent) return;
112
+ const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
112
113
  // make sure this only gets sent once
113
114
  this.resourcesSent = true;
114
115
  // differentiate between internal+external and ajax+non-ajax
@@ -128,6 +129,16 @@ class Aggregate extends _aggregateBase.AggregateBase {
128
129
  if (isAjax(entry)) this.storeSupportabilityMetrics('Generic/Resources/Ajax/External');else this.storeSupportabilityMetrics('Generic/Resources/Non-Ajax/External');
129
130
  }
130
131
  });
132
+
133
+ // Capture per-agent bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
134
+ Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
135
+ this.storeSupportabilityMetrics(`PageSession/Endpoint/${endpoint.charAt(0).toUpperCase() + endpoint.slice(1)}/BytesSent`, agentRuntime.bytesSent[endpoint]);
136
+ });
137
+
138
+ // Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
139
+ if (agentRuntime.ptid) {
140
+ this.storeSupportabilityMetrics('PageSession/Feature/SessionTrace/DurationMs', Math.round(performance.now()));
141
+ }
131
142
  } catch (e) {
132
143
  // do nothing
133
144
  }
@@ -9,12 +9,38 @@ var _workersHelper = require("./workers-helper");
9
9
  var _constants = require("../constants");
10
10
  var _handle = require("../../../common/event-emitter/handle");
11
11
  var _features = require("../../../loaders/features/features");
12
+ var _wrap = require("../../../common/wrap");
13
+ var _stringify = require("../../../common/util/stringify");
12
14
  class Instrument extends _instrumentBase.InstrumentBase {
13
15
  static featureName = _constants.FEATURE_NAME;
14
- constructor(agentIdentifier, aggregator, auto = true) {
16
+ constructor(agentIdentifier, aggregator) {
17
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
15
18
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
16
19
  (0, _workersHelper.insertSupportMetrics)(tag => (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, [tag], undefined, _features.FEATURE_NAMES.metrics, this.ee));
20
+ this.addConsoleSupportabilityMetrics();
17
21
  this.importAggregator();
18
22
  }
23
+ addConsoleSupportabilityMetrics() {
24
+ // For now we are just capturing supportability metrics on `console` usage to assess log forwarding feature.
25
+ const consoleEE = (0, _wrap.wrapConsole)(this.ee);
26
+ for (const method of ['Debug', 'Error', 'Info', 'Log', 'Trace', 'Warn']) {
27
+ consoleEE.on(`${method.toLowerCase()}-console-start`, function (args, target) {
28
+ // Parsing the args individually into a new array ensures that functions and Error objects are represented with
29
+ // useful string values. By default, functions stringify to null and Error objects stringify to empty objects.
30
+ // Note that stack traces printed by the console.trace method are not captured.
31
+ let parsedArgs = [];
32
+ for (const arg of args) {
33
+ if (typeof arg === 'function' || arg && arg.message && arg.stack // Duck typing for Error objects
34
+ ) {
35
+ parsedArgs.push(arg.toString());
36
+ } else {
37
+ parsedArgs.push(arg);
38
+ }
39
+ }
40
+ const parsedArgsJSON = (0, _stringify.stringify)(parsedArgs);
41
+ (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, [`Console/${method}/Seen`, parsedArgsJSON.length], undefined, _features.FEATURE_NAMES.metrics, consoleEE);
42
+ });
43
+ }
44
+ }
19
45
  }
20
46
  exports.Instrument = Instrument;
@@ -94,7 +94,10 @@ function insertSupportMetrics(report) {
94
94
  * @returns Refer to ServiceWorkerContainer.register()
95
95
  */
96
96
  function extendServiceCreation(origFunc) {
97
- return (...args) => {
97
+ return function () {
98
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
99
+ args[_key] = arguments[_key];
100
+ }
98
101
  reportWorkerCreationAttempt('Service', args[1]?.type);
99
102
  return origFunc.apply(navigator.serviceWorker, args); // register() has to be rebound to the ServiceWorkerContainer object
100
103
  };
@@ -22,7 +22,9 @@ var _globalScope = require("../../../common/util/global-scope");
22
22
  class Aggregate extends _aggregateBase.AggregateBase {
23
23
  static featureName = _constants.FEATURE_NAME;
24
24
  constructor(agentIdentifier, aggregator) {
25
+ var _this;
25
26
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
27
+ _this = this;
26
28
  this.eventsPerMinute = 240;
27
29
  this.harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_action.harvestTimeSeconds') || (0, _config.getConfigurationValue)(this.agentIdentifier, 'ins.harvestTimeSeconds') || 30;
28
30
  this.eventsPerHarvest = this.eventsPerMinute * this.harvestTimeSeconds / 60;
@@ -32,11 +34,17 @@ class Aggregate extends _aggregateBase.AggregateBase {
32
34
  this.att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes; // per-agent, aggregators-shared info context
33
35
 
34
36
  if (_globalScope.isBrowserScope && document.referrer) this.referrerUrl = (0, _cleanUrl.cleanURL)(document.referrer);
35
- (0, _registerHandler.registerHandler)('api-addPageAction', (...args) => this.addPageAction(...args), this.featureName, this.ee);
37
+ (0, _registerHandler.registerHandler)('api-addPageAction', function () {
38
+ return _this.addPageAction(...arguments);
39
+ }, this.featureName, this.ee);
36
40
  var scheduler = new _harvestScheduler.HarvestScheduler('ins', {
37
- onFinished: (...args) => this.onHarvestFinished(...args)
41
+ onFinished: function () {
42
+ return _this.onHarvestFinished(...arguments);
43
+ }
38
44
  }, this);
39
- scheduler.harvest.on('ins', (...args) => this.onHarvestStarted(...args));
45
+ scheduler.harvest.on('ins', function () {
46
+ return _this.onHarvestStarted(...arguments);
47
+ });
40
48
  this.ee.on(`drain-${this.featureName}`, () => {
41
49
  if (!this.blocked) scheduler.startTimer(this.harvestTimeSeconds, 0);
42
50
  });
@@ -13,7 +13,8 @@ var _constants = require("../constants");
13
13
 
14
14
  class Instrument extends _instrumentBase.InstrumentBase {
15
15
  static featureName = _constants.FEATURE_NAME;
16
- constructor(agentIdentifier, aggregator, auto = true) {
16
+ constructor(agentIdentifier, aggregator) {
17
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
17
18
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
18
19
  this.importAggregator();
19
20
  }
@@ -34,10 +34,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
34
34
 
35
35
  /* Time To First Byte
36
36
  This listener must record these values *before* PVE's aggregate sends RUM. */
37
- (0, _webVitals.onTTFB)(({
38
- value,
39
- entries
40
- }) => {
37
+ (0, _webVitals.onTTFB)(_ref => {
38
+ let {
39
+ value,
40
+ entries
41
+ } = _ref;
41
42
  if (this.alreadySent) return;
42
43
  this.alreadySent = true;
43
44
  agentRuntime[CONSTANTS.TTFB] = Math.round(value); // this is our "backend" duration; web-vitals will ensure it's lower bounded at 0
@@ -124,6 +125,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
124
125
  var customJsAttributes = (0, _stringify.stringify)(info.jsAttributes);
125
126
  chunksForQueryString.push((0, _encode.param)('ja', customJsAttributes === '{}' ? null : customJsAttributes));
126
127
  var queryString = (0, _encode.fromArray)(chunksForQueryString, agentRuntime.maxBytes);
128
+
129
+ // Capture bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
130
+ agentRuntime.bytesSent[protocol] = (agentRuntime.bytesSent[protocol] || 0) + queryString?.length || 0;
127
131
  const isValidJsonp = _submitData.submitData.jsonp(this.getScheme() + '://' + info.beacon + '/' + protocol + '/' + info.licenseKey + queryString, jsonp);
128
132
  // Usually `drain` is invoked automatically after processing feature flags contained in the JSONP callback from
129
133
  // ingest (see `activateFeatures`), so when JSONP cannot execute (as with module workers), we drain manually.
@@ -16,7 +16,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  class Instrument extends _instrumentBase.InstrumentBase {
18
18
  static featureName = CONSTANTS.FEATURE_NAME;
19
- constructor(agentIdentifier, aggregator, auto = true) {
19
+ constructor(agentIdentifier, aggregator) {
20
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
20
21
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
21
22
  if ((typeof PerformanceNavigationTiming === 'undefined' || _iosVersion.isiOS) && typeof PerformanceTiming !== 'undefined') {
22
23
  // For majority browser versions in which PNT exists, we can get load timings later from the nav entry (in the aggregate portion). At minimum, PT should exist for main window.
@@ -27,7 +27,9 @@ var _features = require("../../../loaders/features/features");
27
27
  class Aggregate extends _aggregateBase.AggregateBase {
28
28
  static featureName = _constants.FEATURE_NAME;
29
29
  constructor(agentIdentifier, aggregator) {
30
+ var _this;
30
31
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
32
+ _this = this;
31
33
  this.timings = [];
32
34
  this.timingsSent = [];
33
35
  this.curSessEndRecorded = false;
@@ -43,10 +45,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
43
45
  this.alreadySent = new Set(); // since we don't support timings on BFCache restores, this tracks and helps cap metrics that web-vitals report more than once
44
46
 
45
47
  /* PerformancePaintTiming API - BFC is not yet supported. */
46
- (0, _firstPaint.onFirstPaint)(({
47
- name,
48
- value
49
- }) => {
48
+ (0, _firstPaint.onFirstPaint)(_ref => {
49
+ let {
50
+ name,
51
+ value
52
+ } = _ref;
50
53
  if (pageStartedHidden) return;
51
54
  this.addTiming(name.toLowerCase(), Math.floor(value));
52
55
  });
@@ -65,10 +68,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
65
68
  }
66
69
  } catch (e) {}
67
70
  } else {
68
- (0, _webVitals.onFCP)(({
69
- name,
70
- value
71
- }) => {
71
+ (0, _webVitals.onFCP)(_ref2 => {
72
+ let {
73
+ name,
74
+ value
75
+ } = _ref2;
72
76
  if (pageStartedHidden || this.alreadySent.has(name)) return;
73
77
  this.alreadySent.add(name);
74
78
  this.addTiming(name.toLowerCase(), value);
@@ -76,11 +80,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
76
80
  }
77
81
 
78
82
  /* First Input Delay (+"First Interaction") - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
79
- (0, _webVitals.onFID)(({
80
- name,
81
- value,
82
- entries
83
- }) => {
83
+ (0, _webVitals.onFID)(_ref3 => {
84
+ let {
85
+ name,
86
+ value,
87
+ entries
88
+ } = _ref3;
84
89
  if (pageStartedHidden || this.alreadySent.has(name)) return;
85
90
  this.alreadySent.add(name);
86
91
 
@@ -95,11 +100,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
95
100
  });
96
101
 
97
102
  /* Largest Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
98
- (0, _webVitals.onLCP)(({
99
- name,
100
- value,
101
- entries
102
- }) => {
103
+ (0, _webVitals.onLCP)(_ref4 => {
104
+ let {
105
+ name,
106
+ value,
107
+ entries
108
+ } = _ref4;
103
109
  if (pageStartedHidden || this.alreadySent.has(name)) return;
104
110
  this.alreadySent.add(name);
105
111
 
@@ -120,34 +126,47 @@ class Aggregate extends _aggregateBase.AggregateBase {
120
126
  });
121
127
 
122
128
  /* Cumulative Layout Shift - We don't have to limit this callback since cls is stored as a state and only sent as attribute on other timings. */
123
- (0, _webVitals.onCLS)(({
124
- value
125
- }) => this.cls = value);
129
+ (0, _webVitals.onCLS)(_ref5 => {
130
+ let {
131
+ value
132
+ } = _ref5;
133
+ return this.cls = value;
134
+ });
126
135
 
127
136
  /* Interaction-to-Next-Paint */
128
- (0, _webVitals.onINP)(({
129
- name,
130
- value,
131
- id
132
- }) => this.addTiming(name.toLowerCase(), value, {
133
- metricId: id
134
- }));
137
+ (0, _webVitals.onINP)(_ref6 => {
138
+ let {
139
+ name,
140
+ value,
141
+ id
142
+ } = _ref6;
143
+ return this.addTiming(name.toLowerCase(), value, {
144
+ metricId: id
145
+ });
146
+ });
135
147
 
136
148
  /* PerformanceLongTaskTiming API */
137
149
  if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) {
138
- (0, _longTasks.onLongTask)(({
139
- name,
140
- value,
141
- info
142
- }) => this.addTiming(name.toLowerCase(), value, info)); // lt context is passed as 'info'=attrs in the timing node
150
+ (0, _longTasks.onLongTask)(_ref7 => {
151
+ let {
152
+ name,
153
+ value,
154
+ info
155
+ } = _ref7;
156
+ return this.addTiming(name.toLowerCase(), value, info);
157
+ }); // lt context is passed as 'info'=attrs in the timing node
143
158
  }
144
159
  /* ------------------------------------End of ex-loader section */
145
160
 
146
161
  /* It's important that CWV api, like "onLCP", is called before this scheduler is initialized. The reason is because they listen to the same
147
162
  on vis change or pagehide events, and we'd want ex. onLCP to record the timing (win the race) before we try to send "final harvest". */
148
163
  this.scheduler = new _harvestScheduler.HarvestScheduler('events', {
149
- onFinished: (...args) => this.onHarvestFinished(...args),
150
- getPayload: (...args) => this.prepareHarvest(...args)
164
+ onFinished: function () {
165
+ return _this.onHarvestFinished(...arguments);
166
+ },
167
+ getPayload: function () {
168
+ return _this.prepareHarvest(...arguments);
169
+ }
151
170
  }, this);
152
171
  (0, _registerHandler.registerHandler)('timing', (name, value, attrs) => this.addTiming(name, value, attrs), this.featureName, this.ee); // notice CLS is added to all timings via 4th param
153
172
  (0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
@@ -19,7 +19,8 @@ var _globalScope = require("../../../common/util/global-scope");
19
19
 
20
20
  class Instrument extends _instrumentBase.InstrumentBase {
21
21
  static featureName = _constants.FEATURE_NAME;
22
- constructor(agentIdentifier, aggregator, auto = true) {
22
+ constructor(agentIdentifier, aggregator) {
23
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
23
24
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
24
25
  if (!_globalScope.isBrowserScope) return; // CWV is irrelevant outside web context
25
26
 
@@ -7,7 +7,6 @@ exports.Aggregate = void 0;
7
7
  var _registerHandler = require("../../../common/event-emitter/register-handler");
8
8
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
9
9
  var _mapOwn = require("../../../common/util/map-own");
10
- var _reduce = require("../../../common/util/reduce");
11
10
  var _stringify = require("../../../common/util/stringify");
12
11
  var _parseUrl = require("../../../common/url/parse-url");
13
12
  var _supportsPerformanceObserver = require("../../../common/window/supports-performance-observer");
@@ -27,8 +26,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
27
26
  class Aggregate extends _aggregateBase.AggregateBase {
28
27
  static featureName = _constants.FEATURE_NAME;
29
28
  constructor(agentIdentifier, aggregator) {
29
+ var _this;
30
30
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
31
-
31
+ _this = this;
32
32
  // Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
33
33
  if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
34
34
  const handlerCache = new _handlerCache.HandlerCache();
@@ -130,14 +130,54 @@ class Aggregate extends _aggregateBase.AggregateBase {
130
130
  }, this.featureName, this.ee);
131
131
 
132
132
  // register the handlers immediately... but let the handlerCache decide if the data should actually get stored...
133
- (0, _registerHandler.registerHandler)('bst', (...args) => handlerCache.settle(() => this.storeEvent(...args)), this.featureName, this.ee);
134
- (0, _registerHandler.registerHandler)('bstTimer', (...args) => handlerCache.settle(() => this.storeTimer(...args)), this.featureName, this.ee);
135
- (0, _registerHandler.registerHandler)('bstResource', (...args) => handlerCache.settle(() => this.storeResources(...args)), this.featureName, this.ee);
136
- (0, _registerHandler.registerHandler)('bstHist', (...args) => handlerCache.settle(() => this.storeHist(...args)), this.featureName, this.ee);
137
- (0, _registerHandler.registerHandler)('bstXhrAgg', (...args) => handlerCache.settle(() => this.storeXhrAgg(...args)), this.featureName, this.ee);
138
- (0, _registerHandler.registerHandler)('bstApi', (...args) => handlerCache.settle(() => this.storeSTN(...args)), this.featureName, this.ee);
139
- (0, _registerHandler.registerHandler)('errorAgg', (...args) => handlerCache.settle(() => this.storeErrorAgg(...args)), this.featureName, this.ee);
140
- (0, _registerHandler.registerHandler)('pvtAdded', (...args) => handlerCache.settle(() => this.processPVT(...args)), this.featureName, this.ee);
133
+ (0, _registerHandler.registerHandler)('bst', function () {
134
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
135
+ args[_key] = arguments[_key];
136
+ }
137
+ return handlerCache.settle(() => _this.storeEvent(...args));
138
+ }, this.featureName, this.ee);
139
+ (0, _registerHandler.registerHandler)('bstTimer', function () {
140
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
141
+ args[_key2] = arguments[_key2];
142
+ }
143
+ return handlerCache.settle(() => _this.storeTimer(...args));
144
+ }, this.featureName, this.ee);
145
+ (0, _registerHandler.registerHandler)('bstResource', function () {
146
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
147
+ args[_key3] = arguments[_key3];
148
+ }
149
+ return handlerCache.settle(() => _this.storeResources(...args));
150
+ }, this.featureName, this.ee);
151
+ (0, _registerHandler.registerHandler)('bstHist', function () {
152
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
153
+ args[_key4] = arguments[_key4];
154
+ }
155
+ return handlerCache.settle(() => _this.storeHist(...args));
156
+ }, this.featureName, this.ee);
157
+ (0, _registerHandler.registerHandler)('bstXhrAgg', function () {
158
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
159
+ args[_key5] = arguments[_key5];
160
+ }
161
+ return handlerCache.settle(() => _this.storeXhrAgg(...args));
162
+ }, this.featureName, this.ee);
163
+ (0, _registerHandler.registerHandler)('bstApi', function () {
164
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
165
+ args[_key6] = arguments[_key6];
166
+ }
167
+ return handlerCache.settle(() => _this.storeSTN(...args));
168
+ }, this.featureName, this.ee);
169
+ (0, _registerHandler.registerHandler)('errorAgg', function () {
170
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
171
+ args[_key7] = arguments[_key7];
172
+ }
173
+ return handlerCache.settle(() => _this.storeErrorAgg(...args));
174
+ }, this.featureName, this.ee);
175
+ (0, _registerHandler.registerHandler)('pvtAdded', function () {
176
+ for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
177
+ args[_key8] = arguments[_key8];
178
+ }
179
+ return handlerCache.settle(() => _this.processPVT(...args));
180
+ }, this.featureName, this.ee);
141
181
  (0, _drain.drain)(this.agentIdentifier, this.featureName);
142
182
  }
143
183
  processPVT(name, value, attrs) {
@@ -296,10 +336,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
296
336
  if (!(0, _supportsPerformanceObserver.supportsPerformanceObserver)()) {
297
337
  this.storeResources(window.performance.getEntriesByType('resource'));
298
338
  }
299
- var stns = (0, _reduce.reduce)((0, _mapOwn.mapOwn)(this.trace, (name, nodes) => {
339
+ var stns = (0, _mapOwn.mapOwn)(this.trace, (name, nodes) => {
300
340
  if (!(name in this.toAggregate)) return nodes;
301
- return (0, _reduce.reduce)((0, _mapOwn.mapOwn)((0, _reduce.reduce)(nodes.sort(this.byStart), this.smearEvtsByOrigin(name), {}), this.val), this.flatten, []);
302
- }), this.flatten, []);
341
+ return (0, _mapOwn.mapOwn)(nodes.sort(this.byStart).reduce(this.smearEvtsByOrigin(name), {}), this.val).reduce(this.flatten, []);
342
+ }).reduce(this.flatten, []);
303
343
  if (stns.length === 0) return {};
304
344
  if (retry) {
305
345
  this.sentTrace = this.trace;
@@ -37,7 +37,8 @@ const {
37
37
  const CRT = 'clearResourceTimings';
38
38
  class Instrument extends _instrumentBase.InstrumentBase {
39
39
  static featureName = FEATURE_NAME;
40
- constructor(agentIdentifier, aggregator, auto = true) {
40
+ constructor(agentIdentifier, aggregator) {
41
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
41
42
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
42
43
  if (!_globalScope.isBrowserScope) return; // session traces not supported outside web env
43
44
 
@@ -32,7 +32,8 @@ const {
32
32
  } = CONSTANTS;
33
33
  class Instrument extends _instrumentBase.InstrumentBase {
34
34
  static featureName = FEATURE_NAME;
35
- constructor(agentIdentifier, aggregator, auto = true) {
35
+ constructor(agentIdentifier, aggregator) {
36
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
36
37
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
37
38
  if (!_globalScope.isBrowserScope) return; // SPA not supported outside web env
38
39
 
@@ -25,7 +25,8 @@ class InstrumentBase extends _featureBase.FeatureBase {
25
25
  * of its pooled instrumentation data handled by the agent's centralized drain functionality, rather than draining
26
26
  * immediately. Primarily useful for fine-grained control in tests.
27
27
  */
28
- constructor(agentIdentifier, aggregator, featureName, auto = true) {
28
+ constructor(agentIdentifier, aggregator, featureName) {
29
+ let auto = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
29
30
  super(agentIdentifier, aggregator, featureName);
30
31
  this.hasAggregator = false;
31
32
  this.auto = auto;