@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
@@ -0,0 +1,128 @@
1
+ import { handle } from '../../../common/event-emitter/handle';
2
+ import { FEATURE_NAMES } from '../../../loaders/features/features';
3
+ import { isiOS } from '../../../common/browser-version/ios-version';
4
+ import { onTTFB } from 'web-vitals';
5
+ import { mapOwn } from '../../../common/util/map-own';
6
+ import { param, fromArray } from '../../../common/url/encode';
7
+ import { addPT, addPN } from '../../../common/timing/nav-timing';
8
+ import { stringify } from '../../../common/util/stringify';
9
+ import { paintMetrics } from '../../../common/metrics/paint-metrics';
10
+ import { submitData } from '../../../common/util/submit-data';
11
+ import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config';
12
+ import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
13
+ import { AggregateBase } from '../../utils/aggregate-base';
14
+ import * as CONSTANTS from '../constants';
15
+ import { getActivatedFeaturesFlags } from './initialized-features';
16
+ import { globalScope, isBrowserScope } from '../../../common/util/global-scope';
17
+ import { drain } from '../../../common/drain/drain';
18
+ const jsonp = 'NREUM.setToken';
19
+ export class Aggregate extends AggregateBase {
20
+ static featureName = CONSTANTS.FEATURE_NAME;
21
+ constructor(agentIdentifier, aggregator) {
22
+ super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
23
+ if (typeof PerformanceNavigationTiming !== 'undefined' && !isiOS) {
24
+ this.alreadySent = false; // we don't support timings on BFCache restores
25
+ const agentRuntime = getRuntime(agentIdentifier); // we'll store timing values on the runtime obj to be read by the aggregate module
26
+
27
+ /* Time To First Byte
28
+ This listener must record these values *before* PVE's aggregate sends RUM. */
29
+ onTTFB(_ref => {
30
+ let {
31
+ value,
32
+ entries
33
+ } = _ref;
34
+ if (this.alreadySent) return;
35
+ this.alreadySent = true;
36
+ agentRuntime[CONSTANTS.TTFB] = Math.round(value); // this is our "backend" duration; web-vitals will ensure it's lower bounded at 0
37
+
38
+ // Similar to what vitals does for ttfb, we have to factor in activation-start when calculating relative timings:
39
+ const navEntry = entries[0];
40
+ const respOrActivStart = Math.max(navEntry.responseStart, navEntry.activationStart || 0);
41
+ agentRuntime[CONSTANTS.FBTWL] = Math.max(Math.round(navEntry.loadEventEnd - respOrActivStart), 0); // our "frontend" duration
42
+ handle('timing', ['load', Math.round(navEntry.loadEventEnd)], undefined, FEATURE_NAMES.pageViewTiming, this.ee);
43
+ agentRuntime[CONSTANTS.FBTDC] = Math.max(Math.round(navEntry.domContentLoadedEventEnd - respOrActivStart), 0); // our "dom processing" duration
44
+
45
+ this.sendRum();
46
+ });
47
+ } else {
48
+ this.sendRum(); // timings either already in runtime from instrument or is meant to get 0'd.
49
+ }
50
+ }
51
+
52
+ getScheme() {
53
+ return getConfigurationValue(this.agentIdentifier, 'ssl') === false ? 'http' : 'https';
54
+ }
55
+ sendRum() {
56
+ const info = getInfo(this.agentIdentifier);
57
+ if (!info.beacon) return;
58
+ if (info.queueTime) this.aggregator.store('measures', 'qt', {
59
+ value: info.queueTime
60
+ });
61
+ if (info.applicationTime) this.aggregator.store('measures', 'ap', {
62
+ value: info.applicationTime
63
+ });
64
+ const agentRuntime = getRuntime(this.agentIdentifier);
65
+
66
+ // These 3 values should've been recorded after load and before this func runs. They are part of the minimum required for PageView events to be created.
67
+ // Following PR #428, which demands that all agents send RUM call, these need to be sent even outside of the main window context where PerformanceTiming
68
+ // or PerformanceNavigationTiming do not exists. Hence, they'll be filled in by 0s instead in, for example, worker threads that still init the PVE module.
69
+ this.aggregator.store('measures', 'be', {
70
+ value: isBrowserScope ? agentRuntime[CONSTANTS.TTFB] : 0
71
+ });
72
+ this.aggregator.store('measures', 'fe', {
73
+ value: isBrowserScope ? agentRuntime[CONSTANTS.FBTWL] : 0
74
+ });
75
+ this.aggregator.store('measures', 'dc', {
76
+ value: isBrowserScope ? agentRuntime[CONSTANTS.FBTDC] : 0
77
+ });
78
+ var measuresMetrics = this.aggregator.get('measures');
79
+ var measuresQueryString = mapOwn(measuresMetrics, function (metricName, measure) {
80
+ return '&' + metricName + '=' + measure.params.value;
81
+ }).join('');
82
+
83
+ // currently we only have one version of our protocol
84
+ // in the future we may add more
85
+ var protocol = '1';
86
+ var scheduler = new HarvestScheduler('page_view_event', {}, this);
87
+ var chunksForQueryString = [scheduler.harvest.baseQueryString()];
88
+ chunksForQueryString.push(measuresQueryString);
89
+ chunksForQueryString.push(param('tt', info.ttGuid));
90
+ chunksForQueryString.push(param('us', info.user));
91
+ chunksForQueryString.push(param('ac', info.account));
92
+ chunksForQueryString.push(param('pr', info.product));
93
+ chunksForQueryString.push(param('af', getActivatedFeaturesFlags(this.agentIdentifier).join(',')));
94
+ if (globalScope.performance && typeof globalScope.performance.timing !== 'undefined') {
95
+ var navTimingApiData = {
96
+ timing: addPT(agentRuntime.offset, globalScope.performance.timing, {}),
97
+ navigation: addPN(globalScope.performance.navigation, {})
98
+ };
99
+ chunksForQueryString.push(param('perf', stringify(navTimingApiData)));
100
+ }
101
+ try {
102
+ // PVTiming sends these too, albeit using web-vitals and slightly different; it's unknown why they're duplicated, but PVT should be the truth
103
+ var entries = globalScope.performance.getEntriesByType('paint');
104
+ entries.forEach(function (entry) {
105
+ if (!entry.startTime || entry.startTime <= 0) return;
106
+ if (entry.name === 'first-paint') {
107
+ chunksForQueryString.push(param('fp', String(Math.floor(entry.startTime))));
108
+ } else if (entry.name === 'first-contentful-paint') {
109
+ chunksForQueryString.push(param('fcp', String(Math.floor(entry.startTime))));
110
+ }
111
+ paintMetrics[entry.name] = Math.floor(entry.startTime); // this is consumed by Spa module
112
+ });
113
+ } catch (e) {}
114
+ chunksForQueryString.push(param('xx', info.extra));
115
+ chunksForQueryString.push(param('ua', info.userAttributes));
116
+ chunksForQueryString.push(param('at', info.atts));
117
+ var customJsAttributes = stringify(info.jsAttributes);
118
+ chunksForQueryString.push(param('ja', customJsAttributes === '{}' ? null : customJsAttributes));
119
+ var queryString = fromArray(chunksForQueryString, agentRuntime.maxBytes);
120
+
121
+ // Capture bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
122
+ agentRuntime.bytesSent[protocol] = (agentRuntime.bytesSent[protocol] || 0) + queryString?.length || 0;
123
+ const isValidJsonp = submitData.jsonp(this.getScheme() + '://' + info.beacon + '/' + protocol + '/' + info.licenseKey + queryString, jsonp);
124
+ // Usually `drain` is invoked automatically after processing feature flags contained in the JSONP callback from
125
+ // ingest (see `activateFeatures`), so when JSONP cannot execute (as with module workers), we drain manually.
126
+ if (!isValidJsonp) drain(this.agentIdentifier, CONSTANTS.FEATURE_NAME);
127
+ }
128
+ }
@@ -0,0 +1,34 @@
1
+ import { FEATURE_NAMES } from '../../../loaders/features/features';
2
+
3
+ /**
4
+ * Get an array of flags required by downstream (NR UI) based on the features initialized in this agent
5
+ * (aka what is running on the page).
6
+ * @param {String} agentId - the ID of the initialized agent on the page, mapping to the one under the global 'newrelic' object
7
+ * @returns {String[]} Up to 5 short strings corresponding to ingest mapping of features.
8
+ */
9
+ export function getActivatedFeaturesFlags(agentId) {
10
+ const flagArr = [];
11
+ Object.keys(newrelic.initializedAgents[agentId].features).forEach(featName => {
12
+ switch (featName) {
13
+ case FEATURE_NAMES.ajax:
14
+ flagArr.push('xhr');
15
+ break;
16
+ case FEATURE_NAMES.jserrors:
17
+ flagArr.push('err');
18
+ break;
19
+ case FEATURE_NAMES.pageAction:
20
+ flagArr.push('ins');
21
+ break;
22
+ case FEATURE_NAMES.sessionTrace:
23
+ flagArr.push('stn');
24
+ break;
25
+ case FEATURE_NAMES.spa:
26
+ flagArr.push('spa');
27
+ break;
28
+ }
29
+ });
30
+ return flagArr;
31
+ }
32
+
33
+ // Note: this module and the "af" param in src/features/page_view_event/aggregate/index.js can be removed in the future at such time
34
+ // that it's no longer being used. For the browser agent, this is an unused flag system.
@@ -0,0 +1,5 @@
1
+ import { FEATURE_NAMES } from '../../loaders/features/features';
2
+ export const FEATURE_NAME = FEATURE_NAMES.pageViewEvent;
3
+ export const TTFB = 'firstbyte';
4
+ export const FBTDC = 'domcontent';
5
+ export const FBTWL = 'windowload';
@@ -0,0 +1 @@
1
+ export { Instrument as PageViewEvent } from './instrument/index';
@@ -0,0 +1,30 @@
1
+ import { handle } from '../../../common/event-emitter/handle';
2
+ import { isiOS } from '../../../common/browser-version/ios-version';
3
+ import { InstrumentBase } from '../../utils/instrument-base';
4
+ import * as CONSTANTS from '../constants';
5
+ import { FEATURE_NAMES } from '../../../loaders/features/features';
6
+ import { getRuntime } from '../../../common/config/config';
7
+ import { onDOMContentLoaded, onWindowLoad } from '../../../common/window/load';
8
+ import { now } from '../../../common/timing/now';
9
+ export class Instrument extends InstrumentBase {
10
+ static featureName = CONSTANTS.FEATURE_NAME;
11
+ constructor(agentIdentifier, aggregator) {
12
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
13
+ super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
14
+ if ((typeof PerformanceNavigationTiming === 'undefined' || isiOS) && typeof PerformanceTiming !== 'undefined') {
15
+ // For majority browser versions in which PNT exists, we can get load timings later from the nav entry (in the aggregate portion). At minimum, PT should exist for main window.
16
+ // *cli Mar'23 - iOS 15.2 & 15.4 testing in Sauce still fails with onTTFB. Hence, all iOS will fallback to this for now. Unknown if this is similar in nature to iOS_below16 bug.
17
+ const agentRuntime = getRuntime(agentIdentifier);
18
+ agentRuntime[CONSTANTS.TTFB] = Math.max(Date.now() - agentRuntime.offset, 0);
19
+ onDOMContentLoaded(() => agentRuntime[CONSTANTS.FBTDC] = Math.max(now() - agentRuntime[CONSTANTS.TTFB], 0));
20
+ onWindowLoad(() => {
21
+ const timeNow = now();
22
+ agentRuntime[CONSTANTS.FBTWL] = Math.max(timeNow - agentRuntime[CONSTANTS.TTFB], 0);
23
+ handle('timing', ['load', timeNow], undefined, FEATURE_NAMES.pageViewTiming, this.ee);
24
+ });
25
+ }
26
+ // Else, inference: inside worker or some other env where these events are irrelevant. They'll get filled in with 0s in RUM call.
27
+
28
+ this.importAggregator();
29
+ }
30
+ }
@@ -0,0 +1,277 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { onFCP, onFID, onLCP, onCLS, onINP } from 'web-vitals';
7
+ import { onFirstPaint } from '../first-paint';
8
+ import { onLongTask } from '../long-tasks';
9
+ import { iOS_below16 } from '../../../common/browser-version/ios-version';
10
+ import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
11
+ import { mapOwn } from '../../../common/util/map-own';
12
+ import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
13
+ import { registerHandler } from '../../../common/event-emitter/register-handler';
14
+ import { cleanURL } from '../../../common/url/clean-url';
15
+ import { handle } from '../../../common/event-emitter/handle';
16
+ import { getInfo, getConfigurationValue, getRuntime } from '../../../common/config/config';
17
+ import { AggregateBase } from '../../utils/aggregate-base';
18
+ import { FEATURE_NAME } from '../constants';
19
+ import { drain } from '../../../common/drain/drain';
20
+ import { FEATURE_NAMES } from '../../../loaders/features/features';
21
+ export class Aggregate extends AggregateBase {
22
+ static featureName = FEATURE_NAME;
23
+ constructor(agentIdentifier, aggregator) {
24
+ var _this;
25
+ super(agentIdentifier, aggregator, FEATURE_NAME);
26
+ _this = this;
27
+ this.timings = [];
28
+ this.timingsSent = [];
29
+ this.curSessEndRecorded = false;
30
+ try {
31
+ // we (only) need to track cls state because it's attached to other timing events rather than reported on change...
32
+ this.clsSupported = PerformanceObserver.supportedEntryTypes.includes('layout-shift');
33
+ this.cls = 0;
34
+ } catch (e) {}
35
+
36
+ /*! This is the section that used to be in the loader portion: !*/
37
+ /* ------------------------------------------------------------ */
38
+ const pageStartedHidden = getRuntime(agentIdentifier).initHidden; // our attempt at recapturing initial vis state since this code runs post-load time
39
+ this.alreadySent = new Set(); // since we don't support timings on BFCache restores, this tracks and helps cap metrics that web-vitals report more than once
40
+
41
+ /* PerformancePaintTiming API - BFC is not yet supported. */
42
+ onFirstPaint(_ref => {
43
+ let {
44
+ name,
45
+ value
46
+ } = _ref;
47
+ if (pageStartedHidden) return;
48
+ this.addTiming(name.toLowerCase(), Math.floor(value));
49
+ });
50
+
51
+ /* First Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
52
+ if (iOS_below16) {
53
+ try {
54
+ if (!pageStartedHidden) {
55
+ // see ios-version.js for detail on this following bug case; tldr: buffered flag doesn't work but getEntriesByType does
56
+ const paintEntries = performance.getEntriesByType('paint');
57
+ paintEntries.forEach(entry => {
58
+ if (entry.name === 'first-contentful-paint') {
59
+ this.addTiming('fcp', Math.floor(entry.startTime));
60
+ }
61
+ });
62
+ }
63
+ } catch (e) {}
64
+ } else {
65
+ onFCP(_ref2 => {
66
+ let {
67
+ name,
68
+ value
69
+ } = _ref2;
70
+ if (pageStartedHidden || this.alreadySent.has(name)) return;
71
+ this.alreadySent.add(name);
72
+ this.addTiming(name.toLowerCase(), value);
73
+ });
74
+ }
75
+
76
+ /* First Input Delay (+"First Interaction") - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
77
+ onFID(_ref3 => {
78
+ let {
79
+ name,
80
+ value,
81
+ entries
82
+ } = _ref3;
83
+ if (pageStartedHidden || this.alreadySent.has(name)) return;
84
+ this.alreadySent.add(name);
85
+
86
+ // CWV will only report one (THE) first-input entry to us; fid isn't reported if there are no user interactions occurs before the *first* page hiding.
87
+ const fiEntry = entries[0];
88
+ const attributes = {
89
+ type: fiEntry.name,
90
+ fid: Math.round(value)
91
+ };
92
+ this.addConnectionAttributes(attributes);
93
+ this.addTiming('fi', Math.round(fiEntry.startTime), attributes);
94
+ });
95
+
96
+ /* Largest Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
97
+ onLCP(_ref4 => {
98
+ let {
99
+ name,
100
+ value,
101
+ entries
102
+ } = _ref4;
103
+ if (pageStartedHidden || this.alreadySent.has(name)) return;
104
+ this.alreadySent.add(name);
105
+
106
+ // CWV will only ever report one (THE) lcp entry to us; lcp is also only reported *once* on earlier(user interaction, page hidden).
107
+ const lcpEntry = entries[entries.length - 1]; // this looks weird if we only expect one, but this is how cwv-attribution gets it so to be sure...
108
+ const attrs = {
109
+ size: lcpEntry.size,
110
+ eid: lcpEntry.id
111
+ };
112
+ this.addConnectionAttributes(attrs);
113
+ if (lcpEntry.url) {
114
+ attrs['elUrl'] = cleanURL(lcpEntry.url);
115
+ }
116
+ if (lcpEntry.element && lcpEntry.element.tagName) {
117
+ attrs['elTag'] = lcpEntry.element.tagName;
118
+ }
119
+ this.addTiming(name.toLowerCase(), value, attrs);
120
+ });
121
+
122
+ /* Cumulative Layout Shift - We don't have to limit this callback since cls is stored as a state and only sent as attribute on other timings. */
123
+ onCLS(_ref5 => {
124
+ let {
125
+ value
126
+ } = _ref5;
127
+ return this.cls = value;
128
+ });
129
+
130
+ /* Interaction-to-Next-Paint */
131
+ onINP(_ref6 => {
132
+ let {
133
+ name,
134
+ value,
135
+ id
136
+ } = _ref6;
137
+ return this.addTiming(name.toLowerCase(), value, {
138
+ metricId: id
139
+ });
140
+ });
141
+
142
+ /* PerformanceLongTaskTiming API */
143
+ if (getConfigurationValue(this.agentIdentifier, 'page_view_timing.long_task') === true) {
144
+ onLongTask(_ref7 => {
145
+ let {
146
+ name,
147
+ value,
148
+ info
149
+ } = _ref7;
150
+ return this.addTiming(name.toLowerCase(), value, info);
151
+ }); // lt context is passed as 'info'=attrs in the timing node
152
+ }
153
+ /* ------------------------------------End of ex-loader section */
154
+
155
+ /* It's important that CWV api, like "onLCP", is called before this scheduler is initialized. The reason is because they listen to the same
156
+ on vis change or pagehide events, and we'd want ex. onLCP to record the timing (win the race) before we try to send "final harvest". */
157
+ this.scheduler = new HarvestScheduler('events', {
158
+ onFinished: function () {
159
+ return _this.onHarvestFinished(...arguments);
160
+ },
161
+ getPayload: function () {
162
+ return _this.prepareHarvest(...arguments);
163
+ }
164
+ }, this);
165
+ registerHandler('timing', (name, value, attrs) => this.addTiming(name, value, attrs), this.featureName, this.ee); // notice CLS is added to all timings via 4th param
166
+ registerHandler('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
167
+ registerHandler('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
168
+ const initialHarvestSeconds = getConfigurationValue(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
169
+ const harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
170
+ // send initial data sooner, then start regular
171
+ this.ee.on(`drain-${this.featureName}`, () => {
172
+ this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
173
+ });
174
+ drain(this.agentIdentifier, this.featureName);
175
+ }
176
+
177
+ // takes an attributes object and appends connection attributes if available
178
+ addConnectionAttributes(attributes) {
179
+ var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; // to date, both window & worker shares the same support for connection
180
+ if (!connection) return;
181
+ if (connection.type) attributes['net-type'] = connection.type;
182
+ if (connection.effectiveType) attributes['net-etype'] = connection.effectiveType;
183
+ if (connection.rtt) attributes['net-rtt'] = connection.rtt;
184
+ if (connection.downlink) attributes['net-dlink'] = connection.downlink;
185
+ return attributes;
186
+ }
187
+
188
+ /**
189
+ * Add the time of _document visibilitychange to hidden_ to the next PVT harvest == NRDB pageHide attr.
190
+ * @param {number} timestamp
191
+ */
192
+ endCurrentSession(timestamp) {
193
+ if (!this.curSessEndRecorded) {
194
+ // TO DO: stage 2 - we don't want to capture this timing twice on page navigating away, but it should run again if we return to page and away *again*
195
+ this.addTiming('pageHide', timestamp, null);
196
+ this.curSessEndRecorded = true;
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Add the time of _window pagehide event_ firing to the next PVT harvest == NRDB windowUnload attr.
202
+ */
203
+ recordPageUnload(timestamp) {
204
+ this.addTiming('unload', timestamp, null);
205
+ // Because window's pageHide commonly fires before vis change and the final harvest occurs on the earlier of the two, we also have to add that now or it won't make it into the last payload out.
206
+ this.endCurrentSession(timestamp);
207
+ }
208
+ addTiming(name, value, attrs) {
209
+ attrs = attrs || {};
210
+
211
+ // If CLS is supported, a cls value should exist and be reported, even at 0.
212
+ // *cli Mar'23 - At this time, it remains attached to all timings. See NEWRELIC-6143.
213
+ if (this.clsSupported) {
214
+ attrs['cls'] = this.cls;
215
+ }
216
+ this.timings.push({
217
+ name: name,
218
+ value: value,
219
+ attrs: attrs
220
+ });
221
+ handle('pvtAdded', [name, value, attrs], undefined, FEATURE_NAMES.sessionTrace, this.ee);
222
+ }
223
+ onHarvestFinished(result) {
224
+ if (result.retry && this.timingsSent.length > 0) {
225
+ for (var i = 0; i < this.timingsSent.length; i++) {
226
+ this.timings.push(this.timingsSent[i]);
227
+ }
228
+ this.timingsSent = [];
229
+ }
230
+ }
231
+ appendGlobalCustomAttributes(timing) {
232
+ var timingAttributes = timing.attrs || {};
233
+ var customAttributes = getInfo(this.agentIdentifier).jsAttributes || {};
234
+ var reservedAttributes = ['size', 'eid', 'cls', 'type', 'fid', 'elTag', 'elUrl', 'net-type', 'net-etype', 'net-rtt', 'net-dlink'];
235
+ mapOwn(customAttributes, function (key, val) {
236
+ if (reservedAttributes.indexOf(key) < 0) {
237
+ timingAttributes[key] = val;
238
+ }
239
+ });
240
+ }
241
+
242
+ // serialize and return current timing data, clear and save current data for retry
243
+ prepareHarvest(options) {
244
+ if (this.timings.length === 0) return;
245
+ var payload = this.getPayload(this.timings);
246
+ if (options.retry) {
247
+ for (var i = 0; i < this.timings.length; i++) {
248
+ this.timingsSent.push(this.timings[i]);
249
+ }
250
+ }
251
+ this.timings = [];
252
+ return {
253
+ body: {
254
+ e: payload
255
+ }
256
+ };
257
+ }
258
+
259
+ // serialize array of timing data
260
+ getPayload(data) {
261
+ var addString = getAddStringContext(this.agentIdentifier);
262
+ var payload = 'bel.6;';
263
+ for (var i = 0; i < data.length; i++) {
264
+ var timing = data[i];
265
+ payload += 'e,';
266
+ payload += addString(timing.name) + ',';
267
+ payload += nullable(timing.value, numeric, false) + ',';
268
+ this.appendGlobalCustomAttributes(timing);
269
+ var attrParts = addCustomAttributes(timing.attrs, addString);
270
+ if (attrParts && attrParts.length > 0) {
271
+ payload += numeric(attrParts.length) + ';' + attrParts.join(';');
272
+ }
273
+ if (i + 1 < data.length) payload += ';';
274
+ }
275
+ return payload;
276
+ }
277
+ }
@@ -0,0 +1,2 @@
1
+ import { FEATURE_NAMES } from '../../loaders/features/features';
2
+ export const FEATURE_NAME = FEATURE_NAMES.pageViewTiming;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Calls the `onReport` function when the 'first-paint' PerformancePaintTiming entry is observed.
3
+ * The argument supplied is an object similar to the Metric type used by web-vitals library.
4
+ *
5
+ * @param {Function} onReport - callback that accepts a `metric` object as the single parameter
6
+ */
7
+ export const onFirstPaint = onReport => {
8
+ const handleEntries = entries => {
9
+ entries.forEach(entry => {
10
+ if (entry.name === 'first-paint') {
11
+ observer.disconnect();
12
+
13
+ /* Initial hidden state and pre-rendering not yet considered for first paint. See web-vitals onFCP for example. */
14
+ const metric = {
15
+ name: 'FP',
16
+ value: entry.startTime
17
+ };
18
+ onReport(metric);
19
+ }
20
+ });
21
+ };
22
+ let observer;
23
+ try {
24
+ if (PerformanceObserver.supportedEntryTypes.includes('paint')) {
25
+ observer = new PerformanceObserver(list => {
26
+ // Delay by a microtask to workaround a bug in Safari where the
27
+ // callback is invoked immediately, rather than in a separate task.
28
+ // See: https://github.com/GoogleChrome/web-vitals/issues/277
29
+ Promise.resolve().then(() => {
30
+ handleEntries(list.getEntries());
31
+ });
32
+ });
33
+ observer.observe({
34
+ type: 'paint',
35
+ buffered: true
36
+ });
37
+ }
38
+ } catch (e) {
39
+ // Do nothing.
40
+ }
41
+
42
+ /* BFCache restore not yet considered for first paint. See web-vitals onFCP for example. */
43
+ };
@@ -0,0 +1 @@
1
+ export { Instrument as PageViewTiming } from './instrument/index';
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { handle } from '../../../common/event-emitter/handle';
6
+ import { getRuntime } from '../../../common/config/config';
7
+ import { subscribeToVisibilityChange } from '../../../common/window/page-visibility';
8
+ import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts';
9
+ import { now } from '../../../common/timing/now';
10
+ import { InstrumentBase } from '../../utils/instrument-base';
11
+ import { FEATURE_NAME } from '../constants';
12
+ import { isBrowserScope } from '../../../common/util/global-scope';
13
+ export class Instrument extends InstrumentBase {
14
+ static featureName = FEATURE_NAME;
15
+ constructor(agentIdentifier, aggregator) {
16
+ let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
17
+ super(agentIdentifier, aggregator, FEATURE_NAME, auto);
18
+ if (!isBrowserScope) return; // CWV is irrelevant outside web context
19
+
20
+ // Document visibility state becomes hidden; this should run as soon as possible in page life.
21
+ // While we try to replicate web-vital's visibilitywatcher logic in an effort to defer that library to post-pageload, this isn't perfect and doesn't consider prerendering.
22
+ getRuntime(agentIdentifier).initHidden = Boolean(document.visibilityState === 'hidden');
23
+ subscribeToVisibilityChange(() => handle('docHidden', [now()], undefined, FEATURE_NAME, this.ee), true);
24
+
25
+ // Window fires its pagehide event (typically on navigation--this occurrence is a *subset* of vis change); don't defer this unless it's guarantee it cannot happen before load(?)
26
+ windowAddEventListener('pagehide', () => handle('winPagehide', [now()], undefined, FEATURE_NAME, this.ee));
27
+ this.importAggregator();
28
+ }
29
+ }
@@ -0,0 +1,69 @@
1
+ import { subscribeToEOL } from '../../common/unload/eol';
2
+
3
+ /**
4
+ * Calls the `onReport` function for every entry reported by the PerformanceLongTaskTiming API.
5
+ * The reported value is a `DOMHighResTimeStamp`.
6
+ *
7
+ * The callback is always called when the page's visibility state changes to hidden.
8
+ * As a result, the `onReport` function might be called multiple times during the same page load.
9
+ *
10
+ * @param {Function} onReport - callback that accepts a `metric` object as the single parameter
11
+ */
12
+ export const onLongTask = onReport => {
13
+ const handleEntries = entries => {
14
+ entries.forEach(entry => {
15
+ const metric = {
16
+ name: 'LT',
17
+ value: entry.duration,
18
+ info: {
19
+ // this property deviates from CWV std interface but will hold the custom context to send to NRDB
20
+ ltFrame: entry.name,
21
+ // MDN: the browsing context or frame that can be attributed to the long task
22
+ ltStart: entry.startTime,
23
+ // MDN: a double representing the time (millisec) when the task started
24
+ ltCtr: entry.attribution[0].containerType // MDN: type of frame container: 'iframe', 'embed', or 'object' ... but this can also be 'window'
25
+ }
26
+ };
27
+
28
+ if (metric.info.ltCtr !== 'window') {
29
+ // the following properties are only of relevance & appended for html elements
30
+ Object.assign(metric.info, {
31
+ ltCtrSrc: entry.attribution[0].containerSrc,
32
+ // MDN: container's 'src' attribute
33
+ ltCtrId: entry.attribution[0].containerId,
34
+ // MDN: container's 'id' attribute
35
+ ltCtrName: entry.attribution[0].containerName // MDN: container's 'name' attribute
36
+ });
37
+ }
38
+
39
+ onReport(metric); // report every long task observed unconditionally
40
+ });
41
+ };
42
+
43
+ let observer;
44
+ try {
45
+ if (PerformanceObserver.supportedEntryTypes.includes('longtask')) {
46
+ observer = new PerformanceObserver(list => {
47
+ // Delay by a microtask to workaround a bug in Safari where the
48
+ // callback is invoked immediately, rather than in a separate task.
49
+ // See: https://github.com/GoogleChrome/web-vitals/issues/277
50
+ Promise.resolve().then(() => {
51
+ handleEntries(list.getEntries());
52
+ });
53
+ });
54
+ observer.observe({
55
+ type: 'longtask',
56
+ buffered: true
57
+ });
58
+ }
59
+ } catch (e) {
60
+ // Do nothing.
61
+ }
62
+ if (observer) {
63
+ subscribeToEOL(() => {
64
+ handleEntries(observer.takeRecords());
65
+ }, true); // this bool is a temp arg under staged BFCache work that runs the func under the new page session logic -- tb removed w/ the feature flag later
66
+
67
+ /* No work needed on BFCache restore for long task. */
68
+ }
69
+ };