@newrelic/browser-agent 0.0.9 → 0.1.230

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 (743) hide show
  1. package/README.md +113 -197
  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 +33 -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 +51 -0
  20. package/dist/cjs/common/constants/environment-variables.js +20 -0
  21. package/dist/cjs/common/context/shared-context.js +26 -0
  22. package/dist/cjs/common/deny-list/deny-list.js +108 -0
  23. package/dist/cjs/common/drain/drain.js +132 -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 +48 -0
  28. package/dist/cjs/common/harvest/harvest-scheduler.js +112 -0
  29. package/dist/cjs/common/harvest/harvest.js +247 -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 +31 -0
  49. package/dist/cjs/common/util/map-own.test.js +49 -0
  50. package/dist/cjs/common/util/obfuscate.js +76 -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 +107 -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 +29 -0
  60. package/dist/cjs/common/window/session-storage.js +87 -0
  61. package/dist/cjs/common/window/supports-performance-observer.js +15 -0
  62. package/dist/cjs/common/wrap/index.js +75 -0
  63. package/dist/cjs/common/wrap/wrap-console.js +54 -0
  64. package/dist/cjs/common/wrap/wrap-events.js +108 -0
  65. package/dist/cjs/common/wrap/wrap-fetch.js +112 -0
  66. package/dist/cjs/common/wrap/wrap-function.js +255 -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 +163 -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 +339 -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 +31 -0
  82. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +215 -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 +40 -0
  86. package/dist/cjs/features/jserrors/aggregate/index.js +288 -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 +27 -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 +155 -0
  93. package/dist/cjs/features/metrics/aggregate/index.js +147 -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 +46 -0
  97. package/dist/cjs/features/metrics/instrument/workers-helper.js +124 -0
  98. package/dist/cjs/features/page_action/aggregate/index.js +120 -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 +22 -0
  102. package/dist/cjs/features/page_view_event/aggregate/index.js +137 -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 +39 -0
  107. package/dist/cjs/features/page_view_timing/aggregate/index.js +284 -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 +37 -0
  112. package/dist/cjs/features/page_view_timing/long-tasks.js +75 -0
  113. package/dist/cjs/features/session_trace/aggregate/index.js +415 -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 +134 -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 +115 -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 +72 -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 +87 -0
  132. package/dist/cjs/loaders/api/api.js +174 -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 +53 -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 +98 -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 +26 -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 +42 -0
  159. package/dist/esm/common/constants/environment-variables.js +11 -0
  160. package/dist/esm/common/context/shared-context.js +19 -0
  161. package/dist/esm/common/deny-list/deny-list.js +101 -0
  162. package/dist/esm/common/drain/drain.js +125 -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 +41 -0
  167. package/dist/esm/common/harvest/harvest-scheduler.js +106 -0
  168. package/dist/esm/common/harvest/harvest.js +239 -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 +24 -0
  188. package/dist/esm/common/util/map-own.test.js +47 -0
  189. package/dist/esm/common/util/obfuscate.js +67 -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 +99 -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 +24 -0
  199. package/dist/esm/common/window/session-storage.js +77 -0
  200. package/dist/esm/common/window/supports-performance-observer.js +9 -0
  201. package/dist/esm/common/wrap/index.js +15 -0
  202. package/dist/esm/common/wrap/wrap-console.js +46 -0
  203. package/dist/esm/common/wrap/wrap-events.js +100 -0
  204. package/dist/esm/common/wrap/wrap-fetch.js +103 -0
  205. package/dist/esm/common/wrap/wrap-function.js +244 -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 +156 -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 +331 -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 +29 -0
  221. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +208 -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 +38 -0
  225. package/dist/esm/features/jserrors/aggregate/index.js +281 -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 +25 -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 +147 -0
  232. package/dist/esm/features/metrics/aggregate/index.js +140 -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 +39 -0
  236. package/dist/esm/features/metrics/instrument/workers-helper.js +119 -0
  237. package/dist/esm/features/page_action/aggregate/index.js +113 -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 +15 -0
  241. package/dist/esm/features/page_view_event/aggregate/index.js +128 -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 +30 -0
  246. package/dist/esm/features/page_view_timing/aggregate/index.js +277 -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 +29 -0
  251. package/dist/esm/features/page_view_timing/long-tasks.js +69 -0
  252. package/dist/esm/features/session_trace/aggregate/index.js +406 -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 +124 -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 +105 -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 +70 -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 +78 -0
  271. package/dist/esm/loaders/api/api.js +168 -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 +47 -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 +91 -0
  279. package/dist/esm/loaders/worker-agent.js +18 -0
  280. package/dist/types/cdn/lite.d.ts +2 -0
  281. package/dist/types/cdn/lite.d.ts.map +1 -0
  282. package/dist/types/cdn/polyfills/lite.d.ts +2 -0
  283. package/dist/types/cdn/polyfills/lite.d.ts.map +1 -0
  284. package/dist/types/cdn/polyfills/pro.d.ts +2 -0
  285. package/dist/types/cdn/polyfills/pro.d.ts.map +1 -0
  286. package/dist/types/cdn/polyfills/spa.d.ts +2 -0
  287. package/dist/types/cdn/polyfills/spa.d.ts.map +1 -0
  288. package/dist/types/cdn/polyfills.d.ts +2 -0
  289. package/dist/types/cdn/polyfills.d.ts.map +1 -0
  290. package/dist/types/cdn/pro.d.ts +2 -0
  291. package/dist/types/cdn/pro.d.ts.map +1 -0
  292. package/dist/types/cdn/spa.d.ts +2 -0
  293. package/dist/types/cdn/spa.d.ts.map +1 -0
  294. package/dist/types/cdn/worker.d.ts +2 -0
  295. package/dist/types/cdn/worker.d.ts.map +1 -0
  296. package/dist/types/common/aggregate/aggregator.d.ts +11 -0
  297. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -0
  298. package/dist/types/common/browser-version/firefox-version.d.ts +2 -0
  299. package/dist/types/common/browser-version/firefox-version.d.ts.map +1 -0
  300. package/dist/types/common/browser-version/ios-version.d.ts +3 -0
  301. package/dist/types/common/browser-version/ios-version.d.ts.map +1 -0
  302. package/dist/types/common/config/config.d.ts +13 -0
  303. package/dist/types/common/config/config.d.ts.map +1 -0
  304. package/dist/types/common/config/state/configurable.d.ts +4 -0
  305. package/dist/types/common/config/state/configurable.d.ts.map +1 -0
  306. package/dist/types/common/config/state/info.d.ts +4 -0
  307. package/dist/types/common/config/state/info.d.ts.map +1 -0
  308. package/dist/types/common/config/state/init.d.ts +4 -0
  309. package/dist/types/common/config/state/init.d.ts.map +1 -0
  310. package/dist/types/common/config/state/loader-config.d.ts +3 -0
  311. package/dist/types/common/config/state/loader-config.d.ts.map +1 -0
  312. package/dist/types/common/config/state/originals.d.ts +2 -0
  313. package/dist/types/common/config/state/originals.d.ts.map +1 -0
  314. package/dist/types/common/config/state/runtime.d.ts +3 -0
  315. package/dist/types/common/config/state/runtime.d.ts.map +1 -0
  316. package/dist/types/common/constants/environment-variables.d.ts +4 -0
  317. package/dist/types/common/constants/environment-variables.d.ts.map +1 -0
  318. package/dist/types/common/context/shared-context.d.ts +5 -0
  319. package/dist/types/common/context/shared-context.d.ts.map +1 -0
  320. package/dist/types/common/deny-list/deny-list.d.ts +12 -0
  321. package/dist/types/common/deny-list/deny-list.d.ts.map +1 -0
  322. package/dist/types/common/drain/drain.d.ts +17 -0
  323. package/dist/types/common/drain/drain.d.ts.map +1 -0
  324. package/dist/types/common/event-emitter/contextual-ee.d.ts +4 -0
  325. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -0
  326. package/dist/types/common/event-emitter/handle.d.ts +3 -0
  327. package/dist/types/common/event-emitter/handle.d.ts.map +1 -0
  328. package/dist/types/common/event-emitter/register-handler.d.ts +8 -0
  329. package/dist/types/common/event-emitter/register-handler.d.ts.map +1 -0
  330. package/dist/types/common/event-listener/event-listener-opts.d.ts +10 -0
  331. package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -0
  332. package/dist/types/common/harvest/harvest-scheduler.d.ts +21 -0
  333. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -0
  334. package/dist/types/common/harvest/harvest.d.ts +58 -0
  335. package/dist/types/common/harvest/harvest.d.ts.map +1 -0
  336. package/dist/types/common/ids/id.d.ts +2 -0
  337. package/dist/types/common/ids/id.d.ts.map +1 -0
  338. package/dist/types/common/ids/unique-id.d.ts +5 -0
  339. package/dist/types/common/ids/unique-id.d.ts.map +1 -0
  340. package/dist/types/common/metrics/framework-detection.d.ts +2 -0
  341. package/dist/types/common/metrics/framework-detection.d.ts.map +1 -0
  342. package/dist/types/common/metrics/paint-metrics.d.ts +2 -0
  343. package/dist/types/common/metrics/paint-metrics.d.ts.map +1 -0
  344. package/dist/types/common/serialize/bel-serializer.d.ts +5 -0
  345. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -0
  346. package/dist/types/common/timing/nav-timing.d.ts +5 -0
  347. package/dist/types/common/timing/nav-timing.d.ts.map +1 -0
  348. package/dist/types/common/timing/now.d.ts +2 -0
  349. package/dist/types/common/timing/now.d.ts.map +1 -0
  350. package/dist/types/common/unload/eol.d.ts +8 -0
  351. package/dist/types/common/unload/eol.d.ts.map +1 -0
  352. package/dist/types/common/url/clean-url.d.ts +2 -0
  353. package/dist/types/common/url/clean-url.d.ts.map +1 -0
  354. package/dist/types/common/url/encode.d.ts +5 -0
  355. package/dist/types/common/url/encode.d.ts.map +1 -0
  356. package/dist/types/common/url/location.d.ts +2 -0
  357. package/dist/types/common/url/location.d.ts.map +1 -0
  358. package/dist/types/common/url/parse-url.d.ts +2 -0
  359. package/dist/types/common/url/parse-url.d.ts.map +1 -0
  360. package/dist/types/common/url/protocol.d.ts +7 -0
  361. package/dist/types/common/url/protocol.d.ts.map +1 -0
  362. package/dist/types/common/util/console.d.ts +8 -0
  363. package/dist/types/common/util/console.d.ts.map +1 -0
  364. package/dist/types/common/util/data-size.d.ts +2 -0
  365. package/dist/types/common/util/data-size.d.ts.map +1 -0
  366. package/dist/types/common/util/feature-flags.d.ts +3 -0
  367. package/dist/types/common/util/feature-flags.d.ts.map +1 -0
  368. package/dist/types/common/util/get-or-set.d.ts +2 -0
  369. package/dist/types/common/util/get-or-set.d.ts.map +1 -0
  370. package/dist/types/common/util/global-scope.d.ts +13 -0
  371. package/dist/types/common/util/global-scope.d.ts.map +1 -0
  372. package/dist/types/common/util/map-own.d.ts +3 -0
  373. package/dist/types/common/util/map-own.d.ts.map +1 -0
  374. package/dist/types/common/util/obfuscate.d.ts +8 -0
  375. package/dist/types/common/util/obfuscate.d.ts.map +1 -0
  376. package/dist/types/common/util/s-hash.d.ts +2 -0
  377. package/dist/types/common/util/s-hash.d.ts.map +1 -0
  378. package/dist/types/common/util/single.d.ts +2 -0
  379. package/dist/types/common/util/single.d.ts.map +1 -0
  380. package/dist/types/common/util/stringify.d.ts +8 -0
  381. package/dist/types/common/util/stringify.d.ts.map +1 -0
  382. package/dist/types/common/util/submit-data.d.ts +35 -0
  383. package/dist/types/common/util/submit-data.d.ts.map +1 -0
  384. package/dist/types/common/util/traverse.d.ts +2 -0
  385. package/dist/types/common/util/traverse.d.ts.map +1 -0
  386. package/dist/types/common/util/user-agent.d.ts +5 -0
  387. package/dist/types/common/util/user-agent.d.ts.map +1 -0
  388. package/dist/types/common/window/load.d.ts +3 -0
  389. package/dist/types/common/window/load.d.ts.map +1 -0
  390. package/dist/types/common/window/nreum.d.ts +14 -0
  391. package/dist/types/common/window/nreum.d.ts.map +1 -0
  392. package/dist/types/common/window/page-visibility.d.ts +7 -0
  393. package/dist/types/common/window/page-visibility.d.ts.map +1 -0
  394. package/dist/types/common/window/session-storage.d.ts +18 -0
  395. package/dist/types/common/window/session-storage.d.ts.map +1 -0
  396. package/dist/types/common/window/supports-performance-observer.d.ts +2 -0
  397. package/dist/types/common/window/supports-performance-observer.d.ts.map +1 -0
  398. package/dist/types/common/wrap/index.d.ts +12 -0
  399. package/dist/types/common/wrap/index.d.ts.map +1 -0
  400. package/dist/types/common/wrap/wrap-console.d.ts +16 -0
  401. package/dist/types/common/wrap/wrap-console.d.ts.map +1 -0
  402. package/dist/types/common/wrap/wrap-events.d.ts +17 -0
  403. package/dist/types/common/wrap/wrap-events.d.ts.map +1 -0
  404. package/dist/types/common/wrap/wrap-fetch.d.ts +18 -0
  405. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -0
  406. package/dist/types/common/wrap/wrap-function.d.ts +28 -0
  407. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -0
  408. package/dist/types/common/wrap/wrap-history.d.ts +16 -0
  409. package/dist/types/common/wrap/wrap-history.d.ts.map +1 -0
  410. package/dist/types/common/wrap/wrap-jsonp.d.ts +16 -0
  411. package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -0
  412. package/dist/types/common/wrap/wrap-mutation.d.ts +16 -0
  413. package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -0
  414. package/dist/types/common/wrap/wrap-promise.d.ts +17 -0
  415. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -0
  416. package/dist/types/common/wrap/wrap-raf.d.ts +16 -0
  417. package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -0
  418. package/dist/types/common/wrap/wrap-timer.d.ts +17 -0
  419. package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -0
  420. package/dist/types/common/wrap/wrap-xhr.d.ts +16 -0
  421. package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -0
  422. package/dist/types/features/ajax/aggregate/index.d.ts +16 -0
  423. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -0
  424. package/dist/types/features/ajax/constants.d.ts +2 -0
  425. package/dist/types/features/ajax/constants.d.ts.map +1 -0
  426. package/dist/types/features/ajax/index.d.ts +2 -0
  427. package/dist/types/features/ajax/index.d.ts.map +1 -0
  428. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +19 -0
  429. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -0
  430. package/dist/types/features/ajax/instrument/index.d.ts +9 -0
  431. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -0
  432. package/dist/types/features/ajax/instrument/response-size.d.ts +2 -0
  433. package/dist/types/features/ajax/instrument/response-size.d.ts.map +1 -0
  434. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts +2 -0
  435. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -0
  436. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts +22 -0
  437. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -0
  438. package/dist/types/features/jserrors/aggregate/format-stack-trace.d.ts +3 -0
  439. package/dist/types/features/jserrors/aggregate/format-stack-trace.d.ts.map +1 -0
  440. package/dist/types/features/jserrors/aggregate/index.d.ts +24 -0
  441. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -0
  442. package/dist/types/features/jserrors/aggregate/string-hash-code.d.ts +2 -0
  443. package/dist/types/features/jserrors/aggregate/string-hash-code.d.ts.map +1 -0
  444. package/dist/types/features/jserrors/constants.d.ts +3 -0
  445. package/dist/types/features/jserrors/constants.d.ts.map +1 -0
  446. package/dist/types/features/jserrors/index.d.ts +2 -0
  447. package/dist/types/features/jserrors/index.d.ts.map +1 -0
  448. package/dist/types/features/jserrors/instrument/debug.d.ts +2 -0
  449. package/dist/types/features/jserrors/instrument/debug.d.ts.map +1 -0
  450. package/dist/types/features/jserrors/instrument/index.d.ts +22 -0
  451. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -0
  452. package/dist/types/features/metrics/aggregate/index.d.ts +12 -0
  453. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -0
  454. package/dist/types/features/metrics/constants.d.ts +6 -0
  455. package/dist/types/features/metrics/constants.d.ts.map +1 -0
  456. package/dist/types/features/metrics/index.d.ts +2 -0
  457. package/dist/types/features/metrics/index.d.ts.map +1 -0
  458. package/dist/types/features/metrics/instrument/index.d.ts +7 -0
  459. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -0
  460. package/dist/types/features/metrics/instrument/workers-helper.d.ts +7 -0
  461. package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -0
  462. package/dist/types/features/page_action/aggregate/index.d.ts +24 -0
  463. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -0
  464. package/dist/types/features/page_action/constants.d.ts +2 -0
  465. package/dist/types/features/page_action/constants.d.ts.map +1 -0
  466. package/dist/types/features/page_action/index.d.ts +2 -0
  467. package/dist/types/features/page_action/index.d.ts.map +1 -0
  468. package/dist/types/features/page_action/instrument/index.d.ts +6 -0
  469. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -0
  470. package/dist/types/features/page_view_event/aggregate/index.d.ts +9 -0
  471. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -0
  472. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts +8 -0
  473. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -0
  474. package/dist/types/features/page_view_event/constants.d.ts +5 -0
  475. package/dist/types/features/page_view_event/constants.d.ts.map +1 -0
  476. package/dist/types/features/page_view_event/index.d.ts +2 -0
  477. package/dist/types/features/page_view_event/index.d.ts.map +1 -0
  478. package/dist/types/features/page_view_event/instrument/index.d.ts +6 -0
  479. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -0
  480. package/dist/types/features/page_view_timing/aggregate/index.d.ts +33 -0
  481. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -0
  482. package/dist/types/features/page_view_timing/constants.d.ts +2 -0
  483. package/dist/types/features/page_view_timing/constants.d.ts.map +1 -0
  484. package/dist/types/features/page_view_timing/first-paint.d.ts +2 -0
  485. package/dist/types/features/page_view_timing/first-paint.d.ts.map +1 -0
  486. package/dist/types/features/page_view_timing/index.d.ts +2 -0
  487. package/dist/types/features/page_view_timing/index.d.ts.map +1 -0
  488. package/dist/types/features/page_view_timing/instrument/index.d.ts +6 -0
  489. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -0
  490. package/dist/types/features/page_view_timing/long-tasks.d.ts +2 -0
  491. package/dist/types/features/page_view_timing/long-tasks.d.ts.map +1 -0
  492. package/dist/types/features/session_trace/aggregate/index.d.ts +77 -0
  493. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -0
  494. package/dist/types/features/session_trace/constants.d.ts +13 -0
  495. package/dist/types/features/session_trace/constants.d.ts.map +1 -0
  496. package/dist/types/features/session_trace/index.d.ts +2 -0
  497. package/dist/types/features/session_trace/index.d.ts.map +1 -0
  498. package/dist/types/features/session_trace/instrument/index.d.ts +11 -0
  499. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -0
  500. package/dist/types/features/spa/aggregate/index.d.ts +25 -0
  501. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -0
  502. package/dist/types/features/spa/aggregate/interaction-node.d.ts +15 -0
  503. package/dist/types/features/spa/aggregate/interaction-node.d.ts.map +1 -0
  504. package/dist/types/features/spa/aggregate/interaction.d.ts +20 -0
  505. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -0
  506. package/dist/types/features/spa/aggregate/serializer.d.ts +15 -0
  507. package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -0
  508. package/dist/types/features/spa/constants.d.ts +23 -0
  509. package/dist/types/features/spa/constants.d.ts.map +1 -0
  510. package/dist/types/features/spa/index.d.ts +2 -0
  511. package/dist/types/features/spa/index.d.ts.map +1 -0
  512. package/dist/types/features/spa/instrument/index.d.ts +8 -0
  513. package/dist/types/features/spa/instrument/index.d.ts.map +1 -0
  514. package/dist/types/features/utils/aggregate-base.d.ts +4 -0
  515. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
  516. package/dist/types/features/utils/feature-base.d.ts +23 -0
  517. package/dist/types/features/utils/feature-base.d.ts.map +1 -0
  518. package/dist/types/features/utils/handler-cache.d.ts +22 -0
  519. package/dist/types/features/utils/handler-cache.d.ts.map +1 -0
  520. package/dist/types/features/utils/instrument-base.d.ts +27 -0
  521. package/dist/types/features/utils/instrument-base.d.ts.map +1 -0
  522. package/dist/types/features/utils/lazy-loader.d.ts +13 -0
  523. package/dist/types/features/utils/lazy-loader.d.ts.map +1 -0
  524. package/dist/types/index.d.ts +12 -0
  525. package/dist/types/index.d.ts.map +1 -0
  526. package/dist/types/loaders/agent.d.ts +20 -0
  527. package/dist/types/loaders/agent.d.ts.map +1 -0
  528. package/dist/types/loaders/api/api.d.ts +17 -0
  529. package/dist/types/loaders/api/api.d.ts.map +1 -0
  530. package/dist/types/loaders/api/apiAsync.d.ts +2 -0
  531. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -0
  532. package/dist/types/loaders/browser-agent.d.ts +9 -0
  533. package/dist/types/loaders/browser-agent.d.ts.map +1 -0
  534. package/dist/types/loaders/configure/configure.d.ts +10 -0
  535. package/dist/types/loaders/configure/configure.d.ts.map +1 -0
  536. package/dist/types/loaders/features/enabled-features.d.ts +2 -0
  537. package/dist/types/loaders/features/enabled-features.d.ts.map +1 -0
  538. package/dist/types/loaders/features/featureDependencies.d.ts +3 -0
  539. package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -0
  540. package/dist/types/loaders/features/features.d.ts +18 -0
  541. package/dist/types/loaders/features/features.d.ts.map +1 -0
  542. package/dist/types/loaders/micro-agent.d.ts +25 -0
  543. package/dist/types/loaders/micro-agent.d.ts.map +1 -0
  544. package/dist/types/loaders/worker-agent.d.ts +8 -0
  545. package/dist/types/loaders/worker-agent.d.ts.map +1 -0
  546. package/package.json +231 -69
  547. package/src/cdn/lite.js +18 -0
  548. package/src/cdn/polyfills/lite.js +7 -0
  549. package/src/cdn/polyfills/pro.js +7 -0
  550. package/src/cdn/polyfills/spa.js +7 -0
  551. package/src/cdn/polyfills.js +17 -0
  552. package/src/cdn/pro.js +27 -0
  553. package/src/cdn/spa.js +28 -0
  554. package/src/cdn/worker.js +21 -0
  555. package/src/common/aggregate/aggregator.js +171 -0
  556. package/src/common/browser-version/firefox-version.js +10 -0
  557. package/src/common/browser-version/ios-version.js +10 -0
  558. package/src/common/config/config.js +12 -0
  559. package/src/common/config/state/configurable.js +26 -0
  560. package/src/common/config/state/info.js +49 -0
  561. package/src/common/config/state/init.js +56 -0
  562. package/src/common/config/state/loader-config.js +25 -0
  563. package/src/common/config/state/originals.js +3 -0
  564. package/src/common/config/state/runtime.js +45 -0
  565. package/src/common/constants/environment-variables.js +11 -0
  566. package/src/common/context/shared-context.js +21 -0
  567. package/src/common/deny-list/deny-list.js +116 -0
  568. package/src/common/drain/drain.js +119 -0
  569. package/src/common/event-emitter/contextual-ee.js +159 -0
  570. package/src/common/event-emitter/handle.js +17 -0
  571. package/src/common/event-emitter/register-handler.js +25 -0
  572. package/src/common/event-listener/event-listener-opts.js +41 -0
  573. package/src/common/harvest/harvest-scheduler.js +112 -0
  574. package/src/common/harvest/harvest.js +248 -0
  575. package/src/common/ids/id.js +23 -0
  576. package/src/common/ids/unique-id.js +81 -0
  577. package/src/common/metrics/framework-detection.js +71 -0
  578. package/src/common/metrics/paint-metrics.js +6 -0
  579. package/src/common/serialize/bel-serializer.js +93 -0
  580. package/src/common/timing/nav-timing.js +70 -0
  581. package/src/common/timing/now.js +9 -0
  582. package/src/common/unload/eol.js +63 -0
  583. package/src/common/url/clean-url.js +10 -0
  584. package/src/common/url/encode.js +75 -0
  585. package/src/common/url/location.js +8 -0
  586. package/src/common/url/parse-url.js +71 -0
  587. package/src/common/url/protocol.js +19 -0
  588. package/src/common/util/console.js +11 -0
  589. package/src/common/util/data-size.js +21 -0
  590. package/src/common/util/feature-flags.js +38 -0
  591. package/src/common/util/get-or-set.js +34 -0
  592. package/src/common/util/global-scope.js +48 -0
  593. package/src/common/util/map-own.js +22 -0
  594. package/src/common/util/map-own.test.js +52 -0
  595. package/src/common/util/obfuscate.js +73 -0
  596. package/src/common/util/s-hash.js +14 -0
  597. package/src/common/util/single.js +18 -0
  598. package/src/common/util/stringify.js +42 -0
  599. package/src/common/util/submit-data.js +101 -0
  600. package/src/common/util/traverse.js +36 -0
  601. package/src/common/util/user-agent.js +56 -0
  602. package/src/common/window/load.js +15 -0
  603. package/src/common/window/nreum.js +110 -0
  604. package/src/common/window/page-visibility.js +24 -0
  605. package/src/common/window/session-storage.js +75 -0
  606. package/src/common/window/supports-performance-observer.js +10 -0
  607. package/src/common/wrap/index.js +18 -0
  608. package/src/common/wrap/wrap-console.js +47 -0
  609. package/src/common/wrap/wrap-events.js +106 -0
  610. package/src/common/wrap/wrap-fetch.js +109 -0
  611. package/src/common/wrap/wrap-function.js +248 -0
  612. package/src/common/wrap/wrap-history.js +48 -0
  613. package/src/common/wrap/wrap-jsonp.js +134 -0
  614. package/src/common/wrap/wrap-mutation.js +55 -0
  615. package/src/common/wrap/wrap-promise.js +165 -0
  616. package/src/common/wrap/wrap-raf.js +50 -0
  617. package/src/common/wrap/wrap-timer.js +67 -0
  618. package/src/common/wrap/wrap-xhr.js +213 -0
  619. package/src/features/ajax/aggregate/index.js +248 -0
  620. package/src/features/ajax/constants.js +3 -0
  621. package/src/features/ajax/index.js +1 -0
  622. package/src/features/ajax/instrument/distributed-tracing.js +166 -0
  623. package/src/features/ajax/instrument/index.js +380 -0
  624. package/src/features/ajax/instrument/response-size.js +18 -0
  625. package/src/features/jserrors/aggregate/canonical-function-name.js +14 -0
  626. package/src/features/jserrors/aggregate/canonical-function-name.test.js +13 -0
  627. package/src/features/jserrors/aggregate/compute-stack-trace.js +231 -0
  628. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +297 -0
  629. package/src/features/jserrors/aggregate/format-stack-trace.js +30 -0
  630. package/src/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
  631. package/src/features/jserrors/aggregate/index.js +310 -0
  632. package/src/features/jserrors/aggregate/string-hash-code.js +17 -0
  633. package/src/features/jserrors/aggregate/string-hash-code.test.js +12 -0
  634. package/src/features/jserrors/constants.js +4 -0
  635. package/src/features/jserrors/index.js +1 -0
  636. package/src/features/jserrors/instrument/debug.js +36 -0
  637. package/src/features/jserrors/instrument/index.js +149 -0
  638. package/src/features/metrics/aggregate/index.js +134 -0
  639. package/src/features/metrics/constants.js +7 -0
  640. package/src/features/metrics/index.js +1 -0
  641. package/src/features/metrics/instrument/index.js +44 -0
  642. package/src/features/metrics/instrument/workers-helper.js +110 -0
  643. package/src/features/page_action/aggregate/index.js +113 -0
  644. package/src/features/page_action/constants.js +3 -0
  645. package/src/features/page_action/index.js +1 -0
  646. package/src/features/page_action/instrument/index.js +15 -0
  647. package/src/features/page_view_event/aggregate/index.js +134 -0
  648. package/src/features/page_view_event/aggregate/initialized-features.js +31 -0
  649. package/src/features/page_view_event/constants.js +6 -0
  650. package/src/features/page_view_event/index.js +1 -0
  651. package/src/features/page_view_event/instrument/index.js +33 -0
  652. package/src/features/page_view_timing/aggregate/index.js +246 -0
  653. package/src/features/page_view_timing/constants.js +3 -0
  654. package/src/features/page_view_timing/first-paint.js +41 -0
  655. package/src/features/page_view_timing/index.js +1 -0
  656. package/src/features/page_view_timing/instrument/index.js +30 -0
  657. package/src/features/page_view_timing/long-tasks.js +60 -0
  658. package/src/features/session_trace/aggregate/index.js +410 -0
  659. package/src/features/session_trace/constants.js +15 -0
  660. package/src/features/session_trace/index.js +1 -0
  661. package/src/features/session_trace/instrument/index.js +126 -0
  662. package/src/features/spa/aggregate/index.js +738 -0
  663. package/src/features/spa/aggregate/interaction-node.js +85 -0
  664. package/src/features/spa/aggregate/interaction-node.test.js +17 -0
  665. package/src/features/spa/aggregate/interaction.js +112 -0
  666. package/src/features/spa/aggregate/serializer.js +198 -0
  667. package/src/features/spa/constants.js +36 -0
  668. package/src/features/spa/index.js +1 -0
  669. package/src/features/spa/instrument/index.js +112 -0
  670. package/src/features/utils/aggregate-base.js +7 -0
  671. package/src/features/utils/feature-base.js +51 -0
  672. package/src/features/utils/handler-cache.js +60 -0
  673. package/src/features/utils/instrument-base.js +68 -0
  674. package/src/features/utils/lazy-loader.js +37 -0
  675. package/src/index.js +15 -0
  676. package/src/loaders/agent.js +80 -0
  677. package/src/loaders/api/api.js +175 -0
  678. package/src/loaders/api/apiAsync.js +92 -0
  679. package/src/loaders/browser-agent.js +33 -0
  680. package/src/loaders/configure/configure.js +39 -0
  681. package/src/loaders/features/enabled-features.js +16 -0
  682. package/src/loaders/features/featureDependencies.js +26 -0
  683. package/src/loaders/features/features.js +25 -0
  684. package/src/loaders/micro-agent.js +84 -0
  685. package/src/loaders/worker-agent.js +24 -0
  686. package/dist/bundled/es5/index.js +0 -2
  687. package/dist/bundled/es5/index.js.map +0 -1
  688. package/dist/bundled/es6/index.js +0 -2
  689. package/dist/bundled/es6/index.js.map +0 -1
  690. package/dist/cjs/index.d.ts +0 -19
  691. package/dist/cjs/index.js.map +0 -1
  692. package/dist/cjs/types.d.ts +0 -94
  693. package/dist/cjs/types.js +0 -28
  694. package/dist/cjs/types.js.map +0 -1
  695. package/dist/cjs/utils/api/api.d.ts +0 -10
  696. package/dist/cjs/utils/api/api.js +0 -40
  697. package/dist/cjs/utils/api/api.js.map +0 -1
  698. package/dist/cjs/utils/config/build-configs.d.ts +0 -6
  699. package/dist/cjs/utils/config/build-configs.js +0 -68
  700. package/dist/cjs/utils/config/build-configs.js.map +0 -1
  701. package/dist/cjs/utils/features/features.d.ts +0 -5
  702. package/dist/cjs/utils/features/features.js +0 -14
  703. package/dist/cjs/utils/features/features.js.map +0 -1
  704. package/dist/cjs/utils/features/initialize.d.ts +0 -5
  705. package/dist/cjs/utils/features/initialize.js +0 -51
  706. package/dist/cjs/utils/features/initialize.js.map +0 -1
  707. package/dist/es/index.d.ts +0 -19
  708. package/dist/es/index.js +0 -55
  709. package/dist/es/index.js.map +0 -1
  710. package/dist/es/types.d.ts +0 -94
  711. package/dist/es/types.js +0 -24
  712. package/dist/es/types.js.map +0 -1
  713. package/dist/es/utils/api/api.d.ts +0 -10
  714. package/dist/es/utils/api/api.js +0 -36
  715. package/dist/es/utils/api/api.js.map +0 -1
  716. package/dist/es/utils/config/build-configs.d.ts +0 -6
  717. package/dist/es/utils/config/build-configs.js +0 -64
  718. package/dist/es/utils/config/build-configs.js.map +0 -1
  719. package/dist/es/utils/features/features.d.ts +0 -5
  720. package/dist/es/utils/features/features.js +0 -10
  721. package/dist/es/utils/features/features.js.map +0 -1
  722. package/dist/es/utils/features/initialize.d.ts +0 -5
  723. package/dist/es/utils/features/initialize.js +0 -24
  724. package/dist/es/utils/features/initialize.js.map +0 -1
  725. package/dist/umd/index.d.ts +0 -19
  726. package/dist/umd/index.js +0 -69
  727. package/dist/umd/index.js.map +0 -1
  728. package/dist/umd/types.d.ts +0 -94
  729. package/dist/umd/types.js +0 -38
  730. package/dist/umd/types.js.map +0 -1
  731. package/dist/umd/utils/api/api.d.ts +0 -10
  732. package/dist/umd/utils/api/api.js +0 -50
  733. package/dist/umd/utils/api/api.js.map +0 -1
  734. package/dist/umd/utils/config/build-configs.d.ts +0 -6
  735. package/dist/umd/utils/config/build-configs.js +0 -78
  736. package/dist/umd/utils/config/build-configs.js.map +0 -1
  737. package/dist/umd/utils/features/features.d.ts +0 -5
  738. package/dist/umd/utils/features/features.js +0 -24
  739. package/dist/umd/utils/features/features.js.map +0 -1
  740. package/dist/umd/utils/features/initialize.d.ts +0 -5
  741. package/dist/umd/utils/features/initialize.js +0 -63
  742. package/dist/umd/utils/features/initialize.js.map +0 -1
  743. package/dist/webpack-analysis.html +0 -38
package/README.md CHANGED
@@ -1,258 +1,174 @@
1
- [![New Relic Experimental header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Experimental.png)](https://opensource.newrelic.com/oss-category/#new-relic-experimental)
1
+ [![Community Plus header](https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Community_Plus.png)](https://opensource.newrelic.com/oss-category/#community-plus)
2
2
 
3
3
  # New Relic Browser Agent
4
4
 
5
- The New Relic Browser Agent instruments your website and provides observability into the performance and behavior of your application. This NPM Library is an ***in-progress*** implementation of the New Relic Browser Agent, accessible through `NPM`. Please see the [Differences](#differences) and [Features](#features) sections to compare how this library differs from the other offerings of the New Relic Browser Agent.
5
+ The New Relic browser agent instruments your web application or site and provides observability into performance, errors, and other behaviors.
6
6
 
7
- ## Installation
7
+ - The instructions on this page pertain to installing the browser agent as an NPM package (currently in pre-release).
8
8
 
9
- ### Using Package Managers
9
+ - The browser agent is also generally available as a copy-paste JavaScript snippet and via auto-injection by backend apps. See *[Install the browser agent](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/)* for info on these alternatives.
10
10
 
11
- Using [npm](https://npmjs.org):
11
+ - For questions and feedback on this pre-release package, please visit the [Explorer's Hub](https://forum.newrelic.com/s/), New Relic's community support forum.
12
12
 
13
- ```bash
14
- npm install @newrelic/browser-agent
15
- ```
16
-
17
- or [yarn](https://yarnpkg.com/)
13
+ - Looking to contribute to the browser agent code base? See [DEVELOPING.md](DEVELOPING.md) for instructions on building and testing the browser agent library, and [CONTRIBUTING.md](CONTRIBUTING.md) for general guidance.
18
14
 
19
- ```bash
20
- yarn add @newrelic/browser-agent
21
- ```
15
+ ## Adding the agent package to your project
22
16
 
23
- ### Directly in HTML/JS
17
+ To make the agent available to your application, install via [NPM](https://docs.npmjs.com/cli/v8/commands/npm-install) or [Yarn](https://classic.yarnpkg.com/lang/en/docs/cli/install/).
24
18
 
25
- Using [unpkg](https://unpkg.com/)
19
+ ```shell
20
+ $ npm install @newrelic/browser-agent --save
21
+ ```
26
22
 
27
- See [Using Unpkg](#using-unpkg) for implementation details
23
+ ```shell
24
+ $ yarn add @newrelic/browser-agent
25
+ ```
28
26
 
29
- ES6 compatible bundle
27
+ ## Creating an app in New Relic One
30
28
 
31
- ```html
32
- <script src="https://unpkg.com/@newrelic/browser-agent/dist/bundled/es6/index.js"></script>
33
- ```
29
+ Before instrumenting your app using the NPM package, a Browser App should be configured in New Relic One. This may be done with or without a corresponding APM agent. Once the app has been created, the Copy/Paste JavaScript code on the app's *Application settings* page will contain the configuration values needed to define options when instantiating the agent via the NPM package.
34
30
 
35
- ES5 compatible bundle
31
+ 1. If a browser app does not already exist, create one:
32
+ - From the *New Relic One* navigation panel, click *Add Data*.
33
+ - Select the *Browser monitoring* data source.
34
+ - Choose the *APM* or *Copy/Paste* method.
35
+ - Select or name your app and click *Enable*.
36
+ 2. From the navigation panel, select *Browser* to view brower apps.
37
+ 3. Select the desired app and navigate to the *Application settings* page.
38
+ 4. From the *Copy/Paste JavaScript* box, copy the configuration values assigned to the `NREUM` object (`init`, `info`, and `loader_config`). You will use these configuration values when instantiating the agent using the NPM package.
36
39
 
37
- ```html
38
- <script src="https://unpkg.com/@newrelic/browser-agent/dist/bundled/es5/index.js"></script>
39
- ```
40
+ ## Instantiating the agent
40
41
 
41
- ## Usage Examples
42
+ For best results, import and instantiate the `BrowserAgent` class as close to the top of the `head` element of your app's HTML output as possible. The specific location and method will vary based on your application's architecture or framework.
42
43
 
43
- ### Basic Setup
44
+ Populate the `options` parameter using configuration values found in the the *Copy/Paste JavaScript* box in your browser app's *Application settings* page in New Relic One.
44
45
 
45
46
  ```javascript
46
- // << App.js >>
47
- // initialize the agent as close to
48
- // the top level of the application as possible
49
- import NR from '@newrelic/browser-agent'
47
+ import { BrowserAgent } from '@newrelic/browser-agent/loaders/browser-agent'
50
48
 
49
+ // Populate using values in copy-paste JavaScript snippet.
51
50
  const options = {
52
- // See 'Configuring your application'
51
+ init: { ... }, // NREUM.init
52
+ info: { ... }, // NREUM.info
53
+ loader_config: { ...} // NREUM.loader_config
53
54
  }
54
- const nr = new NR()
55
55
 
56
- nr.start(options).then(() => {
57
- console.log("Browser Agent Initialized!")
58
- })
56
+ // The agent loader code executes immediately on instantiation.
57
+ new BrowserAgent(options)
59
58
  ```
60
59
 
61
- ### Notice Errors After Setup
62
- ```javascript
63
- // << SomeComponent.js >>
64
- // notice handled errors
65
- try {
66
- ...
67
- } catch (err){
68
- nr.noticeError(err)
69
- }
60
+ ## Turning off features at runtime
70
61
 
71
- // thrown errors *anywhere* on the page will be captured if `auto` is enabled
72
- ```
62
+ Features may be turned off at runtime, which may have a meaningful peformance impact in some cases.
73
63
 
74
- ### Setup Using unpkg
75
-
76
- ```html
77
- <head>
78
- <!-- Download and initialize as soon as possible to avoid missing early events -->
79
- <script src="https://unpkg.com/@newrelic/browser-agent/bundled"></script>
80
- <script>
81
- const { BrowserAgent } = NRBA;
82
- const options = {
83
- // See 'Configuring your application'
84
- }
85
- const agent = new BrowserAgent()
86
- agent.start(options).then(() => {
87
- console.log("Browser Agent Initialized!")
88
- })
89
- </script>
90
- </head>
91
- ```
64
+ In the example below, the `page_view_timing` and `session_trace` features are disabled.
92
65
 
93
- ### Notice Errors after Setup
94
66
  ```javascript
95
- // << somewhere in your app >>
96
-
97
- // notice handled errors
98
- try {
67
+ const options = {
68
+ info: { ... },
69
+ loader_config: { ... },
70
+ init: {
71
+ page_view_timing: { enabled: false },
72
+ session_trace: { enabled: false },
99
73
  ...
100
- } catch (err){
101
- nr.noticeError(err)
74
+ }
102
75
  }
103
-
104
- // thrown errors *anywhere* on the page will be captured if `auto` is enabled
105
76
  ```
106
77
 
107
- ### Instrumenting a Micro Front Ends or Multiple Targets
78
+ The following features may be disabled by adding `init` entries as shown above. Note that the `page_view_event` feature may not be disabled.
108
79
 
109
- The New Relic Browser Agent can maintain separate configuration scopes by creating new instances. Separate NR instances can each report their own scoped data to separate New Relic applications.
80
+ - `ajax`
81
+ - `jserrors`
82
+ - `metrics`
83
+ - `page_action`
84
+ - `page_view_timing`
85
+ - `session_trace`
86
+ - `spa`
110
87
 
111
- ```javascript
112
- // ---- App.js ----
113
- // Initialize as close to top of page as possible
114
- import { BrowserAgent } from '@newrelic/browser-agent'
115
- const options1 = {
116
- // see 'Configuring your application'
117
- licenseKey: 'abc',
118
- applicationID: '123',
119
- beacon: 'bam.nr-data.net'
120
- }
121
- const agent1 = new BrowserAgent()
122
- agent1.features.errors.enabled = true // this is enabled by default, but just for visibility
123
- agent1.start(options1).then(() => {
124
- console.log("Browser Agent (options1) Initialized!")
125
- })
88
+ See the [New Relic documentation site](https://docs.newrelic.com/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring/) for information on the above features.
126
89
 
127
- const options2 = {
128
- // see 'Configuring your application'
129
- licenseKey: 'xyz',
130
- applicationID: '987',
131
- beacon: 'bam.nr-data.net'
132
- }
133
- const agent2 = new BrowserAgent()
134
- agent2.features.errors.auto = false // do not capture global errors on this instance
135
- agent2.start(options2).then(() => {
136
- console.log("Browser Agent (options2) Initialized!")
137
- })
138
90
 
139
- // --- NOTE ---
140
- // thrown errors *anywhere* on the page will be captured if `auto` is enabled in your instance
141
- // agent2 has disabled `auto`, and will not capture globally thrown errors
142
-
143
- // ---- NavBarComponent.js ----
144
- class MyComponent() {
145
- try {
146
- ...
147
- } catch(err) {
148
- agent1.noticeError(err)
149
- // agent1 instance
150
- // reports the error to applicationID '123', licenseKey 'abc'
151
- }
152
- }
91
+ ## Composing a custom agent with selected feature modules
153
92
 
154
- // ---- SearchComponent.js ----
155
- class MyComponent() {
156
- try {
157
- ...
158
- } catch(err) {
159
- agent2.noticeError(err)
160
- // agent2 instance
161
- // reports to applicationID '987', licenseKey 'xyz'
162
- }
163
- }
164
- ```
93
+ The examples above use the `BrowserAgent` class, which is the best option for most use cases. The class makes all browser agent features available but provides the ability to turn off individual features selectively.
94
+
95
+ Using the base `Agent` class, it is also possible to compose a custom agent by passing an array called `features` in the `options` object, containing only the desired feature modules. Depending on which features are included, this may yield a smaller loader script and improved performance.
165
96
 
166
- ## Configuring your application
97
+ The example below includes three feature modules: `Metrics`, `PageViewEvent`, and `PageViewTiming`.
167
98
 
168
- The NR interface's `start` method accepts an `options` object to configure the agent:
99
+ ```javascript
100
+ import { Agent } from '@newrelic/browser-agent/loaders/agent'
101
+ import { Metrics } from '@newrelic/browser-agent/features/metrics'
102
+ import { PageViewEvent } from '@newrelic/browser-agent/features/page_view_event'
103
+ import { PageViewTiming } from '@newrelic/browser-agent/features/page_view_timing'
169
104
 
170
- ```js
171
105
  const options = {
172
- licenseKey: String // (required)
173
- applicationID: String // (required)
174
- beacon: String // (required)
175
- // ... other configurations
106
+ info: { ... },
107
+ loader_config: { ... },
108
+ init: { ... }
176
109
  }
177
- nr.start(options)
178
- ```
179
-
180
- ### Get application ID, license key, beacon
181
-
182
- You can find `licenseKey`, `applicationID` and `beacon` values in the New Relic UI's Browser Application **Settings** page ([one.newrelic.com](https://one.newrelic.com) > Browser > (select an app) > Settings > Application settings.)
183
-
184
- ![configuration](https://user-images.githubusercontent.com/4779220/169617807-110f3938-8af9-4aa8-b651-7712589b0792.jpg)
185
-
186
- ## Features
187
-
188
- |Feature|Subfeature|Default|Description|
189
- |-|-|-|-|
190
- |errors |enabled |true|Enable's `noticeError` method|
191
- |errors |auto |false|Reports all global errors |
192
-
193
- > Features must be set before calling the .start() method.
194
-
195
- ### JavaScript Errors
196
-
197
- This NPM package can currently capture JavaScript Error reporting in two ways. These errors will be reported to the appId & licenseKey specified in your [configuration](#configuring-your-application).
198
-
199
- ```js
200
- import { BrowserAgent } from '@newrelic/browser-agent'
201
- const browserAgent = new BrowserAgent()
202
-
203
- // enable noticeError() API scoped to applicationID (enabled by default)
204
- browserAgent.features.errors.enabled = true
205
-
206
- // report global errors to applicationID (enabled by default)
207
- browserAgent.features.errors.auto = true
208
-
209
- // configure features before starting the agent
210
- browserAgent.start(options)
211
- ```
212
-
213
- ### Capture JavaScript errors via API
214
110
 
215
- ```javascript
216
- // if browserAgent.features.errors.enabled === true (enabled by default)
217
- browserAgent.noticeError(new Error())
111
+ new Agent({
112
+ ...options,
113
+ features: [
114
+ Metrics,
115
+ PageViewEvent,
116
+ PageViewTiming
117
+ ]
118
+ })
218
119
  ```
219
120
 
220
- Set `browserAgent.errors.enabled` to `true` to report specific errors via the noticeError API.
221
-
222
- ### Automatically capture global JavaScript errors
121
+ The following feature modules are available for inclusion in the `features` array:
223
122
 
224
123
  ```javascript
225
- browserAgent.features.errors.auto = true
124
+ import { Ajax } from '@newrelic/browser-agent/features/ajax';
125
+ import { JSErrors } from '@newrelic/browser-agent/features/jserrors';
126
+ import { Metrics } from '@newrelic/browser-agent/features/metrics';
127
+ import { PageAction } from '@newrelic/browser-agent/features/page_action';
128
+ import { PageViewEvent } from '@newrelic/browser-agent/features/page_view_event';
129
+ import { PageViewTiming } from '@newrelic/browser-agent/features/page_view_timing';
130
+ import { SessionTrace } from '@newrelic/browser-agent/features/session_trace';
131
+ import { Spa } from '@newrelic/browser-agent/features/spa';
226
132
  ```
227
133
 
228
- Set `browserAgent.errors.auto` to `true` to report all errors on the page.
229
-
134
+ ## Supported Browsers
230
135
 
231
- ## Differences
136
+ Our supported browser list can be accessed [here](https://docs.newrelic.com/docs/browser/new-relic-browser/getting-started/compatibility-requirements-browser-monitoring/#browser-types).
232
137
 
233
- The Browser Agent delivered through NPM will eventually offer parity to its copy/paste and APM counterparts, but during this initial development phase, **it should not yet be treated as equivalent**. Please see the following table describing the capabilities of each. The availability of these features will change over time.
138
+ If you desire more control over how the agent is built, our package also includes the source code. The source code is written to target the latest ECMAScript standards (ES2022). Please note that if you import the browser agent source code instead of the transpiled distribution code, you may need to alter your project's build system to apply transformations to the browser agent source code. Without these transforms, the code produced by your project's build system may not be compatible with your desired target browsers. Below is an example of how to import the source code.
234
139
 
235
- | Feature | APM Injected | Copy/Paste | NPM |
236
- | ------- | ------------ | ---------- | --- |
237
- | JavaScript Errors | Auto, API | Auto, API | `Auto, API` |
238
- | Page View | Auto | Auto | `None` |
239
- | Page View Timings | Auto | Auto | `None` |
240
- | Ajax Tracking | Auto | Auto | `None` |
241
- | Page Actions | API | API | `None` |
242
- | Session Traces | Auto | Auto | `None` |
243
- | Browser Interactions (SPA) | Auto, API | Auto, API | `None` |
244
- | Multiple Configurable Instances of Browser Agent on One Page | No | No | `Yes` |
245
- | Configurable Code Splitting | No | No | `Yes` |
246
- | IDE Code Completion and Typings | No | No | `Yes` |
140
+ ```javascript
141
+ // Note the /src/ in the import paths below
142
+ import { Agent } from '@newrelic/browser-agent/src/loaders/agent'
143
+ import { Metrics } from '@newrelic/browser-agent/src/features/metrics'
144
+ import { PageViewEvent } from '@newrelic/browser-agent/src/features/page_view_event'
145
+ import { PageViewTiming } from '@newrelic/browser-agent/src/features/page_view_timing'
247
146
 
147
+ const options = {
148
+ info: { ... },
149
+ loader_config: { ... },
150
+ init: { ... }
151
+ }
248
152
 
249
- ## Contributing
153
+ new Agent({
154
+ ...options,
155
+ features: [
156
+ Metrics,
157
+ PageViewEvent,
158
+ PageViewTiming
159
+ ]
160
+ })
161
+ ```
250
162
 
251
- We encourage your contributions to improve the Browser agent! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
163
+ Neither the browser agent development team nor the New Relic support teams can support the numerous build systems that exist in the JavaScript ecosystem. If you run into issues, you may be asked to revert to importing from the transpiled distribution code.
252
164
 
253
- If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.
165
+ **DON'T** mix imports between the browser agent source code and transpiled distribution code. The below will break.
254
166
 
255
- For more details on how best to contribute, see [CONTRIBUTING.md](CONTRIBUTING.md)
167
+ ```javascript
168
+ // THIS IS BAD - do not do this
169
+ import { Agent } from '@newrelic/browser-agent/loaders/agent'
170
+ import { Metrics } from '@newrelic/browser-agent/src/features/metrics'
171
+ ```
256
172
 
257
173
  ## License
258
174
 
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _agent = require("../loaders/agent");
4
+ var _instrument = require("../features/page_view_event/instrument");
5
+ var _instrument2 = require("../features/page_view_timing/instrument");
6
+ var _instrument3 = require("../features/metrics/instrument");
7
+ /**
8
+ * @file Creates a "Lite" agent loader bundle composed of the core Agent and a subset of available feature modules.
9
+ */
10
+
11
+ new _agent.Agent({
12
+ features: [_instrument.Instrument, _instrument2.Instrument, _instrument3.Instrument],
13
+ loaderType: 'lite'
14
+ });
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../polyfills.js");
4
+ require("../lite");
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../polyfills.js");
4
+ require("../pro");
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../polyfills.js");
4
+ require("../spa");
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ require("core-js/stable/promise");
4
+ require("core-js/stable/array/includes");
5
+ require("core-js/stable/array/from");
6
+ require("core-js/stable/array/find");
7
+ require("core-js/stable/array/some");
8
+ require("core-js/stable/object/assign");
9
+ require("core-js/stable/object/entries");
10
+ require("core-js/stable/object/values");
11
+ require("core-js/stable/map");
12
+ require("core-js/stable/reflect");
13
+ require("core-js/stable/set");
14
+ require("core-js/stable/weak-set");
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var _agent = require("../loaders/agent");
4
+ var _instrument = require("../features/page_view_event/instrument");
5
+ var _instrument2 = require("../features/page_view_timing/instrument");
6
+ var _instrument3 = require("../features/metrics/instrument");
7
+ var _instrument4 = require("../features/jserrors/instrument");
8
+ var _instrument5 = require("../features/ajax/instrument");
9
+ var _instrument6 = require("../features/session_trace/instrument");
10
+ var _instrument7 = require("../features/page_action/instrument");
11
+ /**
12
+ * @file Creates a "Pro" agent loader bundle composed of the core Agent and all available feature modules except `spa`.
13
+ * This excludes collection of BrowserInteraction and BrowserTiming events.
14
+ */
15
+
16
+ new _agent.Agent({
17
+ features: [_instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument5.Instrument, _instrument3.Instrument, _instrument7.Instrument, _instrument4.Instrument],
18
+ loaderType: 'pro'
19
+ });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var _agent = require("../loaders/agent");
4
+ var _instrument = require("../features/page_view_event/instrument");
5
+ var _instrument2 = require("../features/page_view_timing/instrument");
6
+ var _instrument3 = require("../features/metrics/instrument");
7
+ var _instrument4 = require("../features/jserrors/instrument");
8
+ var _instrument5 = require("../features/ajax/instrument");
9
+ var _instrument6 = require("../features/session_trace/instrument");
10
+ var _instrument7 = require("../features/spa/instrument");
11
+ var _instrument8 = require("../features/page_action/instrument");
12
+ /**
13
+ * @file Creates a "SPA" agent loader bundle composed of the core agent and all available feature modules.
14
+ */
15
+
16
+ new _agent.Agent({
17
+ features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument3.Instrument, _instrument8.Instrument, _instrument4.Instrument, _instrument7.Instrument],
18
+ loaderType: 'spa'
19
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ var _agent = require("../loaders/agent");
4
+ var _instrument = require("../features/metrics/instrument");
5
+ var _instrument2 = require("../features/jserrors/instrument");
6
+ var _instrument3 = require("../features/ajax/instrument");
7
+ var _instrument4 = require("../features/page_action/instrument");
8
+ /**
9
+ * @file Creates a "Worker" agent loader bundle composed of the core Agent and the subset of feature modules applicable
10
+ * in a service worker context.
11
+ */
12
+
13
+ new _agent.Agent({
14
+ features: [_instrument.Instrument, _instrument2.Instrument, _instrument3.Instrument, _instrument4.Instrument],
15
+ loaderType: 'worker'
16
+ });
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Aggregator = void 0;
7
+ var _sharedContext = require("../context/shared-context");
8
+ var _mapOwn = require("../util/map-own");
9
+ /*
10
+ * Copyright 2020 New Relic Corporation. All rights reserved.
11
+ * SPDX-License-Identifier: Apache-2.0
12
+ */
13
+
14
+ class Aggregator extends _sharedContext.SharedContext {
15
+ constructor(parent) {
16
+ super(parent);
17
+ this.aggregatedData = {};
18
+ }
19
+
20
+ // Items with the same type and name get aggregated together
21
+ // params are example data from the aggregated items
22
+ // metrics are the numeric values to be aggregated
23
+
24
+ store(type, name, params, newMetrics, customParams) {
25
+ var bucket = this.getBucket(type, name, params, customParams);
26
+ bucket.metrics = aggregateMetrics(newMetrics, bucket.metrics);
27
+ return bucket;
28
+ }
29
+ merge(type, name, metrics, params, customParams) {
30
+ var bucket = this.getBucket(type, name, params, customParams);
31
+ if (!bucket.metrics) {
32
+ bucket.metrics = metrics;
33
+ return;
34
+ }
35
+ var oldMetrics = bucket.metrics;
36
+ oldMetrics.count += metrics.count;
37
+
38
+ // iterate through each new metric and merge
39
+ (0, _mapOwn.mapOwn)(metrics, function (key, value) {
40
+ // count is a special case handled above
41
+ if (key === 'count') return;
42
+ var oldMetric = oldMetrics[key];
43
+ var newMetric = metrics[key];
44
+
45
+ // handling the case where newMetric is a single-value first
46
+ if (newMetric && !newMetric.c) {
47
+ oldMetrics[key] = updateMetric(newMetric.t, oldMetric);
48
+ } else {
49
+ // newMetric is a metric object
50
+ oldMetrics[key] = mergeMetric(newMetric, oldMetrics[key]);
51
+ }
52
+ });
53
+ }
54
+ storeMetric(type, name, params, value) {
55
+ var bucket = this.getBucket(type, name, params);
56
+ bucket.stats = updateMetric(value, bucket.stats);
57
+ return bucket;
58
+ }
59
+ getBucket(type, name, params, customParams) {
60
+ if (!this.aggregatedData[type]) this.aggregatedData[type] = {};
61
+ var bucket = this.aggregatedData[type][name];
62
+ if (!bucket) {
63
+ bucket = this.aggregatedData[type][name] = {
64
+ params: params || {}
65
+ };
66
+ if (customParams) {
67
+ bucket.custom = customParams;
68
+ }
69
+ }
70
+ return bucket;
71
+ }
72
+ get(type, name) {
73
+ // if name is passed, get a single bucket
74
+ if (name) return this.aggregatedData[type] && this.aggregatedData[type][name];
75
+ // else, get all buckets of that type
76
+ return this.aggregatedData[type];
77
+ }
78
+
79
+ // Like get, but for many types and it deletes the retrieved content from the aggregatedData
80
+ take(types) {
81
+ var results = {};
82
+ var type = '';
83
+ var hasData = false;
84
+ for (var i = 0; i < types.length; i++) {
85
+ type = types[i];
86
+ results[type] = toArray(this.aggregatedData[type]);
87
+ if (results[type].length) hasData = true;
88
+ delete this.aggregatedData[type];
89
+ }
90
+ return hasData ? results : null;
91
+ }
92
+ }
93
+ exports.Aggregator = Aggregator;
94
+ function aggregateMetrics(newMetrics, oldMetrics) {
95
+ if (!oldMetrics) oldMetrics = {
96
+ count: 0
97
+ };
98
+ oldMetrics.count += 1;
99
+ (0, _mapOwn.mapOwn)(newMetrics, function (key, value) {
100
+ oldMetrics[key] = updateMetric(value, oldMetrics[key]);
101
+ });
102
+ return oldMetrics;
103
+ }
104
+ function updateMetric(value, metric) {
105
+ // when there is no value, then send only count
106
+ if (value == null) {
107
+ return updateCounterMetric(metric);
108
+ }
109
+
110
+ // When there is only one data point, the c (count), min, max, and sos (sum of squares) params are superfluous.
111
+ if (!metric) return {
112
+ t: value
113
+ };
114
+
115
+ // but on the second data point, we need to calculate the other values before aggregating in new values
116
+ if (!metric.c) {
117
+ metric = createMetricObject(metric.t);
118
+ }
119
+
120
+ // at this point, metric is always uncondensed
121
+ metric.c += 1;
122
+ metric.t += value;
123
+ metric.sos += value * value;
124
+ if (value > metric.max) metric.max = value;
125
+ if (value < metric.min) metric.min = value;
126
+ return metric;
127
+ }
128
+ function updateCounterMetric(metric) {
129
+ if (!metric) {
130
+ metric = {
131
+ c: 1
132
+ };
133
+ } else {
134
+ metric.c++;
135
+ }
136
+ return metric;
137
+ }
138
+ function mergeMetric(newMetric, oldMetric) {
139
+ if (!oldMetric) return newMetric;
140
+ if (!oldMetric.c) {
141
+ // oldMetric is a single-value
142
+ oldMetric = createMetricObject(oldMetric.t);
143
+ }
144
+ oldMetric.min = Math.min(newMetric.min, oldMetric.min);
145
+ oldMetric.max = Math.max(newMetric.max, oldMetric.max);
146
+ oldMetric.t += newMetric.t;
147
+ oldMetric.sos += newMetric.sos;
148
+ oldMetric.c += newMetric.c;
149
+ return oldMetric;
150
+ }
151
+
152
+ // take a value and create a metric object
153
+ function createMetricObject(value) {
154
+ return {
155
+ t: value,
156
+ min: value,
157
+ max: value,
158
+ sos: value * value,
159
+ c: 1
160
+ };
161
+ }
162
+ function toArray(obj) {
163
+ if (typeof obj !== 'object') return [];
164
+ return (0, _mapOwn.mapOwn)(obj, getValue);
165
+ }
166
+ function getValue(key, value) {
167
+ return value;
168
+ }