@newrelic/browser-agent 1.252.1 → 1.254.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 (252) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/cdn/experimental.js +6 -2
  4. package/dist/cjs/cdn/polyfills.js +2 -1
  5. package/dist/cjs/cdn/spa.js +5 -3
  6. package/dist/cjs/common/aggregate/aggregator.js +1 -8
  7. package/dist/cjs/common/config/state/init.js +7 -0
  8. package/dist/cjs/common/config/state/runtime.js +4 -1
  9. package/dist/cjs/common/constants/env.cdn.js +1 -1
  10. package/dist/cjs/common/constants/env.npm.js +1 -1
  11. package/dist/cjs/common/drain/drain.js +41 -27
  12. package/dist/cjs/common/event-emitter/contextual-ee.js +17 -12
  13. package/dist/cjs/common/harvest/harvest.js +5 -1
  14. package/dist/cjs/common/session/constants.js +2 -1
  15. package/dist/cjs/common/timing/nav-timing.js +8 -3
  16. package/dist/cjs/common/timing/now.js +1 -1
  17. package/dist/cjs/common/timing/time-keeper.js +94 -0
  18. package/dist/cjs/common/util/feature-flags.js +14 -31
  19. package/dist/cjs/common/wrap/index.js +0 -7
  20. package/dist/cjs/features/ajax/aggregate/index.js +41 -29
  21. package/dist/cjs/features/jserrors/aggregate/index.js +96 -84
  22. package/dist/cjs/features/metrics/aggregate/index.js +25 -24
  23. package/dist/cjs/features/page_action/aggregate/index.js +6 -4
  24. package/dist/cjs/features/page_view_event/aggregate/index.js +23 -3
  25. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -0
  26. package/dist/cjs/features/page_view_timing/aggregate/index.js +15 -16
  27. package/dist/cjs/features/session_replay/aggregate/index.js +102 -92
  28. package/dist/cjs/features/session_replay/constants.js +5 -1
  29. package/dist/cjs/features/session_replay/instrument/index.js +24 -8
  30. package/dist/cjs/features/session_replay/shared/utils.js +26 -0
  31. package/dist/cjs/features/session_trace/aggregate/index.js +11 -8
  32. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +50 -0
  33. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +29 -0
  34. package/dist/cjs/features/soft_navigations/aggregate/index.js +268 -0
  35. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +62 -0
  36. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +146 -0
  37. package/dist/cjs/features/soft_navigations/constants.js +31 -0
  38. package/dist/cjs/features/soft_navigations/index.js +12 -0
  39. package/dist/cjs/features/soft_navigations/instrument/index.js +79 -0
  40. package/dist/cjs/features/spa/aggregate/index.js +23 -18
  41. package/dist/cjs/features/utils/agent-session.js +2 -1
  42. package/dist/cjs/features/utils/aggregate-base.js +18 -5
  43. package/dist/cjs/features/utils/feature-base.js +2 -0
  44. package/dist/cjs/features/utils/instrument-base.js +7 -9
  45. package/dist/cjs/features/utils/lazy-feature-loader.js +2 -0
  46. package/dist/cjs/loaders/agent-base.js +13 -3
  47. package/dist/cjs/loaders/agent.js +19 -22
  48. package/dist/cjs/loaders/api/api-methods.js +2 -1
  49. package/dist/cjs/loaders/api/api.js +15 -12
  50. package/dist/cjs/loaders/configure/configure.js +5 -2
  51. package/dist/cjs/loaders/configure/nonce.cdn.js +13 -0
  52. package/dist/cjs/loaders/configure/nonce.js +2 -13
  53. package/dist/cjs/loaders/configure/public-path.cdn.js +16 -0
  54. package/dist/cjs/loaders/configure/public-path.js +2 -8
  55. package/dist/cjs/loaders/features/enabled-features.js +1 -1
  56. package/dist/cjs/loaders/features/features.js +3 -1
  57. package/dist/esm/cdn/experimental.js +5 -2
  58. package/dist/esm/cdn/polyfills.js +2 -1
  59. package/dist/esm/cdn/spa.js +3 -1
  60. package/dist/esm/common/aggregate/aggregator.js +1 -8
  61. package/dist/esm/common/config/state/init.js +7 -0
  62. package/dist/esm/common/config/state/runtime.js +4 -1
  63. package/dist/esm/common/constants/env.cdn.js +1 -1
  64. package/dist/esm/common/constants/env.npm.js +1 -1
  65. package/dist/esm/common/drain/drain.js +40 -27
  66. package/dist/esm/common/event-emitter/contextual-ee.js +17 -12
  67. package/dist/esm/common/harvest/harvest.js +5 -1
  68. package/dist/esm/common/session/constants.js +1 -0
  69. package/dist/esm/common/timing/nav-timing.js +8 -3
  70. package/dist/esm/common/timing/now.js +1 -1
  71. package/dist/esm/common/timing/time-keeper.js +88 -0
  72. package/dist/esm/common/util/feature-flags.js +14 -31
  73. package/dist/esm/common/wrap/index.js +1 -2
  74. package/dist/esm/features/ajax/aggregate/index.js +43 -31
  75. package/dist/esm/features/jserrors/aggregate/index.js +96 -84
  76. package/dist/esm/features/metrics/aggregate/index.js +25 -24
  77. package/dist/esm/features/page_action/aggregate/index.js +6 -4
  78. package/dist/esm/features/page_view_event/aggregate/index.js +23 -3
  79. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -0
  80. package/dist/esm/features/page_view_timing/aggregate/index.js +15 -16
  81. package/dist/esm/features/session_replay/aggregate/index.js +103 -93
  82. package/dist/esm/features/session_replay/constants.js +4 -0
  83. package/dist/esm/features/session_replay/instrument/index.js +25 -9
  84. package/dist/esm/features/session_replay/shared/utils.js +17 -0
  85. package/dist/esm/features/session_trace/aggregate/index.js +11 -8
  86. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +43 -0
  87. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +22 -0
  88. package/dist/esm/features/soft_navigations/aggregate/index.js +261 -0
  89. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +55 -0
  90. package/dist/esm/features/soft_navigations/aggregate/interaction.js +140 -0
  91. package/dist/esm/features/soft_navigations/constants.js +25 -0
  92. package/dist/esm/features/soft_navigations/index.js +1 -0
  93. package/dist/esm/features/soft_navigations/instrument/index.js +73 -0
  94. package/dist/esm/features/spa/aggregate/index.js +23 -18
  95. package/dist/esm/features/utils/agent-session.js +2 -1
  96. package/dist/esm/features/utils/aggregate-base.js +18 -5
  97. package/dist/esm/features/utils/feature-base.js +2 -0
  98. package/dist/esm/features/utils/instrument-base.js +8 -10
  99. package/dist/esm/features/utils/lazy-feature-loader.js +2 -0
  100. package/dist/esm/loaders/agent-base.js +13 -3
  101. package/dist/esm/loaders/agent.js +19 -22
  102. package/dist/esm/loaders/api/api-methods.js +2 -1
  103. package/dist/esm/loaders/api/api.js +15 -12
  104. package/dist/esm/loaders/configure/configure.js +5 -2
  105. package/dist/esm/loaders/configure/nonce.cdn.js +11 -0
  106. package/dist/esm/loaders/configure/nonce.js +1 -11
  107. package/dist/esm/loaders/configure/public-path.cdn.js +9 -0
  108. package/dist/esm/loaders/configure/public-path.js +2 -8
  109. package/dist/esm/loaders/features/enabled-features.js +1 -1
  110. package/dist/esm/loaders/features/features.js +3 -1
  111. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
  112. package/dist/types/common/config/state/init.d.ts.map +1 -1
  113. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  114. package/dist/types/common/drain/drain.d.ts +6 -0
  115. package/dist/types/common/drain/drain.d.ts.map +1 -1
  116. package/dist/types/common/event-emitter/contextual-ee.d.ts +2 -1
  117. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
  118. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  119. package/dist/types/common/session/constants.d.ts +1 -0
  120. package/dist/types/common/session/constants.d.ts.map +1 -1
  121. package/dist/types/common/timing/nav-timing.d.ts.map +1 -1
  122. package/dist/types/common/timing/time-keeper.d.ts +31 -0
  123. package/dist/types/common/timing/time-keeper.d.ts.map +1 -0
  124. package/dist/types/common/util/feature-flags.d.ts +11 -2
  125. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  126. package/dist/types/common/wrap/index.d.ts +1 -2
  127. package/dist/types/common/wrap/index.d.ts.map +1 -1
  128. package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
  129. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  130. package/dist/types/features/jserrors/aggregate/index.d.ts +4 -3
  131. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  132. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  133. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  134. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  135. package/dist/types/features/page_view_event/aggregate/initialized-features.d.ts.map +1 -1
  136. package/dist/types/features/page_view_timing/aggregate/index.d.ts +0 -2
  137. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  138. package/dist/types/features/session_replay/aggregate/index.d.ts +1 -1
  139. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  140. package/dist/types/features/session_replay/constants.d.ts +4 -0
  141. package/dist/types/features/session_replay/constants.d.ts.map +1 -1
  142. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  143. package/dist/types/features/session_replay/shared/utils.d.ts +4 -0
  144. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -0
  145. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +19 -0
  146. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -0
  147. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts +16 -0
  148. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts.map +1 -0
  149. package/dist/types/features/soft_navigations/aggregate/index.d.ts +34 -0
  150. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -0
  151. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts +12 -0
  152. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts.map +1 -0
  153. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +50 -0
  154. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -0
  155. package/dist/types/features/soft_navigations/constants.d.ts +20 -0
  156. package/dist/types/features/soft_navigations/constants.d.ts.map +1 -0
  157. package/dist/types/features/soft_navigations/index.d.ts +2 -0
  158. package/dist/types/features/soft_navigations/index.d.ts.map +1 -0
  159. package/dist/types/features/soft_navigations/instrument/index.d.ts +7 -0
  160. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -0
  161. package/dist/types/features/spa/aggregate/index.d.ts +2 -0
  162. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  163. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  164. package/dist/types/features/utils/aggregate-base.d.ts +2 -2
  165. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  166. package/dist/types/features/utils/feature-base.d.ts +1 -0
  167. package/dist/types/features/utils/feature-base.d.ts.map +1 -1
  168. package/dist/types/features/utils/instrument-base.d.ts +1 -7
  169. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  170. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -1
  171. package/dist/types/loaders/agent-base.d.ts +5 -1
  172. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  173. package/dist/types/loaders/agent.d.ts +2 -2
  174. package/dist/types/loaders/agent.d.ts.map +1 -1
  175. package/dist/types/loaders/api/api-methods.d.ts.map +1 -1
  176. package/dist/types/loaders/api/api.d.ts +3 -5
  177. package/dist/types/loaders/api/api.d.ts.map +1 -1
  178. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  179. package/dist/types/loaders/configure/public-path.d.ts +1 -1
  180. package/dist/types/loaders/configure/public-path.d.ts.map +1 -1
  181. package/dist/types/loaders/features/features.d.ts +1 -0
  182. package/dist/types/loaders/features/features.d.ts.map +1 -1
  183. package/dist/types/loaders/micro-agent.d.ts +0 -1
  184. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  185. package/package.json +1 -1
  186. package/src/cdn/experimental.js +4 -2
  187. package/src/cdn/polyfills.js +1 -0
  188. package/src/cdn/spa.js +3 -1
  189. package/src/common/aggregate/aggregator.js +2 -11
  190. package/src/common/config/state/init.js +3 -1
  191. package/src/common/config/state/runtime.js +4 -1
  192. package/src/common/drain/drain.js +41 -28
  193. package/src/common/event-emitter/contextual-ee.js +21 -13
  194. package/src/common/harvest/harvest.js +4 -1
  195. package/src/common/session/constants.js +1 -0
  196. package/src/common/timing/nav-timing.js +7 -3
  197. package/src/common/timing/now.js +1 -1
  198. package/src/common/timing/time-keeper.js +96 -0
  199. package/src/common/util/feature-flags.js +13 -31
  200. package/src/common/wrap/index.js +1 -2
  201. package/src/features/ajax/aggregate/index.js +43 -33
  202. package/src/features/jserrors/aggregate/index.js +82 -87
  203. package/src/features/metrics/aggregate/index.js +18 -17
  204. package/src/features/page_action/aggregate/index.js +6 -5
  205. package/src/features/page_view_event/aggregate/index.js +19 -3
  206. package/src/features/page_view_event/aggregate/initialized-features.js +1 -0
  207. package/src/features/page_view_timing/aggregate/index.js +15 -15
  208. package/src/features/session_replay/aggregate/index.js +95 -92
  209. package/src/features/session_replay/constants.js +5 -0
  210. package/src/features/session_replay/instrument/index.js +24 -9
  211. package/src/features/session_replay/shared/utils.js +19 -0
  212. package/src/features/session_trace/aggregate/index.js +2 -2
  213. package/src/features/soft_navigations/aggregate/ajax-node.js +57 -0
  214. package/src/features/soft_navigations/aggregate/bel-node.js +26 -0
  215. package/src/features/soft_navigations/aggregate/index.js +256 -0
  216. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +53 -0
  217. package/src/features/soft_navigations/aggregate/interaction.js +159 -0
  218. package/src/features/soft_navigations/constants.js +29 -0
  219. package/src/features/soft_navigations/index.js +1 -0
  220. package/src/features/soft_navigations/instrument/index.js +67 -0
  221. package/src/features/spa/aggregate/index.js +20 -17
  222. package/src/features/utils/agent-session.js +2 -1
  223. package/src/features/utils/aggregate-base.js +16 -8
  224. package/src/features/utils/feature-base.js +3 -0
  225. package/src/features/utils/instrument-base.js +8 -10
  226. package/src/features/utils/lazy-feature-loader.js +2 -0
  227. package/src/loaders/agent-base.js +13 -3
  228. package/src/loaders/agent.js +20 -19
  229. package/src/loaders/api/api-methods.js +4 -1
  230. package/src/loaders/api/api.js +15 -13
  231. package/src/loaders/configure/configure.js +4 -1
  232. package/src/loaders/configure/nonce.cdn.js +12 -0
  233. package/src/loaders/configure/nonce.js +1 -12
  234. package/src/loaders/configure/public-path.cdn.js +9 -0
  235. package/src/loaders/configure/public-path.js +2 -8
  236. package/src/loaders/features/enabled-features.js +1 -1
  237. package/src/loaders/features/features.js +3 -1
  238. package/dist/cjs/common/wrap/wrap-raf.js +0 -55
  239. package/dist/cjs/loaders/configure/nonce.npm.js +0 -2
  240. package/dist/cjs/loaders/configure/public-path.npm.js +0 -10
  241. package/dist/esm/common/wrap/wrap-raf.js +0 -48
  242. package/dist/esm/loaders/configure/nonce.npm.js +0 -1
  243. package/dist/esm/loaders/configure/public-path.npm.js +0 -3
  244. package/dist/types/common/wrap/wrap-raf.d.ts +0 -16
  245. package/dist/types/common/wrap/wrap-raf.d.ts.map +0 -1
  246. package/dist/types/loaders/configure/nonce.npm.d.ts +0 -1
  247. package/dist/types/loaders/configure/nonce.npm.d.ts.map +0 -1
  248. package/dist/types/loaders/configure/public-path.npm.d.ts +0 -2
  249. package/dist/types/loaders/configure/public-path.npm.d.ts.map +0 -1
  250. package/src/common/wrap/wrap-raf.js +0 -52
  251. package/src/loaders/configure/nonce.npm.js +0 -1
  252. package/src/loaders/configure/public-path.npm.js +0 -3
@@ -16,6 +16,7 @@ var _features = require("../../../loaders/features/features");
16
16
  var _constants2 = require("../../metrics/constants");
17
17
  var _aggregateBase = require("../../utils/aggregate-base");
18
18
  var _gql = require("./gql");
19
+ var _nreum = require("../../../common/window/nreum");
19
20
  /*
20
21
  * Copyright 2020 New Relic Corporation. All rights reserved.
21
22
  * SPDX-License-Identifier: Apache-2.0
@@ -26,12 +27,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
26
27
  constructor(agentIdentifier, aggregator) {
27
28
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
28
29
  const agentInit = (0, _config.getConfiguration)(agentIdentifier);
29
- const allAjaxIsEnabled = agentInit.ajax.enabled !== false;
30
30
  (0, _registerHandler.registerHandler)('xhr', storeXhr, this.featureName, this.ee);
31
- if (!allAjaxIsEnabled) {
31
+ this.waitForFlags([]).then(() => {
32
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
33
+ onFinished: onEventsHarvestFinished,
34
+ getPayload: prepareHarvest
35
+ }, this);
36
+ scheduler.startTimer(harvestTimeSeconds);
32
37
  this.drain();
33
- return; // feature will only collect timeslice metrics & ajax trace nodes if it's not fully enabled
34
- }
38
+ });
35
39
  const denyList = (0, _config.getRuntime)(agentIdentifier).denyList;
36
40
  (0, _denyList.setDenyList)(denyList);
37
41
  let ajaxEvents = [];
@@ -50,27 +54,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
50
54
  spaAjaxEvents
51
55
  };
52
56
  };
53
- ee.on('interactionSaved', interaction => {
54
- if (!spaAjaxEvents[interaction.id]) return;
55
- // remove from the spaAjaxEvents buffer, and let spa harvest it
56
- delete spaAjaxEvents[interaction.id];
57
- });
58
- ee.on('interactionDiscarded', interaction => {
57
+
58
+ // --- v Used by old spa feature
59
+ ee.on('interactionDone', (interaction, wasSaved) => {
59
60
  if (!spaAjaxEvents[interaction.id]) return;
60
- spaAjaxEvents[interaction.id].forEach(function (item) {
61
- // move it from the spaAjaxEvents buffer to the ajaxEvents buffer for harvesting here
62
- ajaxEvents.push(item);
63
- });
61
+ if (!wasSaved) {
62
+ // if the ixn was saved, then its ajax reqs are part of the payload whereas if it was discarded, it should still be harvested in the ajax feature itself
63
+ spaAjaxEvents[interaction.id].forEach(function (item) {
64
+ ajaxEvents.push(item);
65
+ });
66
+ }
64
67
  delete spaAjaxEvents[interaction.id];
65
68
  });
66
- const scheduler = new _harvestScheduler.HarvestScheduler('events', {
67
- onFinished: onEventsHarvestFinished,
68
- getPayload: prepareHarvest
69
- }, this);
70
- ee.on("drain-".concat(this.featureName), () => {
71
- scheduler.startTimer(harvestTimeSeconds);
72
- });
73
- this.drain();
69
+ // --- ^
70
+ // --- v Used by new soft nav
71
+ (0, _registerHandler.registerHandler)('returnAjax', event => ajaxEvents.push(event), this.featureName, this.ee);
72
+ // --- ^
73
+
74
74
  const beacon = (0, _config.getInfo)(agentIdentifier).errorBeacon;
75
75
  const proxyBeacon = agentInit.proxy.beacon;
76
76
  function storeXhr(params, metrics, startTime, endTime, type) {
@@ -83,16 +83,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
83
83
  } else {
84
84
  hash = (0, _stringify.stringify)([params.status, params.host, params.pathname]);
85
85
  }
86
+ const shouldCollect = (0, _denyList.shouldCollectEvent)(params);
87
+ const ajaxMetricDenyListEnabled = agentInit.feature_flags?.includes('ajax_metrics_deny_list');
86
88
 
87
89
  // store as metric
88
- aggregator.store('xhr', hash, params, metrics);
89
- if (!allAjaxIsEnabled) return;
90
- if (!(0, _denyList.shouldCollectEvent)(params)) {
90
+ if (shouldCollect || !ajaxMetricDenyListEnabled) {
91
+ aggregator.store('xhr', hash, params, metrics);
92
+ }
93
+ if (!shouldCollect) {
91
94
  if (params.hostname === beacon || proxyBeacon && params.hostname === proxyBeacon) {
92
95
  // This doesn't make a distinction if the same-domain request is going to a different port or path...
93
96
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
97
+ if (ajaxMetricDenyListEnabled) {
98
+ (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, ee);
99
+ }
94
100
  } else {
95
101
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/App'], undefined, _features.FEATURE_NAMES.metrics, ee);
102
+ if (ajaxMetricDenyListEnabled) {
103
+ (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/App'], undefined, _features.FEATURE_NAMES.metrics, ee);
104
+ }
96
105
  }
97
106
  return;
98
107
  }
@@ -122,10 +131,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
122
131
  query: this?.parsedOrigin?.search
123
132
  });
124
133
  if (event.gql) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/GraphQL/Bytes-Added', (0, _stringify.stringify)(event.gql).length], undefined, _features.FEATURE_NAMES.metrics, ee);
125
-
126
- // if the ajax happened inside an interaction, hold it until the interaction finishes
127
- if (this.spaNode) {
128
- var interactionId = this.spaNode.interaction.id;
134
+ const softNavInUse = Boolean((0, _nreum.getNREUMInitializedAgent)(agentIdentifier)?.features?.[_features.FEATURE_NAMES.softNav]);
135
+ if (softNavInUse) {
136
+ // For newer soft nav (when running), pass the event to it for evaluation -- either part of an interaction or is given back
137
+ (0, _handle.handle)('ajax', [event], undefined, _features.FEATURE_NAMES.softNav, ee);
138
+ } else if (this.spaNode) {
139
+ // For old spa (when running), if the ajax happened inside an interaction, hold it until the interaction finishes
140
+ const interactionId = this.spaNode.interaction.id;
129
141
  spaAjaxEvents[interactionId] = spaAjaxEvents[interactionId] || [];
130
142
  spaAjaxEvents[interactionId].push(event);
131
143
  } else {
@@ -19,6 +19,8 @@ var _runtime = require("../../../common/constants/runtime");
19
19
  var _constants = require("../constants");
20
20
  var _features = require("../../../loaders/features/features");
21
21
  var _aggregateBase = require("../../utils/aggregate-base");
22
+ var _nreum = require("../../../common/window/nreum");
23
+ var _drain = require("../../../common/drain/drain");
22
24
  /*
23
25
  * Copyright 2020 New Relic Corporation. All rights reserved.
24
26
  * SPDX-License-Identifier: Apache-2.0
@@ -37,42 +39,41 @@ class Aggregate extends _aggregateBase.AggregateBase {
37
39
  this.stackReported = {};
38
40
  this.observedAt = {};
39
41
  this.pageviewReported = {};
40
- this.errorCache = {};
42
+ this.bufferedErrorsUnderSpa = {};
41
43
  this.currentBody = undefined;
42
44
  this.errorOnPage = false;
43
45
 
44
46
  // this will need to change to match whatever ee we use in the instrument
45
- this.ee.on('interactionSaved', interaction => this.onInteractionSaved(interaction));
46
-
47
- // this will need to change to match whatever ee we use in the instrument
48
- this.ee.on('interactionDiscarded', interaction => this.onInteractionDiscarded(interaction));
47
+ this.ee.on('interactionDone', (interaction, wasSaved) => this.onInteractionDone(interaction, wasSaved));
49
48
  (0, _registerHandler.registerHandler)('err', function () {
50
49
  return _this.storeError(...arguments);
51
50
  }, this.featureName, this.ee);
52
51
  (0, _registerHandler.registerHandler)('ierr', function () {
53
52
  return _this.storeError(...arguments);
54
53
  }, this.featureName, this.ee);
54
+ (0, _registerHandler.registerHandler)('softNavFlush', (interactionId, wasFinished, softNavAttrs) => this.onSoftNavNotification(interactionId, wasFinished, softNavAttrs), this.featureName, this.ee); // when an ixn is done or cancelled
55
+
55
56
  const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
56
- const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
57
- onFinished: function () {
58
- return _this.onHarvestFinished(...arguments);
59
- }
60
- }, this);
61
- scheduler.harvest.on('jserrors', function () {
62
- return _this.onHarvestStarted(...arguments);
63
- });
64
57
 
65
- // Don't start harvesting until "drain" for this feat has been called (which currently requires RUM response).
66
- this.ee.on("drain-".concat(this.featureName), () => {
67
- if (!this.blocked) scheduler.startTimer(harvestTimeSeconds); // and only if ingest will accept jserror payloads
58
+ // 0 == off, 1 == on
59
+ this.waitForFlags(['err']).then(_ref => {
60
+ let [errFlag] = _ref;
61
+ if (errFlag) {
62
+ const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
63
+ onFinished: function () {
64
+ return _this.onHarvestFinished(...arguments);
65
+ }
66
+ }, this);
67
+ scheduler.harvest.on('jserrors', function () {
68
+ return _this.onHarvestStarted(...arguments);
69
+ });
70
+ scheduler.startTimer(harvestTimeSeconds);
71
+ this.drain();
72
+ } else {
73
+ this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
74
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
75
+ }
68
76
  });
69
-
70
- // If RUM-call's response determines that customer lacks entitlements for the /jserror ingest endpoint, don't harvest at all.
71
- (0, _registerHandler.registerHandler)('block-err', () => {
72
- this.blocked = true;
73
- scheduler.stopTimer(true);
74
- }, this.featureName, this.ee);
75
- this.drain();
76
77
  }
77
78
  onHarvestStarted(options) {
78
79
  // this gets rid of dependency in AJAX module
@@ -193,82 +194,93 @@ class Aggregate extends _aggregateBase.AggregateBase {
193
194
  time
194
195
  };
195
196
 
196
- // sr, stn and spa aggregators listen to this event - stn sends the error in its payload,
197
- // and spa annotates the error with interaction info
198
- const msg = [type, bucketHash, params, newMetrics];
199
- (0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
200
- (0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.spa, this.ee);
201
- (0, _handle.handle)('errorAgg', msg, undefined, _features.FEATURE_NAMES.sessionReplay, this.ee);
202
-
197
+ // Trace sends the error in its payload, and both trace & replay simply listens for any error to occur.
198
+ const jsErrorEvent = [type, bucketHash, params, newMetrics, customAttributes];
199
+ (0, _handle.handle)('errorAgg', jsErrorEvent, undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
200
+ (0, _handle.handle)('errorAgg', jsErrorEvent, undefined, _features.FEATURE_NAMES.sessionReplay, this.ee);
203
201
  // still send EE events for other features such as above, but stop this one from aggregating internal data
204
202
  if (this.blocked) return;
205
- var att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes;
206
- if (params._interactionId != null) {
207
- // hold on to the error until the interaction finishes
208
- this.errorCache[params._interactionId] = this.errorCache[params._interactionId] || [];
209
- this.errorCache[params._interactionId].push([type, bucketHash, params, newMetrics, att, customAttributes]);
203
+ const softNavInUse = Boolean((0, _nreum.getNREUMInitializedAgent)(this.agentIdentifier)?.features[_features.FEATURE_NAMES.softNav]);
204
+ // Note: the following are subject to potential race cond wherein if the other feature aren't fully initialized, it'll be treated as there being no associated interaction.
205
+ // They each will also tack on their respective properties to the params object as part of the decision flow.
206
+ if (softNavInUse) (0, _handle.handle)('jserror', [params, time], undefined, _features.FEATURE_NAMES.softNav, this.ee);else (0, _handle.handle)('errorAgg', jsErrorEvent, undefined, _features.FEATURE_NAMES.spa, this.ee);
207
+ if (params.browserInteractionId && !params._softNavFinished) {
208
+ // hold onto the error until the in-progress interaction is done, eithered saved or discarded
209
+ this.bufferedErrorsUnderSpa[params.browserInteractionId] ??= [];
210
+ this.bufferedErrorsUnderSpa[params.browserInteractionId].push(jsErrorEvent);
211
+ } else if (params._interactionId != null) {
212
+ // same as above, except tailored for the way old spa does it
213
+ this.bufferedErrorsUnderSpa[params._interactionId] = this.bufferedErrorsUnderSpa[params._interactionId] || [];
214
+ this.bufferedErrorsUnderSpa[params._interactionId].push(jsErrorEvent);
210
215
  } else {
211
- // store custom attributes
212
- var customParams = {};
213
- (0, _mapOwn.mapOwn)(att, setCustom);
214
- if (customAttributes) {
215
- (0, _mapOwn.mapOwn)(customAttributes, setCustom);
216
- }
217
- var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
218
- var aggregateHash = bucketHash + ':' + jsAttributesHash;
219
- this.aggregator.store(type, aggregateHash, params, newMetrics, customParams);
216
+ // Either there is no interaction (then all these params properties will be undefined) OR there's a related soft navigation that's already completed.
217
+ // The old spa does not look up completed interactions at all, so there's no need to consider it.
218
+ this.#storeJserrorForHarvest(jsErrorEvent, params.browserInteractionId !== undefined, params._softNavAttributes);
220
219
  }
220
+ }
221
+ #storeJserrorForHarvest(errorInfoArr, softNavOccurredFinished) {
222
+ let softNavCustomAttrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
223
+ let [type, bucketHash, params, newMetrics, localAttrs] = errorInfoArr;
224
+ const allCustomAttrs = {};
225
+ if (softNavOccurredFinished) {
226
+ Object.entries(softNavCustomAttrs).forEach(_ref2 => {
227
+ let [k, v] = _ref2;
228
+ return setCustom(k, v);
229
+ }); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
230
+ bucketHash += params.browserInteractionId;
231
+ delete params._softNavAttributes; // cleanup temp properties from synchronous evaluation; this is harmless when async from soft nav (properties DNE)
232
+ delete params._softNavFinished;
233
+ } else {
234
+ // interaction was cancelled -> error should not be associated OR there was no interaction
235
+ Object.entries((0, _config.getInfo)(this.agentIdentifier).jsAttributes).forEach(_ref3 => {
236
+ let [k, v] = _ref3;
237
+ return setCustom(k, v);
238
+ });
239
+ delete params.browserInteractionId;
240
+ }
241
+ if (localAttrs) Object.entries(localAttrs).forEach(_ref4 => {
242
+ let [k, v] = _ref4;
243
+ return setCustom(k, v);
244
+ }); // local custom attrs are applied in either case with the highest precedence
245
+
246
+ const jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
247
+ const aggregateHash = bucketHash + ':' + jsAttributesHash;
248
+ this.aggregator.store(type, aggregateHash, params, newMetrics, allCustomAttrs);
221
249
  function setCustom(key, val) {
222
- customParams[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
250
+ allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
223
251
  }
224
252
  }
225
- onInteractionSaved(interaction) {
226
- if (!this.errorCache[interaction.id] || this.blocked) return;
227
- this.errorCache[interaction.id].forEach(item => {
228
- var customParams = {};
229
- var globalCustomParams = item[4];
230
- var localCustomParams = item[5];
231
- (0, _mapOwn.mapOwn)(globalCustomParams, setCustom);
232
- (0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom);
233
- (0, _mapOwn.mapOwn)(localCustomParams, setCustom);
253
+
254
+ // TO-DO: Remove this function when old spa is taken out. #storeJserrorForHarvest handles the work with the softnav feature.
255
+ onInteractionDone(interaction, wasSaved) {
256
+ if (!this.bufferedErrorsUnderSpa[interaction.id] || this.blocked) return;
257
+ this.bufferedErrorsUnderSpa[interaction.id].forEach(item => {
258
+ var allCustomAttrs = {};
259
+ const localCustomAttrs = item[4];
260
+ (0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom); // tack on custom attrs from the interaction
261
+ (0, _mapOwn.mapOwn)(localCustomAttrs, setCustom);
234
262
  var params = item[2];
235
- params.browserInteractionId = interaction.root.attrs.id;
236
- delete params._interactionId;
237
- if (params._interactionNodeId) {
238
- params.parentNodeId = params._interactionNodeId.toString();
239
- delete params._interactionNodeId;
240
- }
241
- var hash = item[1] + interaction.root.attrs.id;
242
- var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
243
- var aggregateHash = hash + ':' + jsAttributesHash;
244
- this.aggregator.store(item[0], aggregateHash, params, item[3], customParams);
245
- function setCustom(key, val) {
246
- customParams[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
263
+ if (wasSaved) {
264
+ params.browserInteractionId = interaction.root.attrs.id;
265
+ if (params._interactionNodeId) params.parentNodeId = params._interactionNodeId.toString();
247
266
  }
248
- });
249
- delete this.errorCache[interaction.id];
250
- }
251
- onInteractionDiscarded(interaction) {
252
- if (!this.errorCache || !this.errorCache[interaction.id] || this.blocked) return;
253
- this.errorCache[interaction.id].forEach(item => {
254
- var customParams = {};
255
- var globalCustomParams = item[4];
256
- var localCustomParams = item[5];
257
- (0, _mapOwn.mapOwn)(globalCustomParams, setCustom);
258
- (0, _mapOwn.mapOwn)(interaction.root.attrs.custom, setCustom);
259
- (0, _mapOwn.mapOwn)(localCustomParams, setCustom);
260
- var params = item[2];
261
267
  delete params._interactionId;
262
268
  delete params._interactionNodeId;
263
- var hash = item[1];
264
- var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
269
+ var hash = wasSaved ? item[1] + interaction.root.attrs.id : item[1];
270
+ var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
265
271
  var aggregateHash = hash + ':' + jsAttributesHash;
266
- this.aggregator.store(item[0], aggregateHash, item[2], item[3], customParams);
272
+ this.aggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs);
267
273
  function setCustom(key, val) {
268
- customParams[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
274
+ allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
269
275
  }
270
276
  });
271
- delete this.errorCache[interaction.id];
277
+ delete this.bufferedErrorsUnderSpa[interaction.id];
278
+ }
279
+ onSoftNavNotification(interactionId, wasFinished, softNavAttrs) {
280
+ if (this.blocked) return;
281
+ this.bufferedErrorsUnderSpa[interactionId]?.forEach(jsErrorEvent => this.#storeJserrorForHarvest(jsErrorEvent, wasFinished, softNavAttrs) // this should not modify the re-used softNavAttrs contents
282
+ );
283
+ delete this.bufferedErrorsUnderSpa[interactionId]; // wipe the list of jserrors so they aren't duplicated by another call to the same id
272
284
  }
273
285
  }
274
286
  exports.Aggregate = Aggregate;
@@ -15,35 +15,34 @@ var _load = require("../../../common/window/load");
15
15
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
16
16
  var _runtime = require("../../../common/constants/runtime");
17
17
  var _aggregateBase = require("../../utils/aggregate-base");
18
+ var _drain = require("../../../common/drain/drain");
18
19
  class Aggregate extends _aggregateBase.AggregateBase {
19
20
  static featureName = _constants.FEATURE_NAME;
20
21
  constructor(agentIdentifier, aggregator) {
21
22
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
22
- let scheduler;
23
-
24
- // If RUM-call's response determines that customer lacks entitlements for the /jserror ingest endpoint, don't harvest at all.
25
- (0, _registerHandler.registerHandler)('block-err', () => {
26
- this.blocked = true;
27
- if (scheduler) scheduler.aborted = true; // RUM response may or may not have happened already before scheduler initialization below
28
- }, this.featureName, this.ee);
23
+ this.waitForFlags(['err']).then(_ref => {
24
+ let [errFlag] = _ref;
25
+ if (errFlag) {
26
+ // *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
27
+ const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
28
+ onUnload: () => this.unload()
29
+ }, this);
30
+ // this is needed to ensure EoL is "on" and sent
31
+ scheduler.harvest.on('jserrors', () => ({
32
+ body: this.aggregator.take(['cm', 'sm'])
33
+ }));
34
+ this.drain();
35
+ } else {
36
+ this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
37
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
38
+ }
39
+ });
29
40
 
30
41
  // Allow features external to the metrics feature to capture SMs and CMs through the event emitter
31
42
  (0, _registerHandler.registerHandler)(_constants.SUPPORTABILITY_METRIC_CHANNEL, this.storeSupportabilityMetrics.bind(this), this.featureName, this.ee);
32
43
  (0, _registerHandler.registerHandler)(_constants.CUSTOM_METRIC_CHANNEL, this.storeEventMetrics.bind(this), this.featureName, this.ee);
33
44
  this.singleChecks(); // checks that are run only one time, at script load
34
45
  this.eachSessionChecks(); // the start of every time user engages with page
35
-
36
- this.ee.on("drain-".concat(this.featureName), () => {
37
- // *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
38
- scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
39
- onUnload: () => this.unload()
40
- }, this);
41
- scheduler.harvest.on('jserrors', () => ({
42
- body: this.aggregator.take(['cm', 'sm'])
43
- }));
44
- }); // this is needed to ensure EoL is "on" and sent
45
-
46
- this.drain();
47
46
  }
48
47
  storeSupportabilityMetrics(name, value) {
49
48
  if (this.blocked) return;
@@ -67,6 +66,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
67
66
  distMethod,
68
67
  loaderType
69
68
  } = (0, _config.getRuntime)(this.agentIdentifier);
69
+ const {
70
+ proxy,
71
+ privacy,
72
+ page_view_timing
73
+ } = (0, _config.getConfiguration)(this.agentIdentifier);
70
74
  if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
71
75
  if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
72
76
  if (_runtime.isBrowserScope) {
@@ -82,6 +86,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
82
86
  this.storeSupportabilityMetrics('Framework/' + framework + '/Detected');
83
87
  });
84
88
  });
89
+ if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
90
+ if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled');
85
91
  } else if (_runtime.isWorkerScope) {
86
92
  this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
87
93
  } else {
@@ -100,13 +106,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
100
106
  if (rules.length > 0 && !(0, _obfuscate.validateRules)(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
101
107
 
102
108
  // Check if proxy for either chunks or beacon is being used
103
- const {
104
- proxy,
105
- privacy
106
- } = (0, _config.getConfiguration)(this.agentIdentifier);
107
109
  if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
108
110
  if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
109
- if (!(_runtime.isBrowserScope && privacy.cookies_enabled)) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
110
111
  }
111
112
  eachSessionChecks() {
112
113
  if (!_runtime.isBrowserScope) return;
@@ -13,6 +13,7 @@ var _config = require("../../../common/config/config");
13
13
  var _constants = require("../constants");
14
14
  var _runtime = require("../../../common/constants/runtime");
15
15
  var _aggregateBase = require("../../utils/aggregate-base");
16
+ var _drain = require("../../../common/drain/drain");
16
17
  /*
17
18
  * Copyright 2020 New Relic Corporation. All rights reserved.
18
19
  * SPDX-License-Identifier: Apache-2.0
@@ -37,8 +38,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
37
38
  return _this.addPageAction(...arguments);
38
39
  }, this.featureName, this.ee);
39
40
  this.waitForFlags(['ins']).then(_ref => {
40
- let [enabled] = _ref;
41
- if (enabled) {
41
+ let [insFlag] = _ref;
42
+ if (insFlag) {
42
43
  const scheduler = new _harvestScheduler.HarvestScheduler('ins', {
43
44
  onFinished: function () {
44
45
  return _this.onHarvestFinished(...arguments);
@@ -48,11 +49,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
48
49
  return _this.onHarvestStarted(...arguments);
49
50
  });
50
51
  scheduler.startTimer(this.harvestTimeSeconds, 0);
52
+ this.drain();
51
53
  } else {
52
- this.blocked = true;
54
+ this.blocked = true; // if rum response determines that customer lacks entitlements for ins endpoint, this feature shouldn't harvest
55
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
53
56
  }
54
57
  });
55
- this.drain();
56
58
  }
57
59
  onHarvestStarted(options) {
58
60
  const {
@@ -17,6 +17,10 @@ var _aggregateBase = require("../../utils/aggregate-base");
17
17
  var _firstContentfulPaint = require("../../../common/vitals/first-contentful-paint");
18
18
  var _firstPaint = require("../../../common/vitals/first-paint");
19
19
  var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
20
+ var _drain = require("../../../common/drain/drain");
21
+ var _features = require("../../../loaders/features/features");
22
+ var _handle = require("../../../common/event-emitter/handle");
23
+ var _constants2 = require("../../metrics/constants");
20
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
26
  class Aggregate extends _aggregateBase.AggregateBase {
@@ -125,7 +129,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
125
129
  cbFinished: _ref3 => {
126
130
  let {
127
131
  status,
128
- responseText
132
+ responseText,
133
+ xhr,
134
+ fullUrl
129
135
  } = _ref3;
130
136
  if (status >= 400 || status === 0) {
131
137
  // Adding retry logic for the rum call will be a separate change
@@ -133,11 +139,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
133
139
  return;
134
140
  }
135
141
  try {
136
- (0, _featureFlags.activateFeatures)(JSON.parse(responseText), this.agentIdentifier);
142
+ this.timeKeeper.processRumRequest(xhr, fullUrl);
143
+ } catch (error) {
144
+ (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
145
+ (0, _drain.drain)(this.agentIdentifier, _features.FEATURE_NAMES.metrics, true);
146
+ this.ee.abort();
147
+ (0, _console.warn)('Could not calculate New Relic server time. Agent shutting down.');
148
+ return;
149
+ }
150
+ try {
151
+ const {
152
+ app,
153
+ ...flags
154
+ } = JSON.parse(responseText);
155
+ agentRuntime.appMetadata = app;
156
+ (0, _featureFlags.activateFeatures)(flags, this.agentIdentifier);
137
157
  this.drain();
138
158
  } catch (err) {
139
159
  this.ee.abort();
140
- (0, _console.warn)('RUM call failed. Agent shutting down.');
160
+ (0, _console.warn)('RUM call failed. Agent shutting down.', err);
141
161
  }
142
162
  }
143
163
  });
@@ -30,6 +30,7 @@ function getActivatedFeaturesFlags(agentId) {
30
30
  case _features.FEATURE_NAMES.sessionTrace:
31
31
  flagArr.push('stn');
32
32
  break;
33
+ case _features.FEATURE_NAMES.softNav:
33
34
  case _features.FEATURE_NAMES.spa:
34
35
  flagArr.push('spa');
35
36
  break;
@@ -43,17 +43,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
43
43
  this.timings = [];
44
44
  this.timingsSent = [];
45
45
  this.curSessEndRecorded = false;
46
- _firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
47
- _firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
48
- _firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
49
- _largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
50
- _interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
51
- _timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
52
- let {
53
- entries
54
- } = _ref2;
55
- this.addTiming('load', Math.round(entries[0].loadEventEnd));
56
- });
57
46
  if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
58
47
 
59
48
  /* It's important that CWV api, like "onLCP", is called before this scheduler is initialized. The reason is because they listen to the same
@@ -63,9 +52,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
63
52
  (0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
64
53
  const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
65
54
  const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
66
- // send initial data sooner, then start regular
67
- this.ee.on("drain-".concat(this.featureName), () => {
68
- this.scheduler = new _harvestScheduler.HarvestScheduler('events', {
55
+ this.waitForFlags([]).then(() => {
56
+ _firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
57
+ _firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
58
+ _firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
59
+ _largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
60
+ _interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
61
+ _timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
62
+ let {
63
+ entries
64
+ } = _ref2;
65
+ this.addTiming('load', Math.round(entries[0].loadEventEnd));
66
+ });
67
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
69
68
  onFinished: function () {
70
69
  return _this.onHarvestFinished(...arguments);
71
70
  },
@@ -73,9 +72,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
73
72
  return _this.prepareHarvest(...arguments);
74
73
  }
75
74
  }, this);
76
- this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
75
+ scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
76
+ this.drain();
77
77
  });
78
- this.drain();
79
78
  }
80
79
 
81
80
  /**