@newrelic/browser-agent 1.235.0 → 1.237.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 (389) hide show
  1. package/README.md +41 -1
  2. package/dist/cjs/common/config/state/init.js +4 -0
  3. package/dist/cjs/common/config/state/runtime.js +6 -5
  4. package/dist/cjs/common/constants/env.cdn.js +2 -2
  5. package/dist/cjs/common/constants/env.npm.js +1 -1
  6. package/dist/cjs/common/constants/runtime.js +52 -0
  7. package/dist/cjs/common/deny-list/deny-list.js +14 -10
  8. package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
  9. package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
  10. package/dist/cjs/common/harvest/harvest.js +154 -148
  11. package/dist/cjs/common/harvest/types.js +54 -0
  12. package/dist/cjs/common/ids/id.js +2 -2
  13. package/dist/cjs/common/ids/unique-id.js +3 -3
  14. package/dist/cjs/common/session/session-entity.js +2 -2
  15. package/dist/cjs/common/timer/interaction-timer.js +2 -2
  16. package/dist/cjs/common/unload/eol.js +10 -11
  17. package/dist/cjs/common/url/canonicalize-url.js +2 -2
  18. package/dist/cjs/common/url/parse-url.js +3 -3
  19. package/dist/cjs/common/url/protocol.js +2 -2
  20. package/dist/cjs/common/util/submit-data.js +31 -81
  21. package/dist/cjs/common/window/nreum.js +14 -14
  22. package/dist/cjs/common/wrap/wrap-events.js +3 -3
  23. package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
  24. package/dist/cjs/common/wrap/wrap-history.js +2 -2
  25. package/dist/cjs/common/wrap/wrap-jsonp.js +14 -8
  26. package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
  27. package/dist/cjs/common/wrap/wrap-promise.js +2 -2
  28. package/dist/cjs/common/wrap/wrap-raf.js +2 -2
  29. package/dist/cjs/common/wrap/wrap-timer.js +4 -4
  30. package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
  31. package/dist/cjs/features/ajax/aggregate/index.js +25 -28
  32. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
  33. package/dist/cjs/features/ajax/instrument/index.js +6 -7
  34. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +1 -1
  35. package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
  36. package/dist/cjs/features/jserrors/constants.js +2 -4
  37. package/dist/cjs/features/jserrors/instrument/index.js +80 -89
  38. package/dist/cjs/features/jserrors/instrument/uncaught-error.js +22 -0
  39. package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
  40. package/dist/cjs/features/metrics/aggregate/index.js +3 -3
  41. package/dist/cjs/features/page_action/aggregate/index.js +3 -3
  42. package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
  43. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +23 -19
  44. package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
  45. package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
  46. package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
  47. package/dist/cjs/features/session_replay/aggregate/index.js +65 -34
  48. package/dist/cjs/features/session_replay/replay-mode.js +2 -2
  49. package/dist/cjs/features/session_trace/aggregate/index.js +3 -4
  50. package/dist/cjs/features/session_trace/instrument/index.js +2 -2
  51. package/dist/cjs/features/spa/aggregate/index.js +1 -1
  52. package/dist/cjs/features/spa/instrument/index.js +2 -2
  53. package/dist/cjs/features/utils/instrument-base.js +12 -15
  54. package/dist/cjs/index.js +7 -0
  55. package/dist/cjs/loaders/agent-base.js +87 -0
  56. package/dist/cjs/loaders/agent.js +48 -1
  57. package/dist/cjs/loaders/api/api.js +3 -3
  58. package/dist/cjs/loaders/api/apiAsync.js +6 -4
  59. package/dist/cjs/loaders/api/interaction-types.js +87 -0
  60. package/dist/cjs/loaders/configure/configure.js +4 -3
  61. package/dist/cjs/loaders/micro-agent.js +32 -39
  62. package/dist/esm/common/config/state/init.js +4 -0
  63. package/dist/esm/common/config/state/runtime.js +3 -2
  64. package/dist/esm/common/constants/env.cdn.js +2 -2
  65. package/dist/esm/common/constants/env.npm.js +1 -1
  66. package/dist/esm/common/constants/runtime.js +38 -0
  67. package/dist/esm/common/deny-list/deny-list.js +14 -10
  68. package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
  69. package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
  70. package/dist/esm/common/harvest/harvest.js +150 -146
  71. package/dist/esm/common/harvest/types.js +47 -0
  72. package/dist/esm/common/ids/id.js +1 -1
  73. package/dist/esm/common/ids/unique-id.js +1 -1
  74. package/dist/esm/common/session/session-entity.js +1 -1
  75. package/dist/esm/common/timer/interaction-timer.js +1 -1
  76. package/dist/esm/common/unload/eol.js +1 -2
  77. package/dist/esm/common/url/canonicalize-url.js +1 -1
  78. package/dist/esm/common/url/parse-url.js +1 -1
  79. package/dist/esm/common/url/protocol.js +1 -1
  80. package/dist/esm/common/util/submit-data.js +29 -78
  81. package/dist/esm/common/window/nreum.js +1 -1
  82. package/dist/esm/common/wrap/wrap-events.js +1 -1
  83. package/dist/esm/common/wrap/wrap-fetch.js +1 -1
  84. package/dist/esm/common/wrap/wrap-history.js +1 -1
  85. package/dist/esm/common/wrap/wrap-jsonp.js +13 -7
  86. package/dist/esm/common/wrap/wrap-mutation.js +1 -1
  87. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  88. package/dist/esm/common/wrap/wrap-raf.js +1 -1
  89. package/dist/esm/common/wrap/wrap-timer.js +1 -1
  90. package/dist/esm/common/wrap/wrap-xhr.js +1 -1
  91. package/dist/esm/features/ajax/aggregate/index.js +26 -29
  92. package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
  93. package/dist/esm/features/ajax/instrument/index.js +1 -2
  94. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +1 -1
  95. package/dist/esm/features/jserrors/aggregate/index.js +6 -3
  96. package/dist/esm/features/jserrors/constants.js +1 -2
  97. package/dist/esm/features/jserrors/instrument/index.js +79 -88
  98. package/dist/esm/features/jserrors/instrument/uncaught-error.js +15 -0
  99. package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
  100. package/dist/esm/features/metrics/aggregate/index.js +1 -1
  101. package/dist/esm/features/page_action/aggregate/index.js +1 -1
  102. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  103. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +23 -19
  104. package/dist/esm/features/page_view_event/instrument/index.js +1 -1
  105. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
  106. package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
  107. package/dist/esm/features/session_replay/aggregate/index.js +65 -34
  108. package/dist/esm/features/session_replay/replay-mode.js +2 -2
  109. package/dist/esm/features/session_trace/aggregate/index.js +3 -4
  110. package/dist/esm/features/session_trace/instrument/index.js +1 -1
  111. package/dist/esm/features/spa/aggregate/index.js +1 -1
  112. package/dist/esm/features/spa/instrument/index.js +1 -1
  113. package/dist/esm/features/utils/instrument-base.js +11 -14
  114. package/dist/esm/index.js +1 -4
  115. package/dist/esm/loaders/agent-base.js +80 -0
  116. package/dist/esm/loaders/agent.js +48 -1
  117. package/dist/esm/loaders/api/api.js +2 -2
  118. package/dist/esm/loaders/api/apiAsync.js +3 -3
  119. package/dist/esm/loaders/api/interaction-types.js +80 -0
  120. package/dist/esm/loaders/configure/configure.js +4 -3
  121. package/dist/esm/loaders/micro-agent.js +32 -39
  122. package/dist/types/common/config/state/init.d.ts.map +1 -1
  123. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  124. package/dist/types/common/constants/runtime.d.ts +29 -0
  125. package/dist/types/common/constants/runtime.d.ts.map +1 -0
  126. package/dist/types/common/event-emitter/register-handler.d.ts +1 -1
  127. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
  128. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  129. package/dist/types/common/harvest/harvest.d.ts +49 -38
  130. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  131. package/dist/types/common/harvest/types.d.ts +100 -0
  132. package/dist/types/common/harvest/types.d.ts.map +1 -0
  133. package/dist/types/common/session/session-entity.d.ts +6 -6
  134. package/dist/types/common/unload/eol.d.ts.map +1 -1
  135. package/dist/types/common/util/submit-data.d.ts +44 -64
  136. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  137. package/dist/types/common/window/nreum.d.ts +2 -2
  138. package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
  139. package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
  140. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  141. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  142. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  143. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  144. package/dist/types/features/jserrors/constants.d.ts +0 -1
  145. package/dist/types/features/jserrors/constants.d.ts.map +1 -1
  146. package/dist/types/features/jserrors/instrument/index.d.ts +0 -13
  147. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  148. package/dist/types/features/jserrors/instrument/uncaught-error.d.ts +15 -0
  149. package/dist/types/features/jserrors/instrument/uncaught-error.d.ts.map +1 -0
  150. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +5 -5
  151. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  152. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
  153. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  154. package/dist/types/features/session_replay/aggregate/index.d.ts +16 -30
  155. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  156. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  157. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  158. package/dist/types/index.d.ts +1 -0
  159. package/dist/types/loaders/agent-base.d.ts +59 -0
  160. package/dist/types/loaders/agent-base.d.ts.map +1 -0
  161. package/dist/types/loaders/agent.d.ts +39 -5
  162. package/dist/types/loaders/agent.d.ts.map +1 -1
  163. package/dist/types/loaders/api/interaction-types.d.ts +122 -0
  164. package/dist/types/loaders/api/interaction-types.d.ts.map +1 -0
  165. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  166. package/dist/types/loaders/features/features.d.ts +9 -9
  167. package/dist/types/loaders/micro-agent.d.ts +6 -6
  168. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  169. package/package.json +6 -1
  170. package/src/common/config/__mocks__/config.js +11 -0
  171. package/src/common/config/state/init.js +2 -1
  172. package/src/common/config/state/runtime.js +3 -2
  173. package/src/common/constants/__mocks__/env.js +3 -0
  174. package/src/common/constants/__mocks__/runtime.js +8 -0
  175. package/src/common/constants/env.cdn.test.js +7 -0
  176. package/src/common/constants/env.npm.test.js +7 -0
  177. package/src/common/constants/env.test.js +7 -0
  178. package/src/common/constants/runtime.js +71 -0
  179. package/src/common/constants/runtime.test.js +168 -0
  180. package/src/common/context/__mocks__/shared-context.js +8 -0
  181. package/src/common/deny-list/deny-list.js +11 -11
  182. package/src/common/deny-list/deny-list.test.js +31 -0
  183. package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
  184. package/src/common/event-listener/event-listener-opts.js +1 -1
  185. package/src/common/harvest/__mocks__/harvest.js +13 -0
  186. package/src/common/harvest/harvest-scheduler.js +21 -20
  187. package/src/common/harvest/harvest-scheduler.test.js +496 -0
  188. package/src/common/harvest/harvest.js +142 -134
  189. package/src/common/harvest/harvest.test.js +798 -0
  190. package/src/common/harvest/types.js +47 -0
  191. package/src/common/ids/id.js +1 -1
  192. package/src/common/ids/unique-id.js +1 -1
  193. package/src/common/session/__mocks__/session-entity.js +25 -0
  194. package/src/common/session/session-entity.component-test.js +1 -1
  195. package/src/common/session/session-entity.js +1 -1
  196. package/src/common/timer/interaction-timer.js +1 -1
  197. package/src/common/timing/__mocks__/now.js +1 -0
  198. package/src/common/unload/__mocks__/eol.js +1 -0
  199. package/src/common/unload/eol.js +1 -2
  200. package/src/common/url/__mocks__/clean-url.js +1 -0
  201. package/src/common/url/__mocks__/encode.js +7 -0
  202. package/src/common/url/__mocks__/location.js +1 -0
  203. package/src/common/url/canonicalize-url.js +1 -1
  204. package/src/common/url/canonicalize-url.test.js +2 -2
  205. package/src/common/url/parse-url.js +1 -1
  206. package/src/common/url/parse-url.test.js +3 -3
  207. package/src/common/url/protocol.js +1 -1
  208. package/src/common/util/__mocks__/obfuscate.js +10 -0
  209. package/src/common/util/__mocks__/stringify.js +1 -0
  210. package/src/common/util/__mocks__/submit-data.js +5 -0
  211. package/src/common/util/__mocks__/traverse.js +1 -0
  212. package/src/common/util/submit-data.js +22 -58
  213. package/src/common/util/submit-data.test.js +30 -73
  214. package/src/common/window/nreum.js +1 -1
  215. package/src/common/wrap/wrap-events.js +1 -1
  216. package/src/common/wrap/wrap-fetch.js +1 -1
  217. package/src/common/wrap/wrap-history.js +1 -1
  218. package/src/common/wrap/wrap-jsonp.js +12 -7
  219. package/src/common/wrap/wrap-mutation.js +1 -1
  220. package/src/common/wrap/wrap-promise.js +1 -1
  221. package/src/common/wrap/wrap-promise.test.js +2 -2
  222. package/src/common/wrap/wrap-raf.js +1 -1
  223. package/src/common/wrap/wrap-timer.js +1 -1
  224. package/src/common/wrap/wrap-xhr.js +1 -1
  225. package/src/features/ajax/aggregate/index.js +26 -32
  226. package/src/features/ajax/instrument/distributed-tracing.js +1 -1
  227. package/src/features/ajax/instrument/index.js +1 -2
  228. package/src/features/jserrors/aggregate/compute-stack-trace.js +1 -1
  229. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  230. package/src/features/jserrors/aggregate/index.js +7 -3
  231. package/src/features/jserrors/constants.js +0 -1
  232. package/src/features/jserrors/instrument/index.js +92 -88
  233. package/src/features/jserrors/instrument/uncaught-error.js +15 -0
  234. package/src/features/metrics/aggregate/framework-detection.js +1 -1
  235. package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
  236. package/src/features/metrics/aggregate/index.js +1 -1
  237. package/src/features/page_action/aggregate/index.js +1 -1
  238. package/src/features/page_view_event/aggregate/index.js +1 -2
  239. package/src/features/page_view_event/aggregate/initialized-features.js +18 -14
  240. package/src/features/page_view_event/instrument/index.js +1 -1
  241. package/src/features/page_view_timing/aggregate/index.js +2 -4
  242. package/src/features/page_view_timing/instrument/index.js +1 -1
  243. package/src/features/session_replay/aggregate/index.component-test.js +17 -56
  244. package/src/features/session_replay/aggregate/index.js +47 -28
  245. package/src/features/session_replay/replay-mode.js +2 -2
  246. package/src/features/session_trace/aggregate/index.js +3 -4
  247. package/src/features/session_trace/instrument/index.js +1 -1
  248. package/src/features/spa/aggregate/index.js +1 -1
  249. package/src/features/spa/instrument/index.js +1 -1
  250. package/src/features/utils/agent-session.test.js +2 -2
  251. package/src/features/utils/instrument-base.js +11 -14
  252. package/src/features/utils/instrument-base.test.js +29 -3
  253. package/src/index.js +1 -3
  254. package/src/loaders/agent-base.js +81 -0
  255. package/src/loaders/agent.js +50 -1
  256. package/src/loaders/api/api.js +2 -2
  257. package/src/loaders/api/apiAsync.js +3 -3
  258. package/src/loaders/api/interaction-types.js +80 -0
  259. package/src/loaders/configure/configure.js +5 -4
  260. package/src/loaders/micro-agent.js +30 -31
  261. package/dist/cjs/common/browser-version/firefox-version.js +0 -17
  262. package/dist/cjs/common/browser-version/ios-version.js +0 -19
  263. package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
  264. package/dist/cjs/common/event-emitter/handle.test.js +0 -58
  265. package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
  266. package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
  267. package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
  268. package/dist/cjs/common/ids/id.test.js +0 -85
  269. package/dist/cjs/common/ids/unique-id.test.js +0 -49
  270. package/dist/cjs/common/session/session-entity.component-test.js +0 -497
  271. package/dist/cjs/common/storage/local-storage.test.js +0 -14
  272. package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
  273. package/dist/cjs/common/timer/timer.test.js +0 -105
  274. package/dist/cjs/common/timing/nav-timing.test.js +0 -192
  275. package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
  276. package/dist/cjs/common/url/clean-url.test.js +0 -9
  277. package/dist/cjs/common/url/encode.component-test.js +0 -74
  278. package/dist/cjs/common/url/location.test.js +0 -13
  279. package/dist/cjs/common/url/parse-url.test.js +0 -111
  280. package/dist/cjs/common/url/protocol.component-test.js +0 -15
  281. package/dist/cjs/common/util/console.test.js +0 -30
  282. package/dist/cjs/common/util/data-size.test.js +0 -64
  283. package/dist/cjs/common/util/feature-flags.test.js +0 -84
  284. package/dist/cjs/common/util/get-or-set.test.js +0 -47
  285. package/dist/cjs/common/util/global-scope.js +0 -27
  286. package/dist/cjs/common/util/global-scope.test.js +0 -72
  287. package/dist/cjs/common/util/invoke.test.js +0 -49
  288. package/dist/cjs/common/util/map-own.test.js +0 -49
  289. package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
  290. package/dist/cjs/common/util/stringify.test.js +0 -48
  291. package/dist/cjs/common/util/submit-data.test.js +0 -245
  292. package/dist/cjs/common/util/traverse.test.js +0 -44
  293. package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
  294. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
  295. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
  296. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
  297. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
  298. package/dist/cjs/features/jserrors/instrument/debug.js +0 -40
  299. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
  300. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
  301. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
  302. package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
  303. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
  304. package/dist/cjs/features/utils/agent-session.test.js +0 -211
  305. package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
  306. package/dist/cjs/features/utils/feature-base.test.js +0 -42
  307. package/dist/cjs/features/utils/handler-cache.test.js +0 -53
  308. package/dist/cjs/features/utils/instrument-base.test.js +0 -179
  309. package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
  310. package/dist/esm/common/browser-version/firefox-version.js +0 -10
  311. package/dist/esm/common/browser-version/ios-version.js +0 -11
  312. package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
  313. package/dist/esm/common/event-emitter/handle.test.js +0 -54
  314. package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
  315. package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
  316. package/dist/esm/common/harvest/harvest.component-test.js +0 -222
  317. package/dist/esm/common/ids/id.test.js +0 -81
  318. package/dist/esm/common/ids/unique-id.test.js +0 -44
  319. package/dist/esm/common/session/session-entity.component-test.js +0 -495
  320. package/dist/esm/common/storage/local-storage.test.js +0 -12
  321. package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
  322. package/dist/esm/common/timer/timer.test.js +0 -103
  323. package/dist/esm/common/timing/nav-timing.test.js +0 -190
  324. package/dist/esm/common/url/canonicalize-url.test.js +0 -34
  325. package/dist/esm/common/url/clean-url.test.js +0 -7
  326. package/dist/esm/common/url/encode.component-test.js +0 -70
  327. package/dist/esm/common/url/location.test.js +0 -11
  328. package/dist/esm/common/url/parse-url.test.js +0 -107
  329. package/dist/esm/common/url/protocol.component-test.js +0 -13
  330. package/dist/esm/common/util/console.test.js +0 -28
  331. package/dist/esm/common/util/data-size.test.js +0 -60
  332. package/dist/esm/common/util/feature-flags.test.js +0 -80
  333. package/dist/esm/common/util/get-or-set.test.js +0 -45
  334. package/dist/esm/common/util/global-scope.js +0 -17
  335. package/dist/esm/common/util/global-scope.test.js +0 -70
  336. package/dist/esm/common/util/invoke.test.js +0 -47
  337. package/dist/esm/common/util/map-own.test.js +0 -47
  338. package/dist/esm/common/util/obfuscate.component-test.js +0 -125
  339. package/dist/esm/common/util/stringify.test.js +0 -46
  340. package/dist/esm/common/util/submit-data.test.js +0 -241
  341. package/dist/esm/common/util/traverse.test.js +0 -42
  342. package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
  343. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
  344. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
  345. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
  346. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
  347. package/dist/esm/features/jserrors/instrument/debug.js +0 -38
  348. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
  349. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
  350. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
  351. package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
  352. package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
  353. package/dist/esm/features/utils/agent-session.test.js +0 -207
  354. package/dist/esm/features/utils/aggregate-base.test.js +0 -108
  355. package/dist/esm/features/utils/feature-base.test.js +0 -40
  356. package/dist/esm/features/utils/handler-cache.test.js +0 -51
  357. package/dist/esm/features/utils/instrument-base.test.js +0 -175
  358. package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
  359. package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
  360. package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
  361. package/dist/types/common/browser-version/ios-version.d.ts +0 -3
  362. package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
  363. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
  364. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
  365. package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
  366. package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
  367. package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
  368. package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
  369. package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
  370. package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
  371. package/dist/types/common/url/encode.component-test.d.ts +0 -2
  372. package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
  373. package/dist/types/common/url/protocol.component-test.d.ts +0 -2
  374. package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
  375. package/dist/types/common/util/global-scope.d.ts +0 -5
  376. package/dist/types/common/util/global-scope.d.ts.map +0 -1
  377. package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
  378. package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
  379. package/dist/types/features/jserrors/instrument/debug.d.ts +0 -2
  380. package/dist/types/features/jserrors/instrument/debug.d.ts.map +0 -1
  381. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
  382. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
  383. package/src/common/browser-version/firefox-version.js +0 -10
  384. package/src/common/browser-version/ios-version.js +0 -11
  385. package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
  386. package/src/common/harvest/harvest.component-test.js +0 -169
  387. package/src/common/util/global-scope.js +0 -23
  388. package/src/common/util/global-scope.test.js +0 -87
  389. package/src/features/jserrors/instrument/debug.js +0 -36
@@ -3,10 +3,9 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- import { mapOwn } from '../util/map-own'
7
6
  import { obj as encodeObj, param as encodeParam } from '../url/encode'
8
7
  import { stringify } from '../util/stringify'
9
- import { submitData } from '../util/submit-data'
8
+ import * as submitData from '../util/submit-data'
10
9
  import { getLocation } from '../url/location'
11
10
  import { getInfo, getConfigurationValue, getRuntime } from '../config/config'
12
11
  import { cleanURL } from '../url/clean-url'
@@ -16,27 +15,18 @@ import { Obfuscator } from '../util/obfuscate'
16
15
  import { applyFnToProps } from '../util/traverse'
17
16
  import { SharedContext } from '../context/shared-context'
18
17
  import { VERSION } from '../constants/env'
19
- import { isBrowserScope, isWorkerScope } from '../util/global-scope'
18
+ import { isWorkerScope, isIE } from '../constants/runtime'
19
+ import { warn } from '../util/console'
20
+
21
+ const warnings = {}
20
22
 
21
23
  /**
22
- * @typedef {object} NetworkSendSpec
23
- * @param {string} endpoint The endpoint to use (jserrors, events, resources etc.)
24
- * @param {object} payload Object representing payload.
25
- * @param {object} payload.qs Map of values that should be sent as part of the request query string.
26
- * @param {string} payload.body String that should be sent as the body of the request.
27
- * @param {string} payload.body.e Special case of body used for browser interactions.
28
- * @param {object} opts Additional options for sending data
29
- * @param {boolean} opts.needResponse Specify whether the caller expects a response data.
30
- * @param {boolean} opts.unload Specify whether the call is a final harvest during page unload.
31
- * @param {boolean} opts.sendEmptyBody Specify whether the call should be made even if the body is empty. Useful for rum calls.
32
- * @param {function} submitMethod The submit method to use {@link ../util/submit-data}
33
- * @param {string} customUrl Override the beacon url the data is sent to; must include protocol if defined
34
- * @param {boolean} gzip Enabled gzip compression on the body of the request before it is sent
35
- * @param {boolean} includeBaseParams Enables the use of base query parameters in the beacon url {@see Harvest.baseQueryString}
24
+ * @typedef {import('./types.js').NetworkSendSpec} NetworkSendSpec
25
+ * @typedef {import('./types.js').HarvestEndpointIdentifier} HarvestEndpointIdentifier
26
+ * @typedef {import('./types.js').HarvestPayload} HarvestPayload
27
+ * @typedef {import('./types.js').FeatureHarvestCallback} FeatureHarvestCallback
28
+ * @typedef {import('./types.js').FeatureHarvestCallbackOptions} FeatureHarvestCallbackOptions
36
29
  */
37
-
38
- const haveSendBeacon = !!navigator.sendBeacon // only the web window obj has sendBeacon at this time, so 'false' for other envs
39
-
40
30
  export class Harvest extends SharedContext {
41
31
  constructor (parent) {
42
32
  super(parent) // gets any allowed properties from the parent and stores them in `sharedContext`
@@ -51,17 +41,16 @@ export class Harvest extends SharedContext {
51
41
  /**
52
42
  * Initiate a harvest from multiple sources. An event that corresponds to the endpoint
53
43
  * name is emitted, which gives any listeners the opportunity to provide payload data.
44
+ * Note: Used by page_action
54
45
  * @param {NetworkSendSpec} spec Specification for sending data
55
46
  */
56
- sendX (spec) {
57
- const { endpoint, opts } = spec
58
- var submitMethod = getSubmitMethod(endpoint, opts)
59
- if (!submitMethod) return false
60
- var options = {
61
- retry: submitMethod.method === submitData.xhr
47
+ sendX (spec = {}) {
48
+ const submitMethod = submitData.getSubmitMethod({ isFinalHarvest: spec.opts?.unload })
49
+ const options = {
50
+ retry: !spec.opts?.unload && submitMethod === submitData.xhr
62
51
  }
63
- const payload = this.createPayload(endpoint, options)
64
- var caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this)
52
+ const payload = this.createPayload(spec.endpoint, options)
53
+ const caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this)
65
54
  return caller({ ...spec, payload, submitMethod })
66
55
  }
67
56
 
@@ -69,69 +58,73 @@ export class Harvest extends SharedContext {
69
58
  * Initiate a harvest call.
70
59
  * @param {NetworkSendSpec} spec Specification for sending data
71
60
  */
72
- send (spec) {
73
- const { payload = {} } = spec
74
- var makeBody = createAccumulator()
75
- var makeQueryString = createAccumulator()
76
- if (payload.body) mapOwn(payload.body, makeBody)
77
- if (payload.qs) mapOwn(payload.qs, makeQueryString)
78
-
79
- var newPayload = { body: makeBody(), qs: makeQueryString() }
80
- var caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this)
61
+ send (spec = {}) {
62
+ const caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this)
81
63
 
82
- return caller({ ...spec, payload: newPayload })
64
+ return caller(spec)
83
65
  }
84
66
 
85
67
  /**
86
68
  * Apply obfuscation rules to the payload and then initial the harvest network call.
87
69
  * @param {NetworkSendSpec} spec Specification for sending data
88
70
  */
89
- obfuscateAndSend (spec) {
71
+ obfuscateAndSend (spec = {}) {
90
72
  const { payload = {} } = spec
91
73
  applyFnToProps(payload, (...args) => this.obfuscator.obfuscateString(...args), 'string', ['e'])
92
74
  return this._send({ ...spec, payload })
93
75
  }
94
76
 
77
+ /**
78
+ * Initiate a harvest call. Typically used by `sendX` and `send` methods or called directly
79
+ * for raw network calls.
80
+ * @param {NetworkSendSpec} param0 Specification for sending data
81
+ * @returns {boolean} True if the network call succeeded. For final harvest calls, the return
82
+ * value should not be relied upon because network calls will be made asynchronously.
83
+ */
95
84
  _send ({ endpoint, payload = {}, opts = {}, submitMethod, cbFinished, customUrl, raw, includeBaseParams = true }) {
96
- var info = getInfo(this.sharedContext.agentIdentifier)
85
+ const info = getInfo(this.sharedContext.agentIdentifier)
97
86
  if (!info.errorBeacon) return false
98
87
 
99
- var agentRuntime = getRuntime(this.sharedContext.agentIdentifier)
88
+ const agentRuntime = getRuntime(this.sharedContext.agentIdentifier)
89
+ let { body, qs } = this.cleanPayload(payload)
100
90
 
101
- if (!payload.body && !opts?.sendEmptyBody) { // no payload body? nothing to send, just run onfinish stuff and return
91
+ if (Object.keys(body).length === 0 && !opts?.sendEmptyBody) { // no payload body? nothing to send, just run onfinish stuff and return
102
92
  if (cbFinished) {
103
93
  cbFinished({ sent: false })
104
94
  }
105
95
  return false
106
96
  }
107
97
 
108
- let url = ''
98
+ let url = `${this.getScheme()}://${info.errorBeacon}${endpoint !== 'rum' ? `/${endpoint}` : ''}/1/${info.licenseKey}`
109
99
  if (customUrl) url = customUrl
110
- else if (raw) url = `${this.getScheme()}://${info.errorBeacon}/${endpoint}`
111
- else url = `${this.getScheme()}://${info.errorBeacon}${endpoint !== 'rum' ? `/${endpoint}` : ''}/1/${info.licenseKey}`
100
+ if (raw) url = `${this.getScheme()}://${info.errorBeacon}/${endpoint}`
112
101
 
113
- var baseParams = !raw && includeBaseParams ? this.baseQueryString() : ''
114
- var payloadParams = payload.qs ? encodeObj(payload.qs, agentRuntime.maxBytes) : ''
102
+ const baseParams = !raw && includeBaseParams ? this.baseQueryString() : ''
103
+ let payloadParams = encodeObj(qs, agentRuntime.maxBytes)
115
104
  if (!submitMethod) {
116
- submitMethod = getSubmitMethod(endpoint, opts)
105
+ submitMethod = submitData.getSubmitMethod({ isFinalHarvest: opts.unload })
106
+ }
107
+ if (baseParams === '' && payloadParams.startsWith('&')) {
108
+ payloadParams = payloadParams.substring(1)
117
109
  }
118
- var method = submitMethod.method
119
- var useBody = submitMethod.useBody
120
-
121
- var body
122
- var fullUrl = `${url}?${baseParams}${payloadParams}`
123
110
 
124
- const gzip = payload?.qs?.content_encoding === 'gzip'
111
+ const fullUrl = `${url}?${baseParams}${payloadParams}`
112
+ const gzip = !!qs?.attributes?.includes('gzip')
125
113
 
126
114
  if (!gzip) {
127
- if (useBody && endpoint === 'events') {
128
- body = payload.body.e
129
- } else if (useBody) {
130
- body = stringify(payload.body)
115
+ if (endpoint === 'events') {
116
+ body = body.e
131
117
  } else {
132
- fullUrl = fullUrl + encodeObj(payload.body, agentRuntime.maxBytes)
118
+ body = stringify(body)
133
119
  }
134
- } else body = payload.body
120
+ /** Warn --once per endpoint-- if the agent tries to send large payloads */
121
+ if (body.length > 750000 && (warnings[endpoint] = (warnings?.[endpoint] || 0) + 1) === 1) warn(`The Browser Agent is attempting to send a very large payload to /${endpoint}. This is usually tied to large amounts of custom attributes. Please check your configurations.`)
122
+ }
123
+
124
+ if (!body || body.length === 0 || body === '{}' || body === '[]') {
125
+ // If body is null, undefined, or an empty object or array, send an empty string instead
126
+ body = ''
127
+ }
135
128
 
136
129
  // Get bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
137
130
  agentRuntime.bytesSent[endpoint] = (agentRuntime.bytesSent[endpoint] || 0) + body?.length || 0
@@ -142,46 +135,41 @@ export class Harvest extends SharedContext {
142
135
 
143
136
  headers.push({ key: 'content-type', value: 'text/plain' })
144
137
 
145
- /* Since workers don't support sendBeacon right now, or Image(), they can only use XHR method.
138
+ /* Since workers don't support sendBeacon right now, they can only use XHR method.
146
139
  Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
147
- we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon. */
148
-
149
- var result = method({ url: fullUrl, body, sync: opts.unload && isWorkerScope, headers })
150
-
151
- if (cbFinished && method === submitData.xhr) {
152
- var xhr = result
153
- xhr.addEventListener('load', function () {
154
- var result = { sent: true, status: this.status }
140
+ we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon.
141
+ Following the removal of img-element method, IE will also use sync XHR on page dismissal to ensure final analytics are sent. */
142
+ let result = submitMethod({ url: fullUrl, body, sync: opts.unload && (isWorkerScope || isIE), headers })
143
+
144
+ if (!opts.unload && cbFinished && submitMethod === submitData.xhr) {
145
+ const harvestScope = this
146
+ result.addEventListener('load', function () {
147
+ // `this` refers to the XHR object in this scope, do not change this to a fat arrow
148
+ const cbResult = { sent: true, status: this.status }
155
149
  if (this.status === 429) {
156
- result.retry = true
157
- result.delay = this.tooManyRequestsDelay
150
+ cbResult.retry = true
151
+ cbResult.delay = harvestScope.tooManyRequestsDelay
158
152
  } else if (this.status === 408 || this.status === 500 || this.status === 503) {
159
- result.retry = true
153
+ cbResult.retry = true
160
154
  }
161
155
 
162
156
  if (opts.needResponse) {
163
- result.responseText = this.responseText
157
+ cbResult.responseText = this.responseText
164
158
  }
165
- cbFinished(result)
159
+ cbFinished(cbResult)
166
160
  }, eventListenerOpts(false))
167
161
  }
168
162
 
169
- // if beacon request failed, retry with an alternative method -- will not happen for workers
170
- if (!result && method === submitData.beacon) {
171
- method = submitData.img
172
- result = method({ url: fullUrl + encodeObj(payload.body, agentRuntime.maxBytes) })
173
- }
174
-
175
163
  return result
176
164
  }
177
165
 
178
166
  // The stuff that gets sent every time.
179
167
  baseQueryString () {
180
- var runtime = getRuntime(this.sharedContext.agentIdentifier)
181
- var info = getInfo(this.sharedContext.agentIdentifier)
168
+ const runtime = getRuntime(this.sharedContext.agentIdentifier)
169
+ const info = getInfo(this.sharedContext.agentIdentifier)
182
170
 
183
- var location = cleanURL(getLocation())
184
- var ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location
171
+ const location = cleanURL(getLocation())
172
+ const ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location
185
173
 
186
174
  return ([
187
175
  'a=' + info.applicationID,
@@ -197,51 +185,85 @@ export class Harvest extends SharedContext {
197
185
  ].join(''))
198
186
  }
199
187
 
200
- createPayload (type, options) {
201
- var makeBody = createAccumulator()
202
- var makeQueryString = createAccumulator()
203
- var listeners = ((this._events[type] && this._events[type]) || [])
188
+ /**
189
+ * Calls and accumulates data from registered harvesting functions based on
190
+ * the endpoint being harvested.
191
+ * @param {HarvestEndpointIdentifier} endpoint BAM endpoint identifier.
192
+ * @param {FeatureHarvestCallbackOptions} options Options to be passed to the
193
+ * feature harvest listener callback.
194
+ * @returns {HarvestPayload} Payload object to transmit to the bam endpoint.
195
+ */
196
+ createPayload (endpoint, options) {
197
+ const listeners = this._events[endpoint]
198
+ const payload = {
199
+ body: {},
200
+ qs: {}
201
+ }
204
202
 
205
- for (var i = 0; i < listeners.length; i++) {
206
- var singlePayload = listeners[i](options)
207
- if (!singlePayload) continue
208
- if (singlePayload.body) mapOwn(singlePayload.body, makeBody)
209
- if (singlePayload.qs) mapOwn(singlePayload.qs, makeQueryString)
203
+ if (Array.isArray(listeners) && listeners.length > 0) {
204
+ for (let i = 0; i < listeners.length; i++) {
205
+ const singlePayload = listeners[i](options)
206
+
207
+ if (singlePayload) {
208
+ payload.body = {
209
+ ...payload.body,
210
+ ...(singlePayload.body || {})
211
+ }
212
+ payload.qs = {
213
+ ...payload.qs,
214
+ ...(singlePayload.qs || {})
215
+ }
216
+ }
217
+ }
210
218
  }
211
219
 
212
- return { body: makeBody(), qs: makeQueryString() }
220
+ return payload
213
221
  }
214
222
 
215
- on (type, listener) {
216
- var listeners = (this._events[type] || (this._events[type] = []))
217
- listeners.push(listener)
218
- }
223
+ /**
224
+ * Cleans and returns a payload object containing a body and qs
225
+ * object with key/value pairs. KV pairs where the value is null,
226
+ * undefined, or an empty string are removed to save on transmission
227
+ * size.
228
+ * @param {HarvestPayload} payload Payload to be sent to the endpoint.
229
+ * @returns {HarvestPayload} Cleaned payload payload to be sent to the endpoint.
230
+ */
231
+ cleanPayload (payload = {}) {
232
+ const clean = (input) => {
233
+ if ((typeof Uint8Array !== 'undefined' && input instanceof Uint8Array) || typeof input === 'string') {
234
+ return input.length > 0 ? input : null
235
+ }
236
+ return Object.entries(input || {})
237
+ .reduce((accumulator, [key, value]) => {
238
+ if ((typeof value === 'number') ||
239
+ (typeof value === 'string' && value.length > 0) ||
240
+ (typeof value === 'object' && Object.keys(value || {}).length > 0)
241
+ ) {
242
+ accumulator[key] = value
243
+ }
244
+
245
+ return accumulator
246
+ }, {})
247
+ }
219
248
 
220
- resetListeners () {
221
- mapOwn(this._events, (key) => {
222
- this._events[key] = []
223
- })
249
+ return {
250
+ body: clean(payload.body),
251
+ qs: clean(payload.qs)
252
+ }
224
253
  }
225
- }
226
254
 
227
- export function getSubmitMethod (endpoint, opts) {
228
- opts = opts || {}
229
- var method
230
- var useBody
231
-
232
- if (opts.unload && isBrowserScope) { // all the features' final harvest; neither methods work outside window context
233
- useBody = haveSendBeacon
234
- method = haveSendBeacon ? submitData.beacon : submitData.img // really only IE doesn't have Beacon API for web browsers
235
- } else {
236
- // `submitData.beacon` was removed, there is an upper limit to the
237
- // number of data allowed before it starts failing, so we save it only for page unloading
238
- useBody = true
239
- method = submitData.xhr
240
- }
255
+ /**
256
+ * Registers a function to be called when harvesting is triggered for a specific
257
+ * endpoint.
258
+ * @param {HarvestEndpointIdentifier} endpoint
259
+ * @param {FeatureHarvestCallback} listener
260
+ */
261
+ on (endpoint, listener) {
262
+ if (!Array.isArray(this._events[endpoint])) {
263
+ this._events[endpoint] = []
264
+ }
241
265
 
242
- return {
243
- method: method,
244
- useBody: useBody
266
+ this._events[endpoint].push(listener)
245
267
  }
246
268
  }
247
269
 
@@ -252,17 +274,3 @@ function transactionNameParam (info) {
252
274
  if (info.transactionName) return encodeParam('to', info.transactionName)
253
275
  return encodeParam('t', info.tNamePlain || 'Unnamed Transaction')
254
276
  }
255
-
256
- // returns a function that can be called to accumulate values to a single object
257
- // when the function is called without parameters, then the accumulator is returned
258
- function createAccumulator () {
259
- var accumulator = {}
260
- var hasData = false
261
- return function (key, val) {
262
- if (val !== null && val !== undefined && val.toString()?.length) {
263
- accumulator[key] = val
264
- hasData = true
265
- }
266
- if (hasData) return accumulator
267
- }
268
- }