@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
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isFileProtocol = isFileProtocol;
7
- var _globalScope = require("../util/global-scope");
7
+ var _runtime = require("../constants/runtime");
8
8
  /*
9
9
  * Copyright 2020 New Relic Corporation. All rights reserved.
10
10
  * SPDX-License-Identifier: Apache-2.0
11
11
  */
12
12
 
13
13
  function isFileProtocol() {
14
- return Boolean(_globalScope.globalScope?.location?.protocol === 'file:');
14
+ return Boolean(_runtime.globalScope?.location?.protocol === 'file:');
15
15
  }
@@ -3,71 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.submitData = void 0;
7
- var _globalScope = require("./global-scope");
8
- /*
9
- * Copyright 2020 New Relic Corporation. All rights reserved.
10
- * SPDX-License-Identifier: Apache-2.0
6
+ exports.beacon = beacon;
7
+ exports.getSubmitMethod = getSubmitMethod;
8
+ exports.xhr = xhr;
9
+ var _runtime = require("../constants/runtime");
10
+ /**
11
+ * @file Contains common methods used to transmit harvested data.
12
+ * @copyright 2023 New Relic Corporation. All rights reserved.
13
+ * @license Apache-2.0
11
14
  */
12
15
 
13
- const submitData = {};
14
-
15
16
  /**
16
- * Send via JSONP. Do NOT call this function outside of a guaranteed web window environment.
17
- * @param {Object} args - The args
18
- * @param {string} args.url - The URL to send to
19
- * @param {string} args.jsonp - The string name of the jsonp cb method
20
- * @returns {XMLHttpRequest}
21
- * @returns {Element}
17
+ * @typedef {xhr|beacon} NetworkMethods
22
18
  */
23
- exports.submitData = submitData;
24
- submitData.jsonp = function jsonp(_ref) {
25
- let {
26
- url,
27
- jsonp
28
- } = _ref;
29
- try {
30
- if (_globalScope.isWorkerScope) {
31
- try {
32
- return importScripts(url + '&jsonp=' + jsonp);
33
- } catch (e) {
34
- // for now theres no other way to execute the callback from ingest without jsonp, or unsafe eval / new Function calls
35
- // future work needs to be conducted to allow ingest to return a more traditional JSON API-like experience for the entitlement flags
36
- submitData.xhrGet({
37
- url: url + '&jsonp=' + jsonp
38
- });
39
- return false;
40
- }
41
- } else {
42
- var element = document.createElement('script');
43
- element.type = 'text/javascript';
44
- element.src = url + '&jsonp=' + jsonp;
45
- var firstScript = document.getElementsByTagName('script')[0];
46
- firstScript.parentNode.insertBefore(element, firstScript);
47
- return element;
48
- }
49
- } catch (err) {
50
- // do nothing
51
- }
52
- };
53
19
 
54
20
  /**
55
- * Performs an asynchronous GET request using XMLHttpRequest.
56
- *
57
- * @param {Object} args - An object containing a `url` property.
58
- * @param {string} args.url - The URL to send the GET request to.
59
- * @returns {XMLHttpRequest} - An XMLHttpRequest object.
21
+ * Determines the submit method to use based on options.
22
+ * @param {object} opts Options used to determine submit method.
23
+ * @param {boolean} opts.isFinalHarvest Indicates if the data submission is due to
24
+ * a final harvest within the agent.
60
25
  */
61
- submitData.xhrGet = function xhrGet(_ref2) {
26
+ function getSubmitMethod() {
62
27
  let {
63
- url
64
- } = _ref2;
65
- return submitData.xhr({
66
- url,
67
- sync: false,
68
- method: 'GET'
69
- });
70
- };
28
+ isFinalHarvest = false
29
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
+ return isFinalHarvest && _runtime.isBrowserScope && _runtime.supportsSendBeacon
31
+ // Use sendBeacon for final harvest
32
+ ? beacon
33
+ // Only IE does not support sendBeacon for final harvest
34
+ // If not final harvest, or not browserScope, always use xhr post
35
+ : xhr;
36
+ }
71
37
 
72
38
  /**
73
39
  * Send via XHR
@@ -79,7 +45,7 @@ submitData.xhrGet = function xhrGet(_ref2) {
79
45
  * @param {{key: string, value: string}[]} [args.headers] - The headers to attach.
80
46
  * @returns {XMLHttpRequest}
81
47
  */
82
- submitData.xhr = function xhr(_ref3) {
48
+ function xhr(_ref) {
83
49
  let {
84
50
  url,
85
51
  body = null,
@@ -89,8 +55,8 @@ submitData.xhr = function xhr(_ref3) {
89
55
  key: 'content-type',
90
56
  value: 'text/plain'
91
57
  }]
92
- } = _ref3;
93
- var request = new XMLHttpRequest();
58
+ } = _ref;
59
+ const request = new XMLHttpRequest();
94
60
  request.open(method, url, !sync);
95
61
  try {
96
62
  // Set cookie
@@ -103,22 +69,7 @@ submitData.xhr = function xhr(_ref3) {
103
69
  });
104
70
  request.send(body);
105
71
  return request;
106
- };
107
-
108
- /**
109
- * Send by appending an <img> element to the page. Do NOT call this function outside of a guaranteed web window environment.
110
- * @param {Object} args - The args
111
- * @param {string} args.url - The URL to send to
112
- * @returns {HTMLImageElement}
113
- */
114
- submitData.img = function img(_ref4) {
115
- let {
116
- url
117
- } = _ref4;
118
- var element = new Image();
119
- element.src = url;
120
- return element;
121
- };
72
+ }
122
73
 
123
74
  /**
124
75
  * Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
@@ -127,11 +78,11 @@ submitData.img = function img(_ref4) {
127
78
  * @param {string=} args.body - The Stringified body
128
79
  * @returns {boolean}
129
80
  */
130
- submitData.beacon = function (_ref5) {
81
+ function beacon(_ref2) {
131
82
  let {
132
83
  url,
133
84
  body
134
- } = _ref5;
85
+ } = _ref2;
135
86
  try {
136
87
  // Navigator has to be bound to ensure it does not error in some browsers
137
88
  // https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
@@ -139,8 +90,7 @@ submitData.beacon = function (_ref5) {
139
90
  return send(url, body);
140
91
  } catch (err) {
141
92
  // if sendBeacon still trys to throw an illegal invocation error,
142
- // we can catch here and return. The harvest module will fallback to use
143
- // .img to try to send
93
+ // we can catch here and return
144
94
  return false;
145
95
  }
146
- };
96
+ }
@@ -14,18 +14,18 @@ exports.gosNREUMInitializedAgents = gosNREUMInitializedAgents;
14
14
  exports.gosNREUMLoaderConfig = gosNREUMLoaderConfig;
15
15
  exports.gosNREUMOriginals = gosNREUMOriginals;
16
16
  var _now = require("../timing/now");
17
- var _globalScope = require("../util/global-scope");
17
+ var _runtime = require("../constants/runtime");
18
18
  const defaults = {
19
19
  beacon: 'bam.nr-data.net',
20
20
  errorBeacon: 'bam.nr-data.net'
21
21
  };
22
22
  exports.defaults = defaults;
23
23
  function gosNREUM() {
24
- if (!_globalScope.globalScope.NREUM) {
25
- _globalScope.globalScope.NREUM = {};
24
+ if (!_runtime.globalScope.NREUM) {
25
+ _runtime.globalScope.NREUM = {};
26
26
  }
27
- if (typeof _globalScope.globalScope.newrelic === 'undefined') _globalScope.globalScope.newrelic = _globalScope.globalScope.NREUM;
28
- return _globalScope.globalScope.NREUM;
27
+ if (typeof _runtime.globalScope.newrelic === 'undefined') _runtime.globalScope.newrelic = _runtime.globalScope.NREUM;
28
+ return _runtime.globalScope.NREUM;
29
29
  }
30
30
  function gosNREUMInfo() {
31
31
  let nr = gosNREUM();
@@ -57,16 +57,16 @@ function gosNREUMOriginals() {
57
57
  let nr = gosNREUM();
58
58
  if (!nr.o) {
59
59
  nr.o = {
60
- ST: _globalScope.globalScope.setTimeout,
61
- SI: _globalScope.globalScope.setImmediate,
62
- CT: _globalScope.globalScope.clearTimeout,
63
- XHR: _globalScope.globalScope.XMLHttpRequest,
64
- REQ: _globalScope.globalScope.Request,
65
- EV: _globalScope.globalScope.Event,
66
- PR: _globalScope.globalScope.Promise,
67
- MO: _globalScope.globalScope.MutationObserver,
60
+ ST: _runtime.globalScope.setTimeout,
61
+ SI: _runtime.globalScope.setImmediate,
62
+ CT: _runtime.globalScope.clearTimeout,
63
+ XHR: _runtime.globalScope.XMLHttpRequest,
64
+ REQ: _runtime.globalScope.Request,
65
+ EV: _runtime.globalScope.Event,
66
+ PR: _runtime.globalScope.Promise,
67
+ MO: _runtime.globalScope.MutationObserver,
68
68
  // this'll be undefined if not in a web window
69
- FETCH: _globalScope.globalScope.fetch
69
+ FETCH: _runtime.globalScope.fetch
70
70
  };
71
71
  }
72
72
  return nr;
@@ -8,7 +8,7 @@ exports.wrapEvents = wrapEvents;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
9
  var _wrapFunction = require("./wrap-function");
10
10
  var _getOrSet = require("../util/get-or-set");
11
- var _globalScope = require("../util/global-scope");
11
+ var _runtime = require("../constants/runtime");
12
12
  /*
13
13
  * Copyright 2020 New Relic Corporation. All rights reserved.
14
14
  * SPDX-License-Identifier: Apache-2.0
@@ -42,8 +42,8 @@ function wrapEvents(sharedEE) {
42
42
 
43
43
  // Guard against instrumenting environments w/o necessary features
44
44
  if ('getPrototypeOf' in Object) {
45
- if (_globalScope.isBrowserScope) findEventListenerProtoAndCb(document, wrapNode);
46
- findEventListenerProtoAndCb(_globalScope.globalScope, wrapNode);
45
+ if (_runtime.isBrowserScope) findEventListenerProtoAndCb(document, wrapNode);
46
+ findEventListenerProtoAndCb(_runtime.globalScope, wrapNode);
47
47
  findEventListenerProtoAndCb(XHR.prototype, wrapNode);
48
48
  }
49
49
  ee.on(ADD_EVENT_LISTENER + '-start', function (args, target) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.scopedEE = scopedEE;
7
7
  exports.wrapFetch = wrapFetch;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
- var _globalScope = require("../util/global-scope");
9
+ var _runtime = require("../constants/runtime");
10
10
  var _wrapFunction = require("./wrap-function");
11
11
  /*
12
12
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -20,8 +20,8 @@ var _wrapFunction = require("./wrap-function");
20
20
  var prefix = 'fetch-';
21
21
  var bodyPrefix = prefix + 'body-';
22
22
  var bodyMethods = ['arrayBuffer', 'blob', 'json', 'text', 'formData'];
23
- var Req = _globalScope.globalScope.Request;
24
- var Res = _globalScope.globalScope.Response;
23
+ var Req = _runtime.globalScope.Request;
24
+ var Res = _runtime.globalScope.Response;
25
25
  var proto = 'prototype';
26
26
  var ctxId = 'nr@context';
27
27
  const wrapped = {};
@@ -36,7 +36,7 @@ const wrapped = {};
36
36
  */
37
37
  function wrapFetch(sharedEE) {
38
38
  const ee = scopedEE(sharedEE);
39
- if (!(Req && Res && _globalScope.globalScope.fetch)) {
39
+ if (!(Req && Res && _runtime.globalScope.fetch)) {
40
40
  return ee;
41
41
  }
42
42
 
@@ -49,7 +49,7 @@ function wrapFetch(sharedEE) {
49
49
  wrapPromiseMethod(Req[proto], method, bodyPrefix);
50
50
  wrapPromiseMethod(Res[proto], method, bodyPrefix);
51
51
  });
52
- wrapPromiseMethod(_globalScope.globalScope, 'fetch', prefix);
52
+ wrapPromiseMethod(_runtime.globalScope, 'fetch', prefix);
53
53
  ee.on(prefix + 'end', function (err, res) {
54
54
  var ctx = this;
55
55
  if (res) {
@@ -7,7 +7,7 @@ exports.scopedEE = scopedEE;
7
7
  exports.wrapHistory = wrapHistory;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
9
  var _wrapFunction = require("./wrap-function");
10
- var _globalScope = require("../util/global-scope");
10
+ var _runtime = require("../constants/runtime");
11
11
  /*
12
12
  * Copyright 2020 New Relic Corporation. All rights reserved.
13
13
  * SPDX-License-Identifier: Apache-2.0
@@ -32,7 +32,7 @@ function wrapHistory(sharedEE) {
32
32
  // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
33
33
  // then we increment the count to track # of feats using this at runtime. History API is only
34
34
  // available in browser DOM context.
35
- if (!_globalScope.isBrowserScope || wrapped[ee.debugId]++) return ee;
35
+ if (!_runtime.isBrowserScope || wrapped[ee.debugId]++) return ee;
36
36
  wrapped[ee.debugId] = 1; // otherwise, first feature to wrap history
37
37
 
38
38
  var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
@@ -8,7 +8,7 @@ exports.wrapJsonP = wrapJsonP;
8
8
  var _eventListenerOpts = require("../event-listener/event-listener-opts");
9
9
  var _contextualEe = require("../event-emitter/contextual-ee");
10
10
  var _wrapFunction = require("./wrap-function");
11
- var _globalScope = require("../util/global-scope");
11
+ var _runtime = require("../constants/runtime");
12
12
  /*
13
13
  * Copyright 2020 New Relic Corporation. All rights reserved.
14
14
  * SPDX-License-Identifier: Apache-2.0
@@ -33,7 +33,7 @@ function wrapJsonP(sharedEE) {
33
33
  // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
34
34
  // then we increment the count to track # of feats using this at runtime. JSONP deals with DOM
35
35
  // tags so browser window env is required.
36
- if (!_globalScope.isBrowserScope || wrapped[ee.debugId]) return ee;
36
+ if (!_runtime.isBrowserScope || wrapped[ee.debugId]) return ee;
37
37
  wrapped[ee.debugId] = true; // otherwise, first feature to wrap JSONP
38
38
 
39
39
  var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
@@ -93,13 +93,19 @@ function wrapJsonP(sharedEE) {
93
93
  var matches = src.match(CALLBACK_REGEX);
94
94
  return matches ? matches[1] : null;
95
95
  }
96
+
97
+ /**
98
+ * Traverse a nested object using a '.'-delimited string wherein each substring piece maps to each subsequent object property layer.
99
+ * @param {string} longKey
100
+ * @param {object} obj
101
+ * @returns The final nested object referred to by initial longKey.
102
+ */
96
103
  function discoverValue(longKey, obj) {
97
- var matches = longKey.match(VALUE_REGEX);
98
- var key = matches[1];
99
- var remaining = matches[3];
100
- if (!remaining) {
101
- return obj[key];
102
- }
104
+ if (!longKey) return obj; // end of object recursion depth when no more key levels
105
+ const matches = longKey.match(VALUE_REGEX);
106
+ // if 'longKey' was not undefined, that is it at least had 1 level left, then the regexp would've at least matched 1st group
107
+ const key = matches[1];
108
+ const remaining = matches[3];
103
109
  return discoverValue(remaining, obj[key]);
104
110
  }
105
111
  function discoverParent(key) {
@@ -8,7 +8,7 @@ exports.wrapMutation = wrapMutation;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
9
  var _wrapFunction = require("./wrap-function");
10
10
  var _config = require("../config/config");
11
- var _globalScope = require("../util/global-scope");
11
+ var _runtime = require("../constants/runtime");
12
12
  /*
13
13
  * Copyright 2020 New Relic Corporation. All rights reserved.
14
14
  * SPDX-License-Identifier: Apache-2.0
@@ -32,7 +32,7 @@ function wrapMutation(sharedEE) {
32
32
  // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
33
33
  // then we increment the count to track # of feats using this at runtime. Mutations API is only
34
34
  // available in browser DOM context.
35
- if (!_globalScope.isBrowserScope || wrapped[ee.debugId]) return ee;
35
+ if (!_runtime.isBrowserScope || wrapped[ee.debugId]) return ee;
36
36
  wrapped[ee.debugId] = true; // otherwise, first feature to wrap mutations
37
37
 
38
38
  var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
@@ -8,7 +8,7 @@ exports.wrapPromise = wrapPromise;
8
8
  var _wrapFunction = require("./wrap-function");
9
9
  var _contextualEe = require("../event-emitter/contextual-ee");
10
10
  var _config = require("../config/config");
11
- var _globalScope = require("../util/global-scope");
11
+ var _runtime = require("../constants/runtime");
12
12
  /*
13
13
  * Copyright 2020 New Relic Corporation. All rights reserved.
14
14
  * SPDX-License-Identifier: Apache-2.0
@@ -43,7 +43,7 @@ function wrapPromise(sharedEE) {
43
43
  wrap();
44
44
  }
45
45
  function wrap() {
46
- _globalScope.globalScope.Promise = WrappedPromise;
46
+ _runtime.globalScope.Promise = WrappedPromise;
47
47
 
48
48
  // Renamed from "WrappedPromise" back to "Promise" & toString() so that we appear "native" to TP libraries...
49
49
  Object.defineProperty(WrappedPromise, 'name', {
@@ -7,7 +7,7 @@ exports.scopedEE = scopedEE;
7
7
  exports.wrapRaf = wrapRaf;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
9
  var _wrapFunction = require("./wrap-function");
10
- var _globalScope = require("../util/global-scope");
10
+ var _runtime = require("../constants/runtime");
11
11
  /*
12
12
  * Copyright 2020 New Relic Corporation. All rights reserved.
13
13
  * SPDX-License-Identifier: Apache-2.0
@@ -31,7 +31,7 @@ function wrapRaf(sharedEE) {
31
31
 
32
32
  // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
33
33
  // then we increment the count to track # of feats using this at runtime.
34
- if (!_globalScope.isBrowserScope || wrapped[ee.debugId]++) return ee;
34
+ if (!_runtime.isBrowserScope || wrapped[ee.debugId]++) return ee;
35
35
  wrapped[ee.debugId] = 1; // otherwise, first feature to wrap RAF
36
36
 
37
37
  var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
@@ -7,7 +7,7 @@ exports.scopedEE = scopedEE;
7
7
  exports.wrapTimer = wrapTimer;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
9
  var _wrapFunction = require("./wrap-function");
10
- var _globalScope = require("../util/global-scope");
10
+ var _runtime = require("../constants/runtime");
11
11
  /*
12
12
  * Copyright 2020 New Relic Corporation. All rights reserved.
13
13
  * SPDX-License-Identifier: Apache-2.0
@@ -42,9 +42,9 @@ function wrapTimer(sharedEE) {
42
42
  wrapped[ee.debugId] = 1; // otherwise, first feature to wrap timer
43
43
 
44
44
  var wrapFn = (0, _wrapFunction.createWrapperWithEmitter)(ee);
45
- wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(0, 2), SET_TIMEOUT + DASH);
46
- wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(2, 3), SET_INTERVAL + DASH);
47
- wrapFn.inPlace(_globalScope.globalScope, TIMER_FNS.slice(3), CLEAR_TIMEOUT + DASH);
45
+ wrapFn.inPlace(_runtime.globalScope, TIMER_FNS.slice(0, 2), SET_TIMEOUT + DASH);
46
+ wrapFn.inPlace(_runtime.globalScope, TIMER_FNS.slice(2, 3), SET_INTERVAL + DASH);
47
+ wrapFn.inPlace(_runtime.globalScope, TIMER_FNS.slice(3), CLEAR_TIMEOUT + DASH);
48
48
  ee.on(SET_INTERVAL + START, interval);
49
49
  ee.on(SET_TIMEOUT + START, timer);
50
50
  function interval(args, obj, type) {
@@ -10,7 +10,7 @@ var _contextualEe = require("../event-emitter/contextual-ee");
10
10
  var _eventListenerOpts = require("../event-listener/event-listener-opts");
11
11
  var _wrapFunction = require("./wrap-function");
12
12
  var _config = require("../config/config");
13
- var _globalScope = require("../util/global-scope");
13
+ var _runtime = require("../constants/runtime");
14
14
  var _console = require("../util/console");
15
15
  /*
16
16
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -49,8 +49,8 @@ function wrapXhr(sharedEE) {
49
49
  var READY_STATE_CHANGE = 'readystatechange';
50
50
  var handlers = ['onload', 'onerror', 'onabort', 'onloadstart', 'onloadend', 'onprogress', 'ontimeout'];
51
51
  var pendingXhrs = [];
52
- var activeListeners = _globalScope.globalScope.XMLHttpRequest.listeners;
53
- var XHR = _globalScope.globalScope.XMLHttpRequest = newXHR;
52
+ var activeListeners = _runtime.globalScope.XMLHttpRequest.listeners;
53
+ var XHR = _runtime.globalScope.XMLHttpRequest = newXHR;
54
54
  function newXHR(opts) {
55
55
  var xhr = new OrigXHR(opts);
56
56
  this.listeners = activeListeners ? [...activeListeners, intercept] : [intercept];
@@ -25,13 +25,22 @@ class Aggregate extends _aggregateBase.AggregateBase {
25
25
  static featureName = _constants.FEATURE_NAME;
26
26
  constructor(agentIdentifier, aggregator) {
27
27
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
28
+ const agentInit = (0, _config.getConfiguration)(agentIdentifier);
29
+ const allAjaxIsEnabled = agentInit.ajax.enabled !== false;
30
+ (0, _registerHandler.registerHandler)('xhr', storeXhr, this.featureName, this.ee);
31
+ if (!allAjaxIsEnabled) {
32
+ (0, _drain.drain)(this.agentIdentifier, this.featureName);
33
+ return; // feature will only collect timeslice metrics & ajax trace nodes if it's not fully enabled
34
+ }
35
+
36
+ const denyList = (0, _config.getRuntime)(agentIdentifier).denyList;
37
+ (0, _denyList.setDenyList)(denyList);
28
38
  let ajaxEvents = [];
29
39
  let spaAjaxEvents = {};
30
40
  let sentAjaxEvents = [];
31
- let scheduler;
32
41
  const ee = this.ee;
33
- const harvestTimeSeconds = (0, _config.getConfigurationValue)(agentIdentifier, 'ajax.harvestTimeSeconds') || 10;
34
- const MAX_PAYLOAD_SIZE = (0, _config.getConfigurationValue)(agentIdentifier, 'ajax.maxPayloadSize') || 1000000;
42
+ const harvestTimeSeconds = agentInit.ajax.harvestTimeSeconds || 10;
43
+ const MAX_PAYLOAD_SIZE = agentInit.ajax.maxPayloadSize || 1000000;
35
44
 
36
45
  // Exposes these methods to browser test files -- future TO DO: can be removed once these fns are extracted from the constructor into class func
37
46
  this.storeXhr = storeXhr;
@@ -48,24 +57,22 @@ class Aggregate extends _aggregateBase.AggregateBase {
48
57
  delete spaAjaxEvents[interaction.id];
49
58
  });
50
59
  ee.on('interactionDiscarded', interaction => {
51
- if (!spaAjaxEvents[interaction.id] || !allAjaxIsEnabled()) return;
60
+ if (!spaAjaxEvents[interaction.id]) return;
52
61
  spaAjaxEvents[interaction.id].forEach(function (item) {
53
62
  // move it from the spaAjaxEvents buffer to the ajaxEvents buffer for harvesting here
54
63
  ajaxEvents.push(item);
55
64
  });
56
65
  delete spaAjaxEvents[interaction.id];
57
66
  });
58
- if (allAjaxIsEnabled()) (0, _denyList.setDenyList)((0, _config.getConfigurationValue)(agentIdentifier, 'ajax.deny_list'));
59
- (0, _registerHandler.registerHandler)('xhr', storeXhr, this.featureName, this.ee);
60
- if (allAjaxIsEnabled()) {
61
- scheduler = new _harvestScheduler.HarvestScheduler('events', {
62
- onFinished: onEventsHarvestFinished,
63
- getPayload: prepareHarvest
64
- }, this);
65
- ee.on("drain-".concat(this.featureName), () => {
66
- scheduler.startTimer(harvestTimeSeconds);
67
- });
68
- }
67
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
68
+ onFinished: onEventsHarvestFinished,
69
+ getPayload: prepareHarvest
70
+ }, this);
71
+ ee.on("drain-".concat(this.featureName), () => {
72
+ scheduler.startTimer(harvestTimeSeconds);
73
+ });
74
+ (0, _drain.drain)(this.agentIdentifier, this.featureName);
75
+ return;
69
76
  function storeXhr(params, metrics, startTime, endTime, type) {
70
77
  metrics.time = startTime;
71
78
 
@@ -80,9 +87,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
80
87
 
81
88
  // store as metric
82
89
  aggregator.store('xhr', hash, params, metrics);
83
- if (!allAjaxIsEnabled()) {
84
- return;
85
- }
90
+ if (!allAjaxIsEnabled) return;
86
91
  if (!(0, _denyList.shouldCollectEvent)(params)) {
87
92
  if (params.hostname === (0, _config.getInfo)(agentIdentifier).errorBeacon) {
88
93
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
@@ -164,8 +169,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
164
169
  return tooBig ? getPayload(events, maxPayloadSize, ++chunks) : payload;
165
170
  }
166
171
  function onEventsHarvestFinished(result) {
167
- if (result.retry && sentAjaxEvents.length > 0 && allAjaxIsEnabled()) {
168
- ajaxEvents = ajaxEvents.concat(sentAjaxEvents);
172
+ if (result.retry && sentAjaxEvents.length > 0) {
173
+ ajaxEvents.unshift(...sentAjaxEvents);
169
174
  sentAjaxEvents = [];
170
175
  }
171
176
  }
@@ -213,14 +218,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
213
218
  return this.payload.length * 2 > maxPayloadSize;
214
219
  };
215
220
  }
216
- function allAjaxIsEnabled() {
217
- var enabled = (0, _config.getConfigurationValue)(agentIdentifier, 'ajax.enabled');
218
- if (enabled === false) {
219
- return false;
220
- }
221
- return true;
222
- }
223
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
224
221
  }
225
222
  }
226
223
  exports.Aggregate = Aggregate;
@@ -7,7 +7,7 @@ exports.DT = void 0;
7
7
  var _config = require("../../../common/config/config");
8
8
  var _uniqueId = require("../../../common/ids/unique-id");
9
9
  var _parseUrl = require("../../../common/url/parse-url");
10
- var _globalScope = require("../../../common/util/global-scope");
10
+ var _runtime = require("../../../common/constants/runtime");
11
11
  var _stringify = require("../../../common/util/stringify");
12
12
  /*
13
13
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -65,7 +65,7 @@ class DT {
65
65
  return trustKey + '@nr=' + version + '-' + parentType + '-' + accountId + '-' + appId + '-' + spanId + '-' + transactionId + '-' + sampled + '-' + priority + '-' + timestamp;
66
66
  }
67
67
  generateTraceHeader(spanId, traceId, timestamp, accountId, appId, trustKey) {
68
- var hasBtoa = typeof _globalScope.globalScope?.btoa === 'function';
68
+ var hasBtoa = typeof _runtime.globalScope?.btoa === 'function';
69
69
  if (!hasBtoa) {
70
70
  return null;
71
71
  }
@@ -7,7 +7,7 @@ exports.Instrument = void 0;
7
7
  var _config = require("../../../common/config/config");
8
8
  var _handle = require("../../../common/event-emitter/handle");
9
9
  var _id = require("../../../common/ids/id");
10
- var _firefoxVersion = require("../../../common/browser-version/firefox-version");
10
+ var _runtime = require("../../../common/constants/runtime");
11
11
  var _dataSize = require("../../../common/util/data-size");
12
12
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
13
13
  var _now = require("../../../common/timing/now");
@@ -18,7 +18,6 @@ var _responseSize = require("./response-size");
18
18
  var _instrumentBase = require("../../utils/instrument-base");
19
19
  var _constants = require("../constants");
20
20
  var _features = require("../../../loaders/features/features");
21
- var _globalScope = require("../../../common/util/global-scope");
22
21
  /*
23
22
  * Copyright 2020 New Relic Corporation. All rights reserved.
24
23
  * SPDX-License-Identifier: Apache-2.0
@@ -27,7 +26,7 @@ var _globalScope = require("../../../common/util/global-scope");
27
26
  var handlers = ['load', 'error', 'abort', 'timeout'];
28
27
  var handlersLen = handlers.length;
29
28
  var origRequest = _config.originals.REQ;
30
- var origXHR = _globalScope.globalScope.XMLHttpRequest;
29
+ var origXHR = _runtime.globalScope.XMLHttpRequest;
31
30
  class Instrument extends _instrumentBase.InstrumentBase {
32
31
  static featureName = _constants.FEATURE_NAME;
33
32
  constructor(agentIdentifier, aggregator) {
@@ -85,7 +84,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
85
84
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1227674
86
85
  //
87
86
  // So we don't use ProgressEvents to measure XHR sizes for FF.
88
- if (_firefoxVersion.ffVersion) return;
87
+ if (_runtime.ffVersion) return;
89
88
  xhr.addEventListener('progress', function (event) {
90
89
  ctx.lastSize = event.loaded;
91
90
  }, (0, _eventListenerOpts.eventListenerOpts)(false));
@@ -201,7 +200,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
201
200
  } else if (args[0] && args[0].url) {
202
201
  url = args[0].url;
203
202
  // argument is URL object
204
- } else if (_globalScope.globalScope?.URL && args[0] && args[0] instanceof URL) {
203
+ } else if (_runtime.globalScope?.URL && args[0] && args[0] instanceof URL) {
205
204
  url = args[0].href;
206
205
  }
207
206
  if (url) {
@@ -212,7 +211,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
212
211
  if (!payload || !payload.newrelicHeader && !payload.traceContextParentHeader) {
213
212
  return;
214
213
  }
215
- if (typeof args[0] === 'string' || _globalScope.globalScope?.URL && args[0] && args[0] instanceof URL) {
214
+ if (typeof args[0] === 'string' || _runtime.globalScope?.URL && args[0] && args[0] instanceof URL) {
216
215
  var clone = {};
217
216
  for (var key in opts) {
218
217
  clone[key] = opts[key];
@@ -261,7 +260,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
261
260
  url = target;
262
261
  } else if (typeof target === 'object' && target instanceof origRequest) {
263
262
  url = target.url;
264
- } else if (_globalScope.globalScope?.URL && typeof target === 'object' && target instanceof URL) {
263
+ } else if (_runtime.globalScope?.URL && typeof target === 'object' && target instanceof URL) {
265
264
  url = target.href;
266
265
  }
267
266
  addUrl(this, url);
@@ -229,7 +229,7 @@ function computeStackTraceBySourceAndLine(ex) {
229
229
  mode: 'sourceline',
230
230
  name: className,
231
231
  message: ex.message,
232
- stackString: getClassName(ex) + ': ' + ex.message + '\n in evaluated code',
232
+ stackString: className + ': ' + ex.message + '\n in evaluated code',
233
233
  frames: [{
234
234
  func: 'evaluated code'
235
235
  }]