@newrelic/browser-agent 0.0.9 → 0.1.229

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 (339) hide show
  1. package/README.md +84 -207
  2. package/dist/cjs/cdn/lite.js +14 -0
  3. package/dist/cjs/cdn/polyfills/lite.js +4 -0
  4. package/dist/cjs/cdn/polyfills/pro.js +4 -0
  5. package/dist/cjs/cdn/polyfills/spa.js +4 -0
  6. package/dist/cjs/cdn/polyfills.js +14 -0
  7. package/dist/cjs/cdn/pro.js +19 -0
  8. package/dist/cjs/cdn/spa.js +19 -0
  9. package/dist/cjs/cdn/worker.js +16 -0
  10. package/dist/cjs/common/aggregate/aggregator.js +168 -0
  11. package/dist/cjs/common/browser-version/firefox-version.js +17 -0
  12. package/dist/cjs/common/browser-version/ios-version.js +18 -0
  13. package/dist/cjs/common/config/config.js +76 -0
  14. package/dist/cjs/common/config/state/configurable.js +32 -0
  15. package/dist/cjs/common/config/state/info.js +50 -0
  16. package/dist/cjs/common/config/state/init.js +86 -0
  17. package/dist/cjs/common/config/state/loader-config.js +28 -0
  18. package/dist/cjs/common/config/state/originals.js +9 -0
  19. package/dist/cjs/common/config/state/runtime.js +50 -0
  20. package/dist/cjs/common/constants/environment-variables.js +20 -0
  21. package/dist/cjs/common/context/shared-context.js +25 -0
  22. package/dist/cjs/common/deny-list/deny-list.js +108 -0
  23. package/dist/cjs/common/drain/drain.js +126 -0
  24. package/dist/cjs/common/event-emitter/contextual-ee.js +149 -0
  25. package/dist/cjs/common/event-emitter/handle.js +24 -0
  26. package/dist/cjs/common/event-emitter/register-handler.js +24 -0
  27. package/dist/cjs/common/event-listener/event-listener-opts.js +46 -0
  28. package/dist/cjs/common/harvest/harvest-scheduler.js +111 -0
  29. package/dist/cjs/common/harvest/harvest.js +236 -0
  30. package/dist/cjs/common/ids/id.js +30 -0
  31. package/dist/cjs/common/ids/unique-id.js +84 -0
  32. package/dist/cjs/common/metrics/framework-detection.js +72 -0
  33. package/dist/cjs/common/metrics/paint-metrics.js +13 -0
  34. package/dist/cjs/common/serialize/bel-serializer.js +89 -0
  35. package/dist/cjs/common/timing/nav-timing.js +77 -0
  36. package/dist/cjs/common/timing/now.js +15 -0
  37. package/dist/cjs/common/unload/eol.js +69 -0
  38. package/dist/cjs/common/url/clean-url.js +16 -0
  39. package/dist/cjs/common/url/encode.js +79 -0
  40. package/dist/cjs/common/url/location.js +14 -0
  41. package/dist/cjs/common/url/parse-url.js +66 -0
  42. package/dist/cjs/common/url/protocol.js +25 -0
  43. package/dist/cjs/common/util/console.js +17 -0
  44. package/dist/cjs/common/util/data-size.js +25 -0
  45. package/dist/cjs/common/util/feature-flags.js +42 -0
  46. package/dist/cjs/common/util/get-or-set.js +39 -0
  47. package/dist/cjs/common/util/global-scope.js +56 -0
  48. package/dist/cjs/common/util/map-own.js +24 -0
  49. package/dist/cjs/common/util/obfuscate.js +76 -0
  50. package/dist/cjs/common/util/reduce.js +22 -0
  51. package/dist/cjs/common/util/s-hash.js +19 -0
  52. package/dist/cjs/common/util/single.js +23 -0
  53. package/dist/cjs/common/util/stringify.js +47 -0
  54. package/dist/cjs/common/util/submit-data.js +99 -0
  55. package/dist/cjs/common/util/traverse.js +41 -0
  56. package/dist/cjs/common/util/user-agent.js +57 -0
  57. package/dist/cjs/common/window/load.js +19 -0
  58. package/dist/cjs/common/window/nreum.js +107 -0
  59. package/dist/cjs/common/window/page-visibility.js +28 -0
  60. package/dist/cjs/common/window/session-storage.js +42 -0
  61. package/dist/cjs/common/window/supports-performance-observer.js +15 -0
  62. package/dist/cjs/common/window/top-level-callers.js +23 -0
  63. package/dist/cjs/common/wrap/index.js +68 -0
  64. package/dist/cjs/common/wrap/wrap-events.js +105 -0
  65. package/dist/cjs/common/wrap/wrap-fetch.js +114 -0
  66. package/dist/cjs/common/wrap/wrap-function.js +269 -0
  67. package/dist/cjs/common/wrap/wrap-history.js +56 -0
  68. package/dist/cjs/common/wrap/wrap-jsonp.js +129 -0
  69. package/dist/cjs/common/wrap/wrap-mutation.js +61 -0
  70. package/dist/cjs/common/wrap/wrap-promise.js +160 -0
  71. package/dist/cjs/common/wrap/wrap-raf.js +55 -0
  72. package/dist/cjs/common/wrap/wrap-timer.js +70 -0
  73. package/dist/cjs/common/wrap/wrap-xhr.js +206 -0
  74. package/dist/cjs/features/ajax/aggregate/index.js +226 -0
  75. package/dist/cjs/features/ajax/constants.js +9 -0
  76. package/dist/cjs/features/ajax/index.js +12 -0
  77. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +145 -0
  78. package/dist/cjs/features/ajax/instrument/index.js +338 -0
  79. package/dist/cjs/features/ajax/instrument/response-size.js +26 -0
  80. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +18 -0
  81. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +30 -0
  82. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +216 -0
  83. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +257 -0
  84. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.js +36 -0
  85. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
  86. package/dist/cjs/features/jserrors/aggregate/index.js +267 -0
  87. package/dist/cjs/features/jserrors/aggregate/string-hash-code.js +23 -0
  88. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +26 -0
  89. package/dist/cjs/features/jserrors/constants.js +11 -0
  90. package/dist/cjs/features/jserrors/index.js +12 -0
  91. package/dist/cjs/features/jserrors/instrument/debug.js +40 -0
  92. package/dist/cjs/features/jserrors/instrument/index.js +158 -0
  93. package/dist/cjs/features/metrics/aggregate/index.js +136 -0
  94. package/dist/cjs/features/metrics/constants.js +17 -0
  95. package/dist/cjs/features/metrics/index.js +12 -0
  96. package/dist/cjs/features/metrics/instrument/index.js +20 -0
  97. package/dist/cjs/features/metrics/instrument/workers-helper.js +121 -0
  98. package/dist/cjs/features/page_action/aggregate/index.js +112 -0
  99. package/dist/cjs/features/page_action/constants.js +9 -0
  100. package/dist/cjs/features/page_action/index.js +12 -0
  101. package/dist/cjs/features/page_action/instrument/index.js +21 -0
  102. package/dist/cjs/features/page_view_event/aggregate/index.js +133 -0
  103. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +39 -0
  104. package/dist/cjs/features/page_view_event/constants.js +15 -0
  105. package/dist/cjs/features/page_view_event/index.js +12 -0
  106. package/dist/cjs/features/page_view_event/instrument/index.js +38 -0
  107. package/dist/cjs/features/page_view_timing/aggregate/index.js +265 -0
  108. package/dist/cjs/features/page_view_timing/constants.js +9 -0
  109. package/dist/cjs/features/page_view_timing/first-paint.js +50 -0
  110. package/dist/cjs/features/page_view_timing/index.js +12 -0
  111. package/dist/cjs/features/page_view_timing/instrument/index.js +36 -0
  112. package/dist/cjs/features/page_view_timing/long-tasks.js +75 -0
  113. package/dist/cjs/features/session_trace/aggregate/index.js +375 -0
  114. package/dist/cjs/features/session_trace/constants.js +32 -0
  115. package/dist/cjs/features/session_trace/index.js +12 -0
  116. package/dist/cjs/features/session_trace/instrument/index.js +133 -0
  117. package/dist/cjs/features/spa/aggregate/index.js +684 -0
  118. package/dist/cjs/features/spa/aggregate/interaction-node.js +84 -0
  119. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +16 -0
  120. package/dist/cjs/features/spa/aggregate/interaction.js +98 -0
  121. package/dist/cjs/features/spa/aggregate/serializer.js +147 -0
  122. package/dist/cjs/features/spa/constants.js +53 -0
  123. package/dist/cjs/features/spa/index.js +12 -0
  124. package/dist/cjs/features/spa/instrument/index.js +114 -0
  125. package/dist/cjs/features/utils/aggregate-base.js +13 -0
  126. package/dist/cjs/features/utils/feature-base.js +58 -0
  127. package/dist/cjs/features/utils/handler-cache.js +64 -0
  128. package/dist/cjs/features/utils/instrument-base.js +71 -0
  129. package/dist/cjs/features/utils/lazy-loader.js +44 -0
  130. package/dist/cjs/index.js +81 -58
  131. package/dist/cjs/loaders/agent.js +86 -0
  132. package/dist/cjs/loaders/api/api.js +109 -0
  133. package/dist/cjs/loaders/api/apiAsync.js +94 -0
  134. package/dist/cjs/loaders/browser-agent.js +29 -0
  135. package/dist/cjs/loaders/configure/configure.js +47 -0
  136. package/dist/cjs/loaders/features/enabled-features.js +19 -0
  137. package/dist/cjs/loaders/features/featureDependencies.js +32 -0
  138. package/dist/cjs/loaders/features/features.js +33 -0
  139. package/dist/cjs/loaders/micro-agent.js +93 -0
  140. package/dist/cjs/loaders/worker-agent.js +24 -0
  141. package/dist/esm/cdn/lite.js +12 -0
  142. package/dist/esm/cdn/polyfills/lite.js +7 -0
  143. package/dist/esm/cdn/polyfills/pro.js +7 -0
  144. package/dist/esm/cdn/polyfills/spa.js +7 -0
  145. package/dist/esm/cdn/polyfills.js +17 -0
  146. package/dist/esm/cdn/pro.js +17 -0
  147. package/dist/esm/cdn/spa.js +17 -0
  148. package/dist/esm/cdn/worker.js +14 -0
  149. package/dist/esm/common/aggregate/aggregator.js +161 -0
  150. package/dist/esm/common/browser-version/firefox-version.js +10 -0
  151. package/dist/esm/common/browser-version/ios-version.js +10 -0
  152. package/dist/esm/common/config/config.js +11 -0
  153. package/dist/esm/common/config/state/configurable.js +25 -0
  154. package/dist/esm/common/config/state/info.js +42 -0
  155. package/dist/esm/common/config/state/init.js +78 -0
  156. package/dist/esm/common/config/state/loader-config.js +21 -0
  157. package/dist/esm/common/config/state/originals.js +2 -0
  158. package/dist/esm/common/config/state/runtime.js +41 -0
  159. package/dist/esm/common/constants/environment-variables.js +11 -0
  160. package/dist/esm/common/context/shared-context.js +18 -0
  161. package/dist/esm/common/deny-list/deny-list.js +101 -0
  162. package/dist/esm/common/drain/drain.js +119 -0
  163. package/dist/esm/common/event-emitter/contextual-ee.js +142 -0
  164. package/dist/esm/common/event-emitter/handle.js +16 -0
  165. package/dist/esm/common/event-emitter/register-handler.js +19 -0
  166. package/dist/esm/common/event-listener/event-listener-opts.js +39 -0
  167. package/dist/esm/common/harvest/harvest-scheduler.js +105 -0
  168. package/dist/esm/common/harvest/harvest.js +228 -0
  169. package/dist/esm/common/ids/id.js +23 -0
  170. package/dist/esm/common/ids/unique-id.js +75 -0
  171. package/dist/esm/common/metrics/framework-detection.js +66 -0
  172. package/dist/esm/common/metrics/paint-metrics.js +6 -0
  173. package/dist/esm/common/serialize/bel-serializer.js +80 -0
  174. package/dist/esm/common/timing/nav-timing.js +67 -0
  175. package/dist/esm/common/timing/now.js +9 -0
  176. package/dist/esm/common/unload/eol.js +62 -0
  177. package/dist/esm/common/url/clean-url.js +10 -0
  178. package/dist/esm/common/url/encode.js +71 -0
  179. package/dist/esm/common/url/location.js +8 -0
  180. package/dist/esm/common/url/parse-url.js +60 -0
  181. package/dist/esm/common/url/protocol.js +17 -0
  182. package/dist/esm/common/util/console.js +11 -0
  183. package/dist/esm/common/util/data-size.js +19 -0
  184. package/dist/esm/common/util/feature-flags.js +33 -0
  185. package/dist/esm/common/util/get-or-set.js +33 -0
  186. package/dist/esm/common/util/global-scope.js +44 -0
  187. package/dist/esm/common/util/map-own.js +18 -0
  188. package/dist/esm/common/util/obfuscate.js +67 -0
  189. package/dist/esm/common/util/reduce.js +16 -0
  190. package/dist/esm/common/util/s-hash.js +13 -0
  191. package/dist/esm/common/util/single.js +16 -0
  192. package/dist/esm/common/util/stringify.js +42 -0
  193. package/dist/esm/common/util/submit-data.js +91 -0
  194. package/dist/esm/common/util/traverse.js +35 -0
  195. package/dist/esm/common/util/user-agent.js +48 -0
  196. package/dist/esm/common/window/load.js +12 -0
  197. package/dist/esm/common/window/nreum.js +91 -0
  198. package/dist/esm/common/window/page-visibility.js +23 -0
  199. package/dist/esm/common/window/session-storage.js +36 -0
  200. package/dist/esm/common/window/supports-performance-observer.js +9 -0
  201. package/dist/esm/common/window/top-level-callers.js +17 -0
  202. package/dist/esm/common/wrap/index.js +14 -0
  203. package/dist/esm/common/wrap/wrap-events.js +97 -0
  204. package/dist/esm/common/wrap/wrap-fetch.js +105 -0
  205. package/dist/esm/common/wrap/wrap-function.js +257 -0
  206. package/dist/esm/common/wrap/wrap-history.js +48 -0
  207. package/dist/esm/common/wrap/wrap-jsonp.js +122 -0
  208. package/dist/esm/common/wrap/wrap-mutation.js +54 -0
  209. package/dist/esm/common/wrap/wrap-promise.js +153 -0
  210. package/dist/esm/common/wrap/wrap-raf.js +48 -0
  211. package/dist/esm/common/wrap/wrap-timer.js +63 -0
  212. package/dist/esm/common/wrap/wrap-xhr.js +199 -0
  213. package/dist/esm/features/ajax/aggregate/index.js +218 -0
  214. package/dist/esm/features/ajax/constants.js +2 -0
  215. package/dist/esm/features/ajax/index.js +1 -0
  216. package/dist/esm/features/ajax/instrument/distributed-tracing.js +137 -0
  217. package/dist/esm/features/ajax/instrument/index.js +330 -0
  218. package/dist/esm/features/ajax/instrument/response-size.js +19 -0
  219. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -0
  220. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +28 -0
  221. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +209 -0
  222. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +255 -0
  223. package/dist/esm/features/jserrors/aggregate/format-stack-trace.js +29 -0
  224. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +37 -0
  225. package/dist/esm/features/jserrors/aggregate/index.js +260 -0
  226. package/dist/esm/features/jserrors/aggregate/string-hash-code.js +17 -0
  227. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +24 -0
  228. package/dist/esm/features/jserrors/constants.js +3 -0
  229. package/dist/esm/features/jserrors/index.js +1 -0
  230. package/dist/esm/features/jserrors/instrument/debug.js +38 -0
  231. package/dist/esm/features/jserrors/instrument/index.js +150 -0
  232. package/dist/esm/features/metrics/aggregate/index.js +129 -0
  233. package/dist/esm/features/metrics/constants.js +6 -0
  234. package/dist/esm/features/metrics/index.js +1 -0
  235. package/dist/esm/features/metrics/instrument/index.js +13 -0
  236. package/dist/esm/features/metrics/instrument/workers-helper.js +116 -0
  237. package/dist/esm/features/page_action/aggregate/index.js +105 -0
  238. package/dist/esm/features/page_action/constants.js +2 -0
  239. package/dist/esm/features/page_action/index.js +1 -0
  240. package/dist/esm/features/page_action/instrument/index.js +14 -0
  241. package/dist/esm/features/page_view_event/aggregate/index.js +124 -0
  242. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +34 -0
  243. package/dist/esm/features/page_view_event/constants.js +5 -0
  244. package/dist/esm/features/page_view_event/index.js +1 -0
  245. package/dist/esm/features/page_view_event/instrument/index.js +29 -0
  246. package/dist/esm/features/page_view_timing/aggregate/index.js +258 -0
  247. package/dist/esm/features/page_view_timing/constants.js +2 -0
  248. package/dist/esm/features/page_view_timing/first-paint.js +43 -0
  249. package/dist/esm/features/page_view_timing/index.js +1 -0
  250. package/dist/esm/features/page_view_timing/instrument/index.js +28 -0
  251. package/dist/esm/features/page_view_timing/long-tasks.js +69 -0
  252. package/dist/esm/features/session_trace/aggregate/index.js +366 -0
  253. package/dist/esm/features/session_trace/constants.js +14 -0
  254. package/dist/esm/features/session_trace/index.js +1 -0
  255. package/dist/esm/features/session_trace/instrument/index.js +123 -0
  256. package/dist/esm/features/spa/aggregate/index.js +674 -0
  257. package/dist/esm/features/spa/aggregate/interaction-node.js +78 -0
  258. package/dist/esm/features/spa/aggregate/interaction-node.test.js +14 -0
  259. package/dist/esm/features/spa/aggregate/interaction.js +92 -0
  260. package/dist/esm/features/spa/aggregate/serializer.js +139 -0
  261. package/dist/esm/features/spa/constants.js +25 -0
  262. package/dist/esm/features/spa/index.js +1 -0
  263. package/dist/esm/features/spa/instrument/index.js +104 -0
  264. package/dist/esm/features/utils/aggregate-base.js +6 -0
  265. package/dist/esm/features/utils/feature-base.js +51 -0
  266. package/dist/esm/features/utils/handler-cache.js +57 -0
  267. package/dist/esm/features/utils/instrument-base.js +69 -0
  268. package/dist/esm/features/utils/lazy-loader.js +37 -0
  269. package/dist/esm/index.js +15 -0
  270. package/dist/esm/loaders/agent.js +77 -0
  271. package/dist/esm/loaders/api/api.js +104 -0
  272. package/dist/esm/loaders/api/apiAsync.js +88 -0
  273. package/dist/esm/loaders/browser-agent.js +23 -0
  274. package/dist/esm/loaders/configure/configure.js +41 -0
  275. package/dist/esm/loaders/features/enabled-features.js +13 -0
  276. package/dist/esm/loaders/features/featureDependencies.js +25 -0
  277. package/dist/esm/loaders/features/features.js +25 -0
  278. package/dist/esm/loaders/micro-agent.js +86 -0
  279. package/dist/esm/loaders/worker-agent.js +18 -0
  280. package/package.json +204 -71
  281. package/types.ts +221 -0
  282. package/dist/bundled/es5/index.js +0 -2
  283. package/dist/bundled/es5/index.js.map +0 -1
  284. package/dist/bundled/es6/index.js +0 -2
  285. package/dist/bundled/es6/index.js.map +0 -1
  286. package/dist/cjs/index.d.ts +0 -19
  287. package/dist/cjs/index.js.map +0 -1
  288. package/dist/cjs/types.d.ts +0 -94
  289. package/dist/cjs/types.js +0 -28
  290. package/dist/cjs/types.js.map +0 -1
  291. package/dist/cjs/utils/api/api.d.ts +0 -10
  292. package/dist/cjs/utils/api/api.js +0 -40
  293. package/dist/cjs/utils/api/api.js.map +0 -1
  294. package/dist/cjs/utils/config/build-configs.d.ts +0 -6
  295. package/dist/cjs/utils/config/build-configs.js +0 -68
  296. package/dist/cjs/utils/config/build-configs.js.map +0 -1
  297. package/dist/cjs/utils/features/features.d.ts +0 -5
  298. package/dist/cjs/utils/features/features.js +0 -14
  299. package/dist/cjs/utils/features/features.js.map +0 -1
  300. package/dist/cjs/utils/features/initialize.d.ts +0 -5
  301. package/dist/cjs/utils/features/initialize.js +0 -51
  302. package/dist/cjs/utils/features/initialize.js.map +0 -1
  303. package/dist/es/index.d.ts +0 -19
  304. package/dist/es/index.js +0 -55
  305. package/dist/es/index.js.map +0 -1
  306. package/dist/es/types.d.ts +0 -94
  307. package/dist/es/types.js +0 -24
  308. package/dist/es/types.js.map +0 -1
  309. package/dist/es/utils/api/api.d.ts +0 -10
  310. package/dist/es/utils/api/api.js +0 -36
  311. package/dist/es/utils/api/api.js.map +0 -1
  312. package/dist/es/utils/config/build-configs.d.ts +0 -6
  313. package/dist/es/utils/config/build-configs.js +0 -64
  314. package/dist/es/utils/config/build-configs.js.map +0 -1
  315. package/dist/es/utils/features/features.d.ts +0 -5
  316. package/dist/es/utils/features/features.js +0 -10
  317. package/dist/es/utils/features/features.js.map +0 -1
  318. package/dist/es/utils/features/initialize.d.ts +0 -5
  319. package/dist/es/utils/features/initialize.js +0 -24
  320. package/dist/es/utils/features/initialize.js.map +0 -1
  321. package/dist/umd/index.d.ts +0 -19
  322. package/dist/umd/index.js +0 -69
  323. package/dist/umd/index.js.map +0 -1
  324. package/dist/umd/types.d.ts +0 -94
  325. package/dist/umd/types.js +0 -38
  326. package/dist/umd/types.js.map +0 -1
  327. package/dist/umd/utils/api/api.d.ts +0 -10
  328. package/dist/umd/utils/api/api.js +0 -50
  329. package/dist/umd/utils/api/api.js.map +0 -1
  330. package/dist/umd/utils/config/build-configs.d.ts +0 -6
  331. package/dist/umd/utils/config/build-configs.js +0 -78
  332. package/dist/umd/utils/config/build-configs.js.map +0 -1
  333. package/dist/umd/utils/features/features.d.ts +0 -5
  334. package/dist/umd/utils/features/features.js +0 -24
  335. package/dist/umd/utils/features/features.js.map +0 -1
  336. package/dist/umd/utils/features/initialize.d.ts +0 -5
  337. package/dist/umd/utils/features/initialize.js +0 -63
  338. package/dist/umd/utils/features/initialize.js.map +0 -1
  339. package/dist/webpack-analysis.html +0 -38
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFeatureDependencyNames = getFeatureDependencyNames;
7
+ exports.getFrozenAttributes = getFrozenAttributes;
8
+ var _features = require("./features");
9
+ function getFeatureDependencyNames(feature) {
10
+ switch (feature) {
11
+ case _features.FEATURE_NAMES.ajax:
12
+ return [_features.FEATURE_NAMES.jserrors];
13
+ case _features.FEATURE_NAMES.sessionTrace:
14
+ return [_features.FEATURE_NAMES.ajax, _features.FEATURE_NAMES.pageViewEvent];
15
+ case _features.FEATURE_NAMES.pageViewTiming:
16
+ return [_features.FEATURE_NAMES.pageViewEvent];
17
+ // this could change if we disconnect window load timings
18
+ default:
19
+ return [];
20
+ }
21
+ }
22
+ function getFrozenAttributes(feature) {
23
+ switch (feature) {
24
+ // right now, jserrors is the only feature that can have "on" or "off" page-level auto-instrumentation...
25
+ // page_action is always "off" (no instr)
26
+ // as new API/manual implementation methods are added, this list can likely be pruned
27
+ case _features.FEATURE_NAMES.jserrors:
28
+ return [];
29
+ default:
30
+ return ['auto'];
31
+ }
32
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.featurePriority = exports.FEATURE_NAMES = void 0;
7
+ const FEATURE_NAMES = {
8
+ ajax: 'ajax',
9
+ jserrors: 'jserrors',
10
+ metrics: 'metrics',
11
+ pageAction: 'page_action',
12
+ pageViewEvent: 'page_view_event',
13
+ pageViewTiming: 'page_view_timing',
14
+ sessionTrace: 'session_trace',
15
+ spa: 'spa'
16
+ };
17
+
18
+ /**
19
+ * The order in which features will be instrumented. This is the traditional order. It's unclear if the order of
20
+ * wrapping events has any ramifications, so we are enforcing this order intentionally for now.
21
+ */
22
+ exports.FEATURE_NAMES = FEATURE_NAMES;
23
+ const featurePriority = {
24
+ [FEATURE_NAMES.pageViewEvent]: 1,
25
+ [FEATURE_NAMES.pageViewTiming]: 2,
26
+ [FEATURE_NAMES.metrics]: 3,
27
+ [FEATURE_NAMES.jserrors]: 4,
28
+ [FEATURE_NAMES.ajax]: 5,
29
+ [FEATURE_NAMES.sessionTrace]: 6,
30
+ [FEATURE_NAMES.pageAction]: 7,
31
+ [FEATURE_NAMES.spa]: 8
32
+ };
33
+ exports.featurePriority = featurePriority;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MicroAgent = void 0;
7
+ var _enabledFeatures = require("./features/enabled-features");
8
+ var _configure = require("./configure/configure");
9
+ var _aggregator = require("../common/aggregate/aggregator");
10
+ var _nreum = require("../common/window/nreum");
11
+ var _uniqueId = require("../common/ids/unique-id");
12
+ var _config = require("../common/config/config");
13
+ var _features = require("./features/features");
14
+ var _console = require("../common/util/console");
15
+ 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
+ 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; }
17
+ const nonAutoFeatures = [_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.pageAction];
18
+ const autoFeatures = [_features.FEATURE_NAMES.metrics];
19
+
20
+ /**
21
+ * A minimal agent class designed to be loaded multiple times on the same page, each instance narrowly scoped to the
22
+ * concerns of a particular component, as with the micro-frontend architectural pattern. This class does not
23
+ * automatically instrument. Instead, each MicroAgent instance may be configured to lazy-load specific
24
+ * instrumentations at runtime, and to report desired data, events, and errors programatically.
25
+ */
26
+ class MicroAgent {
27
+ /**
28
+ * @param {Object} options - Specifies features and runtime configuration,
29
+ * @param {string=} agentIdentifier - The optional unique ID of the agent.
30
+ */
31
+ constructor(options, agentIdentifier = (0, _uniqueId.generateRandomHexString)(16)) {
32
+ this.agentIdentifier = agentIdentifier;
33
+ this.sharedAggregator = new _aggregator.Aggregator({
34
+ agentIdentifier: this.agentIdentifier
35
+ });
36
+ this.features = {};
37
+ Object.assign(this, (0, _configure.configure)(this.agentIdentifier, {
38
+ ...options,
39
+ runtime: {
40
+ isolatedBacklog: true
41
+ }
42
+ }, options.loaderType || 'micro-agent'));
43
+ this.start();
44
+ }
45
+ get config() {
46
+ return {
47
+ info: (0, _config.getInfo)(this.agentIdentifier),
48
+ init: (0, _config.getConfiguration)(this.agentIdentifier),
49
+ loader_config: (0, _config.getLoaderConfig)(this.agentIdentifier),
50
+ runtime: (0, _config.getRuntime)(this.agentIdentifier)
51
+ };
52
+ }
53
+ start() {
54
+ try {
55
+ const enabledFeatures = (0, _enabledFeatures.getEnabledFeatures)(this.agentIdentifier);
56
+ autoFeatures.forEach(f => {
57
+ if (enabledFeatures[f]) {
58
+ // TODO - THIS does not work, the instrument switch in lazy loader increases the size of the worker build. Needs to be revisited
59
+ Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-loader" */'../features/utils/lazy-loader'))).then(({
60
+ lazyLoader
61
+ }) => {
62
+ return lazyLoader(f, 'instrument');
63
+ }).then(({
64
+ Instrument
65
+ }) => {
66
+ this.features[f] = new Instrument(this.agentIdentifier, this.sharedAggregator);
67
+ }).catch(err => (0, _console.warn)('Something prevented the agent from being downloaded.'));
68
+ }
69
+ });
70
+ nonAutoFeatures.forEach(f => {
71
+ if (enabledFeatures[f]) {
72
+ // TODO - THIS does not work, the instrument switch in lazy loader increases the size of the worker build. Needs to be revisited
73
+ // Parts of the lazy-loader were removed because webpack was transpiling them into the worker build, errantly inflating the build size.
74
+ Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-loader" */'../features/utils/lazy-loader'))).then(({
75
+ lazyLoader
76
+ }) => {
77
+ return lazyLoader(f, 'aggregate');
78
+ }).then(({
79
+ Aggregate
80
+ }) => {
81
+ this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator);
82
+ }).catch(err => (0, _console.warn)('Something prevented the agent from being downloaded.'));
83
+ }
84
+ });
85
+ (0, _nreum.gosNREUMInitializedAgents)(this.agentIdentifier, this.features, 'features');
86
+ return this;
87
+ } catch (err) {
88
+ (0, _console.warn)('Failed to initialize instrument classes.', err);
89
+ return false;
90
+ }
91
+ }
92
+ }
93
+ exports.MicroAgent = MicroAgent;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WorkerAgent = void 0;
7
+ var _agent = require("./agent");
8
+ var _instrument = require("../features/metrics/instrument");
9
+ var _instrument2 = require("../features/jserrors/instrument");
10
+ var _instrument3 = require("../features/ajax/instrument");
11
+ var _instrument4 = require("../features/page_action/instrument");
12
+ /**
13
+ * A streamlined agent class designed for the service worker context, limited to features relevant in that scope.
14
+ */
15
+ class WorkerAgent extends _agent.Agent {
16
+ constructor(args) {
17
+ super({
18
+ ...args,
19
+ features: [_instrument.Instrument, _instrument2.Instrument, _instrument3.Instrument, _instrument4.Instrument],
20
+ loaderType: 'worker-agent'
21
+ });
22
+ }
23
+ }
24
+ exports.WorkerAgent = WorkerAgent;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file Creates a "Lite" agent loader bundle composed of the core Agent and a subset of available feature modules.
3
+ */
4
+
5
+ import { Agent } from '../loaders/agent';
6
+ import { Instrument as InstrumentPageViewEvent } from '../features/page_view_event/instrument';
7
+ import { Instrument as InstrumentPageViewTiming } from '../features/page_view_timing/instrument';
8
+ import { Instrument as InstrumentMetrics } from '../features/metrics/instrument';
9
+ new Agent({
10
+ features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentMetrics],
11
+ loaderType: 'lite'
12
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file Creates a version of the "Lite" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
3
+ * polyfills for pre-ES6 browsers and IE 11.
4
+ */
5
+
6
+ import '../polyfills.js';
7
+ import '../lite';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file Creates a version of the "Pro" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
3
+ * polyfills for pre-ES6 browsers and IE 11.
4
+ */
5
+
6
+ import '../polyfills.js';
7
+ import '../pro';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file Creates a version of the "SPA" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
3
+ * polyfills for pre-ES6 browsers and IE 11.
4
+ */
5
+
6
+ import '../polyfills.js';
7
+ import '../spa';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Selectively imports {@link https://github.com/zloirock/core-js core-js}
3
+ * polyfills needed for pre-ES6 browsers and IE 11.
4
+ */
5
+
6
+ import 'core-js/stable/promise';
7
+ import 'core-js/stable/array/includes';
8
+ import 'core-js/stable/array/from';
9
+ import 'core-js/stable/array/find';
10
+ import 'core-js/stable/array/some';
11
+ import 'core-js/stable/object/assign';
12
+ import 'core-js/stable/object/entries';
13
+ import 'core-js/stable/object/values';
14
+ import 'core-js/stable/map';
15
+ import 'core-js/stable/reflect';
16
+ import 'core-js/stable/set';
17
+ import 'core-js/stable/weak-set';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Creates a "Pro" agent loader bundle composed of the core Agent and all available feature modules except `spa`.
3
+ * This excludes collection of BrowserInteraction and BrowserTiming events.
4
+ */
5
+
6
+ import { Agent } from '../loaders/agent';
7
+ import { Instrument as InstrumentPageViewEvent } from '../features/page_view_event/instrument';
8
+ import { Instrument as InstrumentPageViewTiming } from '../features/page_view_timing/instrument';
9
+ import { Instrument as InstrumentMetrics } from '../features/metrics/instrument';
10
+ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument';
11
+ import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
12
+ import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
13
+ import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
14
+ new Agent({
15
+ features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentXhr, InstrumentMetrics, InstrumentPageAction, InstrumentErrors],
16
+ loaderType: 'pro'
17
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Creates a "SPA" agent loader bundle composed of the core agent and all available feature modules.
3
+ */
4
+
5
+ import { Agent } from '../loaders/agent';
6
+ import { Instrument as InstrumentPageViewEvent } from '../features/page_view_event/instrument';
7
+ import { Instrument as InstrumentPageViewTiming } from '../features/page_view_timing/instrument';
8
+ import { Instrument as InstrumentMetrics } from '../features/metrics/instrument';
9
+ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument';
10
+ import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
11
+ import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument';
12
+ import { Instrument as InstrumentSpa } from '../features/spa/instrument';
13
+ import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
14
+ new Agent({
15
+ features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentSpa],
16
+ loaderType: 'spa'
17
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file Creates a "Worker" agent loader bundle composed of the core Agent and the subset of feature modules applicable
3
+ * in a service worker context.
4
+ */
5
+
6
+ import { Agent } from '../loaders/agent';
7
+ import { Instrument as InstrumentMetrics } from '../features/metrics/instrument';
8
+ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument';
9
+ import { Instrument as InstrumentXhr } from '../features/ajax/instrument';
10
+ import { Instrument as InstrumentPageAction } from '../features/page_action/instrument';
11
+ new Agent({
12
+ features: [InstrumentMetrics, InstrumentErrors, InstrumentXhr, InstrumentPageAction],
13
+ loaderType: 'worker'
14
+ });
@@ -0,0 +1,161 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { SharedContext } from '../context/shared-context';
7
+ import { mapOwn } from '../util/map-own';
8
+ export class Aggregator extends SharedContext {
9
+ constructor(parent) {
10
+ super(parent);
11
+ this.aggregatedData = {};
12
+ }
13
+
14
+ // Items with the same type and name get aggregated together
15
+ // params are example data from the aggregated items
16
+ // metrics are the numeric values to be aggregated
17
+
18
+ store(type, name, params, newMetrics, customParams) {
19
+ var bucket = this.getBucket(type, name, params, customParams);
20
+ bucket.metrics = aggregateMetrics(newMetrics, bucket.metrics);
21
+ return bucket;
22
+ }
23
+ merge(type, name, metrics, params, customParams) {
24
+ var bucket = this.getBucket(type, name, params, customParams);
25
+ if (!bucket.metrics) {
26
+ bucket.metrics = metrics;
27
+ return;
28
+ }
29
+ var oldMetrics = bucket.metrics;
30
+ oldMetrics.count += metrics.count;
31
+
32
+ // iterate through each new metric and merge
33
+ mapOwn(metrics, function (key, value) {
34
+ // count is a special case handled above
35
+ if (key === 'count') return;
36
+ var oldMetric = oldMetrics[key];
37
+ var newMetric = metrics[key];
38
+
39
+ // handling the case where newMetric is a single-value first
40
+ if (newMetric && !newMetric.c) {
41
+ oldMetrics[key] = updateMetric(newMetric.t, oldMetric);
42
+ } else {
43
+ // newMetric is a metric object
44
+ oldMetrics[key] = mergeMetric(newMetric, oldMetrics[key]);
45
+ }
46
+ });
47
+ }
48
+ storeMetric(type, name, params, value) {
49
+ var bucket = this.getBucket(type, name, params);
50
+ bucket.stats = updateMetric(value, bucket.stats);
51
+ return bucket;
52
+ }
53
+ getBucket(type, name, params, customParams) {
54
+ if (!this.aggregatedData[type]) this.aggregatedData[type] = {};
55
+ var bucket = this.aggregatedData[type][name];
56
+ if (!bucket) {
57
+ bucket = this.aggregatedData[type][name] = {
58
+ params: params || {}
59
+ };
60
+ if (customParams) {
61
+ bucket.custom = customParams;
62
+ }
63
+ }
64
+ return bucket;
65
+ }
66
+ get(type, name) {
67
+ // if name is passed, get a single bucket
68
+ if (name) return this.aggregatedData[type] && this.aggregatedData[type][name];
69
+ // else, get all buckets of that type
70
+ return this.aggregatedData[type];
71
+ }
72
+
73
+ // Like get, but for many types and it deletes the retrieved content from the aggregatedData
74
+ take(types) {
75
+ var results = {};
76
+ var type = '';
77
+ var hasData = false;
78
+ for (var i = 0; i < types.length; i++) {
79
+ type = types[i];
80
+ results[type] = toArray(this.aggregatedData[type]);
81
+ if (results[type].length) hasData = true;
82
+ delete this.aggregatedData[type];
83
+ }
84
+ return hasData ? results : null;
85
+ }
86
+ }
87
+ function aggregateMetrics(newMetrics, oldMetrics) {
88
+ if (!oldMetrics) oldMetrics = {
89
+ count: 0
90
+ };
91
+ oldMetrics.count += 1;
92
+ mapOwn(newMetrics, function (key, value) {
93
+ oldMetrics[key] = updateMetric(value, oldMetrics[key]);
94
+ });
95
+ return oldMetrics;
96
+ }
97
+ function updateMetric(value, metric) {
98
+ // when there is no value, then send only count
99
+ if (value == null) {
100
+ return updateCounterMetric(metric);
101
+ }
102
+
103
+ // When there is only one data point, the c (count), min, max, and sos (sum of squares) params are superfluous.
104
+ if (!metric) return {
105
+ t: value
106
+ };
107
+
108
+ // but on the second data point, we need to calculate the other values before aggregating in new values
109
+ if (!metric.c) {
110
+ metric = createMetricObject(metric.t);
111
+ }
112
+
113
+ // at this point, metric is always uncondensed
114
+ metric.c += 1;
115
+ metric.t += value;
116
+ metric.sos += value * value;
117
+ if (value > metric.max) metric.max = value;
118
+ if (value < metric.min) metric.min = value;
119
+ return metric;
120
+ }
121
+ function updateCounterMetric(metric) {
122
+ if (!metric) {
123
+ metric = {
124
+ c: 1
125
+ };
126
+ } else {
127
+ metric.c++;
128
+ }
129
+ return metric;
130
+ }
131
+ function mergeMetric(newMetric, oldMetric) {
132
+ if (!oldMetric) return newMetric;
133
+ if (!oldMetric.c) {
134
+ // oldMetric is a single-value
135
+ oldMetric = createMetricObject(oldMetric.t);
136
+ }
137
+ oldMetric.min = Math.min(newMetric.min, oldMetric.min);
138
+ oldMetric.max = Math.max(newMetric.max, oldMetric.max);
139
+ oldMetric.t += newMetric.t;
140
+ oldMetric.sos += newMetric.sos;
141
+ oldMetric.c += newMetric.c;
142
+ return oldMetric;
143
+ }
144
+
145
+ // take a value and create a metric object
146
+ function createMetricObject(value) {
147
+ return {
148
+ t: value,
149
+ min: value,
150
+ max: value,
151
+ sos: value * value,
152
+ c: 1
153
+ };
154
+ }
155
+ function toArray(obj) {
156
+ if (typeof obj !== 'object') return [];
157
+ return mapOwn(obj, getValue);
158
+ }
159
+ function getValue(key, value) {
160
+ return value;
161
+ }
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /* eslint-disable no-useless-escape */
7
+
8
+ export var ffVersion = 0;
9
+ var match = navigator.userAgent.match(/Firefox[\/\s](\d+\.\d+)/);
10
+ if (match) ffVersion = +match[1];
@@ -0,0 +1,10 @@
1
+ export const isiOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
2
+
3
+ /* Feature detection to get our version(s). */
4
+
5
+ // Shared Web Workers introduced in iOS 16.0+ and n/a in 15.6-
6
+ export const iOS_below16 = isiOS && Boolean(typeof SharedWorker === 'undefined');
7
+ /* ^ It was discovered in Safari 14 (https://bugs.webkit.org/show_bug.cgi?id=225305) that the buffered flag in PerformanceObserver
8
+ did not work. This affects our onFCP metric in particular since web-vitals uses that flag to retrieve paint timing entries.
9
+ This was fixed in v16+.
10
+ */
@@ -0,0 +1,11 @@
1
+ import { getInfo, isValid, setInfo } from './state/info';
2
+ import { getConfiguration, getConfigurationValue, setConfiguration } from './state/init';
3
+ import { getLoaderConfig, setLoaderConfig } from './state/loader-config';
4
+ import { originals } from './state/originals';
5
+ import { getRuntime, setRuntime } from './state/runtime';
6
+ function isConfigured(agentIdentifier) {
7
+ return isValid(agentIdentifier);
8
+ }
9
+
10
+ // This module acts as a hub that bundles the static and dynamic properties used by each agent instance into one single interface
11
+ export { getInfo, setInfo, getConfiguration, getConfigurationValue, setConfiguration, getLoaderConfig, setLoaderConfig, originals, getRuntime, setRuntime, isConfigured };
@@ -0,0 +1,25 @@
1
+ import { getFrozenAttributes } from '../../../loaders/features/featureDependencies';
2
+ import { warn } from '../../util/console';
3
+ export class Configurable {
4
+ constructor(obj, model) {
5
+ try {
6
+ if (!obj || typeof obj !== 'object') return warn('New setting a Configurable requires an object as input');
7
+ if (!model || typeof model !== 'object') return warn('Setting a Configurable requires a model to set its initial properties');
8
+ Object.assign(this, model);
9
+ Object.entries(obj).forEach(([key, value]) => {
10
+ const frozenAttrs = getFrozenAttributes(key);
11
+ if (frozenAttrs.length && value && typeof value === 'object') {
12
+ frozenAttrs.forEach(attr => {
13
+ if (attr in value) {
14
+ warn(`"${attr}" is a protected attribute and can not be changed in feature ${key}. It will have no effect.`);
15
+ delete value[attr];
16
+ }
17
+ });
18
+ }
19
+ this[key] = value;
20
+ });
21
+ } catch (err) {
22
+ warn('An error occured while setting a Configurable', err);
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,42 @@
1
+ import { defaults as nrDefaults, gosNREUMInitializedAgents } from '../../window/nreum';
2
+ import { Configurable } from './configurable';
3
+ const model = {
4
+ // preset defaults
5
+ beacon: nrDefaults.beacon,
6
+ errorBeacon: nrDefaults.errorBeacon,
7
+ // others must be populated by user
8
+ licenseKey: undefined,
9
+ applicationID: undefined,
10
+ sa: undefined,
11
+ queueTime: undefined,
12
+ applicationTime: undefined,
13
+ ttGuid: undefined,
14
+ user: undefined,
15
+ account: undefined,
16
+ product: undefined,
17
+ extra: undefined,
18
+ jsAttributes: {},
19
+ userAttributes: undefined,
20
+ atts: undefined,
21
+ transactionName: undefined,
22
+ tNamePlain: undefined
23
+ };
24
+ const _cache = {};
25
+ export function isValid(id) {
26
+ try {
27
+ const info = getInfo(id);
28
+ return !!info.licenseKey && !!info.errorBeacon && !!info.applicationID;
29
+ } catch (err) {
30
+ return false;
31
+ }
32
+ }
33
+ export function getInfo(id) {
34
+ if (!id) throw new Error('All info objects require an agent identifier!');
35
+ if (!_cache[id]) throw new Error(`Info for ${id} was never set`);
36
+ return _cache[id];
37
+ }
38
+ export function setInfo(id, obj) {
39
+ if (!id) throw new Error('All info objects require an agent identifier!');
40
+ _cache[id] = new Configurable(obj, model);
41
+ gosNREUMInitializedAgents(id, _cache[id], 'info');
42
+ }
@@ -0,0 +1,78 @@
1
+ import { gosNREUMInitializedAgents } from '../../window/nreum';
2
+ import { Configurable } from './configurable';
3
+ const model = {
4
+ allow_bfcache: true,
5
+ // *cli - temporary feature flag for BFCache work
6
+ privacy: {
7
+ cookies_enabled: true
8
+ },
9
+ // *cli - per discussion, default should be true
10
+ ajax: {
11
+ deny_list: undefined,
12
+ enabled: true,
13
+ harvestTimeSeconds: 10
14
+ },
15
+ distributed_tracing: {
16
+ enabled: undefined,
17
+ exclude_newrelic_header: undefined,
18
+ cors_use_newrelic_header: undefined,
19
+ cors_use_tracecontext_headers: undefined,
20
+ allowed_origins: undefined
21
+ },
22
+ ssl: undefined,
23
+ obfuscate: undefined,
24
+ jserrors: {
25
+ enabled: true,
26
+ harvestTimeSeconds: 10
27
+ },
28
+ metrics: {
29
+ enabled: true
30
+ },
31
+ page_action: {
32
+ enabled: true,
33
+ harvestTimeSeconds: 30
34
+ },
35
+ page_view_event: {
36
+ enabled: true
37
+ },
38
+ page_view_timing: {
39
+ enabled: true,
40
+ harvestTimeSeconds: 30,
41
+ long_task: false
42
+ },
43
+ session_trace: {
44
+ enabled: true,
45
+ harvestTimeSeconds: 10
46
+ },
47
+ spa: {
48
+ enabled: true,
49
+ harvestTimeSeconds: 10
50
+ }
51
+ };
52
+ const _cache = {};
53
+ export function getConfiguration(id) {
54
+ if (!id) throw new Error('All configuration objects require an agent identifier!');
55
+ if (!_cache[id]) throw new Error(`Configuration for ${id} was never set`);
56
+ return _cache[id];
57
+ }
58
+ export function setConfiguration(id, obj) {
59
+ if (!id) throw new Error('All configuration objects require an agent identifier!');
60
+ _cache[id] = new Configurable(obj, model);
61
+ gosNREUMInitializedAgents(id, _cache[id], 'config');
62
+ }
63
+ export function getConfigurationValue(id, path) {
64
+ if (!id) throw new Error('All configuration objects require an agent identifier!');
65
+ var val = getConfiguration(id);
66
+ if (val) {
67
+ var parts = path.split('.');
68
+ for (var i = 0; i < parts.length - 1; i++) {
69
+ val = val[parts[i]];
70
+ if (typeof val !== 'object') return;
71
+ }
72
+ val = val[parts[parts.length - 1]];
73
+ }
74
+ return val;
75
+ }
76
+
77
+ // TO DO: a setConfigurationValue equivalent may be nice so individual
78
+ // properties can be tuned instead of reseting the whole model per call to `setConfiguration(agentIdentifier, {})`
@@ -0,0 +1,21 @@
1
+ import { gosNREUMInitializedAgents } from '../../window/nreum';
2
+ import { Configurable } from './configurable';
3
+ const model = {
4
+ accountID: undefined,
5
+ trustKey: undefined,
6
+ agentID: undefined,
7
+ licenseKey: undefined,
8
+ applicationID: undefined,
9
+ xpid: undefined
10
+ };
11
+ const _cache = {};
12
+ export function getLoaderConfig(id) {
13
+ if (!id) throw new Error('All loader-config objects require an agent identifier!');
14
+ if (!_cache[id]) throw new Error(`LoaderConfig for ${id} was never set`);
15
+ return _cache[id];
16
+ }
17
+ export function setLoaderConfig(id, obj) {
18
+ if (!id) throw new Error('All loader-config objects require an agent identifier!');
19
+ _cache[id] = new Configurable(obj, model);
20
+ gosNREUMInitializedAgents(id, _cache[id], 'loader_config');
21
+ }
@@ -0,0 +1,2 @@
1
+ import { gosNREUMOriginals } from '../../window/nreum';
2
+ export const originals = gosNREUMOriginals().o;