@newrelic/browser-agent 1.235.0 → 1.236.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/README.md +41 -1
  2. package/dist/cjs/common/config/state/init.js +3 -0
  3. package/dist/cjs/common/config/state/runtime.js +4 -4
  4. package/dist/cjs/common/constants/env.cdn.js +2 -2
  5. package/dist/cjs/common/constants/env.npm.js +1 -1
  6. package/dist/cjs/common/constants/runtime.js +52 -0
  7. package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
  8. package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
  9. package/dist/cjs/common/harvest/harvest.js +163 -144
  10. package/dist/cjs/common/harvest/types.js +54 -0
  11. package/dist/cjs/common/ids/id.js +2 -2
  12. package/dist/cjs/common/ids/unique-id.js +3 -3
  13. package/dist/cjs/common/session/session-entity.js +2 -2
  14. package/dist/cjs/common/timer/interaction-timer.js +2 -2
  15. package/dist/cjs/common/unload/eol.js +10 -11
  16. package/dist/cjs/common/url/canonicalize-url.js +2 -2
  17. package/dist/cjs/common/url/parse-url.js +3 -3
  18. package/dist/cjs/common/url/protocol.js +2 -2
  19. package/dist/cjs/common/util/submit-data.js +58 -76
  20. package/dist/cjs/common/window/nreum.js +14 -14
  21. package/dist/cjs/common/wrap/wrap-events.js +3 -3
  22. package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
  23. package/dist/cjs/common/wrap/wrap-history.js +2 -2
  24. package/dist/cjs/common/wrap/wrap-jsonp.js +2 -2
  25. package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
  26. package/dist/cjs/common/wrap/wrap-promise.js +2 -2
  27. package/dist/cjs/common/wrap/wrap-raf.js +2 -2
  28. package/dist/cjs/common/wrap/wrap-timer.js +4 -4
  29. package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
  30. package/dist/cjs/features/ajax/aggregate/index.js +1 -1
  31. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
  32. package/dist/cjs/features/ajax/instrument/index.js +6 -7
  33. package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
  34. package/dist/cjs/features/jserrors/instrument/index.js +4 -4
  35. package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
  36. package/dist/cjs/features/metrics/aggregate/index.js +3 -3
  37. package/dist/cjs/features/page_action/aggregate/index.js +3 -3
  38. package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
  39. package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
  40. package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
  41. package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
  42. package/dist/cjs/features/session_replay/replay-mode.js +2 -2
  43. package/dist/cjs/features/session_trace/instrument/index.js +2 -2
  44. package/dist/cjs/features/spa/aggregate/index.js +1 -1
  45. package/dist/cjs/features/spa/instrument/index.js +2 -2
  46. package/dist/cjs/features/utils/instrument-base.js +6 -7
  47. package/dist/cjs/index.js +7 -0
  48. package/dist/cjs/loaders/agent.js +7 -0
  49. package/dist/cjs/loaders/api/api.js +2 -2
  50. package/dist/cjs/loaders/api/apiAsync.js +6 -4
  51. package/dist/cjs/loaders/configure/configure.js +2 -2
  52. package/dist/cjs/loaders/micro-agent.js +29 -38
  53. package/dist/esm/common/config/state/init.js +3 -0
  54. package/dist/esm/common/config/state/runtime.js +1 -1
  55. package/dist/esm/common/constants/env.cdn.js +2 -2
  56. package/dist/esm/common/constants/env.npm.js +1 -1
  57. package/dist/esm/common/constants/runtime.js +38 -0
  58. package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
  59. package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
  60. package/dist/esm/common/harvest/harvest.js +160 -142
  61. package/dist/esm/common/harvest/types.js +47 -0
  62. package/dist/esm/common/ids/id.js +1 -1
  63. package/dist/esm/common/ids/unique-id.js +1 -1
  64. package/dist/esm/common/session/session-entity.js +1 -1
  65. package/dist/esm/common/timer/interaction-timer.js +1 -1
  66. package/dist/esm/common/unload/eol.js +1 -2
  67. package/dist/esm/common/url/canonicalize-url.js +1 -1
  68. package/dist/esm/common/url/parse-url.js +1 -1
  69. package/dist/esm/common/url/protocol.js +1 -1
  70. package/dist/esm/common/util/submit-data.js +55 -73
  71. package/dist/esm/common/window/nreum.js +1 -1
  72. package/dist/esm/common/wrap/wrap-events.js +1 -1
  73. package/dist/esm/common/wrap/wrap-fetch.js +1 -1
  74. package/dist/esm/common/wrap/wrap-history.js +1 -1
  75. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  76. package/dist/esm/common/wrap/wrap-mutation.js +1 -1
  77. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  78. package/dist/esm/common/wrap/wrap-raf.js +1 -1
  79. package/dist/esm/common/wrap/wrap-timer.js +1 -1
  80. package/dist/esm/common/wrap/wrap-xhr.js +1 -1
  81. package/dist/esm/features/ajax/aggregate/index.js +1 -1
  82. package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
  83. package/dist/esm/features/ajax/instrument/index.js +1 -2
  84. package/dist/esm/features/jserrors/aggregate/index.js +6 -3
  85. package/dist/esm/features/jserrors/instrument/index.js +1 -1
  86. package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
  87. package/dist/esm/features/metrics/aggregate/index.js +1 -1
  88. package/dist/esm/features/page_action/aggregate/index.js +1 -1
  89. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  90. package/dist/esm/features/page_view_event/instrument/index.js +1 -1
  91. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
  92. package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
  93. package/dist/esm/features/session_replay/replay-mode.js +2 -2
  94. package/dist/esm/features/session_trace/instrument/index.js +1 -1
  95. package/dist/esm/features/spa/aggregate/index.js +1 -1
  96. package/dist/esm/features/spa/instrument/index.js +1 -1
  97. package/dist/esm/features/utils/instrument-base.js +4 -5
  98. package/dist/esm/index.js +1 -4
  99. package/dist/esm/loaders/agent.js +7 -0
  100. package/dist/esm/loaders/api/api.js +1 -1
  101. package/dist/esm/loaders/api/apiAsync.js +3 -3
  102. package/dist/esm/loaders/configure/configure.js +1 -1
  103. package/dist/esm/loaders/micro-agent.js +29 -38
  104. package/dist/types/common/config/state/init.d.ts.map +1 -1
  105. package/dist/types/common/constants/runtime.d.ts +29 -0
  106. package/dist/types/common/constants/runtime.d.ts.map +1 -0
  107. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
  108. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest.d.ts +49 -38
  110. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  111. package/dist/types/common/harvest/types.d.ts +100 -0
  112. package/dist/types/common/harvest/types.d.ts.map +1 -0
  113. package/dist/types/common/unload/eol.d.ts.map +1 -1
  114. package/dist/types/common/util/submit-data.d.ts +62 -64
  115. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  116. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  117. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  118. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  119. package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
  120. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  121. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  122. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  123. package/dist/types/index.d.ts +1 -0
  124. package/dist/types/loaders/agent.d.ts +4 -4
  125. package/dist/types/loaders/agent.d.ts.map +1 -1
  126. package/dist/types/loaders/micro-agent.d.ts +3 -4
  127. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  128. package/package.json +6 -1
  129. package/src/common/config/__mocks__/config.js +11 -0
  130. package/src/common/config/state/init.js +1 -0
  131. package/src/common/config/state/runtime.js +1 -1
  132. package/src/common/constants/__mocks__/env.js +3 -0
  133. package/src/common/constants/__mocks__/runtime.js +8 -0
  134. package/src/common/constants/env.cdn.test.js +7 -0
  135. package/src/common/constants/env.npm.test.js +7 -0
  136. package/src/common/constants/env.test.js +7 -0
  137. package/src/common/constants/runtime.js +71 -0
  138. package/src/common/constants/runtime.test.js +168 -0
  139. package/src/common/context/__mocks__/shared-context.js +8 -0
  140. package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
  141. package/src/common/event-listener/event-listener-opts.js +1 -1
  142. package/src/common/harvest/__mocks__/harvest.js +13 -0
  143. package/src/common/harvest/harvest-scheduler.js +21 -20
  144. package/src/common/harvest/harvest-scheduler.test.js +496 -0
  145. package/src/common/harvest/harvest.js +147 -130
  146. package/src/common/harvest/harvest.test.js +818 -0
  147. package/src/common/harvest/types.js +47 -0
  148. package/src/common/ids/id.js +1 -1
  149. package/src/common/ids/unique-id.js +1 -1
  150. package/src/common/session/__mocks__/session-entity.js +25 -0
  151. package/src/common/session/session-entity.component-test.js +1 -1
  152. package/src/common/session/session-entity.js +1 -1
  153. package/src/common/timer/interaction-timer.js +1 -1
  154. package/src/common/timing/__mocks__/now.js +1 -0
  155. package/src/common/unload/__mocks__/eol.js +1 -0
  156. package/src/common/unload/eol.js +1 -2
  157. package/src/common/url/__mocks__/clean-url.js +1 -0
  158. package/src/common/url/__mocks__/encode.js +7 -0
  159. package/src/common/url/__mocks__/location.js +1 -0
  160. package/src/common/url/canonicalize-url.js +1 -1
  161. package/src/common/url/canonicalize-url.test.js +2 -2
  162. package/src/common/url/parse-url.js +1 -1
  163. package/src/common/url/parse-url.test.js +3 -3
  164. package/src/common/url/protocol.js +1 -1
  165. package/src/common/util/__mocks__/obfuscate.js +10 -0
  166. package/src/common/util/__mocks__/stringify.js +1 -0
  167. package/src/common/util/__mocks__/submit-data.js +6 -0
  168. package/src/common/util/__mocks__/traverse.js +1 -0
  169. package/src/common/util/submit-data.js +39 -53
  170. package/src/common/util/submit-data.test.js +81 -68
  171. package/src/common/window/nreum.js +1 -1
  172. package/src/common/wrap/wrap-events.js +1 -1
  173. package/src/common/wrap/wrap-fetch.js +1 -1
  174. package/src/common/wrap/wrap-history.js +1 -1
  175. package/src/common/wrap/wrap-jsonp.js +1 -1
  176. package/src/common/wrap/wrap-mutation.js +1 -1
  177. package/src/common/wrap/wrap-promise.js +1 -1
  178. package/src/common/wrap/wrap-promise.test.js +2 -2
  179. package/src/common/wrap/wrap-raf.js +1 -1
  180. package/src/common/wrap/wrap-timer.js +1 -1
  181. package/src/common/wrap/wrap-xhr.js +1 -1
  182. package/src/features/ajax/aggregate/index.js +1 -1
  183. package/src/features/ajax/instrument/distributed-tracing.js +1 -1
  184. package/src/features/ajax/instrument/index.js +1 -2
  185. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  186. package/src/features/jserrors/aggregate/index.js +7 -3
  187. package/src/features/jserrors/instrument/index.js +1 -1
  188. package/src/features/metrics/aggregate/framework-detection.js +1 -1
  189. package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
  190. package/src/features/metrics/aggregate/index.js +1 -1
  191. package/src/features/page_action/aggregate/index.js +1 -1
  192. package/src/features/page_view_event/aggregate/index.js +1 -2
  193. package/src/features/page_view_event/instrument/index.js +1 -1
  194. package/src/features/page_view_timing/aggregate/index.js +2 -4
  195. package/src/features/page_view_timing/instrument/index.js +1 -1
  196. package/src/features/session_replay/replay-mode.js +2 -2
  197. package/src/features/session_trace/instrument/index.js +1 -1
  198. package/src/features/spa/aggregate/index.js +1 -1
  199. package/src/features/spa/instrument/index.js +1 -1
  200. package/src/features/utils/agent-session.test.js +2 -2
  201. package/src/features/utils/instrument-base.js +5 -5
  202. package/src/features/utils/instrument-base.test.js +22 -3
  203. package/src/index.js +1 -3
  204. package/src/loaders/agent.js +8 -0
  205. package/src/loaders/api/api.js +1 -1
  206. package/src/loaders/api/apiAsync.js +3 -3
  207. package/src/loaders/configure/configure.js +1 -1
  208. package/src/loaders/micro-agent.js +26 -30
  209. package/dist/cjs/common/browser-version/firefox-version.js +0 -17
  210. package/dist/cjs/common/browser-version/ios-version.js +0 -19
  211. package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
  212. package/dist/cjs/common/event-emitter/handle.test.js +0 -58
  213. package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
  214. package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
  215. package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
  216. package/dist/cjs/common/ids/id.test.js +0 -85
  217. package/dist/cjs/common/ids/unique-id.test.js +0 -49
  218. package/dist/cjs/common/session/session-entity.component-test.js +0 -497
  219. package/dist/cjs/common/storage/local-storage.test.js +0 -14
  220. package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
  221. package/dist/cjs/common/timer/timer.test.js +0 -105
  222. package/dist/cjs/common/timing/nav-timing.test.js +0 -192
  223. package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
  224. package/dist/cjs/common/url/clean-url.test.js +0 -9
  225. package/dist/cjs/common/url/encode.component-test.js +0 -74
  226. package/dist/cjs/common/url/location.test.js +0 -13
  227. package/dist/cjs/common/url/parse-url.test.js +0 -111
  228. package/dist/cjs/common/url/protocol.component-test.js +0 -15
  229. package/dist/cjs/common/util/console.test.js +0 -30
  230. package/dist/cjs/common/util/data-size.test.js +0 -64
  231. package/dist/cjs/common/util/feature-flags.test.js +0 -84
  232. package/dist/cjs/common/util/get-or-set.test.js +0 -47
  233. package/dist/cjs/common/util/global-scope.js +0 -27
  234. package/dist/cjs/common/util/global-scope.test.js +0 -72
  235. package/dist/cjs/common/util/invoke.test.js +0 -49
  236. package/dist/cjs/common/util/map-own.test.js +0 -49
  237. package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
  238. package/dist/cjs/common/util/stringify.test.js +0 -48
  239. package/dist/cjs/common/util/submit-data.test.js +0 -245
  240. package/dist/cjs/common/util/traverse.test.js +0 -44
  241. package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
  242. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
  243. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
  244. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
  245. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
  246. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
  247. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
  248. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
  249. package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
  250. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
  251. package/dist/cjs/features/utils/agent-session.test.js +0 -211
  252. package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
  253. package/dist/cjs/features/utils/feature-base.test.js +0 -42
  254. package/dist/cjs/features/utils/handler-cache.test.js +0 -53
  255. package/dist/cjs/features/utils/instrument-base.test.js +0 -179
  256. package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
  257. package/dist/esm/common/browser-version/firefox-version.js +0 -10
  258. package/dist/esm/common/browser-version/ios-version.js +0 -11
  259. package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
  260. package/dist/esm/common/event-emitter/handle.test.js +0 -54
  261. package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
  262. package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
  263. package/dist/esm/common/harvest/harvest.component-test.js +0 -222
  264. package/dist/esm/common/ids/id.test.js +0 -81
  265. package/dist/esm/common/ids/unique-id.test.js +0 -44
  266. package/dist/esm/common/session/session-entity.component-test.js +0 -495
  267. package/dist/esm/common/storage/local-storage.test.js +0 -12
  268. package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
  269. package/dist/esm/common/timer/timer.test.js +0 -103
  270. package/dist/esm/common/timing/nav-timing.test.js +0 -190
  271. package/dist/esm/common/url/canonicalize-url.test.js +0 -34
  272. package/dist/esm/common/url/clean-url.test.js +0 -7
  273. package/dist/esm/common/url/encode.component-test.js +0 -70
  274. package/dist/esm/common/url/location.test.js +0 -11
  275. package/dist/esm/common/url/parse-url.test.js +0 -107
  276. package/dist/esm/common/url/protocol.component-test.js +0 -13
  277. package/dist/esm/common/util/console.test.js +0 -28
  278. package/dist/esm/common/util/data-size.test.js +0 -60
  279. package/dist/esm/common/util/feature-flags.test.js +0 -80
  280. package/dist/esm/common/util/get-or-set.test.js +0 -45
  281. package/dist/esm/common/util/global-scope.js +0 -17
  282. package/dist/esm/common/util/global-scope.test.js +0 -70
  283. package/dist/esm/common/util/invoke.test.js +0 -47
  284. package/dist/esm/common/util/map-own.test.js +0 -47
  285. package/dist/esm/common/util/obfuscate.component-test.js +0 -125
  286. package/dist/esm/common/util/stringify.test.js +0 -46
  287. package/dist/esm/common/util/submit-data.test.js +0 -241
  288. package/dist/esm/common/util/traverse.test.js +0 -42
  289. package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
  290. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
  291. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
  292. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
  293. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
  294. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
  295. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
  296. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
  297. package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
  298. package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
  299. package/dist/esm/features/utils/agent-session.test.js +0 -207
  300. package/dist/esm/features/utils/aggregate-base.test.js +0 -108
  301. package/dist/esm/features/utils/feature-base.test.js +0 -40
  302. package/dist/esm/features/utils/handler-cache.test.js +0 -51
  303. package/dist/esm/features/utils/instrument-base.test.js +0 -175
  304. package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
  305. package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
  306. package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
  307. package/dist/types/common/browser-version/ios-version.d.ts +0 -3
  308. package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
  309. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
  310. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
  311. package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
  312. package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
  313. package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
  314. package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
  315. package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
  316. package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
  317. package/dist/types/common/url/encode.component-test.d.ts +0 -2
  318. package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
  319. package/dist/types/common/url/protocol.component-test.d.ts +0 -2
  320. package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
  321. package/dist/types/common/util/global-scope.d.ts +0 -5
  322. package/dist/types/common/util/global-scope.d.ts.map +0 -1
  323. package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
  324. package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
  325. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
  326. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
  327. package/src/common/browser-version/firefox-version.js +0 -10
  328. package/src/common/browser-version/ios-version.js +0 -11
  329. package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
  330. package/src/common/harvest/harvest.component-test.js +0 -169
  331. package/src/common/util/global-scope.js +0 -23
  332. package/src/common/util/global-scope.test.js +0 -87
@@ -16,7 +16,7 @@ var _obfuscate = require("../../../common/util/obfuscate");
16
16
  var _env = require("../../../common/constants/env.npm");
17
17
  var _load = require("../../../common/window/load");
18
18
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
19
- var _globalScope = require("../../../common/util/global-scope");
19
+ var _runtime = require("../../../common/constants/runtime");
20
20
  var _aggregateBase = require("../../utils/aggregate-base");
21
21
  var _stringify = require("../../../common/util/stringify");
22
22
  var _endpointMap = require("./endpoint-map");
@@ -77,7 +77,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
77
77
  if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
78
78
 
79
79
  // frameworks on page
80
- if (_globalScope.isBrowserScope) {
80
+ if (_runtime.isBrowserScope) {
81
81
  (0, _load.onDOMContentLoaded)(() => {
82
82
  (0, _frameworkDetection.getFrameworks)().forEach(framework => {
83
83
  this.storeSupportabilityMetrics('Framework/' + framework + '/Detected');
@@ -99,7 +99,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
99
99
  if (rules.length > 0 && !(0, _obfuscate.validateRules)(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
100
100
  }
101
101
  eachSessionChecks() {
102
- if (!_globalScope.isBrowserScope) return;
102
+ if (!_runtime.isBrowserScope) return;
103
103
 
104
104
  // [Temporary] Report restores from BFCache to NR1 while feature flag is in place in lieu of sending pageshow events.
105
105
  (0, _eventListenerOpts.windowAddEventListener)('pageshow', evt => {
@@ -12,7 +12,7 @@ var _cleanUrl = require("../../../common/url/clean-url");
12
12
  var _config = require("../../../common/config/config");
13
13
  var _constants = require("../constants");
14
14
  var _drain = require("../../../common/drain/drain");
15
- var _globalScope = require("../../../common/util/global-scope");
15
+ var _runtime = require("../../../common/constants/runtime");
16
16
  var _aggregateBase = require("../../utils/aggregate-base");
17
17
  /*
18
18
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -33,7 +33,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
33
33
  this.events = [];
34
34
  this.att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes; // per-agent, aggregators-shared info context
35
35
 
36
- if (_globalScope.isBrowserScope && document.referrer) this.referrerUrl = (0, _cleanUrl.cleanURL)(document.referrer);
36
+ if (_runtime.isBrowserScope && document.referrer) this.referrerUrl = (0, _cleanUrl.cleanURL)(document.referrer);
37
37
  (0, _registerHandler.registerHandler)('api-addPageAction', function () {
38
38
  return _this.addPageAction(...arguments);
39
39
  }, this.featureName, this.ee);
@@ -89,7 +89,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
89
89
  var width;
90
90
  var height;
91
91
  var eventAttributes = {};
92
- if (_globalScope.isBrowserScope && window.document.documentElement) {
92
+ if (_runtime.isBrowserScope && window.document.documentElement) {
93
93
  // Doesn't include the nav bar when it disappears in mobile safari
94
94
  // https://github.com/jquery/jquery/blob/10399ddcf8a239acc27bdec9231b996b178224d3/src/dimensions.js#L23
95
95
  width = window.document.documentElement.clientWidth;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Aggregate = void 0;
7
7
  var _handle = require("../../../common/event-emitter/handle");
8
8
  var _features = require("../../../loaders/features/features");
9
- var _iosVersion = require("../../../common/browser-version/ios-version");
9
+ var _runtime = require("../../../common/constants/runtime");
10
10
  var _webVitals = require("web-vitals");
11
11
  var _navTiming = require("../../../common/timing/nav-timing");
12
12
  var _stringify = require("../../../common/util/stringify");
@@ -15,7 +15,6 @@ var _config = require("../../../common/config/config");
15
15
  var _harvest = require("../../../common/harvest/harvest");
16
16
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
17
17
  var _initializedFeatures = require("./initialized-features");
18
- var _globalScope = require("../../../common/util/global-scope");
19
18
  var _drain = require("../../../common/drain/drain");
20
19
  var _featureFlags = require("../../../common/util/feature-flags");
21
20
  var _console = require("../../../common/util/console");
@@ -26,7 +25,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
26
25
  static featureName = CONSTANTS.FEATURE_NAME;
27
26
  constructor(agentIdentifier, aggregator) {
28
27
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
29
- if (typeof PerformanceNavigationTiming !== 'undefined' && !_iosVersion.isiOS) {
28
+ if (typeof PerformanceNavigationTiming !== 'undefined' && !_runtime.isiOS) {
30
29
  this.alreadySent = false; // we don't support timings on BFCache restores
31
30
  const agentRuntime = (0, _config.getRuntime)(agentIdentifier); // we'll store timing values on the runtime obj to be read by the aggregate module
32
31
 
@@ -74,13 +73,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
74
73
  // Following PR #428, which demands that all agents send RUM call, these need to be sent even outside of the main window context where PerformanceTiming
75
74
  // or PerformanceNavigationTiming do not exists. Hence, they'll be filled in by 0s instead in, for example, worker threads that still init the PVE module.
76
75
  this.aggregator.store('measures', 'be', {
77
- value: _globalScope.isBrowserScope ? agentRuntime[CONSTANTS.TTFB] : 0
76
+ value: _runtime.isBrowserScope ? agentRuntime[CONSTANTS.TTFB] : 0
78
77
  });
79
78
  this.aggregator.store('measures', 'fe', {
80
- value: _globalScope.isBrowserScope ? agentRuntime[CONSTANTS.FBTWL] : 0
79
+ value: _runtime.isBrowserScope ? agentRuntime[CONSTANTS.FBTWL] : 0
81
80
  });
82
81
  this.aggregator.store('measures', 'dc', {
83
- value: _globalScope.isBrowserScope ? agentRuntime[CONSTANTS.FBTDC] : 0
82
+ value: _runtime.isBrowserScope ? agentRuntime[CONSTANTS.FBTDC] : 0
84
83
  });
85
84
  const queryParameters = {
86
85
  tt: info.ttGuid,
@@ -103,10 +102,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
103
102
  ja: info.jsAttributes
104
103
  };
105
104
  }
106
- if (_globalScope.globalScope.performance) {
105
+ if (_runtime.globalScope.performance) {
107
106
  if (typeof PerformanceNavigationTiming !== 'undefined') {
108
107
  // Navigation Timing level 2 API that replaced PerformanceTiming & PerformanceNavigation
109
- const navTimingEntry = _globalScope.globalScope?.performance?.getEntriesByType('navigation')?.[0];
108
+ const navTimingEntry = _runtime.globalScope?.performance?.getEntriesByType('navigation')?.[0];
110
109
  const perf = {
111
110
  timing: (0, _navTiming.addPT)(agentRuntime.offset, navTimingEntry, {}),
112
111
  navigation: (0, _navTiming.addPN)(navTimingEntry, {})
@@ -115,15 +114,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
115
114
  } else if (typeof PerformanceTiming !== 'undefined') {
116
115
  // Safari pre-15 did not support level 2 timing
117
116
  const perf = {
118
- timing: (0, _navTiming.addPT)(agentRuntime.offset, _globalScope.globalScope.performance.timing, {}, true),
119
- navigation: (0, _navTiming.addPN)(_globalScope.globalScope.performance.navigation, {})
117
+ timing: (0, _navTiming.addPT)(agentRuntime.offset, _runtime.globalScope.performance.timing, {}, true),
118
+ navigation: (0, _navTiming.addPN)(_runtime.globalScope.performance.navigation, {})
120
119
  };
121
120
  queryParameters.perf = (0, _stringify.stringify)(perf);
122
121
  }
123
122
  }
124
123
  try {
125
124
  // PVTiming sends these too, albeit using web-vitals and slightly different; it's unknown why they're duplicated, but PVT should be the truth
126
- var entries = _globalScope.globalScope.performance.getEntriesByType('paint');
125
+ var entries = _runtime.globalScope.performance.getEntriesByType('paint');
127
126
  entries.forEach(function (entry) {
128
127
  if (!entry.startTime || entry.startTime <= 0) return;
129
128
  if (entry.name === 'first-paint') {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Instrument = void 0;
7
7
  var _handle = require("../../../common/event-emitter/handle");
8
- var _iosVersion = require("../../../common/browser-version/ios-version");
8
+ var _runtime = require("../../../common/constants/runtime");
9
9
  var _instrumentBase = require("../../utils/instrument-base");
10
10
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
11
11
  var _features = require("../../../loaders/features/features");
@@ -19,7 +19,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
19
19
  constructor(agentIdentifier, aggregator) {
20
20
  let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
21
21
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
22
- if ((typeof PerformanceNavigationTiming === 'undefined' || _iosVersion.isiOS) && typeof PerformanceTiming !== 'undefined') {
22
+ if ((typeof PerformanceNavigationTiming === 'undefined' || _runtime.isiOS) && typeof PerformanceTiming !== 'undefined') {
23
23
  // For majority browser versions in which PNT exists, we can get load timings later from the nav entry (in the aggregate portion). At minimum, PT should exist for main window.
24
24
  // *cli Mar'23 - iOS 15.2 & 15.4 testing in Sauce still fails with onTTFB. Hence, all iOS will fallback to this for now. Unknown if this is similar in nature to iOS_below16 bug.
25
25
  const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
@@ -7,7 +7,7 @@ exports.Aggregate = void 0;
7
7
  var _webVitals = require("web-vitals");
8
8
  var _firstPaint = require("../first-paint");
9
9
  var _longTasks = require("../long-tasks");
10
- var _iosVersion = require("../../../common/browser-version/ios-version");
10
+ var _runtime = require("../../../common/constants/runtime");
11
11
  var _belSerializer = require("../../../common/serialize/bel-serializer");
12
12
  var _mapOwn = require("../../../common/util/map-own");
13
13
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
@@ -51,7 +51,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
51
51
  });
52
52
 
53
53
  /* First Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
54
- if (_iosVersion.iOS_below16) {
54
+ if (_runtime.iOS_below16) {
55
55
  try {
56
56
  if (!pageStartedHidden) {
57
57
  // see ios-version.js for detail on this following bug case; tldr: buffered flag doesn't work but getEntriesByType does
@@ -238,9 +238,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
238
238
  }
239
239
  onHarvestFinished(result) {
240
240
  if (result.retry && this.timingsSent.length > 0) {
241
- for (var i = 0; i < this.timingsSent.length; i++) {
242
- this.timings.push(this.timingsSent[i]);
243
- }
241
+ this.timings.unshift(...this.timingsSent);
244
242
  this.timingsSent = [];
245
243
  }
246
244
  }
@@ -11,7 +11,7 @@ var _eventListenerOpts = require("../../../common/event-listener/event-listener-
11
11
  var _now = require("../../../common/timing/now");
12
12
  var _instrumentBase = require("../../utils/instrument-base");
13
13
  var _constants = require("../constants");
14
- var _globalScope = require("../../../common/util/global-scope");
14
+ var _runtime = require("../../../common/constants/runtime");
15
15
  /*
16
16
  * Copyright 2020 New Relic Corporation. All rights reserved.
17
17
  * SPDX-License-Identifier: Apache-2.0
@@ -22,7 +22,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
22
22
  constructor(agentIdentifier, aggregator) {
23
23
  let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
24
24
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
25
- if (!_globalScope.isBrowserScope) return; // CWV is irrelevant outside web context
25
+ if (!_runtime.isBrowserScope) return; // CWV is irrelevant outside web context
26
26
 
27
27
  // Document visibility state becomes hidden; this should run as soon as possible in page life.
28
28
  // While we try to replicate web-vital's visibilitywatcher logic in an effort to defer that library to post-pageload, this isn't perfect and doesn't consider prerendering.
@@ -20,8 +20,8 @@ async function getSessionReplayMode(agentId) {
20
20
  const newrelic = (0, _nreum.gosNREUM)();
21
21
  // Should be enabled by configuration and using an agent build that includes it (via checking that the instrument class was initialized).
22
22
  if ((0, _config.getConfigurationValue)(agentId, 'session_replay.enabled') && typeof newrelic.initializedAgents[agentId].features.session_replay === 'object') {
23
- await newrelic.initializedAgents[agentId].features.session_replay.onAggregateImported; // if Replay could not initialize, this throws a (uncaught) rejection
24
- return await _sharedChannel.sharedChannel.sessionReplayInitialized; // wait for replay to determine which mode it's after running its sampling logic
23
+ const srInitialized = await newrelic.initializedAgents[agentId].features.session_replay.onAggregateImported;
24
+ if (srInitialized) return await _sharedChannel.sharedChannel.sessionReplayInitialized; // wait for replay to determine which mode it's after running its sampling logic
25
25
  }
26
26
  } catch (e) {/* exception ==> off */}
27
27
  return _sessionEntity.MODE.OFF; // at any step of the way s.t. SR cannot be on by implication or is explicitly off
@@ -10,7 +10,7 @@ var _now = require("../../../common/timing/now");
10
10
  var _instrumentBase = require("../../utils/instrument-base");
11
11
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
12
12
  var _features = require("../../../loaders/features/features");
13
- var _globalScope = require("../../../common/util/global-scope");
13
+ var _runtime = require("../../../common/constants/runtime");
14
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
16
  /*
@@ -33,7 +33,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
33
33
  constructor(agentIdentifier, aggregator) {
34
34
  let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
35
35
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
36
- if (!_globalScope.isBrowserScope) return; // session traces not supported outside web env
36
+ if (!_runtime.isBrowserScope) return; // session traces not supported outside web env
37
37
 
38
38
  const thisInstrumentEE = this.ee;
39
39
  (0, _wrap.wrapHistory)(thisInstrumentEE);
@@ -628,7 +628,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
628
628
  function onHarvestFinished(result) {
629
629
  if (result.sent && result.retry && state.interactionsSent.length > 0) {
630
630
  state.interactionsSent.forEach(function (interaction) {
631
- state.interactionsToHarvest.push(interaction);
631
+ state.interactionsToHarvest.unshift(interaction);
632
632
  });
633
633
  state.interactionsSent = [];
634
634
  }
@@ -10,7 +10,7 @@ var _instrumentBase = require("../../utils/instrument-base");
10
10
  var _config = require("../../../common/config/config");
11
11
  var _now = require("../../../common/timing/now");
12
12
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
13
- var _globalScope = require("../../../common/util/global-scope");
13
+ var _runtime = require("../../../common/constants/runtime");
14
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
16
  /*
@@ -35,7 +35,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
35
35
  constructor(agentIdentifier, aggregator) {
36
36
  let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
37
37
  super(agentIdentifier, aggregator, FEATURE_NAME, auto);
38
- if (!_globalScope.isBrowserScope) return; // SPA not supported outside web env
38
+ if (!_runtime.isBrowserScope) return; // SPA not supported outside web env
39
39
 
40
40
  if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
41
41
  try {
@@ -7,7 +7,7 @@ exports.InstrumentBase = void 0;
7
7
  var _drain = require("../../common/drain/drain");
8
8
  var _featureBase = require("./feature-base");
9
9
  var _load = require("../../common/window/load");
10
- var _globalScope = require("../../common/util/global-scope");
10
+ var _runtime = require("../../common/constants/runtime");
11
11
  var _console = require("../../common/util/console");
12
12
  var _features = require("../../loaders/features/features");
13
13
  var _config = require("../../common/config/config");
@@ -60,11 +60,10 @@ class InstrumentBase extends _featureBase.FeatureBase {
60
60
  importAggregator() {
61
61
  let argsObjFromInstrument = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
62
  if (this.featAggregate || !this.auto) return;
63
- const enableSessionTracking = _globalScope.isBrowserScope && (0, _config.getConfigurationValue)(this.agentIdentifier, 'privacy.cookies_enabled') === true;
63
+ const enableSessionTracking = _runtime.isBrowserScope && (0, _config.getConfigurationValue)(this.agentIdentifier, 'privacy.cookies_enabled') === true;
64
64
  let loadedSuccessfully, loadFailed;
65
- this.onAggregateImported = new Promise((resolve, reject) => {
65
+ this.onAggregateImported = new Promise(resolve => {
66
66
  loadedSuccessfully = resolve;
67
- loadFailed = reject;
68
67
  });
69
68
  const importLater = async () => {
70
69
  let session;
@@ -96,18 +95,18 @@ class InstrumentBase extends _featureBase.FeatureBase {
96
95
  Aggregate
97
96
  } = await lazyFeatureLoader(this.featureName, 'aggregate');
98
97
  this.featAggregate = new Aggregate(this.agentIdentifier, this.aggregator, argsObjFromInstrument);
99
- loadedSuccessfully();
98
+ loadedSuccessfully(true);
100
99
  } catch (e) {
101
100
  (0, _console.warn)("Downloading and initializing ".concat(this.featureName, " failed..."), e);
102
101
  this.abortHandler?.(); // undo any important alterations made to the page
103
102
  // not supported yet but nice to do: "abort" this agent's EE for this feature specifically
104
- loadFailed();
103
+ loadedSuccessfully(false);
105
104
  }
106
105
  };
107
106
 
108
107
  // For regular web pages, we want to wait and lazy-load the aggregator only after all page resources are loaded.
109
108
  // Non-browser scopes (i.e. workers) have no `window.load` event, so the aggregator can be lazy-loaded immediately.
110
- if (!_globalScope.isBrowserScope) importLater();else (0, _load.onWindowLoad)(() => importLater(), true);
109
+ if (!_runtime.isBrowserScope) importLater();else (0, _load.onWindowLoad)(() => importLater(), true);
111
110
  }
112
111
 
113
112
  /**
package/dist/cjs/index.js CHANGED
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "Metrics", {
33
33
  return _metrics.Metrics;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "MicroAgent", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _microAgent.MicroAgent;
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "PageAction", {
37
43
  enumerable: true,
38
44
  get: function () {
@@ -72,6 +78,7 @@ Object.defineProperty(exports, "WorkerAgent", {
72
78
  var _agent = require("./loaders/agent");
73
79
  var _browserAgent = require("./loaders/browser-agent");
74
80
  var _workerAgent = require("./loaders/worker-agent");
81
+ var _microAgent = require("./loaders/micro-agent");
75
82
  var _ajax = require("./features/ajax");
76
83
  var _jserrors = require("./features/jserrors");
77
84
  var _metrics = require("./features/metrics");
@@ -15,6 +15,7 @@ var _uniqueId = require("../common/ids/unique-id");
15
15
  var _config = require("../common/config/config");
16
16
  var _console = require("../common/util/console");
17
17
  var _stringify = require("../common/util/stringify");
18
+ var _runtime = require("../common/constants/runtime");
18
19
  // loader files
19
20
 
20
21
  // required features
@@ -28,6 +29,12 @@ var _stringify = require("../common/util/stringify");
28
29
  class Agent {
29
30
  constructor(options) {
30
31
  let agentIdentifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _uniqueId.generateRandomHexString)(16);
32
+ if (!_runtime.globalScope) {
33
+ // We could not determine the runtime environment. Short-circuite the agent here
34
+ // to avoid possible exceptions later that may cause issues with customer's application.
35
+ (0, _console.warn)('Failed to initial the agent. Could not determine the runtime environment.');
36
+ return;
37
+ }
31
38
  this.agentIdentifier = agentIdentifier;
32
39
  this.sharedAggregator = new _aggregator.Aggregator({
33
40
  agentIdentifier: this.agentIdentifier
@@ -13,7 +13,7 @@ var _contextualEe = require("../../common/event-emitter/contextual-ee");
13
13
  var _now = require("../../common/timing/now");
14
14
  var _drain = require("../../common/drain/drain");
15
15
  var _load = require("../../common/window/load");
16
- var _globalScope = require("../../common/util/global-scope");
16
+ var _runtime = require("../../common/constants/runtime");
17
17
  var _console = require("../../common/util/console");
18
18
  var _constants = require("../../features/metrics/constants");
19
19
  var _nreum = require("../../common/window/nreum");
@@ -158,7 +158,7 @@ function setAPI(agentIdentifier, forceDrain) {
158
158
  };
159
159
 
160
160
  // theres no window.load event on non-browser scopes, lazy load immediately
161
- if (!_globalScope.isBrowserScope) lazyLoad();
161
+ if (!_runtime.isBrowserScope) lazyLoad();
162
162
  // try to stay out of the way of the window.load event, lazy load once that has finished.
163
163
  else (0, _load.onWindowLoad)(() => lazyLoad(), true);
164
164
  function lazyLoad() {
@@ -10,9 +10,11 @@ var _contextualEe = require("../../common/event-emitter/contextual-ee");
10
10
  var _handle = require("../../common/event-emitter/handle");
11
11
  var _registerHandler = require("../../common/event-emitter/register-handler");
12
12
  var _invoke = require("../../common/util/invoke");
13
- var _submitData = require("../../common/util/submit-data");
14
- var _globalScope = require("../../common/util/global-scope");
13
+ var submitData = _interopRequireWildcard(require("../../common/util/submit-data"));
14
+ var _runtime = require("../../common/constants/runtime");
15
15
  var _constants = require("../../features/metrics/constants");
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
18
  function setAPI(agentIdentifier) {
17
19
  var instanceEE = _contextualEe.ee.get(agentIdentifier);
18
20
  var cycle = 0;
@@ -67,7 +69,7 @@ function setAPI(agentIdentifier) {
67
69
  // dom_time - the time spent processing the result of the service call (or user defined)
68
70
  // fe_time - the time spent rendering the result of the service call (or user defined)
69
71
  function inlineHit(t, request_name, queue_time, app_time, total_be_time, dom_time, fe_time) {
70
- if (!_globalScope.isBrowserScope) return;
72
+ if (!_runtime.isBrowserScope) return;
71
73
  request_name = window.encodeURIComponent(request_name);
72
74
  cycle += 1;
73
75
  const agentInfo = (0, _config.getInfo)(agentIdentifier);
@@ -82,7 +84,7 @@ function setAPI(agentIdentifier) {
82
84
  url += 'dc=' + ~~dom_time + '&';
83
85
  url += 'fe=' + ~~fe_time + '&';
84
86
  url += 'c=' + cycle;
85
- _submitData.submitData.img({
87
+ submitData.xhr({
86
88
  url
87
89
  });
88
90
  }
@@ -8,7 +8,7 @@ var _api = require("../api/api");
8
8
  var _nreum = require("../../common/window/nreum");
9
9
  var _config = require("../../common/config/config");
10
10
  var _featureFlags = require("../../common/util/feature-flags");
11
- var _globalScope = require("../../common/util/global-scope");
11
+ var _runtime = require("../../common/constants/runtime");
12
12
  function configure(agentIdentifier) {
13
13
  let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
14
  let loaderType = arguments.length > 2 ? arguments[2] : undefined;
@@ -32,7 +32,7 @@ function configure(agentIdentifier) {
32
32
  (0, _config.setLoaderConfig)(agentIdentifier, loader_config || {});
33
33
  (0, _config.setRuntime)(agentIdentifier, runtime);
34
34
  info.jsAttributes ??= {};
35
- if (_globalScope.isWorkerScope) {
35
+ if (_runtime.isWorkerScope) {
36
36
  // add a default attr to all worker payloads
37
37
  info.jsAttributes.isWorker = true;
38
38
  }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MicroAgent = void 0;
7
+ var _instrument = require("../features/page_view_event/instrument");
7
8
  var _enabledFeatures = require("./features/enabled-features");
8
9
  var _configure = require("./configure/configure");
9
10
  var _aggregator = require("../common/aggregate/aggregator");
@@ -12,17 +13,16 @@ var _uniqueId = require("../common/ids/unique-id");
12
13
  var _config = require("../common/config/config");
13
14
  var _features = require("./features/features");
14
15
  var _console = require("../common/util/console");
16
+ var _load = require("../common/window/load");
15
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } // loader files
17
19
  // core files
18
- const nonAutoFeatures = [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.pageAction];
19
- const autoFeatures = [_features.FEATURE_NAMES.metrics];
20
+ const nonAutoFeatures = [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.pageAction, _features.FEATURE_NAMES.metrics];
20
21
 
21
22
  /**
22
- * A minimal agent class designed to be loaded multiple times on the same page, each instance narrowly scoped to the
23
- * concerns of a particular component, as with the micro-frontend architectural pattern. This class does not
24
- * automatically instrument. Instead, each MicroAgent instance may be configured to lazy-load specific
25
- * instrumentations at runtime, and to report desired data, events, and errors programatically.
23
+ * A minimal agent class designed to only respond to manual user input. As such, this class does not
24
+ * automatically instrument. Instead, each MicroAgent instance will lazy load the required features and can support loading multiple instances on one page.
25
+ * Out of the box, it can manually handle and report Page View, Page Action, and Error events.
26
26
  */
27
27
  class MicroAgent {
28
28
  /**
@@ -55,38 +55,29 @@ class MicroAgent {
55
55
  start() {
56
56
  try {
57
57
  const enabledFeatures = (0, _enabledFeatures.getEnabledFeatures)(this.agentIdentifier);
58
- autoFeatures.forEach(f => {
59
- if (enabledFeatures[f]) {
60
- // TODO - THIS does not work, the instrument switch in lazy loader increases the size of the worker build. Needs to be revisited
61
- Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(_ref => {
62
- let {
63
- lazyFeatureLoader
64
- } = _ref;
65
- return lazyFeatureLoader(f, 'instrument');
66
- }).then(_ref2 => {
67
- let {
68
- Instrument
69
- } = _ref2;
70
- this.features[f] = new Instrument(this.agentIdentifier, this.sharedAggregator);
71
- }).catch(err => (0, _console.warn)('Something prevented the agent from being downloaded.'));
72
- }
73
- });
74
- nonAutoFeatures.forEach(f => {
75
- if (enabledFeatures[f]) {
76
- // TODO - THIS does not work, the instrument switch in lazy loader increases the size of the worker build. Needs to be revisited
77
- // Parts of the lazy-loader were removed because webpack was transpiling them into the worker build, errantly inflating the build size.
78
- Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(_ref3 => {
79
- let {
80
- lazyFeatureLoader
81
- } = _ref3;
82
- return lazyFeatureLoader(f, 'aggregate');
83
- }).then(_ref4 => {
84
- let {
85
- Aggregate
86
- } = _ref4;
87
- this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator);
88
- }).catch(err => (0, _console.warn)('Something prevented the agent from being downloaded.'));
89
- }
58
+ try {
59
+ // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
60
+ this.features.page_view_event = new _instrument.Instrument(this.agentIdentifier, this.sharedAggregator);
61
+ } catch (err) {
62
+ (0, _console.warn)('Something prevented the agent from instrumenting.', err);
63
+ }
64
+ (0, _load.onWindowLoad)(() => {
65
+ // these features do not import an "instrument" file, meaning they are only hooked up to the API.
66
+ nonAutoFeatures.forEach(f => {
67
+ if (enabledFeatures[f]) {
68
+ Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-feature-loader" */'../features/utils/lazy-feature-loader'))).then(_ref => {
69
+ let {
70
+ lazyFeatureLoader
71
+ } = _ref;
72
+ return lazyFeatureLoader(f, 'aggregate');
73
+ }).then(_ref2 => {
74
+ let {
75
+ Aggregate
76
+ } = _ref2;
77
+ this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator);
78
+ }).catch(err => (0, _console.warn)('Something prevented the agent from being downloaded.', err));
79
+ }
80
+ });
90
81
  });
91
82
  (0, _nreum.gosNREUMInitializedAgents)(this.agentIdentifier, this.features, 'features');
92
83
  return this;
@@ -58,6 +58,9 @@ const model = () => {
58
58
  enabled: true,
59
59
  harvestTimeSeconds: 10
60
60
  },
61
+ harvest: {
62
+ tooManyRequestsDelay: 60
63
+ },
61
64
  session_replay: {
62
65
  // feature settings
63
66
  enabled: false,
@@ -1,6 +1,6 @@
1
1
  import { getModeledObject } from './configurable';
2
2
  import { gosNREUMInitializedAgents } from '../../window/nreum';
3
- import { globalScope } from '../../util/global-scope';
3
+ import { globalScope } from '../../constants/runtime';
4
4
  import { BUILD_ENV, DIST_METHOD, VERSION } from "../../constants/env.npm";
5
5
  const model = {
6
6
  buildEnv: BUILD_ENV,
@@ -6,13 +6,13 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.235.0";
9
+ export const VERSION = "1.236.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
13
13
  * Valid values are LOCAL, PROD, DEV
14
14
  */
15
- export const BUILD_ENV = undefined;
15
+ export const BUILD_ENV = "CDN";
16
16
 
17
17
  /**
18
18
  * Exposes the distribution method of the agent
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.235.0";
9
+ export const VERSION = "1.236.0";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @file Contains constants about the environment the agent is running
3
+ * within. These values are derived at the time the agent is first loaded.
4
+ * @copyright 2023 New Relic Corporation. All rights reserved.
5
+ * @license Apache-2.0
6
+ */
7
+
8
+ /**
9
+ * Indicates if the agent is running within a normal browser window context.
10
+ */
11
+ export const isBrowserScope = typeof window !== 'undefined' && !!window.document;
12
+
13
+ /**
14
+ * Indicates if the agent is running within a worker context.
15
+ */
16
+ export const isWorkerScope = typeof WorkerGlobalScope !== 'undefined' && (typeof self !== 'undefined' && self instanceof WorkerGlobalScope && self.navigator instanceof WorkerNavigator || typeof globalThis !== 'undefined' && globalThis instanceof WorkerGlobalScope && globalThis.navigator instanceof WorkerNavigator);
17
+ export const globalScope = isBrowserScope ? window : typeof WorkerGlobalScope !== 'undefined' && (typeof self !== 'undefined' && self instanceof WorkerGlobalScope && self || typeof globalThis !== 'undefined' && globalThis instanceof WorkerGlobalScope && globalThis);
18
+ export const initialLocation = '' + globalScope?.location;
19
+ export const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
20
+
21
+ /**
22
+ * Shared Web Workers introduced in iOS 16.0+ and n/a in 15.6-
23
+ *
24
+ * It was discovered in Safari 14 (https://bugs.webkit.org/show_bug.cgi?id=225305) that the buffered flag in PerformanceObserver
25
+ * did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
26
+ * This was fixed in v16+.
27
+ */
28
+ export const iOS_below16 = isiOS && typeof SharedWorker === 'undefined';
29
+ export const ffVersion = (() => {
30
+ const match = navigator.userAgent.match(/Firefox[/\s](\d+\.\d+)/);
31
+ if (Array.isArray(match) && match.length >= 2) {
32
+ return +match[1];
33
+ }
34
+ return 0;
35
+ })();
36
+ export const isIE = Boolean(isBrowserScope && window.document.documentMode); // deprecated property that only works in IE
37
+
38
+ export const supportsSendBeacon = !!navigator.sendBeacon;
@@ -1,4 +1,4 @@
1
- import { globalScope } from '../util/global-scope';
1
+ import { globalScope } from '../constants/runtime';
2
2
 
3
3
  /*
4
4
  * See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#safely_detecting_option_support