@newrelic/browser-agent 0.1.230 → 1.232.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/README.md +27 -3
  2. package/dist/cjs/common/browser-version/ios-version.js +4 -3
  3. package/dist/cjs/common/config/state/configurable.js +27 -21
  4. package/dist/cjs/common/config/state/info.js +1 -1
  5. package/dist/cjs/common/config/state/init.js +9 -1
  6. package/dist/cjs/common/config/state/loader-config.js +1 -1
  7. package/dist/cjs/common/config/state/runtime.js +26 -28
  8. package/dist/cjs/common/constants/env.cdn.js +29 -0
  9. package/dist/cjs/common/constants/env.js +32 -0
  10. package/dist/cjs/common/constants/env.npm.js +30 -0
  11. package/dist/cjs/common/context/shared-context.js +2 -1
  12. package/dist/cjs/common/event-emitter/contextual-ee.test.js +282 -0
  13. package/dist/cjs/common/event-emitter/handle.test.js +58 -0
  14. package/dist/cjs/common/event-emitter/register-handler.test.js +55 -0
  15. package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
  16. package/dist/cjs/common/harvest/harvest-scheduler.js +14 -11
  17. package/dist/cjs/common/harvest/harvest.js +5 -3
  18. package/dist/cjs/common/ids/id.js +14 -6
  19. package/dist/cjs/common/ids/id.test.js +85 -0
  20. package/dist/cjs/common/ids/unique-id.js +75 -51
  21. package/dist/cjs/common/ids/unique-id.test.js +49 -0
  22. package/dist/cjs/common/session/constants.js +12 -0
  23. package/dist/cjs/common/session/session-entity.js +278 -0
  24. package/dist/cjs/common/session/session-entity.test.js +436 -0
  25. package/dist/cjs/common/storage/first-party-cookies.js +35 -0
  26. package/dist/cjs/common/storage/local-memory.js +35 -0
  27. package/dist/cjs/common/storage/local-memory.test.js +20 -0
  28. package/dist/cjs/common/storage/local-storage.js +33 -0
  29. package/dist/cjs/common/storage/local-storage.test.js +14 -0
  30. package/dist/cjs/common/timer/interaction-timer.js +78 -0
  31. package/dist/cjs/common/timer/interaction-timer.test.js +216 -0
  32. package/dist/cjs/common/timer/timer.js +32 -0
  33. package/dist/cjs/common/timer/timer.test.js +105 -0
  34. package/dist/cjs/common/timing/nav-timing.js +51 -30
  35. package/dist/cjs/common/timing/nav-timing.test.js +192 -0
  36. package/dist/cjs/common/unload/eol.js +2 -2
  37. package/dist/cjs/common/url/clean-url.test.js +9 -0
  38. package/dist/cjs/common/url/encode.test.js +74 -0
  39. package/dist/cjs/common/url/location.js +4 -0
  40. package/dist/cjs/common/url/location.test.js +13 -0
  41. package/dist/cjs/common/url/parse-url.test.js +111 -0
  42. package/dist/cjs/common/url/protocol.js +2 -12
  43. package/dist/cjs/common/url/protocol.test.js +16 -0
  44. package/dist/cjs/common/util/console.js +1 -1
  45. package/dist/cjs/common/util/data-size.js +6 -0
  46. package/dist/cjs/common/util/data-size.test.js +47 -0
  47. package/dist/cjs/common/util/invoke.js +73 -0
  48. package/dist/cjs/common/util/invoke.test.js +49 -0
  49. package/dist/cjs/common/util/map-own.test.js +3 -3
  50. package/dist/cjs/common/util/obfuscate.js +1 -5
  51. package/dist/cjs/common/window/page-visibility.js +5 -2
  52. package/dist/cjs/common/wrap/index.js +0 -7
  53. package/dist/cjs/common/wrap/wrap-events.js +6 -9
  54. package/dist/cjs/common/wrap/wrap-fetch.js +6 -6
  55. package/dist/cjs/common/wrap/wrap-history.js +7 -6
  56. package/dist/cjs/common/wrap/wrap-jsonp.js +7 -6
  57. package/dist/cjs/common/wrap/wrap-mutation.js +7 -6
  58. package/dist/cjs/common/wrap/wrap-promise.js +7 -6
  59. package/dist/cjs/common/wrap/wrap-promise.test.js +119 -0
  60. package/dist/cjs/common/wrap/wrap-raf.js +6 -6
  61. package/dist/cjs/common/wrap/wrap-timer.js +7 -7
  62. package/dist/cjs/common/wrap/wrap-xhr.js +5 -6
  63. package/dist/cjs/features/ajax/aggregate/index.js +3 -3
  64. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
  65. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
  66. package/dist/cjs/features/jserrors/aggregate/index.js +6 -6
  67. package/dist/cjs/features/jserrors/instrument/index.js +2 -2
  68. package/dist/cjs/features/metrics/aggregate/index.js +19 -9
  69. package/dist/cjs/features/metrics/instrument/index.js +0 -25
  70. package/dist/cjs/features/metrics/instrument/workers-helper.js +5 -5
  71. package/dist/cjs/features/page_action/aggregate/index.js +3 -3
  72. package/dist/cjs/features/page_view_event/aggregate/index.js +23 -9
  73. package/dist/cjs/features/page_view_timing/aggregate/index.js +40 -30
  74. package/dist/cjs/features/session_trace/aggregate/index.js +18 -15
  75. package/dist/cjs/features/spa/aggregate/index.js +6 -5
  76. package/dist/cjs/features/utils/agent-session.js +73 -0
  77. package/dist/cjs/features/utils/feature-base.js +1 -1
  78. package/dist/cjs/features/utils/instrument-base.js +12 -3
  79. package/dist/cjs/features/utils/lazy-loader.js +2 -2
  80. package/dist/cjs/loaders/agent.js +2 -2
  81. package/dist/cjs/loaders/api/api.js +9 -9
  82. package/dist/cjs/loaders/api/apiAsync.js +3 -2
  83. package/dist/cjs/loaders/configure/configure.js +0 -6
  84. package/dist/cjs/loaders/features/enabled-features.js +1 -1
  85. package/dist/cjs/loaders/micro-agent.js +2 -1
  86. package/dist/esm/common/browser-version/ios-version.js +4 -3
  87. package/dist/esm/common/config/state/configurable.js +26 -20
  88. package/dist/esm/common/config/state/info.js +1 -1
  89. package/dist/esm/common/config/state/init.js +9 -1
  90. package/dist/esm/common/config/state/loader-config.js +1 -1
  91. package/dist/esm/common/config/state/runtime.js +26 -28
  92. package/dist/esm/common/constants/env.cdn.js +20 -0
  93. package/dist/esm/common/constants/env.js +23 -0
  94. package/dist/esm/common/constants/env.npm.js +21 -0
  95. package/dist/esm/common/context/shared-context.js +2 -1
  96. package/dist/esm/common/event-emitter/contextual-ee.test.js +278 -0
  97. package/dist/esm/common/event-emitter/handle.test.js +54 -0
  98. package/dist/esm/common/event-emitter/register-handler.test.js +51 -0
  99. package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
  100. package/dist/esm/common/harvest/harvest-scheduler.js +14 -11
  101. package/dist/esm/common/harvest/harvest.js +4 -2
  102. package/dist/esm/common/ids/id.js +16 -6
  103. package/dist/esm/common/ids/id.test.js +81 -0
  104. package/dist/esm/common/ids/unique-id.js +75 -51
  105. package/dist/esm/common/ids/unique-id.test.js +44 -0
  106. package/dist/esm/common/session/constants.js +3 -0
  107. package/dist/esm/common/session/session-entity.js +271 -0
  108. package/dist/esm/common/session/session-entity.test.js +434 -0
  109. package/dist/esm/common/storage/first-party-cookies.js +28 -0
  110. package/dist/esm/common/storage/local-memory.js +28 -0
  111. package/dist/esm/common/storage/local-memory.test.js +18 -0
  112. package/dist/esm/common/storage/local-storage.js +26 -0
  113. package/dist/esm/common/storage/local-storage.test.js +12 -0
  114. package/dist/esm/common/timer/interaction-timer.js +71 -0
  115. package/dist/esm/common/timer/interaction-timer.test.js +214 -0
  116. package/dist/esm/common/timer/timer.js +25 -0
  117. package/dist/esm/common/timer/timer.test.js +103 -0
  118. package/dist/esm/common/timing/nav-timing.js +51 -29
  119. package/dist/esm/common/timing/nav-timing.test.js +190 -0
  120. package/dist/esm/common/unload/eol.js +1 -1
  121. package/dist/esm/common/url/clean-url.test.js +7 -0
  122. package/dist/esm/common/url/encode.test.js +70 -0
  123. package/dist/esm/common/url/location.js +4 -0
  124. package/dist/esm/common/url/location.test.js +11 -0
  125. package/dist/esm/common/url/parse-url.test.js +107 -0
  126. package/dist/esm/common/url/protocol.js +3 -12
  127. package/dist/esm/common/url/protocol.test.js +14 -0
  128. package/dist/esm/common/util/console.js +1 -1
  129. package/dist/esm/common/util/data-size.js +7 -0
  130. package/dist/esm/common/util/data-size.test.js +45 -0
  131. package/dist/esm/common/util/invoke.js +66 -0
  132. package/dist/esm/common/util/invoke.test.js +47 -0
  133. package/dist/esm/common/util/map-own.test.js +3 -3
  134. package/dist/esm/common/util/obfuscate.js +2 -6
  135. package/dist/esm/common/window/page-visibility.js +5 -2
  136. package/dist/esm/common/wrap/index.js +1 -2
  137. package/dist/esm/common/wrap/wrap-events.js +6 -9
  138. package/dist/esm/common/wrap/wrap-fetch.js +6 -6
  139. package/dist/esm/common/wrap/wrap-history.js +7 -6
  140. package/dist/esm/common/wrap/wrap-jsonp.js +7 -6
  141. package/dist/esm/common/wrap/wrap-mutation.js +7 -6
  142. package/dist/esm/common/wrap/wrap-promise.js +7 -6
  143. package/dist/esm/common/wrap/wrap-promise.test.js +115 -0
  144. package/dist/esm/common/wrap/wrap-raf.js +6 -6
  145. package/dist/esm/common/wrap/wrap-timer.js +7 -7
  146. package/dist/esm/common/wrap/wrap-xhr.js +5 -6
  147. package/dist/esm/features/ajax/aggregate/index.js +3 -3
  148. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +5 -5
  149. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +1 -1
  150. package/dist/esm/features/jserrors/aggregate/index.js +6 -6
  151. package/dist/esm/features/jserrors/instrument/index.js +2 -2
  152. package/dist/esm/features/metrics/aggregate/index.js +21 -11
  153. package/dist/esm/features/metrics/instrument/index.js +0 -25
  154. package/dist/esm/features/metrics/instrument/workers-helper.js +5 -5
  155. package/dist/esm/features/page_action/aggregate/index.js +3 -3
  156. package/dist/esm/features/page_view_event/aggregate/index.js +23 -9
  157. package/dist/esm/features/page_view_timing/aggregate/index.js +40 -30
  158. package/dist/esm/features/session_trace/aggregate/index.js +18 -15
  159. package/dist/esm/features/spa/aggregate/index.js +6 -5
  160. package/dist/esm/features/utils/agent-session.js +67 -0
  161. package/dist/esm/features/utils/feature-base.js +1 -1
  162. package/dist/esm/features/utils/instrument-base.js +7 -2
  163. package/dist/esm/features/utils/lazy-loader.js +2 -2
  164. package/dist/esm/loaders/agent.js +2 -2
  165. package/dist/esm/loaders/api/api.js +6 -9
  166. package/dist/esm/loaders/api/apiAsync.js +2 -1
  167. package/dist/esm/loaders/configure/configure.js +2 -8
  168. package/dist/esm/loaders/features/enabled-features.js +1 -1
  169. package/dist/types/common/config/state/configurable.d.ts.map +1 -1
  170. package/dist/types/common/config/state/init.d.ts.map +1 -1
  171. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  172. package/dist/types/common/constants/env.cdn.d.ts +18 -0
  173. package/dist/types/common/constants/env.cdn.d.ts.map +1 -0
  174. package/dist/types/common/constants/env.d.ts +13 -0
  175. package/dist/types/common/constants/env.d.ts.map +1 -0
  176. package/dist/types/common/constants/env.npm.d.ts +19 -0
  177. package/dist/types/common/constants/env.npm.d.ts.map +1 -0
  178. package/dist/types/common/context/shared-context.d.ts.map +1 -1
  179. package/dist/types/common/event-listener/event-listener-opts.d.ts +2 -2
  180. package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -1
  181. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -0
  182. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  183. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  184. package/dist/types/common/ids/id.d.ts +11 -1
  185. package/dist/types/common/ids/id.d.ts.map +1 -1
  186. package/dist/types/common/ids/unique-id.d.ts +24 -1
  187. package/dist/types/common/ids/unique-id.d.ts.map +1 -1
  188. package/dist/types/common/session/constants.d.ts +4 -0
  189. package/dist/types/common/session/constants.d.ts.map +1 -0
  190. package/dist/types/common/session/session-entity.d.ts +72 -0
  191. package/dist/types/common/session/session-entity.d.ts.map +1 -0
  192. package/dist/types/common/storage/first-party-cookies.d.ts +8 -0
  193. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -0
  194. package/dist/types/common/storage/local-memory.d.ts +8 -0
  195. package/dist/types/common/storage/local-memory.d.ts.map +1 -0
  196. package/dist/types/common/storage/local-storage.d.ts +6 -0
  197. package/dist/types/common/storage/local-storage.d.ts.map +1 -0
  198. package/dist/types/common/timer/interaction-timer.d.ts +11 -0
  199. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -0
  200. package/dist/types/common/timer/timer.d.ts +12 -0
  201. package/dist/types/common/timer/timer.d.ts.map +1 -0
  202. package/dist/types/common/timing/nav-timing.d.ts +1 -2
  203. package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
  204. package/dist/types/common/unload/eol.d.ts.map +1 -1
  205. package/dist/types/common/url/location.d.ts +4 -0
  206. package/dist/types/common/url/location.d.ts.map +1 -1
  207. package/dist/types/common/url/parse-url.d.ts.map +1 -1
  208. package/dist/types/common/url/protocol.d.ts +1 -6
  209. package/dist/types/common/url/protocol.d.ts.map +1 -1
  210. package/dist/types/common/util/data-size.d.ts +7 -1
  211. package/dist/types/common/util/data-size.d.ts.map +1 -1
  212. package/dist/types/common/util/global-scope.d.ts.map +1 -1
  213. package/dist/types/common/util/invoke.d.ts +35 -0
  214. package/dist/types/common/util/invoke.d.ts.map +1 -0
  215. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  216. package/dist/types/common/window/page-visibility.d.ts +1 -1
  217. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  218. package/dist/types/common/wrap/index.d.ts +1 -2
  219. package/dist/types/common/wrap/index.d.ts.map +1 -1
  220. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  221. package/dist/types/common/wrap/wrap-history.d.ts.map +1 -1
  222. package/dist/types/common/wrap/wrap-jsonp.d.ts.map +1 -1
  223. package/dist/types/common/wrap/wrap-mutation.d.ts.map +1 -1
  224. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
  225. package/dist/types/common/wrap/wrap-raf.d.ts.map +1 -1
  226. package/dist/types/common/wrap/wrap-timer.d.ts.map +1 -1
  227. package/dist/types/common/wrap/wrap-xhr.d.ts.map +1 -1
  228. package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
  229. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  230. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  231. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  232. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  233. package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
  234. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  235. package/dist/types/features/metrics/instrument/index.d.ts +0 -1
  236. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  237. package/dist/types/features/metrics/instrument/workers-helper.d.ts.map +1 -1
  238. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  239. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  240. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
  241. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  242. package/dist/types/features/page_view_timing/aggregate/index.d.ts +3 -4
  243. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  244. package/dist/types/features/session_trace/aggregate/index.d.ts +3 -3
  245. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  246. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  247. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  248. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  249. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  250. package/dist/types/features/utils/agent-session.d.ts +2 -0
  251. package/dist/types/features/utils/agent-session.d.ts.map +1 -0
  252. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  253. package/dist/types/features/utils/lazy-loader.d.ts +2 -2
  254. package/dist/types/features/utils/lazy-loader.d.ts.map +1 -1
  255. package/dist/types/loaders/api/api.d.ts.map +1 -1
  256. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  257. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  258. package/package.json +12 -32
  259. package/src/common/browser-version/ios-version.js +4 -3
  260. package/src/common/config/state/configurable.js +26 -19
  261. package/src/common/config/state/init.js +7 -0
  262. package/src/common/config/state/runtime.js +7 -10
  263. package/src/common/constants/env.cdn.js +20 -0
  264. package/src/common/constants/env.js +23 -0
  265. package/src/common/constants/env.npm.js +21 -0
  266. package/src/common/context/shared-context.js +2 -1
  267. package/src/common/event-emitter/contextual-ee.test.js +310 -0
  268. package/src/common/event-emitter/handle.test.js +56 -0
  269. package/src/common/event-emitter/register-handler.test.js +61 -0
  270. package/src/common/event-listener/event-listener-opts.js +4 -4
  271. package/src/common/harvest/harvest-scheduler.js +12 -8
  272. package/src/common/harvest/harvest.js +5 -3
  273. package/src/common/ids/id.js +15 -6
  274. package/src/common/ids/id.test.js +92 -0
  275. package/src/common/ids/unique-id.js +77 -54
  276. package/src/common/ids/unique-id.test.js +58 -0
  277. package/src/common/session/constants.js +3 -0
  278. package/src/common/session/session-entity.js +271 -0
  279. package/src/common/session/session-entity.test.js +317 -0
  280. package/src/common/storage/first-party-cookies.js +31 -0
  281. package/src/common/storage/local-memory.js +30 -0
  282. package/src/common/storage/local-memory.test.js +19 -0
  283. package/src/common/storage/local-storage.js +28 -0
  284. package/src/common/storage/local-storage.test.js +17 -0
  285. package/src/common/timer/interaction-timer.js +75 -0
  286. package/src/common/timer/interaction-timer.test.js +167 -0
  287. package/src/common/timer/timer.js +31 -0
  288. package/src/common/timer/timer.test.js +100 -0
  289. package/src/common/timing/nav-timing.js +50 -30
  290. package/src/common/timing/nav-timing.test.js +161 -0
  291. package/src/common/unload/eol.js +2 -3
  292. package/src/common/url/clean-url.test.js +25 -0
  293. package/src/common/url/encode.test.js +80 -0
  294. package/src/common/url/location.js +4 -0
  295. package/src/common/url/location.test.js +15 -0
  296. package/src/common/url/parse-url.js +1 -2
  297. package/src/common/url/parse-url.test.js +110 -0
  298. package/src/common/url/protocol.js +3 -13
  299. package/src/common/url/protocol.test.js +18 -0
  300. package/src/common/util/data-size.js +6 -0
  301. package/src/common/util/data-size.test.js +50 -0
  302. package/src/common/util/global-scope.js +1 -2
  303. package/src/common/util/invoke.js +55 -0
  304. package/src/common/util/invoke.test.js +65 -0
  305. package/src/common/util/obfuscate.js +2 -6
  306. package/src/common/window/page-visibility.js +3 -3
  307. package/src/common/wrap/index.js +1 -2
  308. package/src/common/wrap/wrap-events.js +5 -5
  309. package/src/common/wrap/wrap-fetch.js +4 -3
  310. package/src/common/wrap/wrap-history.js +6 -3
  311. package/src/common/wrap/wrap-jsonp.js +5 -3
  312. package/src/common/wrap/wrap-mutation.js +6 -3
  313. package/src/common/wrap/wrap-promise.js +7 -6
  314. package/src/common/wrap/wrap-promise.test.js +140 -0
  315. package/src/common/wrap/wrap-raf.js +5 -3
  316. package/src/common/wrap/wrap-timer.js +6 -4
  317. package/src/common/wrap/wrap-xhr.js +4 -3
  318. package/src/features/ajax/aggregate/index.js +2 -2
  319. package/src/features/ajax/instrument/index.js +1 -1
  320. package/src/features/jserrors/aggregate/index.js +3 -3
  321. package/src/features/jserrors/instrument/index.js +4 -2
  322. package/src/features/metrics/aggregate/index.js +21 -7
  323. package/src/features/metrics/instrument/index.js +0 -30
  324. package/src/features/metrics/instrument/workers-helper.js +9 -6
  325. package/src/features/page_action/aggregate/index.js +2 -2
  326. package/src/features/page_view_event/aggregate/index.js +21 -9
  327. package/src/features/page_view_timing/aggregate/index.js +40 -29
  328. package/src/features/page_view_timing/long-tasks.js +10 -10
  329. package/src/features/session_trace/aggregate/index.js +17 -14
  330. package/src/features/session_trace/instrument/index.js +3 -2
  331. package/src/features/spa/aggregate/index.js +5 -5
  332. package/src/features/spa/instrument/index.js +4 -2
  333. package/src/features/utils/agent-session.js +68 -0
  334. package/src/features/utils/feature-base.js +1 -1
  335. package/src/features/utils/instrument-base.js +5 -2
  336. package/src/features/utils/lazy-loader.js +1 -1
  337. package/src/loaders/agent.js +1 -1
  338. package/src/loaders/api/api.js +3 -6
  339. package/src/loaders/api/apiAsync.js +2 -1
  340. package/src/loaders/configure/configure.js +2 -7
  341. package/dist/cjs/common/constants/environment-variables.js +0 -20
  342. package/dist/cjs/common/util/single.js +0 -23
  343. package/dist/cjs/common/window/session-storage.js +0 -87
  344. package/dist/cjs/common/wrap/wrap-console.js +0 -54
  345. package/dist/cjs/features/utils/aggregate-base.js +0 -13
  346. package/dist/esm/common/constants/environment-variables.js +0 -11
  347. package/dist/esm/common/util/single.js +0 -16
  348. package/dist/esm/common/window/session-storage.js +0 -77
  349. package/dist/esm/common/wrap/wrap-console.js +0 -46
  350. package/dist/esm/features/utils/aggregate-base.js +0 -6
  351. package/dist/types/common/constants/environment-variables.d.ts +0 -4
  352. package/dist/types/common/constants/environment-variables.d.ts.map +0 -1
  353. package/dist/types/common/util/single.d.ts +0 -2
  354. package/dist/types/common/util/single.d.ts.map +0 -1
  355. package/dist/types/common/window/session-storage.d.ts +0 -18
  356. package/dist/types/common/window/session-storage.d.ts.map +0 -1
  357. package/dist/types/common/wrap/wrap-console.d.ts +0 -16
  358. package/dist/types/common/wrap/wrap-console.d.ts.map +0 -1
  359. package/dist/types/features/utils/aggregate-base.d.ts +0 -4
  360. package/dist/types/features/utils/aggregate-base.d.ts.map +0 -1
  361. package/src/common/constants/environment-variables.js +0 -11
  362. package/src/common/util/single.js +0 -18
  363. package/src/common/window/session-storage.js +0 -75
  364. package/src/common/wrap/wrap-console.js +0 -47
  365. package/src/features/utils/aggregate-base.js +0 -7
@@ -7,17 +7,18 @@ exports.Aggregate = void 0;
7
7
  var _config = require("../../../common/config/config");
8
8
  var _registerHandler = require("../../../common/event-emitter/register-handler");
9
9
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
10
- var _aggregateBase = require("../../utils/aggregate-base");
11
10
  var _constants = require("../constants");
12
11
  var _drain = require("../../../common/drain/drain");
13
12
  var _frameworkDetection = require("../../../common/metrics/framework-detection");
14
13
  var _protocol = require("../../../common/url/protocol");
15
14
  var _obfuscate = require("../../../common/util/obfuscate");
16
- var _environmentVariables = require("../../../common/constants/environment-variables");
15
+ var _env = require("../../../common/constants/env.npm");
17
16
  var _load = require("../../../common/window/load");
18
17
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
19
18
  var _globalScope = require("../../../common/util/global-scope");
20
- class Aggregate extends _aggregateBase.AggregateBase {
19
+ var _featureBase = require("../../utils/feature-base");
20
+ var _stringify = require("../../../common/util/stringify");
21
+ class Aggregate extends _featureBase.FeatureBase {
21
22
  static featureName = _constants.FEATURE_NAME;
22
23
  constructor(agentIdentifier, aggregator) {
23
24
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
@@ -64,14 +65,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
64
65
  singleChecks() {
65
66
  // report generic info about the agent itself
66
67
  // note the browser agent version
67
- this.storeSupportabilityMetrics(`Generic/Version/${_environmentVariables.VERSION}/Detected`);
68
+ this.storeSupportabilityMetrics("Generic/Version/".concat(_env.VERSION, "/Detected"));
68
69
  // report loaderType
69
70
  const {
70
71
  distMethod,
71
72
  loaderType
72
73
  } = (0, _config.getRuntime)(this.agentIdentifier);
73
- if (loaderType) this.storeSupportabilityMetrics(`Generic/LoaderType/${loaderType}/Detected`);
74
- if (distMethod) this.storeSupportabilityMetrics(`Generic/DistMethod/${distMethod}/Detected`);
74
+ if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
75
+ if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
75
76
 
76
77
  // frameworks on page
77
78
  if (_globalScope.isBrowserScope) {
@@ -83,9 +84,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
83
84
  }
84
85
 
85
86
  // file protocol detection
86
- if (_protocol.protocol.isFileProtocol()) {
87
+ if ((0, _protocol.isFileProtocol)()) {
87
88
  this.storeSupportabilityMetrics('Generic/FileProtocol/Detected');
88
- _protocol.protocol.supportabilityMetricSent = true;
89
89
  }
90
90
 
91
91
  // obfuscation rules detection
@@ -110,6 +110,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
110
110
  try {
111
111
  if (this.resourcesSent) return;
112
112
  const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
113
+ const info = (0, _config.getInfo)(this.agentIdentifier);
113
114
  // make sure this only gets sent once
114
115
  this.resourcesSent = true;
115
116
  // differentiate between internal+external and ajax+non-ajax
@@ -132,13 +133,22 @@ class Aggregate extends _aggregateBase.AggregateBase {
132
133
 
133
134
  // Capture per-agent bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
134
135
  Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
135
- this.storeSupportabilityMetrics(`PageSession/Endpoint/${endpoint.charAt(0).toUpperCase() + endpoint.slice(1)}/BytesSent`, agentRuntime.bytesSent[endpoint]);
136
+ this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/BytesSent"), agentRuntime.bytesSent[endpoint]);
137
+ });
138
+
139
+ // Capture per-agent query bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
140
+ Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
141
+ this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/QueryBytesSent"), agentRuntime.queryBytesSent[endpoint]);
136
142
  });
137
143
 
138
144
  // Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
139
145
  if (agentRuntime.ptid) {
140
146
  this.storeSupportabilityMetrics('PageSession/Feature/SessionTrace/DurationMs', Math.round(performance.now()));
141
147
  }
148
+
149
+ // Capture metrics for size of custom attributes
150
+ const jsAttributes = (0, _stringify.stringify)(info.jsAttributes);
151
+ this.storeSupportabilityMetrics('PageSession/Feature/CustomData/Bytes', jsAttributes === '{}' ? 0 : jsAttributes.length);
142
152
  } catch (e) {
143
153
  // do nothing
144
154
  }
@@ -9,38 +9,13 @@ var _workersHelper = require("./workers-helper");
9
9
  var _constants = require("../constants");
10
10
  var _handle = require("../../../common/event-emitter/handle");
11
11
  var _features = require("../../../loaders/features/features");
12
- var _wrap = require("../../../common/wrap");
13
- var _stringify = require("../../../common/util/stringify");
14
12
  class Instrument extends _instrumentBase.InstrumentBase {
15
13
  static featureName = _constants.FEATURE_NAME;
16
14
  constructor(agentIdentifier, aggregator) {
17
15
  let auto = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
18
16
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
19
17
  (0, _workersHelper.insertSupportMetrics)(tag => (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, [tag], undefined, _features.FEATURE_NAMES.metrics, this.ee));
20
- this.addConsoleSupportabilityMetrics();
21
18
  this.importAggregator();
22
19
  }
23
- addConsoleSupportabilityMetrics() {
24
- // For now we are just capturing supportability metrics on `console` usage to assess log forwarding feature.
25
- const consoleEE = (0, _wrap.wrapConsole)(this.ee);
26
- for (const method of ['Debug', 'Error', 'Info', 'Log', 'Trace', 'Warn']) {
27
- consoleEE.on(`${method.toLowerCase()}-console-start`, function (args, target) {
28
- // Parsing the args individually into a new array ensures that functions and Error objects are represented with
29
- // useful string values. By default, functions stringify to null and Error objects stringify to empty objects.
30
- // Note that stack traces printed by the console.trace method are not captured.
31
- let parsedArgs = [];
32
- for (const arg of args) {
33
- if (typeof arg === 'function' || arg && arg.message && arg.stack // Duck typing for Error objects
34
- ) {
35
- parsedArgs.push(arg.toString());
36
- } else {
37
- parsedArgs.push(arg);
38
- }
39
- }
40
- const parsedArgsJSON = (0, _stringify.stringify)(parsedArgs);
41
- (0, _handle.handle)(_constants.SUPPORTABILITY_METRIC_CHANNEL, [`Console/${method}/Seen`, parsedArgsJSON.length], undefined, _features.FEATURE_NAMES.metrics, consoleEE);
42
- });
43
- }
44
- }
45
20
  }
46
21
  exports.Instrument = Instrument;
@@ -107,18 +107,18 @@ function insertSupportMetrics(report) {
107
107
  function reportUnavailable(workerType) {
108
108
  if (_globalScope.isWorkerScope) return; // assume that the main browser window has already reported unsupported worker APIs (once per page life);
109
109
  // on top of that, not all workers are available inside a certain worker per se--e.g. no sharedWorker() inside Worker
110
- report(`Workers/${workerType}/Unavailable`);
110
+ report("Workers/".concat(workerType, "/Unavailable"));
111
111
  }
112
112
  function reportWorkerCreationAttempt(workerType, optionType) {
113
113
  if (optionType === 'module') {
114
- report(`Workers/${workerType}/Module`);
114
+ report("Workers/".concat(workerType, "/Module"));
115
115
  } else {
116
- report(`Workers/${workerType}/Classic`);
116
+ report("Workers/".concat(workerType, "/Classic"));
117
117
  }
118
118
  }
119
119
  function handleInsertionError(e, workerType) {
120
120
  // indicates the browser version doesn't support how code is injected, such as Proxy API
121
- report(`Workers/${workerType}/SM/Unsupported`); // expected to be niche & for older borderline-ES6 browser versions
122
- (0, _console.warn)(`NR Agent: Unable to capture ${workerType} workers.`, e);
121
+ report("Workers/".concat(workerType, "/SM/Unsupported")); // expected to be niche & for older borderline-ES6 browser versions
122
+ (0, _console.warn)("NR Agent: Unable to capture ".concat(workerType, " workers."), e);
123
123
  }
124
124
  }
@@ -10,16 +10,16 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
10
10
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
11
11
  var _cleanUrl = require("../../../common/url/clean-url");
12
12
  var _config = require("../../../common/config/config");
13
- var _aggregateBase = require("../../utils/aggregate-base");
14
13
  var _constants = require("../constants");
15
14
  var _drain = require("../../../common/drain/drain");
16
15
  var _globalScope = require("../../../common/util/global-scope");
16
+ var _featureBase = require("../../utils/feature-base");
17
17
  /*
18
18
  * Copyright 2020 New Relic Corporation. All rights reserved.
19
19
  * SPDX-License-Identifier: Apache-2.0
20
20
  */
21
21
 
22
- class Aggregate extends _aggregateBase.AggregateBase {
22
+ class Aggregate extends _featureBase.FeatureBase {
23
23
  static featureName = _constants.FEATURE_NAME;
24
24
  constructor(agentIdentifier, aggregator) {
25
25
  var _this;
@@ -45,7 +45,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
45
45
  scheduler.harvest.on('ins', function () {
46
46
  return _this.onHarvestStarted(...arguments);
47
47
  });
48
- this.ee.on(`drain-${this.featureName}`, () => {
48
+ this.ee.on("drain-".concat(this.featureName), () => {
49
49
  if (!this.blocked) scheduler.startTimer(this.harvestTimeSeconds, 0);
50
50
  });
51
51
 
@@ -16,15 +16,15 @@ var _paintMetrics = require("../../../common/metrics/paint-metrics");
16
16
  var _submitData = require("../../../common/util/submit-data");
17
17
  var _config = require("../../../common/config/config");
18
18
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
19
- var _aggregateBase = require("../../utils/aggregate-base");
20
19
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
21
20
  var _initializedFeatures = require("./initialized-features");
22
21
  var _globalScope = require("../../../common/util/global-scope");
23
22
  var _drain = require("../../../common/drain/drain");
23
+ var _featureBase = require("../../utils/feature-base");
24
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
26
  const jsonp = 'NREUM.setToken';
27
- class Aggregate extends _aggregateBase.AggregateBase {
27
+ class Aggregate extends _featureBase.FeatureBase {
28
28
  static featureName = CONSTANTS.FEATURE_NAME;
29
29
  constructor(agentIdentifier, aggregator) {
30
30
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
@@ -99,12 +99,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
99
99
  chunksForQueryString.push((0, _encode.param)('ac', info.account));
100
100
  chunksForQueryString.push((0, _encode.param)('pr', info.product));
101
101
  chunksForQueryString.push((0, _encode.param)('af', (0, _initializedFeatures.getActivatedFeaturesFlags)(this.agentIdentifier).join(',')));
102
- if (_globalScope.globalScope.performance && typeof _globalScope.globalScope.performance.timing !== 'undefined') {
103
- var navTimingApiData = {
104
- timing: (0, _navTiming.addPT)(agentRuntime.offset, _globalScope.globalScope.performance.timing, {}),
105
- navigation: (0, _navTiming.addPN)(_globalScope.globalScope.performance.navigation, {})
106
- };
107
- chunksForQueryString.push((0, _encode.param)('perf', (0, _stringify.stringify)(navTimingApiData)));
102
+ if (_globalScope.globalScope.performance) {
103
+ if (typeof PerformanceNavigationTiming !== 'undefined') {
104
+ // Navigation Timing level 2 API that replaced PerformanceTiming & PerformanceNavigation
105
+ const navTimingEntry = _globalScope.globalScope?.performance?.getEntriesByType('navigation')?.[0];
106
+ const perf = {
107
+ timing: (0, _navTiming.addPT)(agentRuntime.offset, navTimingEntry, {}),
108
+ navigation: (0, _navTiming.addPN)(navTimingEntry, {})
109
+ };
110
+ chunksForQueryString.push((0, _encode.param)('perf', (0, _stringify.stringify)(perf)));
111
+ } else if (typeof PerformanceTiming !== 'undefined') {
112
+ // Safari pre-15 did not support level 2 timing
113
+ const perf = {
114
+ timing: (0, _navTiming.addPT)(agentRuntime.offset, _globalScope.globalScope.performance.timing, {}, true),
115
+ navigation: (0, _navTiming.addPN)(_globalScope.globalScope.performance.navigation, {})
116
+ };
117
+ chunksForQueryString.push((0, _encode.param)('perf', (0, _stringify.stringify)(perf)));
118
+ }
108
119
  }
109
120
  try {
110
121
  // PVTiming sends these too, albeit using web-vitals and slightly different; it's unknown why they're duplicated, but PVT should be the truth
@@ -127,7 +138,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
127
138
  var queryString = (0, _encode.fromArray)(chunksForQueryString, agentRuntime.maxBytes);
128
139
 
129
140
  // Capture bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
130
- agentRuntime.bytesSent[protocol] = (agentRuntime.bytesSent[protocol] || 0) + queryString?.length || 0;
141
+ agentRuntime.bytesSent[protocol] = 0; // Set to zero for now until RUM is moved to POST
142
+
143
+ // Capture query bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
144
+ agentRuntime.queryBytesSent[protocol] = (agentRuntime.queryBytesSent[protocol] || 0) + queryString?.length || 0;
131
145
  const isValidJsonp = _submitData.submitData.jsonp(this.getScheme() + '://' + info.beacon + '/' + protocol + '/' + info.licenseKey + queryString, jsonp);
132
146
  // Usually `drain` is invoked automatically after processing feature flags contained in the JSONP callback from
133
147
  // ingest (see `activateFeatures`), so when JSONP cannot execute (as with module workers), we drain manually.
@@ -15,16 +15,16 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
15
15
  var _cleanUrl = require("../../../common/url/clean-url");
16
16
  var _handle = require("../../../common/event-emitter/handle");
17
17
  var _config = require("../../../common/config/config");
18
- var _aggregateBase = require("../../utils/aggregate-base");
19
18
  var _constants = require("../constants");
20
19
  var _drain = require("../../../common/drain/drain");
21
20
  var _features = require("../../../loaders/features/features");
21
+ var _featureBase = require("../../utils/feature-base");
22
22
  /*
23
23
  * Copyright 2020 New Relic Corporation. All rights reserved.
24
24
  * SPDX-License-Identifier: Apache-2.0
25
25
  */
26
26
 
27
- class Aggregate extends _aggregateBase.AggregateBase {
27
+ class Aggregate extends _featureBase.FeatureBase {
28
28
  static featureName = _constants.FEATURE_NAME;
29
29
  constructor(agentIdentifier, aggregator) {
30
30
  var _this;
@@ -33,13 +33,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
33
33
  this.timings = [];
34
34
  this.timingsSent = [];
35
35
  this.curSessEndRecorded = false;
36
- try {
37
- // we (only) need to track cls state because it's attached to other timing events rather than reported on change...
38
- this.clsSupported = PerformanceObserver.supportedEntryTypes.includes('layout-shift');
39
- this.cls = 0;
40
- } catch (e) {}
36
+ this.cls = null; // this should be null unless set to a numeric value by web-vitals so that we differentiate if CLS is supported
41
37
 
42
- /*! This is the section that used to be in the loader portion: !*/
38
+ /* ! This is the section that used to be in the loader portion: ! */
43
39
  /* ------------------------------------------------------------ */
44
40
  const pageStartedHidden = (0, _config.getRuntime)(agentIdentifier).initHidden; // our attempt at recapturing initial vis state since this code runs post-load time
45
41
  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
@@ -86,7 +82,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
86
82
  value,
87
83
  entries
88
84
  } = _ref3;
89
- if (pageStartedHidden || this.alreadySent.has(name)) return;
85
+ if (pageStartedHidden || this.alreadySent.has(name) || entries.length === 0) return;
90
86
  this.alreadySent.add(name);
91
87
 
92
88
  // 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.
@@ -108,29 +104,32 @@ class Aggregate extends _aggregateBase.AggregateBase {
108
104
  } = _ref4;
109
105
  if (pageStartedHidden || this.alreadySent.has(name)) return;
110
106
  this.alreadySent.add(name);
111
-
112
- // CWV will only ever report one (THE) lcp entry to us; lcp is also only reported *once* on earlier(user interaction, page hidden).
113
- 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...
114
- const attrs = {
115
- size: lcpEntry.size,
116
- eid: lcpEntry.id
117
- };
118
- this.addConnectionAttributes(attrs);
119
- if (lcpEntry.url) {
120
- attrs['elUrl'] = (0, _cleanUrl.cleanURL)(lcpEntry.url);
121
- }
122
- if (lcpEntry.element && lcpEntry.element.tagName) {
123
- attrs['elTag'] = lcpEntry.element.tagName;
107
+ const attributes = {};
108
+ if (entries.length > 0) {
109
+ // CWV will only ever report one (THE) lcp entry to us; lcp is also only reported *once* on earlier(user interaction, page hidden).
110
+ 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...
111
+ attributes.size = lcpEntry.size;
112
+ attributes.eid = lcpEntry.id;
113
+ if (lcpEntry.url) {
114
+ attributes.elUrl = (0, _cleanUrl.cleanURL)(lcpEntry.url);
115
+ }
116
+ if (lcpEntry.element?.tagName) {
117
+ attributes.elTag = lcpEntry.element.tagName;
118
+ }
124
119
  }
125
- this.addTiming(name.toLowerCase(), value, attrs);
120
+ this.addConnectionAttributes(attributes);
121
+ this.addTiming(name.toLowerCase(), value, attributes);
126
122
  });
127
123
 
128
- /* 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. */
124
+ /* 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.
125
+ reportAllChanges ensures our tracked cls has the most recent rolling value to attach to 'unload' and 'pagehide'. */
129
126
  (0, _webVitals.onCLS)(_ref5 => {
130
127
  let {
131
128
  value
132
129
  } = _ref5;
133
130
  return this.cls = value;
131
+ }, {
132
+ reportAllChanges: true
134
133
  });
135
134
 
136
135
  /* Interaction-to-Next-Paint */
@@ -174,7 +173,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
174
173
  const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
175
174
  const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
176
175
  // send initial data sooner, then start regular
177
- this.ee.on(`drain-${this.featureName}`, () => {
176
+ this.ee.on("drain-".concat(this.featureName), () => {
178
177
  this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
179
178
  });
180
179
  (0, _drain.drain)(this.agentIdentifier, this.featureName);
@@ -208,16 +207,27 @@ class Aggregate extends _aggregateBase.AggregateBase {
208
207
  */
209
208
  recordPageUnload(timestamp) {
210
209
  this.addTiming('unload', timestamp, null);
211
- // 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.
210
+ /*
211
+ Issue: Because window's pageHide commonly fires BEFORE vis change and "final" harvest would happen at the former in this case, we also have to add our vis-change event now or it may not be sent.
212
+ Affected: Safari < v14.1/.5 ; versions that don't support 'visiilitychange' event
213
+ Impact: For affected w/o this, NR 'pageHide' attribute may not be sent. For other browsers w/o this, NR 'pageHide' gets fragmented into its own harvest call on page unloading because of dual EoL logic.
214
+ Mitigation: NR 'unload' and 'pageHide' are both recorded when window pageHide fires, rather than only recording 'unload'.
215
+ Future: When EoL can become the singular subscribeToVisibilityChange, it's likely endCurrentSession isn't needed here as 'unload'-'pageHide' can be untangled.
216
+ */
212
217
  this.endCurrentSession(timestamp);
213
218
  }
214
219
  addTiming(name, value, attrs) {
215
220
  attrs = attrs || {};
216
221
 
217
- // If CLS is supported, a cls value should exist and be reported, even at 0.
218
- // *cli Mar'23 - At this time, it remains attached to all timings. See NEWRELIC-6143.
219
- if (this.clsSupported) {
220
- attrs['cls'] = this.cls;
222
+ // If cls was set to another value by `onCLS`, then it's supported and is attached onto any timing but is omitted until such time.
223
+ /*
224
+ *cli Apr'23 - Convert attach-to-all -> attach-if-not-null. See NEWRELIC-6143.
225
+ Issue: Because NR 'pageHide' was only sent once with what is considered the "final" CLS value, in the case that 'pageHide' fires before 'load' happens, we incorrectly a final CLS of 0 for that page.
226
+ Mitigation: We've set initial CLS to null so that it's omitted from timings like 'pageHide' in that edge case. It should only be included if onCLS callback was executed at least once.
227
+ Future: onCLS value changes should be reported directly & CLS separated into its own timing node so it's not beholden to 'pageHide' firing. It'd also be possible to report the real final CLS.
228
+ */
229
+ if (this.cls !== null) {
230
+ attrs.cls = this.cls;
221
231
  }
222
232
  this.timings.push({
223
233
  name: name,
@@ -13,23 +13,23 @@ var _supportsPerformanceObserver = require("../../../common/window/supports-perf
13
13
  var _lodash = _interopRequireDefault(require("lodash._slice"));
14
14
  var _config = require("../../../common/config/config");
15
15
  var _now = require("../../../common/timing/now");
16
- var _aggregateBase = require("../../utils/aggregate-base");
17
16
  var _constants = require("../constants");
18
17
  var _drain = require("../../../common/drain/drain");
19
18
  var _handlerCache = require("../../utils/handler-cache");
19
+ var _featureBase = require("../../utils/feature-base");
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
  /*
22
22
  * Copyright 2020 New Relic Corporation. All rights reserved.
23
23
  * SPDX-License-Identifier: Apache-2.0
24
24
  */
25
25
 
26
- class Aggregate extends _aggregateBase.AggregateBase {
26
+ class Aggregate extends _featureBase.FeatureBase {
27
27
  static featureName = _constants.FEATURE_NAME;
28
28
  constructor(agentIdentifier, aggregator) {
29
29
  var _this;
30
+ // Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
30
31
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
31
32
  _this = this;
32
- // Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
33
33
  if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
34
34
  const handlerCache = new _handlerCache.HandlerCache();
35
35
  this.ptid = '';
@@ -87,7 +87,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
87
87
  this.maxNodesPerHarvest = (0, _config.getConfigurationValue)(agentIdentifier, 'session_trace.maxNodesPerHarvest') || 1000;
88
88
  this.laststart = 0;
89
89
  (0, _registerHandler.registerHandler)('feat-stn', () => {
90
- this.storeTiming(window.performance.timing);
90
+ if (typeof PerformanceNavigationTiming !== 'undefined') {
91
+ this.storeTiming(window.performance?.getEntriesByType('navigation')?.[0] || {});
92
+ } else {
93
+ this.storeTiming(window.performance?.timing);
94
+ }
91
95
  var scheduler = new _harvestScheduler.HarvestScheduler('resources', {
92
96
  onFinished: onHarvestFinished.bind(this),
93
97
  retryDelay: this.harvestTimeSeconds
@@ -183,26 +187,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
183
187
  processPVT(name, value, attrs) {
184
188
  var t = {};
185
189
  t[name] = value;
186
- this.storeTiming(t, true);
190
+ this.storeTiming(t);
187
191
  if (this.hasFID(name, attrs)) this.storeEvent({
188
192
  type: 'fid',
189
193
  target: 'document'
190
194
  }, 'document', value, value + attrs.fid);
191
195
  }
192
- storeTiming(_t, ignoreOffset) {
193
- var key;
194
- var val;
195
- var timeOffset;
196
- var dateNow = Date.now();
197
-
196
+ storeTiming(_t) {
198
197
  // loop iterates through prototype also (for FF)
199
- for (key in _t) {
200
- val = _t[key];
198
+ for (let key in _t) {
199
+ const val = _t[key];
200
+
201
+ // ignore size and status type nodes that do not map to timestamp metrics
202
+ const lck = key.toLowerCase();
203
+ if (lck.indexOf('size') >= 0 || lck.indexOf('status') >= 0) continue;
201
204
 
202
205
  // ignore inherited methods, meaningless 0 values, and bogus timestamps
203
206
  // that are in the future (Microsoft Edge seems to sometimes produce these)
204
- if (!(typeof val === 'number' && val > 0 && val < dateNow)) continue;
205
- timeOffset = !ignoreOffset ? _t[key] - (0, _config.getRuntime)(this.agentIdentifier).offset : _t[key];
207
+ if (!(typeof val === 'number' && val >= 0)) continue;
208
+ const timeOffset = Math.round(_t[key]);
206
209
  this.storeSTN({
207
210
  n: key,
208
211
  s: timeOffset,
@@ -14,20 +14,20 @@ var _paintMetrics = require("../../../common/metrics/paint-metrics");
14
14
  var _interaction = require("./interaction");
15
15
  var _config = require("../../../common/config/config");
16
16
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
17
- var _aggregateBase = require("../../utils/aggregate-base");
18
17
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
19
18
  var _serializer = require("./serializer");
20
19
  var _contextualEe = require("../../../common/event-emitter/contextual-ee");
21
20
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
22
21
  var _drain = require("../../../common/drain/drain");
23
22
  var _features = require("../../../loaders/features/features");
23
+ var _featureBase = require("../../utils/feature-base");
24
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
26
  /*
27
27
  * Copyright 2020 New Relic Corporation. All rights reserved.
28
28
  * SPDX-License-Identifier: Apache-2.0
29
29
  */
30
- /*eslint no-undef: "error"*/
30
+ /* eslint no-undef: "error" */
31
31
 
32
32
  const {
33
33
  FEATURE_NAME,
@@ -47,7 +47,7 @@ const {
47
47
  JSONP_END,
48
48
  originalSetTimeout
49
49
  } = CONSTANTS;
50
- class Aggregate extends _aggregateBase.AggregateBase {
50
+ class Aggregate extends _featureBase.FeatureBase {
51
51
  static featureName = FEATURE_NAME;
52
52
  constructor(agentIdentifier, aggregator) {
53
53
  super(agentIdentifier, aggregator, FEATURE_NAME);
@@ -90,7 +90,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
90
90
  onFinished: onHarvestFinished,
91
91
  retryDelay: state.harvestTimeSeconds
92
92
  }, {
93
- agentIdentifier
93
+ agentIdentifier,
94
+ ee: baseEE
94
95
  });
95
96
  scheduler.harvest.on('events', onHarvestStarted);
96
97
 
@@ -222,7 +223,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
222
223
  if (evName === 'click') {
223
224
  var value = getActionText(ev.target);
224
225
  if (value) {
225
- state.currentNode.attrs.custom['actionText'] = value;
226
+ state.currentNode.attrs.custom.actionText = value;
226
227
  }
227
228
  }
228
229
  }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setupAgentSession = setupAgentSession;
7
+ var _config = require("../../common/config/config");
8
+ var _drain = require("../../common/drain/drain");
9
+ var _contextualEe = require("../../common/event-emitter/contextual-ee");
10
+ var _registerHandler = require("../../common/event-emitter/register-handler");
11
+ var _globalScope = require("../../common/util/global-scope");
12
+ var _sessionEntity = require("../../common/session/session-entity");
13
+ var _localStorage = require("../../common/storage/local-storage.js");
14
+ var _firstPartyCookies = require("../../common/storage/first-party-cookies");
15
+ var _localMemory = require("../../common/storage/local-memory");
16
+ let ranOnce = 0;
17
+ function setupAgentSession(agentIdentifier) {
18
+ const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
19
+ if (ranOnce++) return agentRuntime.session;
20
+ const sharedEE = _contextualEe.ee.get(agentIdentifier);
21
+
22
+ // domain is a string that can be specified by customer.
23
+ // only way to keep the session object across subdomains is using first party cookies
24
+ // This determines which storage wrapper the session manager will use to keep state
25
+ let storageAPI;
26
+ const cookiesEnabled = (0, _config.getConfigurationValue)(agentIdentifier, 'privacy.cookies_enabled') === true;
27
+ if (cookiesEnabled && _globalScope.isBrowserScope) {
28
+ storageAPI = (0, _config.getConfigurationValue)(agentIdentifier, 'session.domain') ? new _firstPartyCookies.FirstPartyCookies((0, _config.getConfigurationValue)(agentIdentifier, 'session.domain')) : new _localStorage.LocalStorage();
29
+ }
30
+ if (cookiesEnabled) {
31
+ // defaults to "LocalMemory" if storageAPI is undefined, such as in Worker build
32
+ agentRuntime.session = new _sessionEntity.SessionEntity({
33
+ agentIdentifier,
34
+ key: 'SESSION',
35
+ storageAPI,
36
+ expiresMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.expiresMs'),
37
+ inactiveMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.inactiveMs')
38
+ });
39
+ }
40
+
41
+ // The first time the agent runs on a page, it should put everything
42
+ // that's currently stored in the storage API into the local info.jsAttributes object
43
+ if (_globalScope.isBrowserScope) {
44
+ // retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
45
+ const customSessionData = agentRuntime.session?.read?.()?.custom;
46
+ const agentInfo = (0, _config.getInfo)(agentIdentifier);
47
+ if (customSessionData) {
48
+ (0, _config.setInfo)(agentIdentifier, {
49
+ ...agentInfo,
50
+ jsAttributes: {
51
+ ...agentInfo.jsAttributes,
52
+ ...customSessionData
53
+ }
54
+ });
55
+ }
56
+ }
57
+
58
+ // any calls to newrelic.setCustomAttribute(<persisted>) will need to be added to:
59
+ // local info.jsAttributes {}
60
+ // the session's storage API
61
+ (0, _registerHandler.registerHandler)('api-setCustomAttribute', (time, key, value) => {
62
+ agentRuntime.session.syncCustomAttribute(key, value);
63
+ }, 'session', sharedEE);
64
+
65
+ // any calls to newrelic.setUserId(...) will need to be added to:
66
+ // local info.jsAttributes {}
67
+ // the session's storage API
68
+ (0, _registerHandler.registerHandler)('api-setUserId', (time, key, value) => {
69
+ agentRuntime.session.syncCustomAttribute(key, value);
70
+ }, 'session', sharedEE);
71
+ (0, _drain.drain)(agentIdentifier, 'session');
72
+ return agentRuntime.session;
73
+ }
@@ -32,7 +32,7 @@ class FeatureBase {
32
32
  * loader configurations may appear after the loader code is executed.
33
33
  */
34
34
  checkConfiguration() {
35
- // NOTE: This check has to happen at aggregator load time, but could be moved to `AggregateBase`.
35
+ // NOTE: This check has to happen at aggregator load time
36
36
  if (!(0, _config.isConfigured)(this.agentIdentifier)) {
37
37
  let jsAttributes = {
38
38
  ...(0, _nreum.gosCDN)().info?.jsAttributes
@@ -10,7 +10,11 @@ var _load = require("../../common/window/load");
10
10
  var _globalScope = require("../../common/util/global-scope");
11
11
  var _console = require("../../common/util/console");
12
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /**
14
+ * @file Defines `InstrumentBase` to be used as the super of the Instrument classes implemented by each feature.
15
+ * Inherits and executes the `checkConfiguration` method from [FeatureBase]{@link ./feature-base}, which also
16
+ * exposes the `blocked` property.
17
+ */
14
18
  /**
15
19
  * Base class for instrumenting a feature.
16
20
  * @extends FeatureBase
@@ -49,6 +53,12 @@ class InstrumentBase extends _featureBase.FeatureBase {
49
53
  * it's only responsible for aborting its one specific feature, rather than all.
50
54
  */
51
55
  try {
56
+ // The session entity needs to be attached to the config internals before the aggregator chunk runs
57
+ const {
58
+ setupAgentSession
59
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "session-manager" */'./agent-session')));
60
+ setupAgentSession(this.agentIdentifier);
61
+ // import and instantiate the aggregator chunk
52
62
  const {
53
63
  lazyLoader
54
64
  } = await Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-loader" */'./lazy-loader')));
@@ -57,9 +67,8 @@ class InstrumentBase extends _featureBase.FeatureBase {
57
67
  } = await lazyLoader(this.featureName, 'aggregate');
58
68
  new Aggregate(this.agentIdentifier, this.aggregator);
59
69
  } catch (e) {
60
- (0, _console.warn)(`Downloading ${this.featureName} failed...`);
70
+ (0, _console.warn)("Downloading ".concat(this.featureName, " failed..."), e);
61
71
  this.abortHandler?.(); // undo any important alterations made to the page
62
-
63
72
  // not supported yet but nice to do: "abort" this agent's EE for this feature specifically
64
73
  }
65
74
  };