@newrelic/browser-agent 1.238.0 → 1.239.1

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 (249) hide show
  1. package/dist/cjs/common/config/state/init.js +21 -13
  2. package/dist/cjs/common/config/state/runtime.js +0 -4
  3. package/dist/cjs/common/constants/env.cdn.js +1 -1
  4. package/dist/cjs/common/constants/env.npm.js +1 -1
  5. package/dist/cjs/common/constants/runtime.js +3 -3
  6. package/dist/cjs/common/constants/shared-channel.js +3 -1
  7. package/dist/cjs/common/deny-list/deny-list.js +2 -8
  8. package/dist/cjs/common/drain/drain.js +1 -1
  9. package/dist/cjs/common/event-emitter/contextual-ee.js +6 -6
  10. package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
  11. package/dist/cjs/common/harvest/harvest.js +2 -6
  12. package/dist/cjs/common/serialize/bel-serializer.js +1 -1
  13. package/dist/cjs/common/session/session-entity.js +16 -12
  14. package/dist/cjs/common/storage/first-party-cookies.js +5 -4
  15. package/dist/cjs/common/storage/local-storage.js +3 -2
  16. package/dist/cjs/common/timer/interaction-timer.js +14 -6
  17. package/dist/cjs/common/timing/nav-timing.js +1 -1
  18. package/dist/cjs/common/unload/eol.js +4 -30
  19. package/dist/cjs/common/util/feature-flags.js +14 -15
  20. package/dist/cjs/common/util/invoke.js +3 -1
  21. package/dist/cjs/common/util/obfuscate.js +3 -5
  22. package/dist/cjs/common/util/traverse.js +1 -0
  23. package/dist/cjs/common/window/page-visibility.js +1 -2
  24. package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
  25. package/dist/cjs/features/ajax/aggregate/index.js +5 -7
  26. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -8
  27. package/dist/cjs/features/ajax/instrument/index.js +47 -15
  28. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
  29. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  30. package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
  31. package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
  32. package/dist/cjs/features/metrics/aggregate/index.js +20 -37
  33. package/dist/cjs/features/metrics/instrument/index.js +0 -2
  34. package/dist/cjs/features/page_action/aggregate/index.js +17 -19
  35. package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
  36. package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
  37. package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
  38. package/dist/cjs/features/session_replay/aggregate/index.js +3 -3
  39. package/dist/cjs/features/session_trace/aggregate/index.js +8 -8
  40. package/dist/cjs/features/spa/aggregate/index.js +14 -20
  41. package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
  42. package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
  43. package/dist/cjs/features/utils/aggregate-base.js +4 -0
  44. package/dist/cjs/features/utils/handler-cache.js +3 -1
  45. package/dist/cjs/features/utils/instrument-base.js +24 -6
  46. package/dist/cjs/loaders/agent-base.js +11 -0
  47. package/dist/cjs/loaders/agent.js +7 -7
  48. package/dist/cjs/loaders/api/api.js +21 -4
  49. package/dist/cjs/loaders/api/apiAsync.js +19 -20
  50. package/dist/cjs/loaders/configure/configure.js +3 -0
  51. package/dist/cjs/loaders/micro-agent.js +20 -3
  52. package/dist/esm/common/config/state/init.js +21 -13
  53. package/dist/esm/common/config/state/runtime.js +0 -4
  54. package/dist/esm/common/constants/env.cdn.js +1 -1
  55. package/dist/esm/common/constants/env.npm.js +1 -1
  56. package/dist/esm/common/constants/runtime.js +1 -1
  57. package/dist/esm/common/constants/shared-channel.js +3 -1
  58. package/dist/esm/common/deny-list/deny-list.js +2 -8
  59. package/dist/esm/common/drain/drain.js +1 -1
  60. package/dist/esm/common/event-emitter/contextual-ee.js +6 -6
  61. package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
  62. package/dist/esm/common/harvest/harvest.js +2 -6
  63. package/dist/esm/common/serialize/bel-serializer.js +1 -1
  64. package/dist/esm/common/session/session-entity.js +16 -12
  65. package/dist/esm/common/storage/first-party-cookies.js +5 -4
  66. package/dist/esm/common/storage/local-storage.js +3 -2
  67. package/dist/esm/common/timer/interaction-timer.js +14 -6
  68. package/dist/esm/common/timing/nav-timing.js +1 -1
  69. package/dist/esm/common/unload/eol.js +5 -31
  70. package/dist/esm/common/util/feature-flags.js +14 -15
  71. package/dist/esm/common/util/invoke.js +3 -1
  72. package/dist/esm/common/util/obfuscate.js +3 -5
  73. package/dist/esm/common/util/traverse.js +1 -0
  74. package/dist/esm/common/window/page-visibility.js +1 -2
  75. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  76. package/dist/esm/features/ajax/aggregate/index.js +5 -7
  77. package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -8
  78. package/dist/esm/features/ajax/instrument/index.js +47 -15
  79. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
  80. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  81. package/dist/esm/features/jserrors/aggregate/index.js +4 -5
  82. package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
  83. package/dist/esm/features/metrics/aggregate/index.js +22 -39
  84. package/dist/esm/features/metrics/instrument/index.js +1 -3
  85. package/dist/esm/features/page_action/aggregate/index.js +17 -19
  86. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  87. package/dist/esm/features/page_view_event/instrument/index.js +4 -2
  88. package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
  89. package/dist/esm/features/session_replay/aggregate/index.js +2 -2
  90. package/dist/esm/features/session_trace/aggregate/index.js +8 -8
  91. package/dist/esm/features/spa/aggregate/index.js +14 -20
  92. package/dist/esm/features/spa/aggregate/interaction.js +0 -2
  93. package/dist/esm/features/spa/aggregate/serializer.js +1 -1
  94. package/dist/esm/features/utils/aggregate-base.js +4 -0
  95. package/dist/esm/features/utils/handler-cache.js +3 -1
  96. package/dist/esm/features/utils/instrument-base.js +24 -6
  97. package/dist/esm/loaders/agent-base.js +11 -0
  98. package/dist/esm/loaders/agent.js +7 -7
  99. package/dist/esm/loaders/api/api.js +21 -4
  100. package/dist/esm/loaders/api/apiAsync.js +19 -20
  101. package/dist/esm/loaders/configure/configure.js +3 -0
  102. package/dist/esm/loaders/features/enabled-features.js +1 -1
  103. package/dist/esm/loaders/micro-agent.js +21 -4
  104. package/dist/types/common/config/state/init.d.ts.map +1 -1
  105. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  106. package/dist/types/common/constants/runtime.d.ts +1 -1
  107. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  108. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  110. package/dist/types/common/session/session-entity.d.ts +6 -9
  111. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  112. package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
  113. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
  114. package/dist/types/common/storage/local-storage.d.ts.map +1 -1
  115. package/dist/types/common/timer/interaction-timer.d.ts +3 -0
  116. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  117. package/dist/types/common/unload/eol.d.ts +1 -2
  118. package/dist/types/common/unload/eol.d.ts.map +1 -1
  119. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  120. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  121. package/dist/types/common/util/traverse.d.ts.map +1 -1
  122. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  123. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  124. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  125. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
  126. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  127. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  128. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -1
  129. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  130. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  131. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  132. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  133. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  134. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  135. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  136. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  137. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  138. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  139. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  140. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  141. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  142. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  143. package/dist/types/loaders/agent-base.d.ts +6 -0
  144. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  145. package/dist/types/loaders/agent.d.ts +1 -1
  146. package/dist/types/loaders/agent.d.ts.map +1 -1
  147. package/dist/types/loaders/api/api.d.ts +1 -0
  148. package/dist/types/loaders/api/api.d.ts.map +1 -1
  149. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  150. package/dist/types/loaders/configure/configure.d.ts +1 -0
  151. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  152. package/dist/types/loaders/micro-agent.d.ts +7 -1
  153. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  154. package/package.json +41 -12
  155. package/src/common/aggregate/aggregator.test.js +107 -0
  156. package/src/common/config/state/configurable.test.js +73 -0
  157. package/src/common/config/state/info.test.js +31 -0
  158. package/src/common/config/state/init.js +13 -12
  159. package/src/common/config/state/init.test.js +28 -0
  160. package/src/common/config/state/loader-config.test.js +21 -0
  161. package/src/common/config/state/runtime.js +0 -2
  162. package/src/common/config/state/runtime.test.js +21 -0
  163. package/src/common/constants/__mocks__/runtime.js +1 -1
  164. package/src/common/constants/runtime.js +1 -1
  165. package/src/common/constants/runtime.test.js +2 -2
  166. package/src/common/constants/shared-channel.js +1 -1
  167. package/src/common/deny-list/deny-list.js +2 -10
  168. package/src/common/drain/drain.js +1 -1
  169. package/src/common/drain/drain.test.js +74 -0
  170. package/src/common/event-emitter/contextual-ee.js +6 -6
  171. package/src/common/harvest/harvest-scheduler.js +2 -5
  172. package/src/common/harvest/harvest-scheduler.test.js +2 -6
  173. package/src/common/harvest/harvest.js +2 -6
  174. package/src/common/harvest/harvest.test.js +0 -2
  175. package/src/common/ids/id.test.js +6 -6
  176. package/src/common/serialize/bel-serializer.js +1 -1
  177. package/src/common/session/session-entity.component-test.js +3 -2
  178. package/src/common/session/session-entity.js +11 -9
  179. package/src/common/storage/first-party-cookies.js +5 -4
  180. package/src/common/storage/local-storage.js +3 -2
  181. package/src/common/timer/interaction-timer.component-test.js +52 -7
  182. package/src/common/timer/interaction-timer.js +15 -6
  183. package/src/common/timer/timer.test.js +0 -1
  184. package/src/common/timing/nav-timing.js +1 -1
  185. package/src/common/unload/eol.js +5 -31
  186. package/src/common/url/encode.test.js +1 -0
  187. package/src/common/util/__mocks__/invoke.js +1 -0
  188. package/src/common/util/data-size.test.js +0 -1
  189. package/src/common/util/feature-flags.js +15 -17
  190. package/src/common/util/feature-flags.test.js +4 -8
  191. package/src/common/util/invoke.js +1 -1
  192. package/src/common/util/obfuscate.js +3 -5
  193. package/src/common/util/submit-data.test.js +1 -1
  194. package/src/common/util/traverse.js +1 -0
  195. package/src/common/window/__mocks__/nreum.js +3 -1
  196. package/src/common/window/page-visibility.js +1 -2
  197. package/src/common/wrap/wrap-jsonp.js +1 -1
  198. package/src/features/ajax/aggregate/index.js +5 -7
  199. package/src/features/ajax/instrument/distributed-tracing.js +8 -8
  200. package/src/features/ajax/instrument/index.js +40 -17
  201. package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
  202. package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  203. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  204. package/src/features/jserrors/aggregate/index.js +4 -5
  205. package/src/features/metrics/aggregate/framework-detection.js +129 -8
  206. package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
  207. package/src/features/metrics/aggregate/index.js +22 -45
  208. package/src/features/metrics/instrument/index.js +1 -3
  209. package/src/features/page_action/aggregate/index.js +12 -13
  210. package/src/features/page_view_event/aggregate/index.js +1 -2
  211. package/src/features/page_view_event/instrument/index.js +2 -2
  212. package/src/features/page_view_timing/aggregate/index.js +7 -8
  213. package/src/features/session_replay/aggregate/index.component-test.js +3 -15
  214. package/src/features/session_replay/aggregate/index.js +2 -2
  215. package/src/features/session_trace/aggregate/index.js +6 -9
  216. package/src/features/spa/aggregate/index.js +14 -20
  217. package/src/features/spa/aggregate/interaction.js +0 -2
  218. package/src/features/spa/aggregate/serializer.js +1 -1
  219. package/src/features/utils/aggregate-base.js +5 -0
  220. package/src/features/utils/aggregate-base.test.js +2 -1
  221. package/src/features/utils/handler-cache.js +3 -2
  222. package/src/features/utils/instrument-base.js +25 -6
  223. package/src/features/utils/instrument-base.test.js +2 -2
  224. package/src/loaders/agent-base.js +11 -0
  225. package/src/loaders/agent.js +7 -7
  226. package/src/loaders/api/api.js +21 -4
  227. package/src/loaders/api/api.test.js +85 -0
  228. package/src/loaders/api/apiAsync.js +19 -20
  229. package/src/loaders/api/apiAsync.test.js +17 -0
  230. package/src/loaders/configure/configure.js +3 -0
  231. package/src/loaders/features/enabled-features.js +1 -1
  232. package/src/loaders/micro-agent.js +22 -4
  233. package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
  234. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
  235. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
  236. package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
  237. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  238. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
  239. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
  240. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
  241. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
  242. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
  243. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
  244. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
  245. package/src/features/metrics/aggregate/endpoint-map.js +0 -7
  246. package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  247. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
  248. package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
  249. package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
@@ -12,7 +12,6 @@ var _config = require("../../../common/config/config");
12
12
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
13
13
  var _denyList = require("../../../common/deny-list/deny-list");
14
14
  var _constants = require("../constants");
15
- var _drain = require("../../../common/drain/drain");
16
15
  var _features = require("../../../loaders/features/features");
17
16
  var _constants2 = require("../../metrics/constants");
18
17
  var _aggregateBase = require("../../utils/aggregate-base");
@@ -29,7 +28,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
29
28
  const allAjaxIsEnabled = agentInit.ajax.enabled !== false;
30
29
  (0, _registerHandler.registerHandler)('xhr', storeXhr, this.featureName, this.ee);
31
30
  if (!allAjaxIsEnabled) {
32
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
31
+ this.drain();
33
32
  return; // feature will only collect timeslice metrics & ajax trace nodes if it's not fully enabled
34
33
  }
35
34
 
@@ -71,8 +70,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
71
70
  ee.on("drain-".concat(this.featureName), () => {
72
71
  scheduler.startTimer(harvestTimeSeconds);
73
72
  });
74
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
75
- return;
73
+ this.drain();
76
74
  function storeXhr(params, metrics, startTime, endTime, type) {
77
75
  metrics.time = startTime;
78
76
 
@@ -104,9 +102,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
104
102
  path: params.pathname,
105
103
  requestSize: metrics.txSize,
106
104
  responseSize: metrics.rxSize,
107
- type: type,
108
- startTime: startTime,
109
- endTime: endTime,
105
+ type,
106
+ startTime,
107
+ endTime,
110
108
  callbackDuration: metrics.cbTime
111
109
  };
112
110
  if (xhrContext.dt) {
@@ -22,13 +22,13 @@ class DT {
22
22
  if (!this.shouldGenerateTrace(parsedOrigin)) {
23
23
  return null;
24
24
  }
25
- var loader_config = (0, _config.getLoaderConfig)(this.agentIdentifier);
26
- if (!loader_config) {
25
+ var loaderConfig = (0, _config.getLoaderConfig)(this.agentIdentifier);
26
+ if (!loaderConfig) {
27
27
  return null;
28
28
  }
29
- var accountId = (loader_config.accountID || '').toString() || null;
30
- var agentId = (loader_config.agentID || '').toString() || null;
31
- var trustKey = (loader_config.trustKey || '').toString() || null;
29
+ var accountId = (loaderConfig.accountID || '').toString() || null;
30
+ var agentId = (loaderConfig.agentID || '').toString() || null;
31
+ var trustKey = (loaderConfig.trustKey || '').toString() || null;
32
32
  if (!accountId || !agentId) {
33
33
  return null;
34
34
  }
@@ -36,9 +36,9 @@ class DT {
36
36
  var traceId = (0, _uniqueId.generateTraceId)();
37
37
  var timestamp = Date.now();
38
38
  var payload = {
39
- spanId: spanId,
40
- traceId: traceId,
41
- timestamp: timestamp
39
+ spanId,
40
+ traceId,
41
+ timestamp
42
42
  };
43
43
  if (parsedOrigin.sameOrigin || this.isAllowedOrigin(parsedOrigin) && this.useTraceContextHeadersForCors()) {
44
44
  payload.traceContextParentHeader = this.generateTraceContextParentHeader(spanId, traceId);
@@ -37,6 +37,38 @@ class Instrument extends _instrumentBase.InstrumentBase {
37
37
  if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
38
38
  this.dt = new _distributedTracing.DT(agentIdentifier);
39
39
  this.handler = (type, args, ctx, group) => (0, _handle.handle)(type, args, ctx, group, this.ee);
40
+
41
+ // this is a best (but imperfect) effort at capturing AJAX calls that may have fired before the agent was instantiated
42
+ // this could happen because the agent was "improperly" set up (ie, not at the top of the head) or
43
+ // because it was deferred from loading in some way -- e.g. 'deferred' script loading tags or other lazy-loading techniques
44
+ //
45
+ // it is "imperfect" because we cannot capture the following with the API vs wrapping the events directly:
46
+ // * requestBodySize - (txSize -- request body size)
47
+ // * method - request type (GET, POST, etc)
48
+ // * callbackDuration - (cbTime -- sum of resulting callback time)
49
+ try {
50
+ const initiators = {
51
+ xmlhttprequest: 'xhr',
52
+ fetch: 'fetch',
53
+ beacon: 'beacon'
54
+ };
55
+ _runtime.globalScope?.performance?.getEntriesByType('resource').forEach(resource => {
56
+ if (resource.initiatorType in initiators && resource.responseStatus !== 0) {
57
+ const params = {
58
+ status: resource.responseStatus
59
+ };
60
+ const metrics = {
61
+ rxSize: resource.transferSize,
62
+ duration: Math.floor(resource.duration),
63
+ cbTime: 0
64
+ };
65
+ addUrl(params, resource.name);
66
+ this.handler('xhr', [params, metrics, resource.startTime, resource.responseEnd, initiators[resource.initiatorType]], undefined, _features.FEATURE_NAMES.ajax);
67
+ }
68
+ });
69
+ } catch (err) {
70
+ // do nothing
71
+ }
40
72
  (0, _wrap.wrapFetch)(this.ee);
41
73
  (0, _wrap.wrapXhr)(this.ee);
42
74
  subscribeToEvents(agentIdentifier, this.ee, this.handler, this.dt);
@@ -97,9 +129,9 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
97
129
  this.metrics = {};
98
130
  }
99
131
  function onOpenXhrEnd(args, xhr) {
100
- var loader_config = (0, _config.getLoaderConfig)(agentIdentifier);
101
- if (loader_config.xpid && this.sameOrigin) {
102
- xhr.setRequestHeader('X-NewRelic-ID', loader_config.xpid);
132
+ var loaderConfig = (0, _config.getLoaderConfig)(agentIdentifier);
133
+ if (loaderConfig.xpid && this.sameOrigin) {
134
+ xhr.setRequestHeader('X-NewRelic-ID', loaderConfig.xpid);
103
135
  }
104
136
  var payload = dt.generateTracePayload(this.parsedOrigin);
105
137
  if (payload) {
@@ -281,7 +313,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
281
313
 
282
314
  // we capture failed call as status 0, the actual error is ignored
283
315
  // eslint-disable-next-line handle-callback-err
284
- function onFetchDone(err, res) {
316
+ function onFetchDone(_, res) {
285
317
  this.endTime = (0, _now.now)();
286
318
  if (!this.params) {
287
319
  this.params = {};
@@ -322,17 +354,6 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
322
354
  metrics.cbTime = this.cbTime;
323
355
  handler('xhr', [params, metrics, this.startTime, this.endTime, 'xhr'], this, _features.FEATURE_NAMES.ajax);
324
356
  }
325
- function addUrl(ctx, url) {
326
- var parsed = (0, _parseUrl.parseUrl)(url);
327
- var params = ctx.params;
328
- params.hostname = parsed.hostname;
329
- params.port = parsed.port;
330
- params.protocol = parsed.protocol;
331
- params.host = parsed.hostname + ':' + parsed.port;
332
- params.pathname = parsed.pathname;
333
- ctx.parsedOrigin = parsed;
334
- ctx.sameOrigin = parsed.sameOrigin;
335
- }
336
357
  function captureXhrData(ctx, xhr) {
337
358
  ctx.params.status = xhr.status;
338
359
  var size = (0, _responseSize.responseSizeFromXhr)(xhr, ctx.lastSize);
@@ -345,4 +366,15 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
345
366
  }
346
367
  ctx.loadCaptureCalled = true;
347
368
  }
369
+ }
370
+ function addUrl(ctx, url) {
371
+ var parsed = (0, _parseUrl.parseUrl)(url);
372
+ var params = ctx.params || ctx;
373
+ params.hostname = parsed.hostname;
374
+ params.port = parsed.port;
375
+ params.protocol = parsed.protocol;
376
+ params.host = parsed.hostname + ':' + parsed.port;
377
+ params.pathname = parsed.pathname;
378
+ ctx.parsedOrigin = parsed;
379
+ ctx.sameOrigin = parsed.sameOrigin;
348
380
  }
@@ -22,5 +22,4 @@ function canonicalFunctionName(functionNameString) {
22
22
  if (!functionNameString) return;
23
23
  const match = functionNameString.match(canonicalFunctionNameRe);
24
24
  if (match) return match[1];
25
- return;
26
25
  }
@@ -69,8 +69,8 @@ var debug = false;
69
69
  var classNameRegex = /function (.+?)\s*\(/;
70
70
  var chrome = /^\s*at (?:((?:\[object object\])?(?:[^(]*\([^)]*\))*[^()]*(?: \[as \S+\])?) )?\(?((?:file|http|https|chrome-extension):.*?)?:(\d+)(?::(\d+))?\)?\s*$/i;
71
71
  var gecko = /^\s*(?:(\S*|global code)(?:\(.*?\))?@)?((?:file|http|https|chrome|safari-extension).*?):(\d+)(?::(\d+))?\s*$/i;
72
- var chrome_eval = /^\s*at .+ \(eval at \S+ \((?:(?:file|http|https):[^)]+)?\)(?:, [^:]*:\d+:\d+)?\)$/i;
73
- var ie_eval = /^\s*at Function code \(Function code:\d+:\d+\)\s*/i;
72
+ var chromeEval = /^\s*at .+ \(eval at \S+ \((?:(?:file|http|https):[^)]+)?\)(?:, [^:]*:\d+:\d+)?\)$/i;
73
+ var ieEval = /^\s*at Function code \(Function code:\d+:\d+\)\s*/i;
74
74
 
75
75
  /**
76
76
  * Represents an error with a stack trace.
@@ -204,7 +204,7 @@ function getStackElement(line) {
204
204
  column: parts[4] ? +parts[4] : null
205
205
  };
206
206
  }
207
- if (line.match(chrome_eval) || line.match(ie_eval) || line === 'anonymous') {
207
+ if (line.match(chromeEval) || line.match(ieEval) || line === 'anonymous') {
208
208
  return {
209
209
  func: 'evaluated code'
210
210
  };
@@ -249,7 +249,7 @@ function computeStackTraceBySourceAndLine(ex) {
249
249
  mode: 'sourceline',
250
250
  name: className,
251
251
  message: ex.message,
252
- stackString: stackString,
252
+ stackString,
253
253
  frames: [{
254
254
  url: canonicalUrl,
255
255
  line: ex.line,
@@ -17,7 +17,6 @@ var _config = require("../../../common/config/config");
17
17
  var _now = require("../../../common/timing/now");
18
18
  var _runtime = require("../../../common/constants/runtime");
19
19
  var _constants = require("../constants");
20
- var _drain = require("../../../common/drain/drain");
21
20
  var _features = require("../../../loaders/features/features");
22
21
  var _aggregateBase = require("../../utils/aggregate-base");
23
22
  /*
@@ -39,7 +38,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
39
38
  this.observedAt = {};
40
39
  this.pageviewReported = {};
41
40
  this.errorCache = {};
42
- this.currentBody;
41
+ this.currentBody = undefined;
43
42
  this.errorOnPage = false;
44
43
 
45
44
  // this will need to change to match whatever ee we use in the instrument
@@ -73,7 +72,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
73
72
  this.blocked = true;
74
73
  scheduler.stopTimer(true);
75
74
  }, this.featureName, this.ee);
76
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
75
+ this.drain();
77
76
  }
78
77
  onHarvestStarted(options) {
79
78
  // this gets rid of dependency in AJAX module
@@ -82,7 +81,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
82
81
  this.currentBody = body;
83
82
  }
84
83
  var payload = {
85
- body: body,
84
+ body,
86
85
  qs: {}
87
86
  };
88
87
  var releaseIds = (0, _stringify.stringify)((0, _config.getRuntime)(this.agentIdentifier).releaseIds);
@@ -192,7 +191,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
192
191
  params.firstOccurrenceTimestamp = this.observedAt[bucketHash];
193
192
  var type = internal ? 'ierr' : 'err';
194
193
  var newMetrics = {
195
- time: time
194
+ time
196
195
  };
197
196
 
198
197
  // sr, stn and spa aggregators listen to this event - stn sends the error in its payload,
@@ -7,31 +7,59 @@ exports.getFrameworks = getFrameworks;
7
7
  var _runtime = require("../../../common/constants/runtime");
8
8
  const FRAMEWORKS = {
9
9
  REACT: 'React',
10
+ NEXTJS: 'NextJS',
11
+ VUE: 'Vue',
12
+ NUXTJS: 'NuxtJS',
10
13
  ANGULAR: 'Angular',
14
+ ANGULARUNIVERSAL: 'AngularUniversal',
15
+ SVELTE: 'Svelte',
16
+ SVELTEKIT: 'SvelteKit',
17
+ PREACT: 'Preact',
18
+ PREACTSSR: 'PreactSSR',
11
19
  ANGULARJS: 'AngularJS',
12
20
  BACKBONE: 'Backbone',
13
21
  EMBER: 'Ember',
14
- VUE: 'Vue',
15
22
  METEOR: 'Meteor',
16
23
  ZEPTO: 'Zepto',
17
24
  JQUERY: 'Jquery',
18
- MOOTOOLS: 'MooTools'
25
+ MOOTOOLS: 'MooTools',
26
+ QWIK: 'Qwik',
27
+ ELECTRON: 'Electron'
19
28
  };
20
29
  function getFrameworks() {
21
30
  if (!_runtime.isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
22
31
 
23
32
  const frameworks = [];
24
33
  try {
25
- if (detectReact()) frameworks.push(FRAMEWORKS.REACT);
34
+ if (detectReact()) {
35
+ frameworks.push(FRAMEWORKS.REACT);
36
+ if (detectNextJS()) frameworks.push(FRAMEWORKS.NEXTJS);
37
+ }
38
+ if (detectVue()) {
39
+ frameworks.push(FRAMEWORKS.VUE);
40
+ if (detectNuxtJS()) frameworks.push(FRAMEWORKS.NUXTJS);
41
+ }
42
+ if (detectAngular()) {
43
+ frameworks.push(FRAMEWORKS.ANGULAR);
44
+ if (detectAngularUniversal()) frameworks.push(FRAMEWORKS.ANGULARUNIVERSAL);
45
+ }
46
+ if (detectSvelte()) {
47
+ frameworks.push(FRAMEWORKS.SVELTE);
48
+ if (detectSvelteKit()) frameworks.push(FRAMEWORKS.SVELTEKIT);
49
+ }
50
+ if (detectPreact()) {
51
+ frameworks.push(FRAMEWORKS.PREACT);
52
+ if (detectPreactSSR()) frameworks.push(FRAMEWORKS.PREACTSSR);
53
+ }
26
54
  if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS);
27
- if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR);
28
55
  if (Object.prototype.hasOwnProperty.call(window, 'Backbone')) frameworks.push(FRAMEWORKS.BACKBONE);
29
56
  if (Object.prototype.hasOwnProperty.call(window, 'Ember')) frameworks.push(FRAMEWORKS.EMBER);
30
- if (Object.prototype.hasOwnProperty.call(window, 'Vue')) frameworks.push(FRAMEWORKS.VUE);
31
57
  if (Object.prototype.hasOwnProperty.call(window, 'Meteor')) frameworks.push(FRAMEWORKS.METEOR);
32
58
  if (Object.prototype.hasOwnProperty.call(window, 'Zepto')) frameworks.push(FRAMEWORKS.ZEPTO);
33
59
  if (Object.prototype.hasOwnProperty.call(window, 'jQuery')) frameworks.push(FRAMEWORKS.JQUERY);
34
60
  if (Object.prototype.hasOwnProperty.call(window, 'MooTools')) frameworks.push(FRAMEWORKS.MOOTOOLS);
61
+ if (Object.prototype.hasOwnProperty.call(window, 'qwikevents')) frameworks.push(FRAMEWORKS.QWIK);
62
+ if (detectElectron()) frameworks.push(FRAMEWORKS.ELECTRON);
35
63
  } catch (err) {
36
64
  // Possibly not supported
37
65
  }
@@ -51,9 +79,25 @@ function detectReact() {
51
79
  return false;
52
80
  }
53
81
  }
54
- function detectAngularJs() {
82
+ function detectNextJS() {
83
+ // React SSR
55
84
  try {
56
- return Object.prototype.hasOwnProperty.call(window, 'angular') || document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]') || document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]');
85
+ return Object.prototype.hasOwnProperty.call(window, 'next') && Object.prototype.hasOwnProperty.call(window.next, 'version');
86
+ } catch (err) {
87
+ return false;
88
+ }
89
+ }
90
+ function detectVue() {
91
+ try {
92
+ return Object.prototype.hasOwnProperty.call(window, 'Vue');
93
+ } catch (err) {
94
+ return false;
95
+ }
96
+ }
97
+ function detectNuxtJS() {
98
+ // Vue SSR
99
+ try {
100
+ return Object.prototype.hasOwnProperty.call(window, '$nuxt') && Object.prototype.hasOwnProperty.call(window.$nuxt, 'nuxt');
57
101
  } catch (err) {
58
102
  return false;
59
103
  }
@@ -64,4 +108,56 @@ function detectAngular() {
64
108
  } catch (err) {
65
109
  return false;
66
110
  }
111
+ }
112
+ function detectAngularUniversal() {
113
+ // Anguler SSR
114
+ try {
115
+ return document.querySelector('[ng-server-context]');
116
+ } catch (err) {
117
+ return false;
118
+ }
119
+ }
120
+ function detectSvelte() {
121
+ try {
122
+ return Object.prototype.hasOwnProperty.call(window, '__svelte');
123
+ } catch (err) {
124
+ return false;
125
+ }
126
+ }
127
+ function detectSvelteKit() {
128
+ // Svelte SSR
129
+ try {
130
+ return !!Object.keys(window).find(prop => prop.startsWith('__sveltekit'));
131
+ } catch (err) {
132
+ return false;
133
+ }
134
+ }
135
+ function detectPreact() {
136
+ try {
137
+ return Object.prototype.hasOwnProperty.call(window, 'preact');
138
+ } catch (err) {
139
+ return false;
140
+ }
141
+ }
142
+ function detectPreactSSR() {
143
+ // Svelte SSR
144
+ try {
145
+ return document.querySelector('script[type="__PREACT_CLI_DATA__"]');
146
+ } catch (err) {
147
+ return false;
148
+ }
149
+ }
150
+ function detectAngularJs() {
151
+ try {
152
+ return Object.prototype.hasOwnProperty.call(window, 'angular') || document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]') || document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]');
153
+ } catch (err) {
154
+ return false;
155
+ }
156
+ }
157
+ function detectElectron() {
158
+ try {
159
+ return typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0;
160
+ } catch (err) {
161
+ return false;
162
+ }
67
163
  }
@@ -8,18 +8,13 @@ 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
10
  var _constants = require("../constants");
11
- var _drain = require("../../../common/drain/drain");
12
11
  var _frameworkDetection = require("./framework-detection");
13
- var _polyfillDetection = require("./polyfill-detection");
14
12
  var _protocol = require("../../../common/url/protocol");
15
13
  var _obfuscate = require("../../../common/util/obfuscate");
16
- var _env = require("../../../common/constants/env.npm");
17
14
  var _load = require("../../../common/window/load");
18
15
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
19
16
  var _runtime = require("../../../common/constants/runtime");
20
17
  var _aggregateBase = require("../../utils/aggregate-base");
21
- var _stringify = require("../../../common/util/stringify");
22
- var _endpointMap = require("./endpoint-map");
23
18
  class Aggregate extends _aggregateBase.AggregateBase {
24
19
  static featureName = _constants.FEATURE_NAME;
25
20
  constructor(agentIdentifier, aggregator) {
@@ -45,9 +40,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
45
40
  scheduler.harvest.on('jserrors', () => ({
46
41
  body: this.aggregator.take(['cm', 'sm'])
47
42
  }));
48
- (0, _drain.drain)(this.agentIdentifier, this.featureName); // regardless if this is blocked or not, drain is needed to unblock other features from harvesting (counteract registerDrain)
43
+ this.drain();
49
44
  }
50
-
51
45
  storeSupportabilityMetrics(name, value) {
52
46
  if (this.blocked) return;
53
47
  const type = _constants.SUPPORTABILITY_METRIC;
@@ -65,9 +59,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
65
59
  this.aggregator.store(type, name, params, metrics);
66
60
  }
67
61
  singleChecks() {
68
- // report generic info about the agent itself
69
- // note the browser agent version
70
- this.storeSupportabilityMetrics("Generic/Version/".concat(_env.VERSION, "/Detected"));
71
62
  // report loaderType
72
63
  const {
73
64
  distMethod,
@@ -78,22 +69,27 @@ class Aggregate extends _aggregateBase.AggregateBase {
78
69
 
79
70
  // frameworks on page
80
71
  if (_runtime.isBrowserScope) {
72
+ this.storeSupportabilityMetrics('Generic/Runtime/Browser/Detected');
73
+
74
+ // These SMs are used by the AppExp team
81
75
  (0, _load.onDOMContentLoaded)(() => {
82
76
  (0, _frameworkDetection.getFrameworks)().forEach(framework => {
83
77
  this.storeSupportabilityMetrics('Framework/' + framework + '/Detected');
84
78
  });
85
79
  });
80
+ } else if (_runtime.isWorkerScope) {
81
+ this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
82
+ } else {
83
+ this.storeSupportabilityMetrics('Generic/Runtime/Unknown/Detected');
86
84
  }
87
- (0, _polyfillDetection.getPolyfills)().forEach(polyfill => {
88
- this.storeSupportabilityMetrics('Polyfill/' + polyfill + '/Detected');
89
- });
90
85
 
91
- // file protocol detection
86
+ // Track if the agent is being loaded using a file protocol such as is the case in some
87
+ // set-top box applications or Electron applications
92
88
  if ((0, _protocol.isFileProtocol)()) {
93
89
  this.storeSupportabilityMetrics('Generic/FileProtocol/Detected');
94
90
  }
95
91
 
96
- // obfuscation rules detection
92
+ // Capture SMs to assess customer engagement with the obfuscation config
97
93
  const rules = (0, _obfuscate.getRules)(this.agentIdentifier);
98
94
  if (rules.length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
99
95
  if (rules.length > 0 && !(0, _obfuscate.validateRules)(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
@@ -106,18 +102,17 @@ class Aggregate extends _aggregateBase.AggregateBase {
106
102
  if (evt.persisted) {
107
103
  this.storeSupportabilityMetrics('Generic/BFCache/PageRestored');
108
104
  }
109
- return;
110
105
  });
111
106
  }
112
107
  unload() {
113
- // Page Resources detection for estimations with resources feature work
114
- // TODO - these SMs are to be removed when we implement the actual resources feature
115
108
  try {
116
109
  if (this.resourcesSent) return;
110
+ this.resourcesSent = true; // make sure this only gets sent once
111
+
117
112
  const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
118
- const info = (0, _config.getInfo)(this.agentIdentifier);
119
- // make sure this only gets sent once
120
- this.resourcesSent = true;
113
+
114
+ // Capture SMs around network resources using the performance API to assess
115
+ // work to split this out from the ST nodes
121
116
  // differentiate between internal+external and ajax+non-ajax
122
117
  const ajaxResources = ['beacon', 'fetch', 'xmlhttprequest'];
123
118
  const internalUrls = ['nr-data.net', 'newrelic.com', 'nr-local.net', 'localhost'];
@@ -136,26 +131,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
136
131
  }
137
132
  });
138
133
 
139
- // Capture per-agent 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(_endpointMap.endpointMap[endpoint], "/BytesSent"), agentRuntime.bytesSent[endpoint]);
142
- });
143
-
144
- // Capture per-agent query bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
145
- Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
146
- this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(_endpointMap.endpointMap[endpoint], "/QueryBytesSent"), agentRuntime.queryBytesSent[endpoint]);
147
- });
148
-
149
- // Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
134
+ // Capture SMs for session trace if active (`ptid` is set when returned by replay ingest).
135
+ // Retain these SMs while we are working through the session_replay feature
150
136
  if (agentRuntime.ptid) {
151
137
  this.storeSupportabilityMetrics('PageSession/Feature/SessionTrace/DurationMs', Math.round(performance.now()));
152
138
  }
153
139
 
154
- // Capture metrics for size of custom attributes
155
- const jsAttributes = (0, _stringify.stringify)(info.jsAttributes);
156
- this.storeSupportabilityMetrics('PageSession/Feature/CustomData/Bytes', jsAttributes === '{}' ? 0 : jsAttributes.length);
157
-
158
- // Capture metrics for performance markers and measures
140
+ // Capture SMs for performance markers and measures to assess the usage and possible inclusion of this
141
+ // data in the agent for use in NR
159
142
  if (typeof performance !== 'undefined') {
160
143
  const markers = performance.getEntriesByType('mark');
161
144
  const measures = performance.getEntriesByType('measure');
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Instrument = void 0;
7
7
  var _instrumentBase = require("../../utils/instrument-base");
8
8
  var _constants = require("../constants");
9
- var _handle = require("../../../common/event-emitter/handle");
10
- var _features = require("../../../loaders/features/features");
11
9
  class Instrument extends _instrumentBase.InstrumentBase {
12
10
  static featureName = _constants.FEATURE_NAME;
13
11
  constructor(agentIdentifier, aggregator) {
@@ -11,7 +11,6 @@ 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
13
  var _constants = require("../constants");
14
- var _drain = require("../../../common/drain/drain");
15
14
  var _runtime = require("../../../common/constants/runtime");
16
15
  var _aggregateBase = require("../../utils/aggregate-base");
17
16
  /*
@@ -28,8 +27,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
28
27
  this.eventsPerMinute = 240;
29
28
  this.harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_action.harvestTimeSeconds') || (0, _config.getConfigurationValue)(this.agentIdentifier, 'ins.harvestTimeSeconds') || 30;
30
29
  this.eventsPerHarvest = this.eventsPerMinute * this.harvestTimeSeconds / 60;
31
- this.referrerUrl;
32
- this.currentEvents;
30
+ this.referrerUrl = undefined;
31
+ this.currentEvents = undefined;
33
32
  this.events = [];
34
33
  this.att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes; // per-agent, aggregators-shared info context
35
34
 
@@ -37,24 +36,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
37
36
  (0, _registerHandler.registerHandler)('api-addPageAction', function () {
38
37
  return _this.addPageAction(...arguments);
39
38
  }, this.featureName, this.ee);
40
- var scheduler = new _harvestScheduler.HarvestScheduler('ins', {
41
- onFinished: function () {
42
- return _this.onHarvestFinished(...arguments);
39
+ this.waitForFlags(['ins']).then(_ref => {
40
+ let [enabled] = _ref;
41
+ if (enabled) {
42
+ const scheduler = new _harvestScheduler.HarvestScheduler('ins', {
43
+ onFinished: function () {
44
+ return _this.onHarvestFinished(...arguments);
45
+ }
46
+ }, this);
47
+ scheduler.harvest.on('ins', function () {
48
+ return _this.onHarvestStarted(...arguments);
49
+ });
50
+ scheduler.startTimer(this.harvestTimeSeconds, 0);
51
+ } else {
52
+ this.blocked = true;
43
53
  }
44
- }, this);
45
- scheduler.harvest.on('ins', function () {
46
- return _this.onHarvestStarted(...arguments);
47
54
  });
48
- this.ee.on("drain-".concat(this.featureName), () => {
49
- if (!this.blocked) scheduler.startTimer(this.harvestTimeSeconds, 0);
50
- });
51
-
52
- // if rum response determines that customer lacks entitlements for ins endpoint, block it
53
- (0, _registerHandler.registerHandler)('block-ins', () => {
54
- this.blocked = true;
55
- scheduler.stopTimer(true);
56
- }, this.featureName, this.ee);
57
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
55
+ this.drain();
58
56
  }
59
57
  onHarvestStarted(options) {
60
58
  const {
@@ -15,7 +15,6 @@ var _config = require("../../../common/config/config");
15
15
  var _harvest = require("../../../common/harvest/harvest");
16
16
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
17
17
  var _initializedFeatures = require("./initialized-features");
18
- var _drain = require("../../../common/drain/drain");
19
18
  var _featureFlags = require("../../../common/util/feature-flags");
20
19
  var _console = require("../../../common/util/console");
21
20
  var _aggregateBase = require("../../utils/aggregate-base");
@@ -155,7 +154,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
155
154
  }
156
155
  try {
157
156
  (0, _featureFlags.activateFeatures)(JSON.parse(responseText), this.agentIdentifier);
158
- (0, _drain.drain)(this.agentIdentifier, this.featureName);
157
+ this.drain();
159
158
  } catch (err) {
160
159
  this.ee.abort();
161
160
  (0, _console.warn)('RUM call failed. Agent shutting down.');
@@ -21,10 +21,12 @@ class Instrument extends _instrumentBase.InstrumentBase {
21
21
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
22
22
  if ((typeof PerformanceNavigationTiming === 'undefined' || _runtime.isiOS) && typeof PerformanceTiming !== 'undefined') {
23
23
  // For majority browser versions in which PNT exists, we can get load timings later from the nav entry (in the aggregate portion). At minimum, PT should exist for main window.
24
- // *cli Mar'23 - iOS 15.2 & 15.4 testing in Sauce still fails with onTTFB. Hence, all iOS will fallback to this for now. Unknown if this is similar in nature to iOS_below16 bug.
24
+ // *cli Mar'23 - iOS 15.2 & 15.4 testing in Sauce still fails with onTTFB. Hence, all iOS will fallback to this for now. Unknown if this is similar in nature to iOSBelow16 bug.
25
25
  const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
26
26
  agentRuntime[CONSTANTS.TTFB] = Math.max(Date.now() - agentRuntime.offset, 0);
27
- (0, _load.onDOMContentLoaded)(() => agentRuntime[CONSTANTS.FBTDC] = Math.max((0, _now.now)() - agentRuntime[CONSTANTS.TTFB], 0));
27
+ (0, _load.onDOMContentLoaded)(() => {
28
+ agentRuntime[CONSTANTS.FBTDC] = Math.max((0, _now.now)() - agentRuntime[CONSTANTS.TTFB], 0);
29
+ });
28
30
  (0, _load.onWindowLoad)(() => {
29
31
  const timeNow = (0, _now.now)();
30
32
  agentRuntime[CONSTANTS.FBTWL] = Math.max(timeNow - agentRuntime[CONSTANTS.TTFB], 0);