@newrelic/browser-agent 1.238.0 → 1.239.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 (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
@@ -15,13 +15,13 @@ export class DT {
15
15
  if (!this.shouldGenerateTrace(parsedOrigin)) {
16
16
  return null;
17
17
  }
18
- var loader_config = getLoaderConfig(this.agentIdentifier);
19
- if (!loader_config) {
18
+ var loaderConfig = getLoaderConfig(this.agentIdentifier);
19
+ if (!loaderConfig) {
20
20
  return null;
21
21
  }
22
- var accountId = (loader_config.accountID || '').toString() || null;
23
- var agentId = (loader_config.agentID || '').toString() || null;
24
- var trustKey = (loader_config.trustKey || '').toString() || null;
22
+ var accountId = (loaderConfig.accountID || '').toString() || null;
23
+ var agentId = (loaderConfig.agentID || '').toString() || null;
24
+ var trustKey = (loaderConfig.trustKey || '').toString() || null;
25
25
  if (!accountId || !agentId) {
26
26
  return null;
27
27
  }
@@ -29,9 +29,9 @@ export class DT {
29
29
  var traceId = generateTraceId();
30
30
  var timestamp = Date.now();
31
31
  var payload = {
32
- spanId: spanId,
33
- traceId: traceId,
34
- timestamp: timestamp
32
+ spanId,
33
+ traceId,
34
+ timestamp
35
35
  };
36
36
  if (parsedOrigin.sameOrigin || this.isAllowedOrigin(parsedOrigin) && this.useTraceContextHeadersForCors()) {
37
37
  payload.traceContextParentHeader = this.generateTraceContextParentHeader(spanId, traceId);
@@ -30,6 +30,38 @@ export class Instrument extends InstrumentBase {
30
30
  if (!getRuntime(agentIdentifier).xhrWrappable) return;
31
31
  this.dt = new DT(agentIdentifier);
32
32
  this.handler = (type, args, ctx, group) => handle(type, args, ctx, group, this.ee);
33
+
34
+ // this is a best (but imperfect) effort at capturing AJAX calls that may have fired before the agent was instantiated
35
+ // this could happen because the agent was "improperly" set up (ie, not at the top of the head) or
36
+ // because it was deferred from loading in some way -- e.g. 'deferred' script loading tags or other lazy-loading techniques
37
+ //
38
+ // it is "imperfect" because we cannot capture the following with the API vs wrapping the events directly:
39
+ // * requestBodySize - (txSize -- request body size)
40
+ // * method - request type (GET, POST, etc)
41
+ // * callbackDuration - (cbTime -- sum of resulting callback time)
42
+ try {
43
+ const initiators = {
44
+ xmlhttprequest: 'xhr',
45
+ fetch: 'fetch',
46
+ beacon: 'beacon'
47
+ };
48
+ globalScope?.performance?.getEntriesByType('resource').forEach(resource => {
49
+ if (resource.initiatorType in initiators && resource.responseStatus !== 0) {
50
+ const params = {
51
+ status: resource.responseStatus
52
+ };
53
+ const metrics = {
54
+ rxSize: resource.transferSize,
55
+ duration: Math.floor(resource.duration),
56
+ cbTime: 0
57
+ };
58
+ addUrl(params, resource.name);
59
+ this.handler('xhr', [params, metrics, resource.startTime, resource.responseEnd, initiators[resource.initiatorType]], undefined, FEATURE_NAMES.ajax);
60
+ }
61
+ });
62
+ } catch (err) {
63
+ // do nothing
64
+ }
33
65
  wrapFetch(this.ee);
34
66
  wrapXhr(this.ee);
35
67
  subscribeToEvents(agentIdentifier, this.ee, this.handler, this.dt);
@@ -89,9 +121,9 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
89
121
  this.metrics = {};
90
122
  }
91
123
  function onOpenXhrEnd(args, xhr) {
92
- var loader_config = getLoaderConfig(agentIdentifier);
93
- if (loader_config.xpid && this.sameOrigin) {
94
- xhr.setRequestHeader('X-NewRelic-ID', loader_config.xpid);
124
+ var loaderConfig = getLoaderConfig(agentIdentifier);
125
+ if (loaderConfig.xpid && this.sameOrigin) {
126
+ xhr.setRequestHeader('X-NewRelic-ID', loaderConfig.xpid);
95
127
  }
96
128
  var payload = dt.generateTracePayload(this.parsedOrigin);
97
129
  if (payload) {
@@ -273,7 +305,7 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
273
305
 
274
306
  // we capture failed call as status 0, the actual error is ignored
275
307
  // eslint-disable-next-line handle-callback-err
276
- function onFetchDone(err, res) {
308
+ function onFetchDone(_, res) {
277
309
  this.endTime = now();
278
310
  if (!this.params) {
279
311
  this.params = {};
@@ -314,17 +346,6 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
314
346
  metrics.cbTime = this.cbTime;
315
347
  handler('xhr', [params, metrics, this.startTime, this.endTime, 'xhr'], this, FEATURE_NAMES.ajax);
316
348
  }
317
- function addUrl(ctx, url) {
318
- var parsed = parseUrl(url);
319
- var params = ctx.params;
320
- params.hostname = parsed.hostname;
321
- params.port = parsed.port;
322
- params.protocol = parsed.protocol;
323
- params.host = parsed.hostname + ':' + parsed.port;
324
- params.pathname = parsed.pathname;
325
- ctx.parsedOrigin = parsed;
326
- ctx.sameOrigin = parsed.sameOrigin;
327
- }
328
349
  function captureXhrData(ctx, xhr) {
329
350
  ctx.params.status = xhr.status;
330
351
  var size = responseSizeFromXhr(xhr, ctx.lastSize);
@@ -337,4 +358,15 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
337
358
  }
338
359
  ctx.loadCaptureCalled = true;
339
360
  }
361
+ }
362
+ function addUrl(ctx, url) {
363
+ var parsed = parseUrl(url);
364
+ var params = ctx.params || ctx;
365
+ params.hostname = parsed.hostname;
366
+ params.port = parsed.port;
367
+ params.protocol = parsed.protocol;
368
+ params.host = parsed.hostname + ':' + parsed.port;
369
+ params.pathname = parsed.pathname;
370
+ ctx.parsedOrigin = parsed;
371
+ ctx.sameOrigin = parsed.sameOrigin;
340
372
  }
@@ -16,5 +16,4 @@ export function canonicalFunctionName(functionNameString) {
16
16
  if (!functionNameString) return;
17
17
  const match = functionNameString.match(canonicalFunctionNameRe);
18
18
  if (match) return match[1];
19
- return;
20
19
  }
@@ -62,8 +62,8 @@ var debug = false;
62
62
  var classNameRegex = /function (.+?)\s*\(/;
63
63
  var chrome = /^\s*at (?:((?:\[object object\])?(?:[^(]*\([^)]*\))*[^()]*(?: \[as \S+\])?) )?\(?((?:file|http|https|chrome-extension):.*?)?:(\d+)(?::(\d+))?\)?\s*$/i;
64
64
  var gecko = /^\s*(?:(\S*|global code)(?:\(.*?\))?@)?((?:file|http|https|chrome|safari-extension).*?):(\d+)(?::(\d+))?\s*$/i;
65
- var chrome_eval = /^\s*at .+ \(eval at \S+ \((?:(?:file|http|https):[^)]+)?\)(?:, [^:]*:\d+:\d+)?\)$/i;
66
- var ie_eval = /^\s*at Function code \(Function code:\d+:\d+\)\s*/i;
65
+ var chromeEval = /^\s*at .+ \(eval at \S+ \((?:(?:file|http|https):[^)]+)?\)(?:, [^:]*:\d+:\d+)?\)$/i;
66
+ var ieEval = /^\s*at Function code \(Function code:\d+:\d+\)\s*/i;
67
67
 
68
68
  /**
69
69
  * Represents an error with a stack trace.
@@ -197,7 +197,7 @@ function getStackElement(line) {
197
197
  column: parts[4] ? +parts[4] : null
198
198
  };
199
199
  }
200
- if (line.match(chrome_eval) || line.match(ie_eval) || line === 'anonymous') {
200
+ if (line.match(chromeEval) || line.match(ieEval) || line === 'anonymous') {
201
201
  return {
202
202
  func: 'evaluated code'
203
203
  };
@@ -242,7 +242,7 @@ function computeStackTraceBySourceAndLine(ex) {
242
242
  mode: 'sourceline',
243
243
  name: className,
244
244
  message: ex.message,
245
- stackString: stackString,
245
+ stackString,
246
246
  frames: [{
247
247
  url: canonicalUrl,
248
248
  line: ex.line,
@@ -16,7 +16,6 @@ import { getInfo, getConfigurationValue, getRuntime } from '../../../common/conf
16
16
  import { now } from '../../../common/timing/now';
17
17
  import { globalScope } from '../../../common/constants/runtime';
18
18
  import { FEATURE_NAME } from '../constants';
19
- import { drain } from '../../../common/drain/drain';
20
19
  import { FEATURE_NAMES } from '../../../loaders/features/features';
21
20
  import { AggregateBase } from '../../utils/aggregate-base';
22
21
 
@@ -34,7 +33,7 @@ export class Aggregate extends AggregateBase {
34
33
  this.observedAt = {};
35
34
  this.pageviewReported = {};
36
35
  this.errorCache = {};
37
- this.currentBody;
36
+ this.currentBody = undefined;
38
37
  this.errorOnPage = false;
39
38
 
40
39
  // this will need to change to match whatever ee we use in the instrument
@@ -68,7 +67,7 @@ export class Aggregate extends AggregateBase {
68
67
  this.blocked = true;
69
68
  scheduler.stopTimer(true);
70
69
  }, this.featureName, this.ee);
71
- drain(this.agentIdentifier, this.featureName);
70
+ this.drain();
72
71
  }
73
72
  onHarvestStarted(options) {
74
73
  // this gets rid of dependency in AJAX module
@@ -77,7 +76,7 @@ export class Aggregate extends AggregateBase {
77
76
  this.currentBody = body;
78
77
  }
79
78
  var payload = {
80
- body: body,
79
+ body,
81
80
  qs: {}
82
81
  };
83
82
  var releaseIds = stringify(getRuntime(this.agentIdentifier).releaseIds);
@@ -187,7 +186,7 @@ export class Aggregate extends AggregateBase {
187
186
  params.firstOccurrenceTimestamp = this.observedAt[bucketHash];
188
187
  var type = internal ? 'ierr' : 'err';
189
188
  var newMetrics = {
190
- time: time
189
+ time
191
190
  };
192
191
 
193
192
  // sr, stn and spa aggregators listen to this event - stn sends the error in its payload,
@@ -1,31 +1,59 @@
1
1
  import { isBrowserScope } from '../../../common/constants/runtime';
2
2
  const FRAMEWORKS = {
3
3
  REACT: 'React',
4
+ NEXTJS: 'NextJS',
5
+ VUE: 'Vue',
6
+ NUXTJS: 'NuxtJS',
4
7
  ANGULAR: 'Angular',
8
+ ANGULARUNIVERSAL: 'AngularUniversal',
9
+ SVELTE: 'Svelte',
10
+ SVELTEKIT: 'SvelteKit',
11
+ PREACT: 'Preact',
12
+ PREACTSSR: 'PreactSSR',
5
13
  ANGULARJS: 'AngularJS',
6
14
  BACKBONE: 'Backbone',
7
15
  EMBER: 'Ember',
8
- VUE: 'Vue',
9
16
  METEOR: 'Meteor',
10
17
  ZEPTO: 'Zepto',
11
18
  JQUERY: 'Jquery',
12
- MOOTOOLS: 'MooTools'
19
+ MOOTOOLS: 'MooTools',
20
+ QWIK: 'Qwik',
21
+ ELECTRON: 'Electron'
13
22
  };
14
23
  export function getFrameworks() {
15
24
  if (!isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
16
25
 
17
26
  const frameworks = [];
18
27
  try {
19
- if (detectReact()) frameworks.push(FRAMEWORKS.REACT);
28
+ if (detectReact()) {
29
+ frameworks.push(FRAMEWORKS.REACT);
30
+ if (detectNextJS()) frameworks.push(FRAMEWORKS.NEXTJS);
31
+ }
32
+ if (detectVue()) {
33
+ frameworks.push(FRAMEWORKS.VUE);
34
+ if (detectNuxtJS()) frameworks.push(FRAMEWORKS.NUXTJS);
35
+ }
36
+ if (detectAngular()) {
37
+ frameworks.push(FRAMEWORKS.ANGULAR);
38
+ if (detectAngularUniversal()) frameworks.push(FRAMEWORKS.ANGULARUNIVERSAL);
39
+ }
40
+ if (detectSvelte()) {
41
+ frameworks.push(FRAMEWORKS.SVELTE);
42
+ if (detectSvelteKit()) frameworks.push(FRAMEWORKS.SVELTEKIT);
43
+ }
44
+ if (detectPreact()) {
45
+ frameworks.push(FRAMEWORKS.PREACT);
46
+ if (detectPreactSSR()) frameworks.push(FRAMEWORKS.PREACTSSR);
47
+ }
20
48
  if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS);
21
- if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR);
22
49
  if (Object.prototype.hasOwnProperty.call(window, 'Backbone')) frameworks.push(FRAMEWORKS.BACKBONE);
23
50
  if (Object.prototype.hasOwnProperty.call(window, 'Ember')) frameworks.push(FRAMEWORKS.EMBER);
24
- if (Object.prototype.hasOwnProperty.call(window, 'Vue')) frameworks.push(FRAMEWORKS.VUE);
25
51
  if (Object.prototype.hasOwnProperty.call(window, 'Meteor')) frameworks.push(FRAMEWORKS.METEOR);
26
52
  if (Object.prototype.hasOwnProperty.call(window, 'Zepto')) frameworks.push(FRAMEWORKS.ZEPTO);
27
53
  if (Object.prototype.hasOwnProperty.call(window, 'jQuery')) frameworks.push(FRAMEWORKS.JQUERY);
28
54
  if (Object.prototype.hasOwnProperty.call(window, 'MooTools')) frameworks.push(FRAMEWORKS.MOOTOOLS);
55
+ if (Object.prototype.hasOwnProperty.call(window, 'qwikevents')) frameworks.push(FRAMEWORKS.QWIK);
56
+ if (detectElectron()) frameworks.push(FRAMEWORKS.ELECTRON);
29
57
  } catch (err) {
30
58
  // Possibly not supported
31
59
  }
@@ -45,9 +73,25 @@ function detectReact() {
45
73
  return false;
46
74
  }
47
75
  }
48
- function detectAngularJs() {
76
+ function detectNextJS() {
77
+ // React SSR
49
78
  try {
50
- 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"]');
79
+ return Object.prototype.hasOwnProperty.call(window, 'next') && Object.prototype.hasOwnProperty.call(window.next, 'version');
80
+ } catch (err) {
81
+ return false;
82
+ }
83
+ }
84
+ function detectVue() {
85
+ try {
86
+ return Object.prototype.hasOwnProperty.call(window, 'Vue');
87
+ } catch (err) {
88
+ return false;
89
+ }
90
+ }
91
+ function detectNuxtJS() {
92
+ // Vue SSR
93
+ try {
94
+ return Object.prototype.hasOwnProperty.call(window, '$nuxt') && Object.prototype.hasOwnProperty.call(window.$nuxt, 'nuxt');
51
95
  } catch (err) {
52
96
  return false;
53
97
  }
@@ -58,4 +102,56 @@ function detectAngular() {
58
102
  } catch (err) {
59
103
  return false;
60
104
  }
105
+ }
106
+ function detectAngularUniversal() {
107
+ // Anguler SSR
108
+ try {
109
+ return document.querySelector('[ng-server-context]');
110
+ } catch (err) {
111
+ return false;
112
+ }
113
+ }
114
+ function detectSvelte() {
115
+ try {
116
+ return Object.prototype.hasOwnProperty.call(window, '__svelte');
117
+ } catch (err) {
118
+ return false;
119
+ }
120
+ }
121
+ function detectSvelteKit() {
122
+ // Svelte SSR
123
+ try {
124
+ return !!Object.keys(window).find(prop => prop.startsWith('__sveltekit'));
125
+ } catch (err) {
126
+ return false;
127
+ }
128
+ }
129
+ function detectPreact() {
130
+ try {
131
+ return Object.prototype.hasOwnProperty.call(window, 'preact');
132
+ } catch (err) {
133
+ return false;
134
+ }
135
+ }
136
+ function detectPreactSSR() {
137
+ // Svelte SSR
138
+ try {
139
+ return document.querySelector('script[type="__PREACT_CLI_DATA__"]');
140
+ } catch (err) {
141
+ return false;
142
+ }
143
+ }
144
+ function detectAngularJs() {
145
+ try {
146
+ 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"]');
147
+ } catch (err) {
148
+ return false;
149
+ }
150
+ }
151
+ function detectElectron() {
152
+ try {
153
+ return typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0;
154
+ } catch (err) {
155
+ return false;
156
+ }
61
157
  }
@@ -1,19 +1,14 @@
1
- import { getRuntime, getInfo } from '../../../common/config/config';
1
+ import { getRuntime } from '../../../common/config/config';
2
2
  import { registerHandler } from '../../../common/event-emitter/register-handler';
3
3
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
4
4
  import { FEATURE_NAME, SUPPORTABILITY_METRIC, CUSTOM_METRIC, SUPPORTABILITY_METRIC_CHANNEL, CUSTOM_METRIC_CHANNEL } from '../constants';
5
- import { drain } from '../../../common/drain/drain';
6
5
  import { getFrameworks } from './framework-detection';
7
- import { getPolyfills } from './polyfill-detection';
8
6
  import { isFileProtocol } from '../../../common/url/protocol';
9
7
  import { getRules, validateRules } from '../../../common/util/obfuscate';
10
- import { VERSION } from "../../../common/constants/env.npm";
11
8
  import { onDOMContentLoaded } from '../../../common/window/load';
12
9
  import { windowAddEventListener } from '../../../common/event-listener/event-listener-opts';
13
- import { isBrowserScope } from '../../../common/constants/runtime';
10
+ import { isBrowserScope, isWorkerScope } from '../../../common/constants/runtime';
14
11
  import { AggregateBase } from '../../utils/aggregate-base';
15
- import { stringify } from '../../../common/util/stringify';
16
- import { endpointMap } from './endpoint-map';
17
12
  export class Aggregate extends AggregateBase {
18
13
  static featureName = FEATURE_NAME;
19
14
  constructor(agentIdentifier, aggregator) {
@@ -39,9 +34,8 @@ export class Aggregate extends AggregateBase {
39
34
  scheduler.harvest.on('jserrors', () => ({
40
35
  body: this.aggregator.take(['cm', 'sm'])
41
36
  }));
42
- drain(this.agentIdentifier, this.featureName); // regardless if this is blocked or not, drain is needed to unblock other features from harvesting (counteract registerDrain)
37
+ this.drain();
43
38
  }
44
-
45
39
  storeSupportabilityMetrics(name, value) {
46
40
  if (this.blocked) return;
47
41
  const type = SUPPORTABILITY_METRIC;
@@ -59,9 +53,6 @@ export class Aggregate extends AggregateBase {
59
53
  this.aggregator.store(type, name, params, metrics);
60
54
  }
61
55
  singleChecks() {
62
- // report generic info about the agent itself
63
- // note the browser agent version
64
- this.storeSupportabilityMetrics("Generic/Version/".concat(VERSION, "/Detected"));
65
56
  // report loaderType
66
57
  const {
67
58
  distMethod,
@@ -72,22 +63,27 @@ export class Aggregate extends AggregateBase {
72
63
 
73
64
  // frameworks on page
74
65
  if (isBrowserScope) {
66
+ this.storeSupportabilityMetrics('Generic/Runtime/Browser/Detected');
67
+
68
+ // These SMs are used by the AppExp team
75
69
  onDOMContentLoaded(() => {
76
70
  getFrameworks().forEach(framework => {
77
71
  this.storeSupportabilityMetrics('Framework/' + framework + '/Detected');
78
72
  });
79
73
  });
74
+ } else if (isWorkerScope) {
75
+ this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
76
+ } else {
77
+ this.storeSupportabilityMetrics('Generic/Runtime/Unknown/Detected');
80
78
  }
81
- getPolyfills().forEach(polyfill => {
82
- this.storeSupportabilityMetrics('Polyfill/' + polyfill + '/Detected');
83
- });
84
79
 
85
- // file protocol detection
80
+ // Track if the agent is being loaded using a file protocol such as is the case in some
81
+ // set-top box applications or Electron applications
86
82
  if (isFileProtocol()) {
87
83
  this.storeSupportabilityMetrics('Generic/FileProtocol/Detected');
88
84
  }
89
85
 
90
- // obfuscation rules detection
86
+ // Capture SMs to assess customer engagement with the obfuscation config
91
87
  const rules = getRules(this.agentIdentifier);
92
88
  if (rules.length > 0) this.storeSupportabilityMetrics('Generic/Obfuscate/Detected');
93
89
  if (rules.length > 0 && !validateRules(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
@@ -100,18 +96,17 @@ export class Aggregate extends AggregateBase {
100
96
  if (evt.persisted) {
101
97
  this.storeSupportabilityMetrics('Generic/BFCache/PageRestored');
102
98
  }
103
- return;
104
99
  });
105
100
  }
106
101
  unload() {
107
- // Page Resources detection for estimations with resources feature work
108
- // TODO - these SMs are to be removed when we implement the actual resources feature
109
102
  try {
110
103
  if (this.resourcesSent) return;
104
+ this.resourcesSent = true; // make sure this only gets sent once
105
+
111
106
  const agentRuntime = getRuntime(this.agentIdentifier);
112
- const info = getInfo(this.agentIdentifier);
113
- // make sure this only gets sent once
114
- this.resourcesSent = true;
107
+
108
+ // Capture SMs around network resources using the performance API to assess
109
+ // work to split this out from the ST nodes
115
110
  // differentiate between internal+external and ajax+non-ajax
116
111
  const ajaxResources = ['beacon', 'fetch', 'xmlhttprequest'];
117
112
  const internalUrls = ['nr-data.net', 'newrelic.com', 'nr-local.net', 'localhost'];
@@ -130,26 +125,14 @@ export class Aggregate extends AggregateBase {
130
125
  }
131
126
  });
132
127
 
133
- // Capture per-agent bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
134
- Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
135
- this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpointMap[endpoint], "/BytesSent"), agentRuntime.bytesSent[endpoint]);
136
- });
137
-
138
- // Capture per-agent query bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
139
- Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
140
- this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpointMap[endpoint], "/QueryBytesSent"), agentRuntime.queryBytesSent[endpoint]);
141
- });
142
-
143
- // Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
128
+ // Capture SMs for session trace if active (`ptid` is set when returned by replay ingest).
129
+ // Retain these SMs while we are working through the session_replay feature
144
130
  if (agentRuntime.ptid) {
145
131
  this.storeSupportabilityMetrics('PageSession/Feature/SessionTrace/DurationMs', Math.round(performance.now()));
146
132
  }
147
133
 
148
- // Capture metrics for size of custom attributes
149
- const jsAttributes = stringify(info.jsAttributes);
150
- this.storeSupportabilityMetrics('PageSession/Feature/CustomData/Bytes', jsAttributes === '{}' ? 0 : jsAttributes.length);
151
-
152
- // Capture metrics for performance markers and measures
134
+ // Capture SMs for performance markers and measures to assess the usage and possible inclusion of this
135
+ // data in the agent for use in NR
153
136
  if (typeof performance !== 'undefined') {
154
137
  const markers = performance.getEntriesByType('mark');
155
138
  const measures = performance.getEntriesByType('measure');
@@ -1,7 +1,5 @@
1
1
  import { InstrumentBase } from '../../utils/instrument-base';
2
- import { FEATURE_NAME, SUPPORTABILITY_METRIC_CHANNEL } from '../constants';
3
- import { handle } from '../../../common/event-emitter/handle';
4
- import { FEATURE_NAMES } from '../../../loaders/features/features';
2
+ import { FEATURE_NAME } from '../constants';
5
3
  export class Instrument extends InstrumentBase {
6
4
  static featureName = FEATURE_NAME;
7
5
  constructor(agentIdentifier, aggregator) {
@@ -10,7 +10,6 @@ import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
10
10
  import { cleanURL } from '../../../common/url/clean-url';
11
11
  import { getConfigurationValue, getInfo, getRuntime } from '../../../common/config/config';
12
12
  import { FEATURE_NAME } from '../constants';
13
- import { drain } from '../../../common/drain/drain';
14
13
  import { isBrowserScope } from '../../../common/constants/runtime';
15
14
  import { AggregateBase } from '../../utils/aggregate-base';
16
15
  export class Aggregate extends AggregateBase {
@@ -22,8 +21,8 @@ export class Aggregate extends AggregateBase {
22
21
  this.eventsPerMinute = 240;
23
22
  this.harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'page_action.harvestTimeSeconds') || getConfigurationValue(this.agentIdentifier, 'ins.harvestTimeSeconds') || 30;
24
23
  this.eventsPerHarvest = this.eventsPerMinute * this.harvestTimeSeconds / 60;
25
- this.referrerUrl;
26
- this.currentEvents;
24
+ this.referrerUrl = undefined;
25
+ this.currentEvents = undefined;
27
26
  this.events = [];
28
27
  this.att = getInfo(this.agentIdentifier).jsAttributes; // per-agent, aggregators-shared info context
29
28
 
@@ -31,24 +30,23 @@ export class Aggregate extends AggregateBase {
31
30
  register('api-addPageAction', function () {
32
31
  return _this.addPageAction(...arguments);
33
32
  }, this.featureName, this.ee);
34
- var scheduler = new HarvestScheduler('ins', {
35
- onFinished: function () {
36
- return _this.onHarvestFinished(...arguments);
33
+ this.waitForFlags(['ins']).then(_ref => {
34
+ let [enabled] = _ref;
35
+ if (enabled) {
36
+ const scheduler = new HarvestScheduler('ins', {
37
+ onFinished: function () {
38
+ return _this.onHarvestFinished(...arguments);
39
+ }
40
+ }, this);
41
+ scheduler.harvest.on('ins', function () {
42
+ return _this.onHarvestStarted(...arguments);
43
+ });
44
+ scheduler.startTimer(this.harvestTimeSeconds, 0);
45
+ } else {
46
+ this.blocked = true;
37
47
  }
38
- }, this);
39
- scheduler.harvest.on('ins', function () {
40
- return _this.onHarvestStarted(...arguments);
41
48
  });
42
- this.ee.on("drain-".concat(this.featureName), () => {
43
- if (!this.blocked) scheduler.startTimer(this.harvestTimeSeconds, 0);
44
- });
45
-
46
- // if rum response determines that customer lacks entitlements for ins endpoint, block it
47
- register('block-ins', () => {
48
- this.blocked = true;
49
- scheduler.stopTimer(true);
50
- }, this.featureName, this.ee);
51
- drain(this.agentIdentifier, this.featureName);
49
+ this.drain();
52
50
  }
53
51
  onHarvestStarted(options) {
54
52
  const {
@@ -9,7 +9,6 @@ import { getConfigurationValue, getInfo, getRuntime } from '../../../common/conf
9
9
  import { Harvest } from '../../../common/harvest/harvest';
10
10
  import * as CONSTANTS from '../constants';
11
11
  import { getActivatedFeaturesFlags } from './initialized-features';
12
- import { drain } from '../../../common/drain/drain';
13
12
  import { activateFeatures } from '../../../common/util/feature-flags';
14
13
  import { warn } from '../../../common/util/console';
15
14
  import { AggregateBase } from '../../utils/aggregate-base';
@@ -147,7 +146,7 @@ export class Aggregate extends AggregateBase {
147
146
  }
148
147
  try {
149
148
  activateFeatures(JSON.parse(responseText), this.agentIdentifier);
150
- drain(this.agentIdentifier, this.featureName);
149
+ this.drain();
151
150
  } catch (err) {
152
151
  this.ee.abort();
153
152
  warn('RUM call failed. Agent shutting down.');
@@ -13,10 +13,12 @@ export class Instrument extends InstrumentBase {
13
13
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME, auto);
14
14
  if ((typeof PerformanceNavigationTiming === 'undefined' || isiOS) && typeof PerformanceTiming !== 'undefined') {
15
15
  // For majority browser versions in which PNT exists, we can get load timings later from the nav entry (in the aggregate portion). At minimum, PT should exist for main window.
16
- // *cli Mar'23 - iOS 15.2 & 15.4 testing in Sauce still fails with onTTFB. Hence, all iOS will fallback to this for now. Unknown if this is similar in nature to iOS_below16 bug.
16
+ // *cli Mar'23 - iOS 15.2 & 15.4 testing in Sauce still fails with onTTFB. Hence, all iOS will fallback to this for now. Unknown if this is similar in nature to iOSBelow16 bug.
17
17
  const agentRuntime = getRuntime(agentIdentifier);
18
18
  agentRuntime[CONSTANTS.TTFB] = Math.max(Date.now() - agentRuntime.offset, 0);
19
- onDOMContentLoaded(() => agentRuntime[CONSTANTS.FBTDC] = Math.max(now() - agentRuntime[CONSTANTS.TTFB], 0));
19
+ onDOMContentLoaded(() => {
20
+ agentRuntime[CONSTANTS.FBTDC] = Math.max(now() - agentRuntime[CONSTANTS.TTFB], 0);
21
+ });
20
22
  onWindowLoad(() => {
21
23
  const timeNow = now();
22
24
  agentRuntime[CONSTANTS.FBTWL] = Math.max(timeNow - agentRuntime[CONSTANTS.TTFB], 0);
@@ -6,7 +6,7 @@
6
6
  import { onFCP, onFID, onLCP, onCLS, onINP } from 'web-vitals';
7
7
  import { onFirstPaint } from '../first-paint';
8
8
  import { onLongTask } from '../long-tasks';
9
- import { iOS_below16 } from '../../../common/constants/runtime';
9
+ import { iOSBelow16 } from '../../../common/constants/runtime';
10
10
  import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
11
11
  import { mapOwn } from '../../../common/util/map-own';
12
12
  import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
@@ -15,7 +15,6 @@ import { cleanURL } from '../../../common/url/clean-url';
15
15
  import { handle } from '../../../common/event-emitter/handle';
16
16
  import { getInfo, getConfigurationValue, getRuntime } from '../../../common/config/config';
17
17
  import { FEATURE_NAME } from '../constants';
18
- import { drain } from '../../../common/drain/drain';
19
18
  import { FEATURE_NAMES } from '../../../loaders/features/features';
20
19
  import { AggregateBase } from '../../utils/aggregate-base';
21
20
  export class Aggregate extends AggregateBase {
@@ -45,7 +44,7 @@ export class Aggregate extends AggregateBase {
45
44
  });
46
45
 
47
46
  /* First Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
48
- if (iOS_below16) {
47
+ if (iOSBelow16) {
49
48
  try {
50
49
  if (!pageStartedHidden) {
51
50
  // see ios-version.js for detail on this following bug case; tldr: buffered flag doesn't work but getEntriesByType does
@@ -121,7 +120,7 @@ export class Aggregate extends AggregateBase {
121
120
  let {
122
121
  value
123
122
  } = _ref5;
124
- return this.cls = value;
123
+ this.cls = value;
125
124
  }, {
126
125
  reportAllChanges: true
127
126
  });
@@ -170,7 +169,7 @@ export class Aggregate extends AggregateBase {
170
169
  this.ee.on("drain-".concat(this.featureName), () => {
171
170
  this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
172
171
  });
173
- drain(this.agentIdentifier, this.featureName);
172
+ this.drain();
174
173
  }
175
174
 
176
175
  // takes an attributes object and appends connection attributes if available
@@ -224,9 +223,9 @@ export class Aggregate extends AggregateBase {
224
223
  attrs.cls = this.cls;
225
224
  }
226
225
  this.timings.push({
227
- name: name,
228
- value: value,
229
- attrs: attrs
226
+ name,
227
+ value,
228
+ attrs
230
229
  });
231
230
  handle('pvtAdded', [name, value, attrs], undefined, FEATURE_NAMES.sessionTrace, this.ee);
232
231
  }