@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,18 @@
1
+ import { faker } from '@faker-js/faker'
2
+ import { isFileProtocol } from './protocol'
3
+
4
+ test('should return true when location url contains file protocol', () => {
5
+ jest.spyOn(window, 'location', 'get').mockReturnValue({
6
+ protocol: 'file:'
7
+ })
8
+
9
+ expect(isFileProtocol()).toEqual(true)
10
+ })
11
+
12
+ test('should return false when location url does not contains file protocol', () => {
13
+ jest.spyOn(window, 'location', 'get').mockReturnValue({
14
+ protocol: 'http:'
15
+ })
16
+
17
+ expect(isFileProtocol()).toEqual(false)
18
+ })
@@ -5,6 +5,12 @@
5
5
 
6
6
  import { stringify } from './stringify'
7
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
+ */
8
14
  export function dataSize (data) {
9
15
  if (typeof data === 'string' && data.length) return data.length
10
16
  if (typeof data !== 'object') return undefined
@@ -0,0 +1,50 @@
1
+ import { dataSize } from './data-size'
2
+
3
+ describe('dataSize', () => {
4
+ test('returns length of string', () => {
5
+ const str = 'Hello, world!'
6
+ expect(dataSize(str)).toBe(str.length)
7
+ })
8
+
9
+ test('returns undefined for non-object, number, or empty string', () => {
10
+ expect(dataSize(Infinity)).toBeUndefined()
11
+ expect(dataSize(12345)).toBeUndefined() // might not actually be by design, but this is how it works today
12
+ expect(dataSize('')).toBeUndefined()
13
+ })
14
+
15
+ test('returns byte length of ArrayBuffer object', () => {
16
+ const buffer = new ArrayBuffer(8)
17
+ expect(dataSize(buffer)).toBe(8)
18
+ })
19
+
20
+ test('returns size of Blob object', () => {
21
+ const blob = new Blob(['Hello, world!'], { type: 'text/plain' })
22
+ expect(dataSize(blob)).toBe(blob.size)
23
+ })
24
+
25
+ test('returns undefined for FormData object', () => {
26
+ const formData = new FormData()
27
+ expect(dataSize(formData)).toBeUndefined()
28
+ })
29
+
30
+ test('returns length of JSON string representation of object', () => {
31
+ const obj = {
32
+ str: 'Hello, world!',
33
+ num: 12345,
34
+ nestedObj: {
35
+ arr: [1, 2, 3]
36
+ }
37
+ }
38
+ const expectedSize = JSON.stringify(obj).length
39
+ expect(dataSize(obj)).toBe(expectedSize)
40
+ })
41
+
42
+ test('returns undefined for object with toJSON method that throws an error', () => {
43
+ const obj = {
44
+ toJSON: () => {
45
+ throw new Error('Error in toJSON')
46
+ }
47
+ }
48
+ expect(dataSize(obj)).toBeUndefined()
49
+ })
50
+ })
@@ -38,8 +38,7 @@ export function resetScope () {
38
38
  } else if (self instanceof WorkerGlobalScope) {
39
39
  globalScope = self
40
40
  }
41
- }
42
- else {
41
+ } else {
43
42
  throw new Error('New Relic browser agent shutting down due to error: Unable to locate global scope. This is possibly due to code redefining browser global variables like "self" and "window".')
44
43
  }
45
44
  }
@@ -0,0 +1,55 @@
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, timeout = 500, options = {}) {
24
+ const leading = options?.leading || false
25
+ let timer
26
+ return (...args) => {
27
+ if (leading && timer === undefined) {
28
+ func.apply(this, args)
29
+ timer = setTimeout(() => timer = clearTimeout(timer), timeout)
30
+ }
31
+
32
+ if (!leading) {
33
+ clearTimeout(timer)
34
+ timer = setTimeout(() => { func.apply(this, args) }, timeout)
35
+ }
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Reduce the invocation of the supplied function so that it is only invoked
41
+ * once.
42
+ * @param {function} func Function whose invocation should be limited so it is only invoked
43
+ * once.
44
+ * @returns {function} A wrapping function that will ensure the provided function
45
+ * is invoked only once.
46
+ */
47
+ export function single (func) {
48
+ let called = false
49
+ return (...args) => {
50
+ if (!called) {
51
+ called = true
52
+ func.apply(this, args)
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,65 @@
1
+ import { debounce, single } from './invoke'
2
+
3
+ jest.useFakeTimers()
4
+
5
+ describe('debounce', () => {
6
+ test('should run the supplied function after 100ms', () => {
7
+ let mockCallback = jest.fn()
8
+
9
+ let debouncedMethod = debounce(mockCallback, 100)
10
+ execFnTimes(debouncedMethod, 100)
11
+
12
+ expect(mockCallback).not.toHaveBeenCalled()
13
+
14
+ jest.advanceTimersByTime(1000)
15
+ expect(mockCallback).toHaveBeenCalledTimes(1)
16
+ })
17
+
18
+ test('should rerun the supplied function when called again after 100ms', () => {
19
+ let mockCallback = jest.fn()
20
+
21
+ let debouncedMethod = debounce(mockCallback, 100)
22
+
23
+ execFnTimes(debouncedMethod, 100)
24
+ jest.advanceTimersByTime(200)
25
+ execFnTimes(debouncedMethod, 100)
26
+ jest.advanceTimersByTime(2000)
27
+
28
+ expect(mockCallback).toHaveBeenCalledTimes(2)
29
+ })
30
+
31
+ test('should run the supplied function on the first event and debounce subsequent events', () => {
32
+ let mockCallback = jest.fn()
33
+
34
+ let debouncedMethod = debounce(mockCallback, 100, { leading: true })
35
+
36
+ execFnTimes(debouncedMethod, 100)
37
+ expect(mockCallback).toHaveBeenCalledTimes(1)
38
+
39
+ jest.advanceTimersByTime(200)
40
+
41
+ expect(mockCallback).toHaveBeenCalledTimes(1)
42
+
43
+ execFnTimes(debouncedMethod, 100)
44
+ jest.advanceTimersByTime(200)
45
+
46
+ expect(mockCallback).toHaveBeenCalledTimes(2)
47
+ })
48
+ })
49
+
50
+ describe('single', () => {
51
+ test('should run the supplied function only once', () => {
52
+ let mockCallback = jest.fn()
53
+
54
+ let singleMethod = single(mockCallback, 100)
55
+ execFnTimes(singleMethod, 100)
56
+
57
+ expect(mockCallback).toHaveBeenCalledTimes(1)
58
+ })
59
+ })
60
+
61
+ function execFnTimes (fn, count) {
62
+ for (let i = 0; i < count; i++) {
63
+ fn()
64
+ }
65
+ }
@@ -1,6 +1,6 @@
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
 
6
6
  var fileProtocolRule = {
@@ -8,10 +8,6 @@ var fileProtocolRule = {
8
8
  replacement: 'file://OBFUSCATED'
9
9
  }
10
10
  export class Obfuscator extends SharedContext {
11
- constructor (parent) {
12
- super(parent) // gets any allowed properties from the parent and stores them in `sharedContext`
13
- }
14
-
15
11
  shouldObfuscate () {
16
12
  return getRules(this.sharedContext.agentIdentifier).length > 0
17
13
  }
@@ -41,7 +37,7 @@ export function getRules (agentIdentifier) {
41
37
 
42
38
  rules = rules.concat(configRules)
43
39
 
44
- if (protocol.isFileProtocol()) rules.push(fileProtocolRule)
40
+ if (isFileProtocol()) rules.push(fileProtocolRule)
45
41
  // could add additional runtime/environment-specific rules here
46
42
 
47
43
  return rules
@@ -10,14 +10,14 @@ import { documentAddEventListener } from '../event-listener/event-listener-opts'
10
10
  * @param {boolean} [toHiddenOnly=false] - only execute the 'cb' when the vis is changing to the hidden state; no arg is passed to 'cb' if used
11
11
  * @returns void
12
12
  */
13
- export function subscribeToVisibilityChange (cb, toHiddenOnly = false) {
14
- documentAddEventListener('visibilitychange', handleVisibilityChange)
13
+ export function subscribeToVisibilityChange (cb, toHiddenOnly = false, capture, abortSignal) {
14
+ documentAddEventListener('visibilitychange', handleVisibilityChange, capture, abortSignal)
15
15
  return
16
16
 
17
17
  function handleVisibilityChange () {
18
18
  if (toHiddenOnly) { // trigger cb on change to hidden state only
19
19
  if (document.visibilityState == 'hidden') cb()
20
- else return
20
+ return
21
21
  }
22
22
  cb(document.visibilityState)
23
23
  }
@@ -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'
@@ -14,5 +13,5 @@ import { wrapTimer } from './wrap-timer'
14
13
  import { wrapXhr } from './wrap-xhr'
15
14
 
16
15
  export {
17
- wrapConsole, wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapRaf, wrapTimer, wrapXhr
16
+ wrapEvents, wrapFetch, wrapHistory, wrapJsonP, wrapMutation, wrapPromise, wrapRaf, wrapTimer, wrapXhr
18
17
  }
@@ -26,16 +26,16 @@ const REMOVE_EVENT_LISTENER = 'removeEventListener'
26
26
  */
27
27
  export function wrapEvents (sharedEE) {
28
28
  var ee = scopedEE(sharedEE)
29
- if (wrapped[ee.debugId]++) // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
30
- { return ee } // then we increment the count to track # of feats using this at runtime.
31
- wrapped[ee.debugId] = 1
32
29
 
30
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
31
+ // then we increment the count to track # of feats using this at runtime.
32
+ if (wrapped[ee.debugId]++) return ee
33
+ wrapped[ee.debugId] = 1 // otherwise, first feature to wrap events
33
34
  var wrapFn = wfn(ee, true)
34
35
 
35
36
  // Guard against instrumenting environments w/o necessary features
36
37
  if ('getPrototypeOf' in Object) {
37
- if (isBrowserScope)
38
- { findEventListenerProtoAndCb(document, wrapNode) }
38
+ if (isBrowserScope) findEventListenerProtoAndCb(document, wrapNode)
39
39
  findEventListenerProtoAndCb(globalScope, wrapNode)
40
40
  findEventListenerProtoAndCb(XHR.prototype, wrapNode)
41
41
  }
@@ -35,9 +35,10 @@ export function wrapFetch (sharedEE) {
35
35
  return ee
36
36
  }
37
37
 
38
- if (wrapped[ee.debugId]++) // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
39
- { return ee } // then we increment the count to track # of feats using this at runtime.
40
- wrapped[ee.debugId] = 1
38
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
39
+ // then we increment the count to track # of feats using this at runtime.
40
+ if (wrapped[ee.debugId]++) return ee
41
+ wrapped[ee.debugId] = 1 // otherwise, first feature to wrap fetch
41
42
 
42
43
  bodyMethods.forEach(method => {
43
44
  wrapPromiseMethod(Req[proto], method, bodyPrefix)
@@ -21,9 +21,12 @@ const HISTORY_FNS = ['pushState', 'replaceState']
21
21
  */
22
22
  export function wrapHistory (sharedEE) {
23
23
  const ee = scopedEE(sharedEE)
24
- if (!isBrowserScope || wrapped[ee.debugId]++) // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
25
- { return ee } // then we increment the count to track # of feats using this at runtime. (History API is only avail in browser DOM context.)
26
- wrapped[ee.debugId] = 1
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. History API is only
27
+ // available in browser DOM context.
28
+ if (!isBrowserScope || wrapped[ee.debugId]++) return ee
29
+ wrapped[ee.debugId] = 1 // otherwise, first feature to wrap history
27
30
 
28
31
  var wrapFn = wfn(ee)
29
32
  /*
@@ -24,9 +24,11 @@ const domInsertMethods = ['appendChild', 'insertBefore', 'replaceChild']
24
24
  export function wrapJsonP (sharedEE) {
25
25
  const ee = scopedEE(sharedEE)
26
26
 
27
- if (!isBrowserScope || wrapped[ee.debugId]) // JSONP deals with DOM tags so browser window env is req'd
28
- { return ee }
29
- wrapped[ee.debugId] = true
27
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
28
+ // then we increment the count to track # of feats using this at runtime. JSONP deals with DOM
29
+ // tags so browser window env is required.
30
+ if (!isBrowserScope || wrapped[ee.debugId]) return ee
31
+ wrapped[ee.debugId] = true // otherwise, first feature to wrap JSONP
30
32
 
31
33
  var wrapFn = wfn(ee)
32
34
 
@@ -22,9 +22,12 @@ const wrapped = {}
22
22
  */
23
23
  export function wrapMutation (sharedEE) {
24
24
  const ee = scopedEE(sharedEE)
25
- if (!isBrowserScope || wrapped[ee.debugId]) // relates to the DOM tree (web env only)
26
- { return ee }
27
- 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. Mutations API is only
28
+ // available in browser DOM context.
29
+ if (!isBrowserScope || wrapped[ee.debugId]) return ee
30
+ wrapped[ee.debugId] = true // otherwise, first feature to wrap mutations
28
31
 
29
32
  var wrapFn = wfn(ee)
30
33
  var OriginalObserver = originals.MO
@@ -24,9 +24,10 @@ const wrapped = {}
24
24
  export function wrapPromise (sharedEE) {
25
25
  const promiseEE = scopedEE(sharedEE)
26
26
 
27
- if (wrapped[promiseEE.debugId])
28
- { return promiseEE }
29
- wrapped[promiseEE.debugId] = true
27
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
28
+ // then we increment the count to track # of feats using this at runtime.
29
+ if (wrapped[promiseEE.debugId]) return promiseEE
30
+ wrapped[promiseEE.debugId] = true // otherwise, first feature to wrap promise
30
31
 
31
32
  var getContext = getOrSetContext
32
33
  var promiseWrapper = wrapFn(promiseEE)
@@ -69,9 +70,9 @@ export function wrapPromise (sharedEE) {
69
70
  const prevStaticFn = prevPromiseObj[method]
70
71
  WrappedPromise[method] = function (subPromises) { // use our own wrapped version of "Promise.all" and ".race" static fns
71
72
  let finalized = false
72
- subPromises?.forEach(sub => {
73
- // eslint-disable-next-line
74
- this.resolve(sub).then(setNrId(method === 'all'), setNrId(false));
73
+
74
+ Array.from(subPromises || []).forEach(sub => {
75
+ this.resolve(sub).then(setNrId(method === 'all'), setNrId(false))
75
76
  })
76
77
 
77
78
  const origFnCallWithThis = prevStaticFn.apply(this, arguments)
@@ -0,0 +1,140 @@
1
+ import { faker } from '@faker-js/faker'
2
+ import { globalScope } from '../util/global-scope'
3
+ import { originals } from '../config/config'
4
+
5
+ jest.mock('./wrap-function', () => ({
6
+ __esModule: true,
7
+ createWrapperWithEmitter: jest.fn(() => (fn) => (...args) => {
8
+ return fn.apply(null, args)
9
+ })
10
+ }))
11
+ jest.mock('../event-emitter/contextual-ee', () => ({
12
+ __esModule: true,
13
+ getOrSetContext: jest.fn(() => ({})),
14
+ ee: {
15
+ get: jest.fn((name) => ({
16
+ debugId: name,
17
+ on: jest.fn(),
18
+ context: jest.fn(() => ({})),
19
+ emit: jest.fn()
20
+ }))
21
+ }
22
+ }))
23
+ jest.mock('../config/config', () => ({
24
+ __esModule: true,
25
+ originals: {}
26
+ }))
27
+ jest.mock('../util/global-scope', () => ({
28
+ __esModule: true,
29
+ globalScope: {
30
+ NREUM: {}
31
+ }
32
+ }))
33
+
34
+ let promiseConstructorCalls
35
+
36
+ beforeEach(async () => {
37
+ promiseConstructorCalls = []
38
+
39
+ // Proxy the global Promise to prevent the wrapping from
40
+ // messing with Jest internal promises
41
+ originals.PR = new Proxy(class extends Promise {}, {
42
+ construct (target, args) {
43
+ promiseConstructorCalls.push(args)
44
+
45
+ return Reflect.construct(target, args)
46
+ }
47
+ })
48
+
49
+ ;(await import('./wrap-promise')).wrapPromise()
50
+ })
51
+
52
+ afterEach(() => {
53
+ jest.resetModules()
54
+ })
55
+
56
+ test('should wrap promise constructor', async () => {
57
+ const promiseInstance = new globalScope.Promise(jest.fn())
58
+
59
+ expect(promiseInstance).toBeInstanceOf(Promise)
60
+ expect(promiseConstructorCalls.length).toEqual(1)
61
+ expect(globalScope.Promise.toString()).toMatch(/\[native code\]/)
62
+ expect(globalScope.Promise.name).toEqual('Promise')
63
+ })
64
+
65
+ describe('all', () => {
66
+ test('should work with acceptable iterables', async () => {
67
+ const resolveValue = faker.datatype.uuid()
68
+ const customIterable = new CustomIterable([
69
+ new globalScope.Promise(resolve => resolve(resolveValue))
70
+ ])
71
+ const arrayIterable = [
72
+ new globalScope.Promise(resolve => resolve(resolveValue))
73
+ ]
74
+ const setIterable = new Set()
75
+ setIterable.add(new globalScope.Promise(resolve => resolve(resolveValue)))
76
+
77
+ await expect(globalScope.Promise.all(customIterable)).resolves.toEqual([resolveValue])
78
+ await expect(globalScope.Promise.all(arrayIterable)).resolves.toEqual([resolveValue])
79
+ await expect(globalScope.Promise.all(setIterable)).resolves.toEqual([resolveValue])
80
+ })
81
+
82
+ test.each([null, undefined])('should not try to iterate a non-iterable %s', async (input) => {
83
+ jest.spyOn(globalScope.Promise, 'resolve')
84
+
85
+ await expect(globalScope.Promise.all(input)).rejects.toThrow()
86
+ expect(globalScope.Promise.resolve).not.toHaveBeenCalled()
87
+ })
88
+ })
89
+
90
+ describe('race', () => {
91
+ test('should work with acceptable iterables', async () => {
92
+ jest.spyOn(globalScope.Promise, 'resolve')
93
+
94
+ const resolveValue = faker.datatype.uuid()
95
+ const customIterable = new CustomIterable([
96
+ new globalScope.Promise(resolve => resolve(resolveValue))
97
+ ])
98
+ const arrayIterable = [
99
+ new globalScope.Promise(resolve => resolve(resolveValue))
100
+ ]
101
+ const setIterable = new Set()
102
+ setIterable.add(new globalScope.Promise(resolve => resolve(resolveValue)))
103
+
104
+ await expect(globalScope.Promise.race(customIterable)).resolves.toEqual(resolveValue)
105
+ await expect(globalScope.Promise.race(arrayIterable)).resolves.toEqual(resolveValue)
106
+ await expect(globalScope.Promise.race(setIterable)).resolves.toEqual(resolveValue)
107
+ expect(globalScope.Promise.resolve).toHaveBeenCalled()
108
+ })
109
+
110
+ test.each([null, undefined])('should not try to iterate a non-iterable %s', async (input) => {
111
+ jest.spyOn(globalScope.Promise, 'resolve')
112
+
113
+ await expect(globalScope.Promise.race(input)).rejects.toThrow()
114
+ expect(globalScope.Promise.resolve).not.toHaveBeenCalled()
115
+ })
116
+ })
117
+
118
+ class CustomIterable {
119
+ #iterables = []
120
+
121
+ constructor (iterables) {
122
+ this.#iterables = iterables
123
+ }
124
+
125
+ [Symbol.iterator] () {
126
+ return {
127
+ index: 0,
128
+ iterables: this.#iterables,
129
+ next () {
130
+ return {
131
+ done: this.index >= this.iterables.length,
132
+ value: this.iterables[this.index++] || undefined
133
+ }
134
+ },
135
+ [Symbol.iterator] () {
136
+ return this
137
+ }
138
+ }
139
+ }
140
+ }
@@ -22,9 +22,11 @@ const RAF_NAME = 'requestAnimationFrame'
22
22
  */
23
23
  export function wrapRaf (sharedEE) {
24
24
  const ee = scopedEE(sharedEE)
25
- if (!isBrowserScope || wrapped[ee.debugId]++) // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
26
- { return ee } // then we increment the count to track # of feats using this at runtime. (RAF is only avail in browser DOM context.)
27
- wrapped[ee.debugId] = 1
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 (!isBrowserScope || wrapped[ee.debugId]++) return ee
29
+ wrapped[ee.debugId] = 1 // otherwise, first feature to wrap RAF
28
30
 
29
31
  var wrapFn = wfn(ee)
30
32
 
@@ -26,12 +26,14 @@ const TIMER_FNS = [SET_TIMEOUT, 'setImmediate', SET_INTERVAL, CLEAR_TIMEOUT, 'cl
26
26
  * @param {Object} sharedEE - The shared event emitter on which a new scoped event emitter will be based.
27
27
  * @returns {Object} Scoped event emitter with a debug ID of `timer`.
28
28
  */
29
- //eslint-disable-next-line
29
+ // eslint-disable-next-line
30
30
  export function wrapTimer(sharedEE) {
31
31
  const ee = scopedEE(sharedEE)
32
- if (wrapped[ee.debugId]++) // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
33
- { return ee } // then we increment the count to track # of feats using this at runtime.
34
- wrapped[ee.debugId] = 1
32
+
33
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
34
+ // then we increment the count to track # of feats using this at runtime.
35
+ if (wrapped[ee.debugId]++) return ee
36
+ wrapped[ee.debugId] = 1 // otherwise, first feature to wrap timer
35
37
 
36
38
  var wrapFn = wfn(ee)
37
39
 
@@ -29,9 +29,10 @@ export function wrapXhr (sharedEE) {
29
29
  var baseEE = sharedEE || contextualEE
30
30
  const ee = scopedEE(baseEE)
31
31
 
32
- if (wrapped[ee.debugId]++) // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
33
- { return ee } // then we increment the count to track # of feats using this at runtime.
34
- wrapped[ee.debugId] = 1 // <- otherwise, first feature to wrap XHR
32
+ // Notice if our wrapping never ran yet, the falsy NaN will not early return; but if it has,
33
+ // then we increment the count to track # of feats using this at runtime.
34
+ if (wrapped[ee.debugId]++) return ee
35
+ wrapped[ee.debugId] = 1 // otherwise, first feature to wrap XHR
35
36
 
36
37
  wrapEvents(baseEE) // wrap-events patches XMLHttpRequest.prototype.addEventListener for us
37
38
  var wrapFn = wfn(ee)
@@ -9,13 +9,13 @@ import { handle } from '../../../common/event-emitter/handle'
9
9
  import { getConfigurationValue, getInfo } from '../../../common/config/config'
10
10
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler'
11
11
  import { setDenyList, shouldCollectEvent } from '../../../common/deny-list/deny-list'
12
- import { AggregateBase } from '../../utils/aggregate-base'
13
12
  import { FEATURE_NAME } from '../constants'
14
13
  import { drain } from '../../../common/drain/drain'
15
14
  import { FEATURE_NAMES } from '../../../loaders/features/features'
16
15
  import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants'
16
+ import { FeatureBase } from '../../utils/feature-base'
17
17
 
18
- export class Aggregate extends AggregateBase {
18
+ export class Aggregate extends FeatureBase {
19
19
  static featureName = FEATURE_NAME
20
20
  constructor (agentIdentifier, aggregator) {
21
21
  super(agentIdentifier, aggregator, FEATURE_NAME)
@@ -140,7 +140,7 @@ function subscribeToEvents (agentIdentifier, ee, handler, dt) {
140
140
  if (evt.type === 'abort' && !(context.loadCaptureCalled)) {
141
141
  context.params.aborted = true
142
142
  }
143
- if (evt.type !== 'load' || (context.called === context.totalCbs) && (context.onloadCalled || typeof (xhr.onload) !== 'function') && typeof context.end === 'function') context.end(xhr)
143
+ if (evt.type !== 'load' || ((context.called === context.totalCbs) && (context.onloadCalled || typeof (xhr.onload) !== 'function') && typeof context.end === 'function')) context.end(xhr)
144
144
  } catch (e) {
145
145
  try {
146
146
  ee.emit('internal-error', [e])
@@ -18,12 +18,12 @@ import { getInfo, getConfigurationValue, getRuntime } from '../../../common/conf
18
18
  import { now } from '../../../common/timing/now'
19
19
  import { globalScope } from '../../../common/util/global-scope'
20
20
 
21
- import { AggregateBase } from '../../utils/aggregate-base'
22
21
  import { FEATURE_NAME } from '../constants'
23
22
  import { drain } from '../../../common/drain/drain'
24
23
  import { FEATURE_NAMES } from '../../../loaders/features/features'
24
+ import { FeatureBase } from '../../utils/feature-base'
25
25
 
26
- export class Aggregate extends AggregateBase {
26
+ export class Aggregate extends FeatureBase {
27
27
  static featureName = FEATURE_NAME
28
28
  constructor (agentIdentifier, aggregator) {
29
29
  super(agentIdentifier, aggregator, FEATURE_NAME)
@@ -222,6 +222,7 @@ export class Aggregate extends AggregateBase {
222
222
 
223
223
  // still send EE events for other features such as above, but stop this one from aggregating internal data
224
224
  if (this.blocked) return
225
+ var att = getInfo(this.agentIdentifier).jsAttributes
225
226
  if (params._interactionId != null) {
226
227
  // hold on to the error until the interaction finishes
227
228
  this.errorCache[params._interactionId] = this.errorCache[params._interactionId] || []
@@ -229,7 +230,6 @@ export class Aggregate extends AggregateBase {
229
230
  } else {
230
231
  // store custom attributes
231
232
  var customParams = {}
232
- var att = getInfo(this.agentIdentifier).jsAttributes
233
233
  mapOwn(att, setCustom)
234
234
  if (customAttributes) {
235
235
  mapOwn(customAttributes, setCustom)
@@ -24,8 +24,10 @@ export class Instrument extends InstrumentBase {
24
24
  // skipNext counter to keep track of uncaught
25
25
  // errors that will be the same as caught errors.
26
26
  this.skipNext = 0
27
- try { this.removeOnAbort = new AbortController() } // this try-catch can be removed when IE11 is completely unsupported & gone
28
- catch (e) {}
27
+ try {
28
+ // this try-catch can be removed when IE11 is completely unsupported & gone
29
+ this.removeOnAbort = new AbortController()
30
+ } catch (e) {}
29
31
 
30
32
  const thisInstrument = this
31
33
  thisInstrument.ee.on('fn-start', function (args, obj, methodName) {