@newrelic/browser-agent 1.235.0 → 1.236.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 (332) hide show
  1. package/README.md +41 -1
  2. package/dist/cjs/common/config/state/init.js +3 -0
  3. package/dist/cjs/common/config/state/runtime.js +4 -4
  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/event-listener/event-listener-opts.js +3 -3
  8. package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
  9. package/dist/cjs/common/harvest/harvest.js +163 -144
  10. package/dist/cjs/common/harvest/types.js +54 -0
  11. package/dist/cjs/common/ids/id.js +2 -2
  12. package/dist/cjs/common/ids/unique-id.js +3 -3
  13. package/dist/cjs/common/session/session-entity.js +2 -2
  14. package/dist/cjs/common/timer/interaction-timer.js +2 -2
  15. package/dist/cjs/common/unload/eol.js +10 -11
  16. package/dist/cjs/common/url/canonicalize-url.js +2 -2
  17. package/dist/cjs/common/url/parse-url.js +3 -3
  18. package/dist/cjs/common/url/protocol.js +2 -2
  19. package/dist/cjs/common/util/submit-data.js +58 -76
  20. package/dist/cjs/common/window/nreum.js +14 -14
  21. package/dist/cjs/common/wrap/wrap-events.js +3 -3
  22. package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
  23. package/dist/cjs/common/wrap/wrap-history.js +2 -2
  24. package/dist/cjs/common/wrap/wrap-jsonp.js +2 -2
  25. package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
  26. package/dist/cjs/common/wrap/wrap-promise.js +2 -2
  27. package/dist/cjs/common/wrap/wrap-raf.js +2 -2
  28. package/dist/cjs/common/wrap/wrap-timer.js +4 -4
  29. package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
  30. package/dist/cjs/features/ajax/aggregate/index.js +1 -1
  31. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
  32. package/dist/cjs/features/ajax/instrument/index.js +6 -7
  33. package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
  34. package/dist/cjs/features/jserrors/instrument/index.js +4 -4
  35. package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
  36. package/dist/cjs/features/metrics/aggregate/index.js +3 -3
  37. package/dist/cjs/features/page_action/aggregate/index.js +3 -3
  38. package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
  39. package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
  40. package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
  41. package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
  42. package/dist/cjs/features/session_replay/replay-mode.js +2 -2
  43. package/dist/cjs/features/session_trace/instrument/index.js +2 -2
  44. package/dist/cjs/features/spa/aggregate/index.js +1 -1
  45. package/dist/cjs/features/spa/instrument/index.js +2 -2
  46. package/dist/cjs/features/utils/instrument-base.js +6 -7
  47. package/dist/cjs/index.js +7 -0
  48. package/dist/cjs/loaders/agent.js +7 -0
  49. package/dist/cjs/loaders/api/api.js +2 -2
  50. package/dist/cjs/loaders/api/apiAsync.js +6 -4
  51. package/dist/cjs/loaders/configure/configure.js +2 -2
  52. package/dist/cjs/loaders/micro-agent.js +29 -38
  53. package/dist/esm/common/config/state/init.js +3 -0
  54. package/dist/esm/common/config/state/runtime.js +1 -1
  55. package/dist/esm/common/constants/env.cdn.js +2 -2
  56. package/dist/esm/common/constants/env.npm.js +1 -1
  57. package/dist/esm/common/constants/runtime.js +38 -0
  58. package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
  59. package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
  60. package/dist/esm/common/harvest/harvest.js +160 -142
  61. package/dist/esm/common/harvest/types.js +47 -0
  62. package/dist/esm/common/ids/id.js +1 -1
  63. package/dist/esm/common/ids/unique-id.js +1 -1
  64. package/dist/esm/common/session/session-entity.js +1 -1
  65. package/dist/esm/common/timer/interaction-timer.js +1 -1
  66. package/dist/esm/common/unload/eol.js +1 -2
  67. package/dist/esm/common/url/canonicalize-url.js +1 -1
  68. package/dist/esm/common/url/parse-url.js +1 -1
  69. package/dist/esm/common/url/protocol.js +1 -1
  70. package/dist/esm/common/util/submit-data.js +55 -73
  71. package/dist/esm/common/window/nreum.js +1 -1
  72. package/dist/esm/common/wrap/wrap-events.js +1 -1
  73. package/dist/esm/common/wrap/wrap-fetch.js +1 -1
  74. package/dist/esm/common/wrap/wrap-history.js +1 -1
  75. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  76. package/dist/esm/common/wrap/wrap-mutation.js +1 -1
  77. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  78. package/dist/esm/common/wrap/wrap-raf.js +1 -1
  79. package/dist/esm/common/wrap/wrap-timer.js +1 -1
  80. package/dist/esm/common/wrap/wrap-xhr.js +1 -1
  81. package/dist/esm/features/ajax/aggregate/index.js +1 -1
  82. package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
  83. package/dist/esm/features/ajax/instrument/index.js +1 -2
  84. package/dist/esm/features/jserrors/aggregate/index.js +6 -3
  85. package/dist/esm/features/jserrors/instrument/index.js +1 -1
  86. package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
  87. package/dist/esm/features/metrics/aggregate/index.js +1 -1
  88. package/dist/esm/features/page_action/aggregate/index.js +1 -1
  89. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  90. package/dist/esm/features/page_view_event/instrument/index.js +1 -1
  91. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
  92. package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
  93. package/dist/esm/features/session_replay/replay-mode.js +2 -2
  94. package/dist/esm/features/session_trace/instrument/index.js +1 -1
  95. package/dist/esm/features/spa/aggregate/index.js +1 -1
  96. package/dist/esm/features/spa/instrument/index.js +1 -1
  97. package/dist/esm/features/utils/instrument-base.js +4 -5
  98. package/dist/esm/index.js +1 -4
  99. package/dist/esm/loaders/agent.js +7 -0
  100. package/dist/esm/loaders/api/api.js +1 -1
  101. package/dist/esm/loaders/api/apiAsync.js +3 -3
  102. package/dist/esm/loaders/configure/configure.js +1 -1
  103. package/dist/esm/loaders/micro-agent.js +29 -38
  104. package/dist/types/common/config/state/init.d.ts.map +1 -1
  105. package/dist/types/common/constants/runtime.d.ts +29 -0
  106. package/dist/types/common/constants/runtime.d.ts.map +1 -0
  107. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
  108. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest.d.ts +49 -38
  110. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  111. package/dist/types/common/harvest/types.d.ts +100 -0
  112. package/dist/types/common/harvest/types.d.ts.map +1 -0
  113. package/dist/types/common/unload/eol.d.ts.map +1 -1
  114. package/dist/types/common/util/submit-data.d.ts +62 -64
  115. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  116. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  117. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  118. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  119. package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
  120. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  121. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  122. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  123. package/dist/types/index.d.ts +1 -0
  124. package/dist/types/loaders/agent.d.ts +4 -4
  125. package/dist/types/loaders/agent.d.ts.map +1 -1
  126. package/dist/types/loaders/micro-agent.d.ts +3 -4
  127. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  128. package/package.json +6 -1
  129. package/src/common/config/__mocks__/config.js +11 -0
  130. package/src/common/config/state/init.js +1 -0
  131. package/src/common/config/state/runtime.js +1 -1
  132. package/src/common/constants/__mocks__/env.js +3 -0
  133. package/src/common/constants/__mocks__/runtime.js +8 -0
  134. package/src/common/constants/env.cdn.test.js +7 -0
  135. package/src/common/constants/env.npm.test.js +7 -0
  136. package/src/common/constants/env.test.js +7 -0
  137. package/src/common/constants/runtime.js +71 -0
  138. package/src/common/constants/runtime.test.js +168 -0
  139. package/src/common/context/__mocks__/shared-context.js +8 -0
  140. package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
  141. package/src/common/event-listener/event-listener-opts.js +1 -1
  142. package/src/common/harvest/__mocks__/harvest.js +13 -0
  143. package/src/common/harvest/harvest-scheduler.js +21 -20
  144. package/src/common/harvest/harvest-scheduler.test.js +496 -0
  145. package/src/common/harvest/harvest.js +147 -130
  146. package/src/common/harvest/harvest.test.js +818 -0
  147. package/src/common/harvest/types.js +47 -0
  148. package/src/common/ids/id.js +1 -1
  149. package/src/common/ids/unique-id.js +1 -1
  150. package/src/common/session/__mocks__/session-entity.js +25 -0
  151. package/src/common/session/session-entity.component-test.js +1 -1
  152. package/src/common/session/session-entity.js +1 -1
  153. package/src/common/timer/interaction-timer.js +1 -1
  154. package/src/common/timing/__mocks__/now.js +1 -0
  155. package/src/common/unload/__mocks__/eol.js +1 -0
  156. package/src/common/unload/eol.js +1 -2
  157. package/src/common/url/__mocks__/clean-url.js +1 -0
  158. package/src/common/url/__mocks__/encode.js +7 -0
  159. package/src/common/url/__mocks__/location.js +1 -0
  160. package/src/common/url/canonicalize-url.js +1 -1
  161. package/src/common/url/canonicalize-url.test.js +2 -2
  162. package/src/common/url/parse-url.js +1 -1
  163. package/src/common/url/parse-url.test.js +3 -3
  164. package/src/common/url/protocol.js +1 -1
  165. package/src/common/util/__mocks__/obfuscate.js +10 -0
  166. package/src/common/util/__mocks__/stringify.js +1 -0
  167. package/src/common/util/__mocks__/submit-data.js +6 -0
  168. package/src/common/util/__mocks__/traverse.js +1 -0
  169. package/src/common/util/submit-data.js +39 -53
  170. package/src/common/util/submit-data.test.js +81 -68
  171. package/src/common/window/nreum.js +1 -1
  172. package/src/common/wrap/wrap-events.js +1 -1
  173. package/src/common/wrap/wrap-fetch.js +1 -1
  174. package/src/common/wrap/wrap-history.js +1 -1
  175. package/src/common/wrap/wrap-jsonp.js +1 -1
  176. package/src/common/wrap/wrap-mutation.js +1 -1
  177. package/src/common/wrap/wrap-promise.js +1 -1
  178. package/src/common/wrap/wrap-promise.test.js +2 -2
  179. package/src/common/wrap/wrap-raf.js +1 -1
  180. package/src/common/wrap/wrap-timer.js +1 -1
  181. package/src/common/wrap/wrap-xhr.js +1 -1
  182. package/src/features/ajax/aggregate/index.js +1 -1
  183. package/src/features/ajax/instrument/distributed-tracing.js +1 -1
  184. package/src/features/ajax/instrument/index.js +1 -2
  185. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  186. package/src/features/jserrors/aggregate/index.js +7 -3
  187. package/src/features/jserrors/instrument/index.js +1 -1
  188. package/src/features/metrics/aggregate/framework-detection.js +1 -1
  189. package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
  190. package/src/features/metrics/aggregate/index.js +1 -1
  191. package/src/features/page_action/aggregate/index.js +1 -1
  192. package/src/features/page_view_event/aggregate/index.js +1 -2
  193. package/src/features/page_view_event/instrument/index.js +1 -1
  194. package/src/features/page_view_timing/aggregate/index.js +2 -4
  195. package/src/features/page_view_timing/instrument/index.js +1 -1
  196. package/src/features/session_replay/replay-mode.js +2 -2
  197. package/src/features/session_trace/instrument/index.js +1 -1
  198. package/src/features/spa/aggregate/index.js +1 -1
  199. package/src/features/spa/instrument/index.js +1 -1
  200. package/src/features/utils/agent-session.test.js +2 -2
  201. package/src/features/utils/instrument-base.js +5 -5
  202. package/src/features/utils/instrument-base.test.js +22 -3
  203. package/src/index.js +1 -3
  204. package/src/loaders/agent.js +8 -0
  205. package/src/loaders/api/api.js +1 -1
  206. package/src/loaders/api/apiAsync.js +3 -3
  207. package/src/loaders/configure/configure.js +1 -1
  208. package/src/loaders/micro-agent.js +26 -30
  209. package/dist/cjs/common/browser-version/firefox-version.js +0 -17
  210. package/dist/cjs/common/browser-version/ios-version.js +0 -19
  211. package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
  212. package/dist/cjs/common/event-emitter/handle.test.js +0 -58
  213. package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
  214. package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
  215. package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
  216. package/dist/cjs/common/ids/id.test.js +0 -85
  217. package/dist/cjs/common/ids/unique-id.test.js +0 -49
  218. package/dist/cjs/common/session/session-entity.component-test.js +0 -497
  219. package/dist/cjs/common/storage/local-storage.test.js +0 -14
  220. package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
  221. package/dist/cjs/common/timer/timer.test.js +0 -105
  222. package/dist/cjs/common/timing/nav-timing.test.js +0 -192
  223. package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
  224. package/dist/cjs/common/url/clean-url.test.js +0 -9
  225. package/dist/cjs/common/url/encode.component-test.js +0 -74
  226. package/dist/cjs/common/url/location.test.js +0 -13
  227. package/dist/cjs/common/url/parse-url.test.js +0 -111
  228. package/dist/cjs/common/url/protocol.component-test.js +0 -15
  229. package/dist/cjs/common/util/console.test.js +0 -30
  230. package/dist/cjs/common/util/data-size.test.js +0 -64
  231. package/dist/cjs/common/util/feature-flags.test.js +0 -84
  232. package/dist/cjs/common/util/get-or-set.test.js +0 -47
  233. package/dist/cjs/common/util/global-scope.js +0 -27
  234. package/dist/cjs/common/util/global-scope.test.js +0 -72
  235. package/dist/cjs/common/util/invoke.test.js +0 -49
  236. package/dist/cjs/common/util/map-own.test.js +0 -49
  237. package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
  238. package/dist/cjs/common/util/stringify.test.js +0 -48
  239. package/dist/cjs/common/util/submit-data.test.js +0 -245
  240. package/dist/cjs/common/util/traverse.test.js +0 -44
  241. package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
  242. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
  243. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
  244. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
  245. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
  246. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
  247. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
  248. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
  249. package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
  250. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
  251. package/dist/cjs/features/utils/agent-session.test.js +0 -211
  252. package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
  253. package/dist/cjs/features/utils/feature-base.test.js +0 -42
  254. package/dist/cjs/features/utils/handler-cache.test.js +0 -53
  255. package/dist/cjs/features/utils/instrument-base.test.js +0 -179
  256. package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
  257. package/dist/esm/common/browser-version/firefox-version.js +0 -10
  258. package/dist/esm/common/browser-version/ios-version.js +0 -11
  259. package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
  260. package/dist/esm/common/event-emitter/handle.test.js +0 -54
  261. package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
  262. package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
  263. package/dist/esm/common/harvest/harvest.component-test.js +0 -222
  264. package/dist/esm/common/ids/id.test.js +0 -81
  265. package/dist/esm/common/ids/unique-id.test.js +0 -44
  266. package/dist/esm/common/session/session-entity.component-test.js +0 -495
  267. package/dist/esm/common/storage/local-storage.test.js +0 -12
  268. package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
  269. package/dist/esm/common/timer/timer.test.js +0 -103
  270. package/dist/esm/common/timing/nav-timing.test.js +0 -190
  271. package/dist/esm/common/url/canonicalize-url.test.js +0 -34
  272. package/dist/esm/common/url/clean-url.test.js +0 -7
  273. package/dist/esm/common/url/encode.component-test.js +0 -70
  274. package/dist/esm/common/url/location.test.js +0 -11
  275. package/dist/esm/common/url/parse-url.test.js +0 -107
  276. package/dist/esm/common/url/protocol.component-test.js +0 -13
  277. package/dist/esm/common/util/console.test.js +0 -28
  278. package/dist/esm/common/util/data-size.test.js +0 -60
  279. package/dist/esm/common/util/feature-flags.test.js +0 -80
  280. package/dist/esm/common/util/get-or-set.test.js +0 -45
  281. package/dist/esm/common/util/global-scope.js +0 -17
  282. package/dist/esm/common/util/global-scope.test.js +0 -70
  283. package/dist/esm/common/util/invoke.test.js +0 -47
  284. package/dist/esm/common/util/map-own.test.js +0 -47
  285. package/dist/esm/common/util/obfuscate.component-test.js +0 -125
  286. package/dist/esm/common/util/stringify.test.js +0 -46
  287. package/dist/esm/common/util/submit-data.test.js +0 -241
  288. package/dist/esm/common/util/traverse.test.js +0 -42
  289. package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
  290. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
  291. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
  292. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
  293. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
  294. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
  295. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
  296. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
  297. package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
  298. package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
  299. package/dist/esm/features/utils/agent-session.test.js +0 -207
  300. package/dist/esm/features/utils/aggregate-base.test.js +0 -108
  301. package/dist/esm/features/utils/feature-base.test.js +0 -40
  302. package/dist/esm/features/utils/handler-cache.test.js +0 -51
  303. package/dist/esm/features/utils/instrument-base.test.js +0 -175
  304. package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
  305. package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
  306. package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
  307. package/dist/types/common/browser-version/ios-version.d.ts +0 -3
  308. package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
  309. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
  310. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
  311. package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
  312. package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
  313. package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
  314. package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
  315. package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
  316. package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
  317. package/dist/types/common/url/encode.component-test.d.ts +0 -2
  318. package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
  319. package/dist/types/common/url/protocol.component-test.d.ts +0 -2
  320. package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
  321. package/dist/types/common/util/global-scope.d.ts +0 -5
  322. package/dist/types/common/util/global-scope.d.ts.map +0 -1
  323. package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
  324. package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
  325. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
  326. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
  327. package/src/common/browser-version/firefox-version.js +0 -10
  328. package/src/common/browser-version/ios-version.js +0 -11
  329. package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
  330. package/src/common/harvest/harvest.component-test.js +0 -169
  331. package/src/common/util/global-scope.js +0 -23
  332. package/src/common/util/global-scope.test.js +0 -87
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parseUrl = parseUrl;
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
@@ -23,9 +23,9 @@ function parseUrl(url) {
23
23
  };
24
24
  }
25
25
  let urlEl;
26
- var location = _globalScope.globalScope?.location;
26
+ var location = _runtime.globalScope?.location;
27
27
  var ret = {};
28
- if (_globalScope.isBrowserScope) {
28
+ if (_runtime.isBrowserScope) {
29
29
  // Use an anchor dom element to resolve the url natively.
30
30
  urlEl = document.createElement('a');
31
31
  urlEl.href = url;
@@ -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,38 @@
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.fetchKeepAlive = fetchKeepAlive;
8
+ exports.getSubmitMethod = getSubmitMethod;
9
+ exports.xhr = xhr;
10
+ var _runtime = require("../constants/runtime");
11
+ /**
12
+ * @file Contains common methods used to transmit harvested data.
13
+ * @copyright 2023 New Relic Corporation. All rights reserved.
14
+ * @license Apache-2.0
11
15
  */
12
16
 
13
- const submitData = {};
14
-
15
17
  /**
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}
18
+ * @typedef {xhr|fetchKeepAlive|beacon} NetworkMethods
22
19
  */
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
20
 
54
21
  /**
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.
22
+ * Determines the submit method to use based on options.
23
+ * @param {object} opts Options used to determine submit method.
24
+ * @param {boolean} opts.isFinalHarvest Indicates if the data submission is due to
25
+ * a final harvest within the agent.
60
26
  */
61
- submitData.xhrGet = function xhrGet(_ref2) {
27
+ function getSubmitMethod() {
62
28
  let {
63
- url
64
- } = _ref2;
65
- return submitData.xhr({
66
- url,
67
- sync: false,
68
- method: 'GET'
69
- });
70
- };
29
+ isFinalHarvest = false
30
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
+ return isFinalHarvest && _runtime.isBrowserScope && _runtime.supportsSendBeacon
32
+ // Use sendBeacon for final harvest
33
+ ? beacon
34
+ // Only IE does not support sendBeacon for final harvest
35
+ // If not final harvest, or not browserScope, always use xhr post
36
+ : xhr;
37
+ }
71
38
 
72
39
  /**
73
40
  * Send via XHR
@@ -79,7 +46,7 @@ submitData.xhrGet = function xhrGet(_ref2) {
79
46
  * @param {{key: string, value: string}[]} [args.headers] - The headers to attach.
80
47
  * @returns {XMLHttpRequest}
81
48
  */
82
- submitData.xhr = function xhr(_ref3) {
49
+ function xhr(_ref) {
83
50
  let {
84
51
  url,
85
52
  body = null,
@@ -89,8 +56,8 @@ submitData.xhr = function xhr(_ref3) {
89
56
  key: 'content-type',
90
57
  value: 'text/plain'
91
58
  }]
92
- } = _ref3;
93
- var request = new XMLHttpRequest();
59
+ } = _ref;
60
+ const request = new XMLHttpRequest();
94
61
  request.open(method, url, !sync);
95
62
  try {
96
63
  // Set cookie
@@ -103,22 +70,37 @@ submitData.xhr = function xhr(_ref3) {
103
70
  });
104
71
  request.send(body);
105
72
  return request;
106
- };
73
+ }
107
74
 
108
75
  /**
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}
76
+ * Send via fetch with keepalive true
77
+ * @param {Object} args - The args.
78
+ * @param {string} args.url - The URL to send to.
79
+ * @param {string=} args.body - The Stringified body.
80
+ * @param {string=} [args.method=POST] - The XHR method to use.
81
+ * @param {{key: string, value: string}[]} [args.headers] - The headers to attach.
82
+ * @returns {XMLHttpRequest}
113
83
  */
114
- submitData.img = function img(_ref4) {
84
+ function fetchKeepAlive(_ref2) {
115
85
  let {
116
- url
117
- } = _ref4;
118
- var element = new Image();
119
- element.src = url;
120
- return element;
121
- };
86
+ url,
87
+ body = null,
88
+ method = 'POST',
89
+ headers = [{
90
+ key: 'content-type',
91
+ value: 'text/plain'
92
+ }]
93
+ } = _ref2;
94
+ return fetch(url, {
95
+ method,
96
+ headers: headers.reduce((aggregator, header) => {
97
+ aggregator.push([header.key, header.value]);
98
+ return aggregator;
99
+ }, []),
100
+ body,
101
+ keepalive: true
102
+ });
103
+ }
122
104
 
123
105
  /**
124
106
  * Send via sendBeacon. Do NOT call this function outside of a guaranteed web window environment.
@@ -127,11 +109,11 @@ submitData.img = function img(_ref4) {
127
109
  * @param {string=} args.body - The Stringified body
128
110
  * @returns {boolean}
129
111
  */
130
- submitData.beacon = function (_ref5) {
112
+ function beacon(_ref3) {
131
113
  let {
132
114
  url,
133
115
  body
134
- } = _ref5;
116
+ } = _ref3;
135
117
  try {
136
118
  // Navigator has to be bound to ensure it does not error in some browsers
137
119
  // https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
@@ -140,7 +122,7 @@ submitData.beacon = function (_ref5) {
140
122
  } catch (err) {
141
123
  // if sendBeacon still trys to throw an illegal invocation error,
142
124
  // we can catch here and return. The harvest module will fallback to use
143
- // .img to try to send
125
+ // fetchKeepAlive to try to send
144
126
  return false;
145
127
  }
146
- };
128
+ }
@@ -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);
@@ -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];
@@ -165,7 +165,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
165
165
  }
166
166
  function onEventsHarvestFinished(result) {
167
167
  if (result.retry && sentAjaxEvents.length > 0 && allAjaxIsEnabled()) {
168
- ajaxEvents = ajaxEvents.concat(sentAjaxEvents);
168
+ ajaxEvents.unshift(...sentAjaxEvents);
169
169
  sentAjaxEvents = [];
170
170
  }
171
171
  }
@@ -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);
@@ -15,7 +15,7 @@ var _handle = require("../../../common/event-emitter/handle");
15
15
  var _mapOwn = require("../../../common/util/map-own");
16
16
  var _config = require("../../../common/config/config");
17
17
  var _now = require("../../../common/timing/now");
18
- var _globalScope = require("../../../common/util/global-scope");
18
+ var _runtime = require("../../../common/constants/runtime");
19
19
  var _constants = require("../constants");
20
20
  var _drain = require("../../../common/drain/drain");
21
21
  var _features = require("../../../loaders/features/features");
@@ -100,7 +100,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
100
100
  (0, _mapOwn.mapOwn)(this.currentBody, (key, value) => {
101
101
  for (var i = 0; i < value.length; i++) {
102
102
  var bucket = value[i];
103
- var name = this.getBucketName(bucket.params, bucket.custom);
103
+ var name = this.getBucketName(key, bucket.params, bucket.custom);
104
104
  this.aggregator.merge(key, name, bucket.metrics, bucket.params, bucket.custom);
105
105
  }
106
106
  });
@@ -110,7 +110,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
110
110
  nameHash(params) {
111
111
  return (0, _stringHashCode.stringHashCode)("".concat(params.exceptionClass, "_").concat(params.message, "_").concat(params.stack_trace || params.browser_stack_hash));
112
112
  }
113
- getBucketName(params, customParams) {
113
+ getBucketName(objType, params, customParams) {
114
+ if (objType === 'xhr') {
115
+ return (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(params)) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
116
+ }
114
117
  return this.nameHash(params) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
115
118
  }
116
119
 
@@ -153,7 +156,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
153
156
  const params = {
154
157
  stackHash: (0, _stringHashCode.stringHashCode)(canonicalStackString),
155
158
  exceptionClass: stackInfo.name,
156
- request_uri: _globalScope.globalScope?.location.pathname
159
+ request_uri: _runtime.globalScope?.location.pathname
157
160
  };
158
161
  if (stackInfo.message) params.message = '' + stackInfo.message;
159
162
  // Notice if filterOutput isn't false|undefined OR our specified object, this func would've returned already (so it's unnecessary to req-check group).
@@ -12,7 +12,7 @@ require("./debug");
12
12
  var _instrumentBase = require("../../utils/instrument-base");
13
13
  var _constants = require("../constants");
14
14
  var _features = require("../../../loaders/features/features");
15
- var _globalScope = require("../../../common/util/global-scope");
15
+ var _runtime = require("../../../common/constants/runtime");
16
16
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
17
17
  var _config = require("../../../common/config/config");
18
18
  var _stringify = require("../../../common/util/stringify");
@@ -55,9 +55,9 @@ class Instrument extends _instrumentBase.InstrumentBase {
55
55
  });
56
56
 
57
57
  // Replace global error handler with our own.
58
- this.origOnerror = _globalScope.globalScope.onerror;
59
- _globalScope.globalScope.onerror = this.onerrorHandler.bind(this);
60
- _globalScope.globalScope.addEventListener('unhandledrejection', e => {
58
+ this.origOnerror = _runtime.globalScope.onerror;
59
+ _runtime.globalScope.onerror = this.onerrorHandler.bind(this);
60
+ _runtime.globalScope.addEventListener('unhandledrejection', e => {
61
61
  /** rejections can contain data of any type -- this is an effort to keep the message human readable */
62
62
  const err = castReasonToError(e.reason);
63
63
  (0, _handle.handle)('err', [err, (0, _now.now)(), false, {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getFrameworks = getFrameworks;
7
- var _globalScope = require("../../../common/util/global-scope");
7
+ var _runtime = require("../../../common/constants/runtime");
8
8
  const FRAMEWORKS = {
9
9
  REACT: 'React',
10
10
  ANGULAR: 'Angular',
@@ -18,7 +18,7 @@ const FRAMEWORKS = {
18
18
  MOOTOOLS: 'MooTools'
19
19
  };
20
20
  function getFrameworks() {
21
- if (!_globalScope.isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
21
+ if (!_runtime.isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
22
22
 
23
23
  const frameworks = [];
24
24
  try {