@newrelic/browser-agent 0.1.230 → 1.232.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 (365) hide show
  1. package/README.md +27 -3
  2. package/dist/cjs/common/browser-version/ios-version.js +4 -3
  3. package/dist/cjs/common/config/state/configurable.js +27 -21
  4. package/dist/cjs/common/config/state/info.js +1 -1
  5. package/dist/cjs/common/config/state/init.js +9 -1
  6. package/dist/cjs/common/config/state/loader-config.js +1 -1
  7. package/dist/cjs/common/config/state/runtime.js +26 -28
  8. package/dist/cjs/common/constants/env.cdn.js +29 -0
  9. package/dist/cjs/common/constants/env.js +32 -0
  10. package/dist/cjs/common/constants/env.npm.js +30 -0
  11. package/dist/cjs/common/context/shared-context.js +2 -1
  12. package/dist/cjs/common/event-emitter/contextual-ee.test.js +282 -0
  13. package/dist/cjs/common/event-emitter/handle.test.js +58 -0
  14. package/dist/cjs/common/event-emitter/register-handler.test.js +55 -0
  15. package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
  16. package/dist/cjs/common/harvest/harvest-scheduler.js +14 -11
  17. package/dist/cjs/common/harvest/harvest.js +5 -3
  18. package/dist/cjs/common/ids/id.js +14 -6
  19. package/dist/cjs/common/ids/id.test.js +85 -0
  20. package/dist/cjs/common/ids/unique-id.js +75 -51
  21. package/dist/cjs/common/ids/unique-id.test.js +49 -0
  22. package/dist/cjs/common/session/constants.js +12 -0
  23. package/dist/cjs/common/session/session-entity.js +278 -0
  24. package/dist/cjs/common/session/session-entity.test.js +436 -0
  25. package/dist/cjs/common/storage/first-party-cookies.js +35 -0
  26. package/dist/cjs/common/storage/local-memory.js +35 -0
  27. package/dist/cjs/common/storage/local-memory.test.js +20 -0
  28. package/dist/cjs/common/storage/local-storage.js +33 -0
  29. package/dist/cjs/common/storage/local-storage.test.js +14 -0
  30. package/dist/cjs/common/timer/interaction-timer.js +78 -0
  31. package/dist/cjs/common/timer/interaction-timer.test.js +216 -0
  32. package/dist/cjs/common/timer/timer.js +32 -0
  33. package/dist/cjs/common/timer/timer.test.js +105 -0
  34. package/dist/cjs/common/timing/nav-timing.js +51 -30
  35. package/dist/cjs/common/timing/nav-timing.test.js +192 -0
  36. package/dist/cjs/common/unload/eol.js +2 -2
  37. package/dist/cjs/common/url/clean-url.test.js +9 -0
  38. package/dist/cjs/common/url/encode.test.js +74 -0
  39. package/dist/cjs/common/url/location.js +4 -0
  40. package/dist/cjs/common/url/location.test.js +13 -0
  41. package/dist/cjs/common/url/parse-url.test.js +111 -0
  42. package/dist/cjs/common/url/protocol.js +2 -12
  43. package/dist/cjs/common/url/protocol.test.js +16 -0
  44. package/dist/cjs/common/util/console.js +1 -1
  45. package/dist/cjs/common/util/data-size.js +6 -0
  46. package/dist/cjs/common/util/data-size.test.js +47 -0
  47. package/dist/cjs/common/util/invoke.js +73 -0
  48. package/dist/cjs/common/util/invoke.test.js +49 -0
  49. package/dist/cjs/common/util/map-own.test.js +3 -3
  50. package/dist/cjs/common/util/obfuscate.js +1 -5
  51. package/dist/cjs/common/window/page-visibility.js +5 -2
  52. package/dist/cjs/common/wrap/index.js +0 -7
  53. package/dist/cjs/common/wrap/wrap-events.js +6 -9
  54. package/dist/cjs/common/wrap/wrap-fetch.js +6 -6
  55. package/dist/cjs/common/wrap/wrap-history.js +7 -6
  56. package/dist/cjs/common/wrap/wrap-jsonp.js +7 -6
  57. package/dist/cjs/common/wrap/wrap-mutation.js +7 -6
  58. package/dist/cjs/common/wrap/wrap-promise.js +7 -6
  59. package/dist/cjs/common/wrap/wrap-promise.test.js +119 -0
  60. package/dist/cjs/common/wrap/wrap-raf.js +6 -6
  61. package/dist/cjs/common/wrap/wrap-timer.js +7 -7
  62. package/dist/cjs/common/wrap/wrap-xhr.js +5 -6
  63. package/dist/cjs/features/ajax/aggregate/index.js +3 -3
  64. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
  65. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
  66. package/dist/cjs/features/jserrors/aggregate/index.js +6 -6
  67. package/dist/cjs/features/jserrors/instrument/index.js +2 -2
  68. package/dist/cjs/features/metrics/aggregate/index.js +19 -9
  69. package/dist/cjs/features/metrics/instrument/index.js +0 -25
  70. package/dist/cjs/features/metrics/instrument/workers-helper.js +5 -5
  71. package/dist/cjs/features/page_action/aggregate/index.js +3 -3
  72. package/dist/cjs/features/page_view_event/aggregate/index.js +23 -9
  73. package/dist/cjs/features/page_view_timing/aggregate/index.js +40 -30
  74. package/dist/cjs/features/session_trace/aggregate/index.js +18 -15
  75. package/dist/cjs/features/spa/aggregate/index.js +6 -5
  76. package/dist/cjs/features/utils/agent-session.js +73 -0
  77. package/dist/cjs/features/utils/feature-base.js +1 -1
  78. package/dist/cjs/features/utils/instrument-base.js +12 -3
  79. package/dist/cjs/features/utils/lazy-loader.js +2 -2
  80. package/dist/cjs/loaders/agent.js +2 -2
  81. package/dist/cjs/loaders/api/api.js +9 -9
  82. package/dist/cjs/loaders/api/apiAsync.js +3 -2
  83. package/dist/cjs/loaders/configure/configure.js +0 -6
  84. package/dist/cjs/loaders/features/enabled-features.js +1 -1
  85. package/dist/cjs/loaders/micro-agent.js +2 -1
  86. package/dist/esm/common/browser-version/ios-version.js +4 -3
  87. package/dist/esm/common/config/state/configurable.js +26 -20
  88. package/dist/esm/common/config/state/info.js +1 -1
  89. package/dist/esm/common/config/state/init.js +9 -1
  90. package/dist/esm/common/config/state/loader-config.js +1 -1
  91. package/dist/esm/common/config/state/runtime.js +26 -28
  92. package/dist/esm/common/constants/env.cdn.js +20 -0
  93. package/dist/esm/common/constants/env.js +23 -0
  94. package/dist/esm/common/constants/env.npm.js +21 -0
  95. package/dist/esm/common/context/shared-context.js +2 -1
  96. package/dist/esm/common/event-emitter/contextual-ee.test.js +278 -0
  97. package/dist/esm/common/event-emitter/handle.test.js +54 -0
  98. package/dist/esm/common/event-emitter/register-handler.test.js +51 -0
  99. package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
  100. package/dist/esm/common/harvest/harvest-scheduler.js +14 -11
  101. package/dist/esm/common/harvest/harvest.js +4 -2
  102. package/dist/esm/common/ids/id.js +16 -6
  103. package/dist/esm/common/ids/id.test.js +81 -0
  104. package/dist/esm/common/ids/unique-id.js +75 -51
  105. package/dist/esm/common/ids/unique-id.test.js +44 -0
  106. package/dist/esm/common/session/constants.js +3 -0
  107. package/dist/esm/common/session/session-entity.js +271 -0
  108. package/dist/esm/common/session/session-entity.test.js +434 -0
  109. package/dist/esm/common/storage/first-party-cookies.js +28 -0
  110. package/dist/esm/common/storage/local-memory.js +28 -0
  111. package/dist/esm/common/storage/local-memory.test.js +18 -0
  112. package/dist/esm/common/storage/local-storage.js +26 -0
  113. package/dist/esm/common/storage/local-storage.test.js +12 -0
  114. package/dist/esm/common/timer/interaction-timer.js +71 -0
  115. package/dist/esm/common/timer/interaction-timer.test.js +214 -0
  116. package/dist/esm/common/timer/timer.js +25 -0
  117. package/dist/esm/common/timer/timer.test.js +103 -0
  118. package/dist/esm/common/timing/nav-timing.js +51 -29
  119. package/dist/esm/common/timing/nav-timing.test.js +190 -0
  120. package/dist/esm/common/unload/eol.js +1 -1
  121. package/dist/esm/common/url/clean-url.test.js +7 -0
  122. package/dist/esm/common/url/encode.test.js +70 -0
  123. package/dist/esm/common/url/location.js +4 -0
  124. package/dist/esm/common/url/location.test.js +11 -0
  125. package/dist/esm/common/url/parse-url.test.js +107 -0
  126. package/dist/esm/common/url/protocol.js +3 -12
  127. package/dist/esm/common/url/protocol.test.js +14 -0
  128. package/dist/esm/common/util/console.js +1 -1
  129. package/dist/esm/common/util/data-size.js +7 -0
  130. package/dist/esm/common/util/data-size.test.js +45 -0
  131. package/dist/esm/common/util/invoke.js +66 -0
  132. package/dist/esm/common/util/invoke.test.js +47 -0
  133. package/dist/esm/common/util/map-own.test.js +3 -3
  134. package/dist/esm/common/util/obfuscate.js +2 -6
  135. package/dist/esm/common/window/page-visibility.js +5 -2
  136. package/dist/esm/common/wrap/index.js +1 -2
  137. package/dist/esm/common/wrap/wrap-events.js +6 -9
  138. package/dist/esm/common/wrap/wrap-fetch.js +6 -6
  139. package/dist/esm/common/wrap/wrap-history.js +7 -6
  140. package/dist/esm/common/wrap/wrap-jsonp.js +7 -6
  141. package/dist/esm/common/wrap/wrap-mutation.js +7 -6
  142. package/dist/esm/common/wrap/wrap-promise.js +7 -6
  143. package/dist/esm/common/wrap/wrap-promise.test.js +115 -0
  144. package/dist/esm/common/wrap/wrap-raf.js +6 -6
  145. package/dist/esm/common/wrap/wrap-timer.js +7 -7
  146. package/dist/esm/common/wrap/wrap-xhr.js +5 -6
  147. package/dist/esm/features/ajax/aggregate/index.js +3 -3
  148. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
  149. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
  150. package/dist/esm/features/jserrors/aggregate/index.js +6 -6
  151. package/dist/esm/features/jserrors/instrument/index.js +2 -2
  152. package/dist/esm/features/metrics/aggregate/index.js +21 -11
  153. package/dist/esm/features/metrics/instrument/index.js +0 -25
  154. package/dist/esm/features/metrics/instrument/workers-helper.js +5 -5
  155. package/dist/esm/features/page_action/aggregate/index.js +3 -3
  156. package/dist/esm/features/page_view_event/aggregate/index.js +23 -9
  157. package/dist/esm/features/page_view_timing/aggregate/index.js +40 -30
  158. package/dist/esm/features/session_trace/aggregate/index.js +18 -15
  159. package/dist/esm/features/spa/aggregate/index.js +6 -5
  160. package/dist/esm/features/utils/agent-session.js +67 -0
  161. package/dist/esm/features/utils/feature-base.js +1 -1
  162. package/dist/esm/features/utils/instrument-base.js +7 -2
  163. package/dist/esm/features/utils/lazy-loader.js +2 -2
  164. package/dist/esm/loaders/agent.js +2 -2
  165. package/dist/esm/loaders/api/api.js +6 -9
  166. package/dist/esm/loaders/api/apiAsync.js +2 -1
  167. package/dist/esm/loaders/configure/configure.js +2 -8
  168. package/dist/esm/loaders/features/enabled-features.js +1 -1
  169. package/dist/types/common/config/state/configurable.d.ts.map +1 -1
  170. package/dist/types/common/config/state/init.d.ts.map +1 -1
  171. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  172. package/dist/types/common/constants/env.cdn.d.ts +18 -0
  173. package/dist/types/common/constants/env.cdn.d.ts.map +1 -0
  174. package/dist/types/common/constants/env.d.ts +13 -0
  175. package/dist/types/common/constants/env.d.ts.map +1 -0
  176. package/dist/types/common/constants/env.npm.d.ts +19 -0
  177. package/dist/types/common/constants/env.npm.d.ts.map +1 -0
  178. package/dist/types/common/context/shared-context.d.ts.map +1 -1
  179. package/dist/types/common/event-listener/event-listener-opts.d.ts +2 -2
  180. package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -1
  181. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -0
  182. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  183. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  184. package/dist/types/common/ids/id.d.ts +11 -1
  185. package/dist/types/common/ids/id.d.ts.map +1 -1
  186. package/dist/types/common/ids/unique-id.d.ts +24 -1
  187. package/dist/types/common/ids/unique-id.d.ts.map +1 -1
  188. package/dist/types/common/session/constants.d.ts +4 -0
  189. package/dist/types/common/session/constants.d.ts.map +1 -0
  190. package/dist/types/common/session/session-entity.d.ts +72 -0
  191. package/dist/types/common/session/session-entity.d.ts.map +1 -0
  192. package/dist/types/common/storage/first-party-cookies.d.ts +8 -0
  193. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -0
  194. package/dist/types/common/storage/local-memory.d.ts +8 -0
  195. package/dist/types/common/storage/local-memory.d.ts.map +1 -0
  196. package/dist/types/common/storage/local-storage.d.ts +6 -0
  197. package/dist/types/common/storage/local-storage.d.ts.map +1 -0
  198. package/dist/types/common/timer/interaction-timer.d.ts +11 -0
  199. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -0
  200. package/dist/types/common/timer/timer.d.ts +12 -0
  201. package/dist/types/common/timer/timer.d.ts.map +1 -0
  202. package/dist/types/common/timing/nav-timing.d.ts +1 -2
  203. package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
  204. package/dist/types/common/unload/eol.d.ts.map +1 -1
  205. package/dist/types/common/url/location.d.ts +4 -0
  206. package/dist/types/common/url/location.d.ts.map +1 -1
  207. package/dist/types/common/url/parse-url.d.ts.map +1 -1
  208. package/dist/types/common/url/protocol.d.ts +1 -6
  209. package/dist/types/common/url/protocol.d.ts.map +1 -1
  210. package/dist/types/common/util/data-size.d.ts +7 -1
  211. package/dist/types/common/util/data-size.d.ts.map +1 -1
  212. package/dist/types/common/util/global-scope.d.ts.map +1 -1
  213. package/dist/types/common/util/invoke.d.ts +35 -0
  214. package/dist/types/common/util/invoke.d.ts.map +1 -0
  215. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  216. package/dist/types/common/window/page-visibility.d.ts +1 -1
  217. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  218. package/dist/types/common/wrap/index.d.ts +1 -2
  219. package/dist/types/common/wrap/index.d.ts.map +1 -1
  220. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  221. package/dist/types/common/wrap/wrap-history.d.ts.map +1 -1
  222. package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
  223. package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
  224. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
  225. package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -1
  226. package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -1
  227. package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
  228. package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
  229. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  230. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  231. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  232. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  233. package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
  234. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  235. package/dist/types/features/metrics/instrument/index.d.ts +0 -1
  236. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  237. package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -1
  238. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  239. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  240. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
  241. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  242. package/dist/types/features/page_view_timing/aggregate/index.d.ts +3 -4
  243. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  244. package/dist/types/features/session_trace/aggregate/index.d.ts +3 -3
  245. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  246. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  247. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  248. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  249. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  250. package/dist/types/features/utils/agent-session.d.ts +2 -0
  251. package/dist/types/features/utils/agent-session.d.ts.map +1 -0
  252. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  253. package/dist/types/features/utils/lazy-loader.d.ts +2 -2
  254. package/dist/types/features/utils/lazy-loader.d.ts.map +1 -1
  255. package/dist/types/loaders/api/api.d.ts.map +1 -1
  256. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  257. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  258. package/package.json +12 -32
  259. package/src/common/browser-version/ios-version.js +4 -3
  260. package/src/common/config/state/configurable.js +26 -19
  261. package/src/common/config/state/init.js +7 -0
  262. package/src/common/config/state/runtime.js +7 -10
  263. package/src/common/constants/env.cdn.js +20 -0
  264. package/src/common/constants/env.js +23 -0
  265. package/src/common/constants/env.npm.js +21 -0
  266. package/src/common/context/shared-context.js +2 -1
  267. package/src/common/event-emitter/contextual-ee.test.js +310 -0
  268. package/src/common/event-emitter/handle.test.js +56 -0
  269. package/src/common/event-emitter/register-handler.test.js +61 -0
  270. package/src/common/event-listener/event-listener-opts.js +4 -4
  271. package/src/common/harvest/harvest-scheduler.js +12 -8
  272. package/src/common/harvest/harvest.js +5 -3
  273. package/src/common/ids/id.js +15 -6
  274. package/src/common/ids/id.test.js +92 -0
  275. package/src/common/ids/unique-id.js +77 -54
  276. package/src/common/ids/unique-id.test.js +58 -0
  277. package/src/common/session/constants.js +3 -0
  278. package/src/common/session/session-entity.js +271 -0
  279. package/src/common/session/session-entity.test.js +317 -0
  280. package/src/common/storage/first-party-cookies.js +31 -0
  281. package/src/common/storage/local-memory.js +30 -0
  282. package/src/common/storage/local-memory.test.js +19 -0
  283. package/src/common/storage/local-storage.js +28 -0
  284. package/src/common/storage/local-storage.test.js +17 -0
  285. package/src/common/timer/interaction-timer.js +75 -0
  286. package/src/common/timer/interaction-timer.test.js +167 -0
  287. package/src/common/timer/timer.js +31 -0
  288. package/src/common/timer/timer.test.js +100 -0
  289. package/src/common/timing/nav-timing.js +50 -30
  290. package/src/common/timing/nav-timing.test.js +161 -0
  291. package/src/common/unload/eol.js +2 -3
  292. package/src/common/url/clean-url.test.js +25 -0
  293. package/src/common/url/encode.test.js +80 -0
  294. package/src/common/url/location.js +4 -0
  295. package/src/common/url/location.test.js +15 -0
  296. package/src/common/url/parse-url.js +1 -2
  297. package/src/common/url/parse-url.test.js +110 -0
  298. package/src/common/url/protocol.js +3 -13
  299. package/src/common/url/protocol.test.js +18 -0
  300. package/src/common/util/data-size.js +6 -0
  301. package/src/common/util/data-size.test.js +50 -0
  302. package/src/common/util/global-scope.js +1 -2
  303. package/src/common/util/invoke.js +55 -0
  304. package/src/common/util/invoke.test.js +65 -0
  305. package/src/common/util/obfuscate.js +2 -6
  306. package/src/common/window/page-visibility.js +3 -3
  307. package/src/common/wrap/index.js +1 -2
  308. package/src/common/wrap/wrap-events.js +5 -5
  309. package/src/common/wrap/wrap-fetch.js +4 -3
  310. package/src/common/wrap/wrap-history.js +6 -3
  311. package/src/common/wrap/wrap-jsonp.js +5 -3
  312. package/src/common/wrap/wrap-mutation.js +6 -3
  313. package/src/common/wrap/wrap-promise.js +7 -6
  314. package/src/common/wrap/wrap-promise.test.js +140 -0
  315. package/src/common/wrap/wrap-raf.js +5 -3
  316. package/src/common/wrap/wrap-timer.js +6 -4
  317. package/src/common/wrap/wrap-xhr.js +4 -3
  318. package/src/features/ajax/aggregate/index.js +2 -2
  319. package/src/features/ajax/instrument/index.js +1 -1
  320. package/src/features/jserrors/aggregate/index.js +3 -3
  321. package/src/features/jserrors/instrument/index.js +4 -2
  322. package/src/features/metrics/aggregate/index.js +21 -7
  323. package/src/features/metrics/instrument/index.js +0 -30
  324. package/src/features/metrics/instrument/workers-helper.js +9 -6
  325. package/src/features/page_action/aggregate/index.js +2 -2
  326. package/src/features/page_view_event/aggregate/index.js +21 -9
  327. package/src/features/page_view_timing/aggregate/index.js +40 -29
  328. package/src/features/page_view_timing/long-tasks.js +10 -10
  329. package/src/features/session_trace/aggregate/index.js +17 -14
  330. package/src/features/session_trace/instrument/index.js +3 -2
  331. package/src/features/spa/aggregate/index.js +5 -5
  332. package/src/features/spa/instrument/index.js +4 -2
  333. package/src/features/utils/agent-session.js +68 -0
  334. package/src/features/utils/feature-base.js +1 -1
  335. package/src/features/utils/instrument-base.js +5 -2
  336. package/src/features/utils/lazy-loader.js +1 -1
  337. package/src/loaders/agent.js +1 -1
  338. package/src/loaders/api/api.js +3 -6
  339. package/src/loaders/api/apiAsync.js +2 -1
  340. package/src/loaders/configure/configure.js +2 -7
  341. package/dist/cjs/common/constants/environment-variables.js +0 -20
  342. package/dist/cjs/common/util/single.js +0 -23
  343. package/dist/cjs/common/window/session-storage.js +0 -87
  344. package/dist/cjs/common/wrap/wrap-console.js +0 -54
  345. package/dist/cjs/features/utils/aggregate-base.js +0 -13
  346. package/dist/esm/common/constants/environment-variables.js +0 -11
  347. package/dist/esm/common/util/single.js +0 -16
  348. package/dist/esm/common/window/session-storage.js +0 -77
  349. package/dist/esm/common/wrap/wrap-console.js +0 -46
  350. package/dist/esm/features/utils/aggregate-base.js +0 -6
  351. package/dist/types/common/constants/environment-variables.d.ts +0 -4
  352. package/dist/types/common/constants/environment-variables.d.ts.map +0 -1
  353. package/dist/types/common/util/single.d.ts +0 -2
  354. package/dist/types/common/util/single.d.ts.map +0 -1
  355. package/dist/types/common/window/session-storage.d.ts +0 -18
  356. package/dist/types/common/window/session-storage.d.ts.map +0 -1
  357. package/dist/types/common/wrap/wrap-console.d.ts +0 -16
  358. package/dist/types/common/wrap/wrap-console.d.ts.map +0 -1
  359. package/dist/types/features/utils/aggregate-base.d.ts +0 -4
  360. package/dist/types/features/utils/aggregate-base.d.ts.map +0 -1
  361. package/src/common/constants/environment-variables.js +0 -11
  362. package/src/common/util/single.js +0 -18
  363. package/src/common/window/session-storage.js +0 -75
  364. package/src/common/wrap/wrap-console.js +0 -47
  365. package/src/features/utils/aggregate-base.js +0 -7
@@ -0,0 +1,70 @@
1
+ import * as encode from './encode';
2
+ describe('query string encoding', () => {
3
+ test('escapes string components except safe characters', () => {
4
+ const input = 'Asdf:, :, /@$;';
5
+ const expected = 'Asdf:,%20:,%20/@$;';
6
+ expect(encode.qs(input)).toEqual(expected);
7
+ });
8
+ test('null and undefined value returns \'null\'', () => {
9
+ expect(encode.qs(null)).toEqual('null');
10
+ expect(encode.qs(undefined)).toEqual('null');
11
+ });
12
+ });
13
+ describe('fromArray encoding', () => {
14
+ test('cuts cleanly at end of byte', () => {
15
+ const input = ['a', 'b', 'c'];
16
+ const expected = 'ab';
17
+ expect(encode.fromArray(input, 2)).toEqual(expected);
18
+ });
19
+ test('fall back to largest whole chunk', () => {
20
+ const input = ['aa', 'bb', 'cc'];
21
+ const expected = 'aabb';
22
+ expect(encode.fromArray(input, 5)).toEqual(expected);
23
+ });
24
+ });
25
+ describe('object encoding', () => {
26
+ test('cuts cleanly at end of byte', () => {
27
+ const input = {
28
+ foo: [1, 2, 3]
29
+ };
30
+ const expected = '&foo=%5B1,2%5D';
31
+ expect(encode.obj(input, 12)).toEqual(expected);
32
+ });
33
+ test('fall back to largest whole chunk', () => {
34
+ const input = {
35
+ bar: ['a', 'b', 'c']
36
+ };
37
+ const expected = '&bar=%5B%22a%22,%22b%22%5D';
38
+ expect(encode.obj(input, 30)).toEqual(expected);
39
+ });
40
+ test('handles circular objects', () => {
41
+ const circular = {};
42
+ circular.circular = circular;
43
+ const input = {
44
+ bar: ['a', circular, 'c']
45
+ };
46
+ const expected = '&bar=%5B%22a%22,%7B%7D,%22c%22%5D';
47
+ expect(encode.obj(input, 1000)).toEqual(expected);
48
+ });
49
+ test('handles circular arrays', () => {
50
+ const circular = [];
51
+ circular.push(circular);
52
+ const input = {
53
+ bar: ['a', circular, 'c']
54
+ };
55
+ const expected = '&bar=%5B%22a%22,%5Bnull%5D,%22c%22%5D';
56
+ expect(encode.obj(input, 1000)).toEqual(expected);
57
+ });
58
+ });
59
+ describe('encode key value pairs as query params', () => {
60
+ test('ignores input when value is null or undefined', () => {
61
+ expect(encode.param('foo', null)).toEqual('');
62
+ expect(encode.param('foo', undefined)).toEqual('');
63
+ });
64
+ test('encodes key value pair correctly', () => {
65
+ expect(encode.param('foo', 'bar')).toEqual('&foo=bar');
66
+ });
67
+ test('ignores input when value is not a string', () => {
68
+ expect(encode.param('foo', {})).toEqual('');
69
+ });
70
+ });
@@ -3,6 +3,10 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
+ /**
7
+ * This method only exists to support testing in JIL and can be removed once tests are migrated to WDIO.
8
+ * @returns global scope location
9
+ */
6
10
  export function getLocation() {
7
11
  return '' + location;
8
12
  }
@@ -0,0 +1,11 @@
1
+ import { faker } from '@faker-js/faker';
2
+ import { getLocation } from './location';
3
+ test('should always return a string', () => {
4
+ jest.spyOn(window, 'location', 'get').mockReturnValue({});
5
+ expect(typeof getLocation()).toEqual('string');
6
+ });
7
+ test('should return window location', () => {
8
+ const expected = faker.internet.url();
9
+ jest.spyOn(window, 'location', 'get').mockReturnValue(expected);
10
+ expect(getLocation()).toEqual(expected);
11
+ });
@@ -0,0 +1,107 @@
1
+ afterEach(() => {
2
+ jest.resetModules();
3
+ jest.clearAllMocks();
4
+ });
5
+ const urlTests = [{
6
+ input: 'http://example.com/path/name?qs=5&a=b',
7
+ expected: {
8
+ hostname: 'example.com',
9
+ pathname: '/path/name',
10
+ protocol: 'http',
11
+ port: '80',
12
+ sameOrigin: false
13
+ }
14
+ }, {
15
+ input: 'http://foo:bar@example.com:8080/path/@name?qs=5&a=b',
16
+ expected: {
17
+ hostname: 'example.com',
18
+ pathname: '/path/@name',
19
+ protocol: 'http',
20
+ port: '8080',
21
+ sameOrigin: false
22
+ }
23
+ }, {
24
+ input: 'https://foo:bar@example.com/path/name?qs=5&a=b',
25
+ expected: {
26
+ hostname: 'example.com',
27
+ pathname: '/path/name',
28
+ protocol: 'https',
29
+ port: '443',
30
+ sameOrigin: false
31
+ }
32
+ }, {
33
+ input: '/path/name?qs=5&a=b',
34
+ expected: {
35
+ hostname: location.hostname,
36
+ pathname: '/path/name',
37
+ protocol: location.protocol.split(':')[0],
38
+ port: '80',
39
+ sameOrigin: true
40
+ }
41
+ }, {
42
+ input: location.protocol + '//' + location.hostname + ':' + location.port + '/path/name?qs=5&a=b',
43
+ expected: {
44
+ hostname: location.hostname,
45
+ pathname: '/path/name',
46
+ protocol: location.protocol.split(':')[0],
47
+ port: '80',
48
+ sameOrigin: true
49
+ }
50
+ }, {
51
+ input: 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==',
52
+ expected: {
53
+ protocol: 'data'
54
+ }
55
+ }];
56
+ test.each(urlTests)('verify url parsing inside browser scope', async _ref => {
57
+ let {
58
+ input,
59
+ expected
60
+ } = _ref;
61
+ jest.doMock('../util/global-scope', () => ({
62
+ __esModule: true,
63
+ isBrowserScope: true,
64
+ globalScope: global
65
+ }));
66
+ const {
67
+ parseUrl
68
+ } = await import('./parse-url');
69
+ expect(parseUrl(input)).toEqual(expected);
70
+ });
71
+ test.each(urlTests)('verify url parsing outside browser scope', async _ref2 => {
72
+ let {
73
+ input,
74
+ expected
75
+ } = _ref2;
76
+ jest.doMock('../util/global-scope', () => ({
77
+ __esModule: true,
78
+ isBrowserScope: false,
79
+ globalScope: global
80
+ }));
81
+ const {
82
+ parseUrl
83
+ } = await import('./parse-url');
84
+ expect(parseUrl(input)).toEqual(expected);
85
+ });
86
+ test('should cache parsed urls', async () => {
87
+ jest.doMock('../util/global-scope', () => ({
88
+ __esModule: true,
89
+ isBrowserScope: true,
90
+ globalScope: global
91
+ }));
92
+ const input = 'http://example.com/';
93
+ const expected = {
94
+ hostname: 'example.com',
95
+ pathname: '/',
96
+ protocol: 'http',
97
+ port: '80',
98
+ sameOrigin: false
99
+ };
100
+ jest.spyOn(document, 'createElement');
101
+ const {
102
+ parseUrl
103
+ } = await import('./parse-url');
104
+ parseUrl(input);
105
+ expect(parseUrl(input)).toEqual(expected);
106
+ expect(document.createElement).toHaveBeenCalledTimes(1);
107
+ });
@@ -2,16 +2,7 @@
2
2
  * Copyright 2020 New Relic Corporation. All rights reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { getGlobalScope } from '../util/global-scope';
6
- export const protocol = {
7
- isFileProtocol: isFileProtocol,
8
- supportabilityMetricSent: false
9
- };
10
- function isFileProtocol() {
11
- let isFile = Boolean(getGlobalScope()?.location?.protocol === 'file:');
12
- if (isFile) {
13
- //metrics.recordSupportability('Generic/FileProtocol/Detected') -- may be implemented later? Probably make sure it's once per window
14
- protocol.supportabilityMetricSent = true;
15
- }
16
- return isFile;
5
+ import { globalScope } from '../util/global-scope';
6
+ export function isFileProtocol() {
7
+ return Boolean(globalScope?.location?.protocol === 'file:');
17
8
  }
@@ -0,0 +1,14 @@
1
+ import { faker } from '@faker-js/faker';
2
+ import { isFileProtocol } from './protocol';
3
+ test('should return true when location url contains file protocol', () => {
4
+ jest.spyOn(window, 'location', 'get').mockReturnValue({
5
+ protocol: 'file:'
6
+ });
7
+ expect(isFileProtocol()).toEqual(true);
8
+ });
9
+ test('should return false when location url does not contains file protocol', () => {
10
+ jest.spyOn(window, 'location', 'get').mockReturnValue({
11
+ protocol: 'http:'
12
+ });
13
+ expect(isFileProtocol()).toEqual(false);
14
+ });
@@ -6,6 +6,6 @@
6
6
  */
7
7
  export function warn(message, secondary) {
8
8
  if (typeof console.warn !== 'function') return;
9
- console.warn(`New Relic: ${message}`);
9
+ console.warn("New Relic: ".concat(message));
10
10
  if (secondary) console.warn(secondary);
11
11
  }
@@ -4,6 +4,13 @@
4
4
  */
5
5
 
6
6
  import { stringify } from './stringify';
7
+
8
+ /**
9
+ * Returns the size of the provided data. Designed for measuring XHR responses.
10
+ *
11
+ * @param {*} data - The data to be measured.
12
+ * @returns {(number|undefined)} - The size of the data or undefined if size cannot be determined.
13
+ */
7
14
  export function dataSize(data) {
8
15
  if (typeof data === 'string' && data.length) return data.length;
9
16
  if (typeof data !== 'object') return undefined;
@@ -0,0 +1,45 @@
1
+ import { dataSize } from './data-size';
2
+ describe('dataSize', () => {
3
+ test('returns length of string', () => {
4
+ const str = 'Hello, world!';
5
+ expect(dataSize(str)).toBe(str.length);
6
+ });
7
+ test('returns undefined for non-object, number, or empty string', () => {
8
+ expect(dataSize(Infinity)).toBeUndefined();
9
+ expect(dataSize(12345)).toBeUndefined(); // might not actually be by design, but this is how it works today
10
+ expect(dataSize('')).toBeUndefined();
11
+ });
12
+ test('returns byte length of ArrayBuffer object', () => {
13
+ const buffer = new ArrayBuffer(8);
14
+ expect(dataSize(buffer)).toBe(8);
15
+ });
16
+ test('returns size of Blob object', () => {
17
+ const blob = new Blob(['Hello, world!'], {
18
+ type: 'text/plain'
19
+ });
20
+ expect(dataSize(blob)).toBe(blob.size);
21
+ });
22
+ test('returns undefined for FormData object', () => {
23
+ const formData = new FormData();
24
+ expect(dataSize(formData)).toBeUndefined();
25
+ });
26
+ test('returns length of JSON string representation of object', () => {
27
+ const obj = {
28
+ str: 'Hello, world!',
29
+ num: 12345,
30
+ nestedObj: {
31
+ arr: [1, 2, 3]
32
+ }
33
+ };
34
+ const expectedSize = JSON.stringify(obj).length;
35
+ expect(dataSize(obj)).toBe(expectedSize);
36
+ });
37
+ test('returns undefined for object with toJSON method that throws an error', () => {
38
+ const obj = {
39
+ toJSON: () => {
40
+ throw new Error('Error in toJSON');
41
+ }
42
+ };
43
+ expect(dataSize(obj)).toBeUndefined();
44
+ });
45
+ });
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Reduce the invocation of the supplied function so that it is only invoked
3
+ * once within a given timeout.
4
+ *
5
+ * If `wait` is `0`, the function will be invoked during the next tick.
6
+ * If `options.leading` is false or not provided, the function will be invoked
7
+ * N milliseconds after the last invocation of the returned function where
8
+ * N is the `timeout` value.
9
+ * If `options.leading` is true, the function will be invoked immediately upon
10
+ * the first invocation of the returned function and not again for N milliseconds
11
+ * where N is the `timeout` value.
12
+ * @param {function} func Function whose invocation should be limited so it is only invoked
13
+ * once within a given timeout period.
14
+ * @param {number} timeout Time in milliseconds that the function should only be invoked
15
+ * once within.
16
+ * @param {object} options Debounce options
17
+ * @param {boolean} options.leading Forces the function to be invoked on the first
18
+ * invocation of the returned function instead of N milliseconds after the last
19
+ * invocation.
20
+ * @returns {function} A wrapping function that will ensure the provided function
21
+ * is invoked only once within the given timeout.
22
+ */
23
+ export function debounce(func) {
24
+ var _this = this;
25
+ let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
26
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
27
+ const leading = options?.leading || false;
28
+ let timer;
29
+ return function () {
30
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
+ args[_key] = arguments[_key];
32
+ }
33
+ if (leading && timer === undefined) {
34
+ func.apply(_this, args);
35
+ timer = setTimeout(() => timer = clearTimeout(timer), timeout);
36
+ }
37
+ if (!leading) {
38
+ clearTimeout(timer);
39
+ timer = setTimeout(() => {
40
+ func.apply(_this, args);
41
+ }, timeout);
42
+ }
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Reduce the invocation of the supplied function so that it is only invoked
48
+ * once.
49
+ * @param {function} func Function whose invocation should be limited so it is only invoked
50
+ * once.
51
+ * @returns {function} A wrapping function that will ensure the provided function
52
+ * is invoked only once.
53
+ */
54
+ export function single(func) {
55
+ var _this2 = this;
56
+ let called = false;
57
+ return function () {
58
+ if (!called) {
59
+ called = true;
60
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
61
+ args[_key2] = arguments[_key2];
62
+ }
63
+ func.apply(_this2, args);
64
+ }
65
+ };
66
+ }
@@ -0,0 +1,47 @@
1
+ import { debounce, single } from './invoke';
2
+ jest.useFakeTimers();
3
+ describe('debounce', () => {
4
+ test('should run the supplied function after 100ms', () => {
5
+ let mockCallback = jest.fn();
6
+ let debouncedMethod = debounce(mockCallback, 100);
7
+ execFnTimes(debouncedMethod, 100);
8
+ expect(mockCallback).not.toHaveBeenCalled();
9
+ jest.advanceTimersByTime(1000);
10
+ expect(mockCallback).toHaveBeenCalledTimes(1);
11
+ });
12
+ test('should rerun the supplied function when called again after 100ms', () => {
13
+ let mockCallback = jest.fn();
14
+ let debouncedMethod = debounce(mockCallback, 100);
15
+ execFnTimes(debouncedMethod, 100);
16
+ jest.advanceTimersByTime(200);
17
+ execFnTimes(debouncedMethod, 100);
18
+ jest.advanceTimersByTime(2000);
19
+ expect(mockCallback).toHaveBeenCalledTimes(2);
20
+ });
21
+ test('should run the supplied function on the first event and debounce subsequent events', () => {
22
+ let mockCallback = jest.fn();
23
+ let debouncedMethod = debounce(mockCallback, 100, {
24
+ leading: true
25
+ });
26
+ execFnTimes(debouncedMethod, 100);
27
+ expect(mockCallback).toHaveBeenCalledTimes(1);
28
+ jest.advanceTimersByTime(200);
29
+ expect(mockCallback).toHaveBeenCalledTimes(1);
30
+ execFnTimes(debouncedMethod, 100);
31
+ jest.advanceTimersByTime(200);
32
+ expect(mockCallback).toHaveBeenCalledTimes(2);
33
+ });
34
+ });
35
+ describe('single', () => {
36
+ test('should run the supplied function only once', () => {
37
+ let mockCallback = jest.fn();
38
+ let singleMethod = single(mockCallback, 100);
39
+ execFnTimes(singleMethod, 100);
40
+ expect(mockCallback).toHaveBeenCalledTimes(1);
41
+ });
42
+ });
43
+ function execFnTimes(fn, count) {
44
+ for (let i = 0; i < count; i++) {
45
+ fn();
46
+ }
47
+ }
@@ -8,7 +8,7 @@ test('enumerates the object properties', () => {
8
8
  expect(callback).toHaveBeenCalledWith('foo', 'bar');
9
9
  });
10
10
  test('return array of results from callback invocation', () => {
11
- const callback = jest.fn((key, value) => `${key}:${value}`);
11
+ const callback = jest.fn((key, value) => "".concat(key, ":").concat(value));
12
12
  const input = {
13
13
  foo: 'bar',
14
14
  biz: 'baz'
@@ -19,7 +19,7 @@ test('return array of results from callback invocation', () => {
19
19
  expect(result).toContain('biz:baz');
20
20
  });
21
21
  test('does not iterate symbol properties', () => {
22
- const callback = jest.fn((key, value) => `${key}:${value}`);
22
+ const callback = jest.fn((key, value) => "".concat(key, ":").concat(value));
23
23
  const input = {
24
24
  foo: 'bar',
25
25
  [Symbol.for('biz')]: 'baz'
@@ -32,7 +32,7 @@ test('does not iterate inherited properties', () => {
32
32
  F.prototype = {
33
33
  biz: 'baz'
34
34
  };
35
- const callback = jest.fn((key, value) => `${key}:${value}`);
35
+ const callback = jest.fn((key, value) => "".concat(key, ":").concat(value));
36
36
  const input = new F();
37
37
  input.foo = 'bar';
38
38
  const result = mapOwn(input, callback);
@@ -1,16 +1,12 @@
1
1
  import { getConfigurationValue } from '../config/config';
2
2
  import { SharedContext } from '../context/shared-context';
3
- import { protocol } from '../url/protocol';
3
+ import { isFileProtocol } from '../url/protocol';
4
4
  import { warn } from './console';
5
5
  var fileProtocolRule = {
6
6
  regex: /^file:\/\/(.*)/,
7
7
  replacement: 'file://OBFUSCATED'
8
8
  };
9
9
  export class Obfuscator extends SharedContext {
10
- constructor(parent) {
11
- super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
12
- }
13
-
14
10
  shouldObfuscate() {
15
11
  return getRules(this.sharedContext.agentIdentifier).length > 0;
16
12
  }
@@ -37,7 +33,7 @@ export function getRules(agentIdentifier) {
37
33
  var rules = [];
38
34
  var configRules = getConfigurationValue(agentIdentifier, 'obfuscate') || [];
39
35
  rules = rules.concat(configRules);
40
- if (protocol.isFileProtocol()) rules.push(fileProtocolRule);
36
+ if (isFileProtocol()) rules.push(fileProtocolRule);
41
37
  // could add additional runtime/environment-specific rules here
42
38
 
43
39
  return rules;
@@ -12,12 +12,15 @@ import { documentAddEventListener } from '../event-listener/event-listener-opts'
12
12
  */
13
13
  export function subscribeToVisibilityChange(cb) {
14
14
  let toHiddenOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15
- documentAddEventListener('visibilitychange', handleVisibilityChange);
15
+ let capture = arguments.length > 2 ? arguments[2] : undefined;
16
+ let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
17
+ documentAddEventListener('visibilitychange', handleVisibilityChange, capture, abortSignal);
16
18
  return;
17
19
  function handleVisibilityChange() {
18
20
  if (toHiddenOnly) {
19
21
  // trigger cb on change to hidden state only
20
- if (document.visibilityState == 'hidden') cb();else return;
22
+ if (document.visibilityState == 'hidden') cb();
23
+ return;
21
24
  }
22
25
  cb(document.visibilityState);
23
26
  }
@@ -2,7 +2,6 @@
2
2
  * @file Wraps assorted native objects and functions for instrumentation.
3
3
  */
4
4
 
5
- import { wrapConsole } from './wrap-console';
6
5
  import { wrapEvents } from './wrap-events';
7
6
  import { wrapFetch } from './wrap-fetch';
8
7
  import { wrapHistory } from './wrap-history';
@@ -12,4 +11,4 @@ import { wrapPromise } from './wrap-promise';
12
11
  import { wrapRaf } from './wrap-raf';
13
12
  import { wrapTimer } from './wrap-timer';
14
13
  import { wrapXhr } from './wrap-xhr';
15
- export { wrapConsole, wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapRaf, wrapTimer, wrapXhr };
14
+ export { wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapRaf, wrapTimer, wrapXhr };
@@ -25,19 +25,16 @@ const REMOVE_EVENT_LISTENER = 'removeEventListener';
25
25
  */
26
26
  export function wrapEvents(sharedEE) {
27
27
  var ee = scopedEE(sharedEE);
28
- if (wrapped[ee.debugId]++)
29
- // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
30
- {
31
- return ee;
32
- } // then we increment the count to track # of feats using this at runtime.
33
- wrapped[ee.debugId] = 1;
28
+
29
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
30
+ // then we increment the count to track # of feats using this at runtime.
31
+ if (wrapped[ee.debugId]++) return ee;
32
+ wrapped[ee.debugId] = 1; // otherwise, first feature to wrap events
34
33
  var wrapFn = wfn(ee, true);
35
34
 
36
35
  // Guard against instrumenting environments w/o necessary features
37
36
  if ('getPrototypeOf' in Object) {
38
- if (isBrowserScope) {
39
- findEventListenerProtoAndCb(document, wrapNode);
40
- }
37
+ if (isBrowserScope) findEventListenerProtoAndCb(document, wrapNode);
41
38
  findEventListenerProtoAndCb(globalScope, wrapNode);
42
39
  findEventListenerProtoAndCb(XHR.prototype, wrapNode);
43
40
  }
@@ -32,12 +32,12 @@ export function wrapFetch(sharedEE) {
32
32
  if (!(Req && Res && globalScope.fetch)) {
33
33
  return ee;
34
34
  }
35
- if (wrapped[ee.debugId]++)
36
- // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
37
- {
38
- return ee;
39
- } // then we increment the count to track # of feats using this at runtime.
40
- wrapped[ee.debugId] = 1;
35
+
36
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
37
+ // then we increment the count to track # of feats using this at runtime.
38
+ if (wrapped[ee.debugId]++) return ee;
39
+ wrapped[ee.debugId] = 1; // otherwise, first feature to wrap fetch
40
+
41
41
  bodyMethods.forEach(method => {
42
42
  wrapPromiseMethod(Req[proto], method, bodyPrefix);
43
43
  wrapPromiseMethod(Res[proto], method, bodyPrefix);
@@ -20,12 +20,13 @@ const HISTORY_FNS = ['pushState', 'replaceState'];
20
20
  */
21
21
  export function wrapHistory(sharedEE) {
22
22
  const ee = scopedEE(sharedEE);
23
- if (!isBrowserScope || wrapped[ee.debugId]++)
24
- // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
25
- {
26
- return ee;
27
- } // then we increment the count to track # of feats using this at runtime. (History API is only avail in browser DOM context.)
28
- wrapped[ee.debugId] = 1;
23
+
24
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
25
+ // then we increment the count to track # of feats using this at runtime. History API is only
26
+ // available in browser DOM context.
27
+ if (!isBrowserScope || wrapped[ee.debugId]++) return ee;
28
+ wrapped[ee.debugId] = 1; // otherwise, first feature to wrap history
29
+
29
30
  var wrapFn = wfn(ee);
30
31
  /*
31
32
  * For objects that will be instantiated more than once, we wrap the object's prototype methods. The history object
@@ -22,12 +22,13 @@ const domInsertMethods = ['appendChild', 'insertBefore', 'replaceChild'];
22
22
  */
23
23
  export function wrapJsonP(sharedEE) {
24
24
  const ee = scopedEE(sharedEE);
25
- if (!isBrowserScope || wrapped[ee.debugId])
26
- // JSONP deals with DOM tags so browser window env is req'd
27
- {
28
- return ee;
29
- }
30
- wrapped[ee.debugId] = true;
25
+
26
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
27
+ // then we increment the count to track # of feats using this at runtime. JSONP deals with DOM
28
+ // tags so browser window env is required.
29
+ if (!isBrowserScope || wrapped[ee.debugId]) return ee;
30
+ wrapped[ee.debugId] = true; // otherwise, first feature to wrap JSONP
31
+
31
32
  var wrapFn = wfn(ee);
32
33
  var CALLBACK_REGEX = /[?&](?:callback|cb)=([^&#]+)/;
33
34
  var PARENT_REGEX = /(.*)\.([^.]+)/;
@@ -21,12 +21,13 @@ const wrapped = {};
21
21
  */
22
22
  export function wrapMutation(sharedEE) {
23
23
  const ee = scopedEE(sharedEE);
24
- if (!isBrowserScope || wrapped[ee.debugId])
25
- // relates to the DOM tree (web env only)
26
- {
27
- return ee;
28
- }
29
- wrapped[ee.debugId] = true;
24
+
25
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
26
+ // then we increment the count to track # of feats using this at runtime. Mutations API is only
27
+ // available in browser DOM context.
28
+ if (!isBrowserScope || wrapped[ee.debugId]) return ee;
29
+ wrapped[ee.debugId] = true; // otherwise, first feature to wrap mutations
30
+
30
31
  var wrapFn = wfn(ee);
31
32
  var OriginalObserver = originals.MO;
32
33
  if (OriginalObserver) {
@@ -22,10 +22,12 @@ const wrapped = {};
22
22
  */
23
23
  export function wrapPromise(sharedEE) {
24
24
  const promiseEE = scopedEE(sharedEE);
25
- if (wrapped[promiseEE.debugId]) {
26
- return promiseEE;
27
- }
28
- wrapped[promiseEE.debugId] = true;
25
+
26
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
27
+ // then we increment the count to track # of feats using this at runtime.
28
+ if (wrapped[promiseEE.debugId]) return promiseEE;
29
+ wrapped[promiseEE.debugId] = true; // otherwise, first feature to wrap promise
30
+
29
31
  var getContext = getOrSetContext;
30
32
  var promiseWrapper = wrapFn(promiseEE);
31
33
  var prevPromiseObj = originals.PR;
@@ -67,8 +69,7 @@ export function wrapPromise(sharedEE) {
67
69
  WrappedPromise[method] = function (subPromises) {
68
70
  // use our own wrapped version of "Promise.all" and ".race" static fns
69
71
  let finalized = false;
70
- subPromises?.forEach(sub => {
71
- // eslint-disable-next-line
72
+ Array.from(subPromises || []).forEach(sub => {
72
73
  this.resolve(sub).then(setNrId(method === 'all'), setNrId(false));
73
74
  });
74
75
  const origFnCallWithThis = prevStaticFn.apply(this, arguments);