@newrelic/browser-agent 1.269.0 → 1.270.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 (165) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/common/constants/env.cdn.js +1 -1
  3. package/dist/cjs/common/constants/env.npm.js +1 -1
  4. package/dist/cjs/common/constants/runtime.js +1 -2
  5. package/dist/cjs/common/harvest/harvest-scheduler.js +3 -4
  6. package/dist/cjs/common/unload/eol.js +2 -5
  7. package/dist/cjs/common/util/submit-data.js +1 -1
  8. package/dist/cjs/features/ajax/aggregate/index.js +8 -17
  9. package/dist/cjs/features/ajax/instrument/index.js +8 -10
  10. package/dist/cjs/features/generic_events/aggregate/index.js +15 -22
  11. package/dist/cjs/features/generic_events/instrument/index.js +5 -8
  12. package/dist/cjs/features/jserrors/aggregate/index.js +17 -22
  13. package/dist/cjs/features/jserrors/instrument/index.js +3 -3
  14. package/dist/cjs/features/logging/aggregate/index.js +16 -23
  15. package/dist/cjs/features/logging/instrument/index.js +3 -3
  16. package/dist/cjs/features/metrics/aggregate/index.js +13 -16
  17. package/dist/cjs/features/metrics/instrument/index.js +3 -3
  18. package/dist/cjs/features/page_view_event/aggregate/index.js +15 -29
  19. package/dist/cjs/features/page_view_event/instrument/index.js +3 -3
  20. package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -23
  21. package/dist/cjs/features/page_view_timing/instrument/index.js +3 -3
  22. package/dist/cjs/features/session_replay/aggregate/index.js +15 -29
  23. package/dist/cjs/features/session_replay/instrument/index.js +7 -5
  24. package/dist/cjs/features/session_trace/aggregate/index.js +25 -31
  25. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +1 -1
  26. package/dist/cjs/features/session_trace/instrument/index.js +4 -5
  27. package/dist/cjs/features/soft_navigations/aggregate/index.js +6 -11
  28. package/dist/cjs/features/soft_navigations/instrument/index.js +3 -3
  29. package/dist/cjs/features/spa/aggregate/index.js +19 -30
  30. package/dist/cjs/features/spa/instrument/index.js +4 -4
  31. package/dist/cjs/features/utils/aggregate-base.js +11 -12
  32. package/dist/cjs/features/utils/feature-base.js +5 -3
  33. package/dist/cjs/features/utils/instrument-base.js +18 -10
  34. package/dist/cjs/loaders/agent.js +1 -5
  35. package/dist/cjs/loaders/micro-agent.js +6 -9
  36. package/dist/esm/common/constants/env.cdn.js +1 -1
  37. package/dist/esm/common/constants/env.npm.js +1 -1
  38. package/dist/esm/common/constants/runtime.js +0 -1
  39. package/dist/esm/common/harvest/harvest-scheduler.js +3 -4
  40. package/dist/esm/common/unload/eol.js +2 -5
  41. package/dist/esm/common/util/submit-data.js +2 -2
  42. package/dist/esm/features/ajax/aggregate/index.js +8 -17
  43. package/dist/esm/features/ajax/instrument/index.js +8 -10
  44. package/dist/esm/features/generic_events/aggregate/index.js +11 -18
  45. package/dist/esm/features/generic_events/instrument/index.js +5 -8
  46. package/dist/esm/features/jserrors/aggregate/index.js +15 -20
  47. package/dist/esm/features/jserrors/instrument/index.js +3 -3
  48. package/dist/esm/features/logging/aggregate/index.js +16 -23
  49. package/dist/esm/features/logging/instrument/index.js +3 -3
  50. package/dist/esm/features/metrics/aggregate/index.js +8 -11
  51. package/dist/esm/features/metrics/instrument/index.js +3 -3
  52. package/dist/esm/features/page_view_event/aggregate/index.js +16 -30
  53. package/dist/esm/features/page_view_event/instrument/index.js +3 -3
  54. package/dist/esm/features/page_view_timing/aggregate/index.js +6 -23
  55. package/dist/esm/features/page_view_timing/instrument/index.js +3 -3
  56. package/dist/esm/features/session_replay/aggregate/index.js +13 -27
  57. package/dist/esm/features/session_replay/instrument/index.js +7 -5
  58. package/dist/esm/features/session_trace/aggregate/index.js +22 -28
  59. package/dist/esm/features/session_trace/aggregate/trace/storage.js +1 -1
  60. package/dist/esm/features/session_trace/instrument/index.js +4 -5
  61. package/dist/esm/features/soft_navigations/aggregate/index.js +6 -11
  62. package/dist/esm/features/soft_navigations/instrument/index.js +3 -3
  63. package/dist/esm/features/spa/aggregate/index.js +17 -28
  64. package/dist/esm/features/spa/instrument/index.js +4 -4
  65. package/dist/esm/features/utils/aggregate-base.js +13 -14
  66. package/dist/esm/features/utils/feature-base.js +5 -3
  67. package/dist/esm/features/utils/instrument-base.js +18 -10
  68. package/dist/esm/loaders/agent.js +1 -5
  69. package/dist/esm/loaders/micro-agent.js +6 -9
  70. package/dist/types/common/constants/runtime.d.ts +0 -1
  71. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  72. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  73. package/dist/types/common/unload/eol.d.ts +1 -1
  74. package/dist/types/common/unload/eol.d.ts.map +1 -1
  75. package/dist/types/features/ajax/aggregate/index.d.ts +1 -1
  76. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  77. package/dist/types/features/ajax/instrument/index.d.ts +1 -1
  78. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  79. package/dist/types/features/generic_events/aggregate/index.d.ts +1 -2
  80. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  81. package/dist/types/features/generic_events/instrument/index.d.ts +1 -1
  82. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -1
  83. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  84. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  85. package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
  86. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  87. package/dist/types/features/logging/aggregate/index.d.ts +1 -2
  88. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  89. package/dist/types/features/logging/instrument/index.d.ts +1 -1
  90. package/dist/types/features/logging/instrument/index.d.ts.map +1 -1
  91. package/dist/types/features/metrics/aggregate/index.d.ts +1 -1
  92. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  93. package/dist/types/features/metrics/instrument/index.d.ts +1 -1
  94. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  95. package/dist/types/features/page_action/instrument/index.d.ts +1 -0
  96. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
  97. package/dist/types/features/page_view_event/aggregate/index.d.ts +1 -1
  98. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  99. package/dist/types/features/page_view_event/instrument/index.d.ts +1 -1
  100. package/dist/types/features/page_view_event/instrument/index.d.ts.map +1 -1
  101. package/dist/types/features/page_view_timing/aggregate/index.d.ts +1 -5
  102. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  103. package/dist/types/features/page_view_timing/instrument/index.d.ts +1 -1
  104. package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
  105. package/dist/types/features/session_replay/aggregate/index.d.ts +0 -1
  106. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  107. package/dist/types/features/session_replay/instrument/index.d.ts +1 -1
  108. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -1
  109. package/dist/types/features/session_trace/aggregate/index.d.ts +1 -3
  110. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  111. package/dist/types/features/session_trace/instrument/index.d.ts +1 -1
  112. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  113. package/dist/types/features/soft_navigations/aggregate/index.d.ts +1 -1
  114. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  115. package/dist/types/features/soft_navigations/instrument/index.d.ts +1 -1
  116. package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
  117. package/dist/types/features/spa/aggregate/index.d.ts +1 -1
  118. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  119. package/dist/types/features/spa/instrument/index.d.ts +1 -1
  120. package/dist/types/features/spa/instrument/index.d.ts.map +1 -1
  121. package/dist/types/features/utils/aggregate-base.d.ts +2 -2
  122. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  123. package/dist/types/features/utils/feature-base.d.ts +2 -3
  124. package/dist/types/features/utils/feature-base.d.ts.map +1 -1
  125. package/dist/types/features/utils/instrument-base.d.ts +3 -3
  126. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  127. package/dist/types/loaders/agent.d.ts +0 -2
  128. package/dist/types/loaders/agent.d.ts.map +1 -1
  129. package/dist/types/loaders/micro-agent.d.ts +0 -2
  130. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  131. package/package.json +1 -1
  132. package/src/common/constants/__mocks__/runtime.js +0 -1
  133. package/src/common/constants/runtime.js +0 -2
  134. package/src/common/harvest/harvest-scheduler.js +3 -4
  135. package/src/common/unload/eol.js +2 -5
  136. package/src/common/util/submit-data.js +2 -2
  137. package/src/features/ajax/aggregate/index.js +8 -18
  138. package/src/features/ajax/instrument/index.js +8 -10
  139. package/src/features/generic_events/aggregate/index.js +11 -20
  140. package/src/features/generic_events/instrument/index.js +7 -10
  141. package/src/features/jserrors/aggregate/index.js +15 -20
  142. package/src/features/jserrors/instrument/index.js +3 -4
  143. package/src/features/logging/aggregate/index.js +15 -23
  144. package/src/features/logging/instrument/index.js +3 -3
  145. package/src/features/metrics/aggregate/index.js +8 -11
  146. package/src/features/metrics/instrument/index.js +3 -3
  147. package/src/features/page_view_event/aggregate/index.js +16 -22
  148. package/src/features/page_view_event/instrument/index.js +3 -3
  149. package/src/features/page_view_timing/aggregate/index.js +6 -23
  150. package/src/features/page_view_timing/instrument/index.js +3 -3
  151. package/src/features/session_replay/aggregate/index.js +13 -21
  152. package/src/features/session_replay/instrument/index.js +7 -5
  153. package/src/features/session_trace/aggregate/index.js +22 -28
  154. package/src/features/session_trace/aggregate/trace/storage.js +1 -1
  155. package/src/features/session_trace/instrument/index.js +4 -5
  156. package/src/features/soft_navigations/aggregate/index.js +6 -8
  157. package/src/features/soft_navigations/instrument/index.js +3 -3
  158. package/src/features/spa/aggregate/index.js +17 -26
  159. package/src/features/spa/instrument/index.js +4 -4
  160. package/src/features/utils/__mocks__/feature-base.js +1 -2
  161. package/src/features/utils/aggregate-base.js +13 -14
  162. package/src/features/utils/feature-base.js +6 -3
  163. package/src/features/utils/instrument-base.js +16 -10
  164. package/src/loaders/agent.js +1 -3
  165. package/src/loaders/micro-agent.js +7 -9
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.270.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.270.0...v1.270.1) (2024-10-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Remove undefined agentRuntime in Session Trace ([#1227](https://github.com/newrelic/newrelic-browser-agent/issues/1227)) ([dc5938f](https://github.com/newrelic/newrelic-browser-agent/commit/dc5938f26e43686759de976d4631b22f112b71e8))
12
+
13
+ ## [1.270.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.269.0...v1.270.0) (2024-10-22)
14
+
15
+
16
+ ### Features
17
+
18
+ * Add Firefox to LCP test matcher ([#1223](https://github.com/newrelic/newrelic-browser-agent/issues/1223)) ([c6a20e1](https://github.com/newrelic/newrelic-browser-agent/commit/c6a20e11b694fcf721ce27b02be1df76caed1a3e))
19
+ * Move deregisterDrain method to feature-base ([#1220](https://github.com/newrelic/newrelic-browser-agent/issues/1220)) ([5fdea14](https://github.com/newrelic/newrelic-browser-agent/commit/5fdea14097d415d7c6f3f98bfe87848e118ec62e))
20
+ * Relocate aggregator from loader and improve agent internals ([#1216](https://github.com/newrelic/newrelic-browser-agent/issues/1216)) ([789df5a](https://github.com/newrelic/newrelic-browser-agent/commit/789df5a0d5574acb02ac0db2aea98150a9c8786e))
21
+ * Remove 'pageHide' from page end-of-lifecycle listener ([#1219](https://github.com/newrelic/newrelic-browser-agent/issues/1219)) ([daf349e](https://github.com/newrelic/newrelic-browser-agent/commit/daf349e632902597c232c3392cc5d188f2995f25))
22
+ * Remove supportsSendBeacon runtime property ([#1224](https://github.com/newrelic/newrelic-browser-agent/issues/1224)) ([a5996be](https://github.com/newrelic/newrelic-browser-agent/commit/a5996bec25f7c4038ce87f2ad72eb61d637f5994))
23
+
6
24
  ## [1.269.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.268.0...v1.269.0) (2024-10-16)
7
25
 
8
26
 
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
12
12
  /**
13
13
  * Exposes the version of the agent
14
14
  */
15
- const VERSION = exports.VERSION = "1.269.0";
15
+ const VERSION = exports.VERSION = "1.270.1";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -12,7 +12,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
12
12
  /**
13
13
  * Exposes the version of the agent
14
14
  */
15
- const VERSION = exports.VERSION = "1.269.0";
15
+ const VERSION = exports.VERSION = "1.270.1";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.supportsSendBeacon = exports.originTime = exports.loadedAsDeferredBrowserScript = exports.isiOS = exports.isWorkerScope = exports.isBrowserScope = exports.initiallyHidden = exports.initialLocation = exports.iOSBelow16 = exports.globalScope = exports.ffVersion = void 0;
6
+ exports.originTime = exports.loadedAsDeferredBrowserScript = exports.isiOS = exports.isWorkerScope = exports.isBrowserScope = exports.initiallyHidden = exports.initialLocation = exports.iOSBelow16 = exports.globalScope = exports.ffVersion = void 0;
7
7
  var _now = require("../timing/now");
8
8
  /**
9
9
  * @file Contains constants about the environment the agent is running
@@ -42,7 +42,6 @@ const ffVersion = exports.ffVersion = (() => {
42
42
  }
43
43
  return 0;
44
44
  })();
45
- const supportsSendBeacon = exports.supportsSendBeacon = !!globalScope.navigator?.sendBeacon;
46
45
 
47
46
  /**
48
47
  * Represents the absolute timestamp in milliseconds that the page was loaded
@@ -41,8 +41,9 @@ class HarvestScheduler extends _sharedContext.SharedContext {
41
41
  this.harvesting = false;
42
42
  this.harvest = new _harvest.Harvest(this.sharedContext);
43
43
 
44
- // unload if EOL mechanism fires
45
- (0, _eol.subscribeToEOL)(this.unload.bind(this));
44
+ // If a feature specifies stuff to be done on page unload, those are frontrunned (via capture phase) before ANY feature final harvests.
45
+ if (typeof this.opts.onUnload === 'function') (0, _eol.subscribeToEOL)(this.opts.onUnload, true);
46
+ (0, _eol.subscribeToEOL)(this.unload.bind(this)); // this should consist only of sending final harvest
46
47
 
47
48
  /* Flush all buffered data if session resets and give up retries. This should be synchronous to ensure that the correct `session` value is sent.
48
49
  Since session-reset generates a new session ID and the ID is grabbed at send-time, any delays or retries would cause the payload to be sent under
@@ -58,8 +59,6 @@ class HarvestScheduler extends _sharedContext.SharedContext {
58
59
  */
59
60
  unload() {
60
61
  if (this.aborted) return;
61
- // If opts.onUnload is defined, these are special actions to execute before attempting to send the final payload.
62
- if (this.opts.onUnload) this.opts.onUnload();
63
62
  this.runHarvest({
64
63
  unload: true
65
64
  });
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.subscribeToEOL = subscribeToEOL;
7
- var _eventListenerOpts = require("../event-listener/event-listener-opts");
8
7
  var _runtime = require("../constants/runtime");
9
8
  var _pageVisibility = require("../window/page-visibility");
10
9
  /*
@@ -30,11 +29,9 @@ if (_runtime.isWorkerScope) {
30
29
  * This is used, for example, to submit a final harvest and send all remaining data on best-effort.
31
30
  * @param {function} cb - func to run before or during the last reliable event or time of an env's life span
32
31
  */
33
- function subscribeToEOL(cb) {
32
+ function subscribeToEOL(cb, capturePhase) {
34
33
  if (_runtime.isBrowserScope) {
35
- (0, _pageVisibility.subscribeToVisibilityChange)(cb, true); // when user switches tab or hides window, esp. mobile scenario
36
- (0, _eventListenerOpts.windowAddEventListener)('pagehide', cb); // when user navigates away, and because safari iOS v14.4- doesn't fully support vis change
37
- // --this ought to be removed once support for version below 14.5 phases out
34
+ (0, _pageVisibility.subscribeToVisibilityChange)(cb, true, capturePhase); // when user switches tab or hides window, esp. mobile scenario
38
35
  } else if (_runtime.isWorkerScope) {
39
36
  _runtime.globalScope.cleanupTasks.push(cb); // close() should run these tasks before quitting thread
40
37
  }
@@ -26,7 +26,7 @@ var _runtime = require("../constants/runtime");
26
26
  function getSubmitMethod({
27
27
  isFinalHarvest = false
28
28
  } = {}) {
29
- return isFinalHarvest && _runtime.isBrowserScope && _runtime.supportsSendBeacon
29
+ return isFinalHarvest && _runtime.isBrowserScope
30
30
  // Use sendBeacon for final harvest
31
31
  ? beacon
32
32
  // If not final harvest, or not browserScope, always use xhr post
@@ -7,9 +7,6 @@ exports.Aggregate = void 0;
7
7
  var _registerHandler = require("../../../common/event-emitter/register-handler");
8
8
  var _stringify = require("../../../common/util/stringify");
9
9
  var _handle = require("../../../common/event-emitter/handle");
10
- var _info = require("../../../common/config/info");
11
- var _init = require("../../../common/config/init");
12
- var _runtime = require("../../../common/config/runtime");
13
10
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
14
11
  var _denyList = require("../../../common/deny-list/deny-list");
15
12
  var _constants = require("../constants");
@@ -28,16 +25,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
28
25
 
29
26
  class Aggregate extends _aggregateBase.AggregateBase {
30
27
  static featureName = _constants.FEATURE_NAME;
31
- #agentInfo;
32
- #agentRuntime;
33
- #agentInit;
34
- constructor(agentIdentifier, aggregator) {
35
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
36
- this.#agentInfo = (0, _info.getInfo)(agentIdentifier);
37
- this.#agentRuntime = (0, _runtime.getRuntime)(agentIdentifier);
38
- this.#agentInit = (0, _init.getConfiguration)(agentIdentifier);
39
- const harvestTimeSeconds = this.#agentInit.ajax.harvestTimeSeconds || 10;
40
- (0, _denyList.setDenyList)(this.#agentRuntime.denyList);
28
+ constructor(agentRef) {
29
+ super(agentRef, _constants.FEATURE_NAME);
30
+ const harvestTimeSeconds = agentRef.init.ajax.harvestTimeSeconds || 10;
31
+ (0, _denyList.setDenyList)(agentRef.runtime.denyList);
41
32
  this.ajaxEvents = new _eventBuffer.EventBuffer();
42
33
  this.spaAjaxEvents = {};
43
34
  const classThis = this;
@@ -79,14 +70,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
79
70
  hash = (0, _stringify.stringify)([params.status, params.host, params.pathname]);
80
71
  }
81
72
  const shouldCollect = (0, _denyList.shouldCollectEvent)(params);
82
- const shouldOmitAjaxMetrics = this.#agentInit.feature_flags?.includes('ajax_metrics_deny_list');
73
+ const shouldOmitAjaxMetrics = this.agentRef.init.feature_flags?.includes('ajax_metrics_deny_list');
83
74
 
84
75
  // store for timeslice metric (harvested by jserrors feature)
85
76
  if (shouldCollect || !shouldOmitAjaxMetrics) {
86
- this.aggregator.store('xhr', hash, params, metrics);
77
+ this.agentRef.sharedAggregator.store('xhr', hash, params, metrics);
87
78
  }
88
79
  if (!shouldCollect) {
89
- if (params.hostname === this.#agentInfo.errorBeacon || this.#agentInit.proxy?.beacon && params.hostname === this.#agentInit.proxy.beacon) {
80
+ if (params.hostname === this.agentRef.info.errorBeacon || this.agentRef.init.proxy?.beacon && params.hostname === this.agentRef.init.proxy.beacon) {
90
81
  // This doesn't make a distinction if the same-domain request is going to a different port or path...
91
82
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
92
83
  if (shouldOmitAjaxMetrics) (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Metrics/Excluded/Agent'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
@@ -113,7 +104,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
113
104
  if (ctx.dt) {
114
105
  event.spanId = ctx.dt.spanId;
115
106
  event.traceId = ctx.dt.traceId;
116
- event.spanTimestamp = Math.floor(this.#agentRuntime.timeKeeper.correctAbsoluteTimestamp(ctx.dt.timestamp));
107
+ event.spanTimestamp = Math.floor(this.agentRef.runtime.timeKeeper.correctAbsoluteTimestamp(ctx.dt.timestamp));
117
108
  }
118
109
 
119
110
  // parsed from the AJAX body, looking for operationName param & parsing query for operationType
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Instrument = exports.Ajax = void 0;
7
7
  var _nreum = require("../../../common/window/nreum");
8
- var _loaderConfig = require("../../../common/config/loader-config");
9
8
  var _handle = require("../../../common/event-emitter/handle");
10
9
  var _id = require("../../../common/ids/id");
11
10
  var _runtime = require("../../../common/constants/runtime");
@@ -33,9 +32,9 @@ var origRequest = (0, _nreum.gosNREUMOriginals)().o.REQ;
33
32
  var origXHR = (0, _nreum.gosNREUMOriginals)().o.XHR;
34
33
  class Instrument extends _instrumentBase.InstrumentBase {
35
34
  static featureName = _constants.FEATURE_NAME;
36
- constructor(agentIdentifier, aggregator, auto = true) {
37
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
38
- this.dt = new _distributedTracing.DT(agentIdentifier);
35
+ constructor(agentRef, auto = true) {
36
+ super(agentRef, _constants.FEATURE_NAME, auto);
37
+ this.dt = new _distributedTracing.DT(agentRef.agentIdentifier);
39
38
  this.handler = (type, args, ctx, group) => (0, _handle.handle)(type, args, ctx, group, this.ee);
40
39
 
41
40
  // this is a best (but imperfect) effort at capturing AJAX calls that may have fired before the agent was instantiated
@@ -71,12 +70,12 @@ class Instrument extends _instrumentBase.InstrumentBase {
71
70
  }
72
71
  (0, _wrapFetch.wrapFetch)(this.ee);
73
72
  (0, _wrapXhr.wrapXhr)(this.ee);
74
- subscribeToEvents(agentIdentifier, this.ee, this.handler, this.dt);
75
- this.importAggregator();
73
+ subscribeToEvents(agentRef, this.ee, this.handler, this.dt);
74
+ this.importAggregator(agentRef);
76
75
  }
77
76
  }
78
77
  exports.Instrument = Instrument;
79
- function subscribeToEvents(agentIdentifier, ee, handler, dt) {
78
+ function subscribeToEvents(agentRef, ee, handler, dt) {
80
79
  ee.on('new-xhr', onNewXhr);
81
80
  ee.on('open-xhr-start', onOpenXhrStart);
82
81
  ee.on('open-xhr-end', onOpenXhrEnd);
@@ -129,9 +128,8 @@ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
129
128
  this.metrics = {};
130
129
  }
131
130
  function onOpenXhrEnd(args, xhr) {
132
- var loaderConfig = (0, _loaderConfig.getLoaderConfig)(agentIdentifier);
133
- if (loaderConfig.xpid && this.sameOrigin) {
134
- xhr.setRequestHeader('X-NewRelic-ID', loaderConfig.xpid);
131
+ if (agentRef.loader_config.xpid && this.sameOrigin) {
132
+ xhr.setRequestHeader('X-NewRelic-ID', agentRef.loader_config.xpid);
135
133
  }
136
134
  var payload = dt.generateTracePayload(this.parsedOrigin);
137
135
  if (payload) {
@@ -7,16 +7,12 @@ exports.Aggregate = void 0;
7
7
  var _stringify = require("../../../common/util/stringify");
8
8
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
9
9
  var _cleanUrl = require("../../../common/url/clean-url");
10
- var _info = require("../../../common/config/info");
11
- var _init = require("../../../common/config/init");
12
- var _runtime = require("../../../common/config/runtime");
13
10
  var _constants = require("../constants");
14
- var _runtime2 = require("../../../common/constants/runtime");
11
+ var _runtime = require("../../../common/constants/runtime");
15
12
  var _aggregateBase = require("../../utils/aggregate-base");
16
13
  var _console = require("../../../common/util/console");
17
14
  var _now = require("../../../common/timing/now");
18
15
  var _registerHandler = require("../../../common/event-emitter/register-handler");
19
- var _drain = require("../../../common/drain/drain");
20
16
  var _constants2 = require("../../metrics/constants");
21
17
  var _eventBuffer = require("../../utils/event-buffer");
22
18
  var _traverse = require("../../../common/util/traverse");
@@ -29,40 +25,37 @@ var _iframe = require("../../../common/dom/iframe");
29
25
  */
30
26
 
31
27
  class Aggregate extends _aggregateBase.AggregateBase {
32
- #agentRuntime;
33
28
  static featureName = _constants.FEATURE_NAME;
34
- constructor(agentIdentifier, aggregator) {
35
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
36
- const agentInit = (0, _init.getConfiguration)(this.agentIdentifier);
29
+ constructor(agentRef) {
30
+ super(agentRef, _constants.FEATURE_NAME);
37
31
  this.eventsPerHarvest = 1000;
38
- this.harvestTimeSeconds = agentInit.generic_events.harvestTimeSeconds;
39
- this.referrerUrl = _runtime2.isBrowserScope && document.referrer ? (0, _cleanUrl.cleanURL)(document.referrer) : undefined;
32
+ this.harvestTimeSeconds = agentRef.init.generic_events.harvestTimeSeconds;
33
+ this.referrerUrl = _runtime.isBrowserScope && document.referrer ? (0, _cleanUrl.cleanURL)(document.referrer) : undefined;
40
34
  this.events = new _eventBuffer.EventBuffer();
41
- this.#agentRuntime = (0, _runtime.getRuntime)(this.agentIdentifier);
42
35
  this.waitForFlags(['ins']).then(([ins]) => {
43
36
  if (!ins) {
44
37
  this.blocked = true;
45
- (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
38
+ this.deregisterDrain();
46
39
  return;
47
40
  }
48
41
  const preHarvestMethods = [];
49
- if (agentInit.page_action.enabled) {
42
+ if (agentRef.init.page_action.enabled) {
50
43
  (0, _registerHandler.registerHandler)('api-addPageAction', (timestamp, name, attributes) => {
51
44
  this.addEvent({
52
45
  ...attributes,
53
46
  eventType: 'PageAction',
54
- timestamp: Math.floor(this.#agentRuntime.timeKeeper.correctRelativeTimestamp(timestamp)),
47
+ timestamp: Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(timestamp)),
55
48
  timeSinceLoad: timestamp / 1000,
56
49
  actionName: name,
57
50
  referrerUrl: this.referrerUrl,
58
- ...(_runtime2.isBrowserScope && {
51
+ ...(_runtime.isBrowserScope && {
59
52
  browserWidth: window.document.documentElement?.clientWidth,
60
53
  browserHeight: window.document.documentElement?.clientHeight
61
54
  })
62
55
  });
63
56
  }, this.featureName, this.ee);
64
57
  }
65
- if (_runtime2.isBrowserScope && agentInit.user_actions.enabled) {
58
+ if (_runtime.isBrowserScope && agentRef.init.user_actions.enabled) {
66
59
  this.userActionAggregator = new _userActionsAggregator.UserActionsAggregator();
67
60
  this.addUserAction = aggregatedUserAction => {
68
61
  try {
@@ -76,7 +69,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
76
69
  } = aggregatedUserAction.event;
77
70
  this.addEvent({
78
71
  eventType: 'UserAction',
79
- timestamp: Math.floor(this.#agentRuntime.timeKeeper.correctRelativeTimestamp(timeStamp)),
72
+ timestamp: Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(timeStamp)),
80
73
  action: type,
81
74
  actionCount: aggregatedUserAction.count,
82
75
  actionDuration: aggregatedUserAction.relativeMs[aggregatedUserAction.relativeMs.length - 1],
@@ -151,14 +144,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
151
144
  }
152
145
  const defaultEventAttributes = {
153
146
  /** should be overridden by the event-specific attributes, but just in case -- set it to now() */
154
- timestamp: Math.floor(this.#agentRuntime.timeKeeper.correctRelativeTimestamp((0, _now.now)())),
147
+ timestamp: Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp((0, _now.now)())),
155
148
  /** all generic events require pageUrl(s) */
156
- pageUrl: (0, _cleanUrl.cleanURL)('' + _runtime2.initialLocation),
149
+ pageUrl: (0, _cleanUrl.cleanURL)('' + _runtime.initialLocation),
157
150
  currentUrl: (0, _cleanUrl.cleanURL)('' + location)
158
151
  };
159
152
  const eventAttributes = {
160
153
  /** Agent-level custom attributes */
161
- ...((0, _info.getInfo)(this.agentIdentifier).jsAttributes || {}),
154
+ ...(this.agentRef.info.jsAttributes || {}),
162
155
  /** Fallbacks for required properties in-case the event did not supply them, should take precedence over agent-level custom attrs */
163
156
  ...defaultEventAttributes,
164
157
  /** Event-specific attributes take precedence over agent-level custom attributes and fallbacks */
@@ -171,7 +164,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
171
164
  const {
172
165
  userAttributes,
173
166
  atts
174
- } = (0, _info.getInfo)(this.agentIdentifier);
167
+ } = this.agentRef.info;
175
168
  if (!this.events.hasData) return;
176
169
  var payload = {
177
170
  qs: {
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Instrument = exports.GenericEvents = void 0;
7
- var _init = require("../../../common/config/init");
8
7
  var _runtime = require("../../../common/constants/runtime");
9
- var _drain = require("../../../common/drain/drain");
10
8
  var _handle = require("../../../common/event-emitter/handle");
11
9
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
12
10
  var _instrumentBase = require("../../utils/instrument-base");
@@ -17,13 +15,12 @@ var _constants = require("../constants");
17
15
 
18
16
  class Instrument extends _instrumentBase.InstrumentBase {
19
17
  static featureName = _constants.FEATURE_NAME;
20
- constructor(agentIdentifier, aggregator, auto = true) {
21
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
22
- const agentInit = (0, _init.getConfiguration)(this.agentIdentifier);
23
- const genericEventSourceConfigs = [agentInit.page_action.enabled, agentInit.user_actions.enabled
18
+ constructor(agentRef, auto = true) {
19
+ super(agentRef, _constants.FEATURE_NAME, auto);
20
+ const genericEventSourceConfigs = [agentRef.init.page_action.enabled, agentRef.init.user_actions.enabled
24
21
  // other future generic event source configs to go here, like M&Ms, PageResouce, etc.
25
22
  ];
26
- if (_runtime.isBrowserScope && agentInit.user_actions.enabled) {
23
+ if (_runtime.isBrowserScope && agentRef.init.user_actions.enabled) {
27
24
  _constants.OBSERVED_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee), true));
28
25
  _constants.OBSERVED_WINDOW_EVENTS.forEach(eventType => (0, _eventListenerOpts.windowAddEventListener)(eventType, evt => (0, _handle.handle)('ua', [evt], undefined, this.featureName, this.ee))
29
26
  // Capture is not used here so that we don't get element focus/blur events, only the window's as they do not bubble. They are also not cancellable, so no worries about being front of line.
@@ -31,7 +28,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
31
28
  }
32
29
 
33
30
  /** If any of the sources are active, import the aggregator. otherwise deregister */
34
- if (genericEventSourceConfigs.some(x => x)) this.importAggregator();else (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
31
+ if (genericEventSourceConfigs.some(x => x)) this.importAggregator(agentRef);else this.deregisterDrain();
35
32
  }
36
33
  }
37
34
  exports.Instrument = Instrument;
@@ -12,15 +12,11 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
12
12
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
13
13
  var _stringify = require("../../../common/util/stringify");
14
14
  var _handle = require("../../../common/event-emitter/handle");
15
- var _info = require("../../../common/config/info");
16
- var _init = require("../../../common/config/init");
17
- var _runtime = require("../../../common/config/runtime");
18
- var _runtime2 = require("../../../common/constants/runtime");
15
+ var _runtime = require("../../../common/constants/runtime");
19
16
  var _constants = require("../constants");
20
17
  var _features = require("../../../loaders/features/features");
21
18
  var _aggregateBase = require("../../utils/aggregate-base");
22
19
  var _nreum = require("../../../common/window/nreum");
23
- var _drain = require("../../../common/drain/drain");
24
20
  var _now = require("../../../common/timing/now");
25
21
  var _traverse = require("../../../common/util/traverse");
26
22
  var _internalErrors = require("./internal-errors");
@@ -36,8 +32,8 @@ var _constants2 = require("../../metrics/constants");
36
32
 
37
33
  class Aggregate extends _aggregateBase.AggregateBase {
38
34
  static featureName = _constants.FEATURE_NAME;
39
- constructor(agentIdentifier, aggregator) {
40
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
35
+ constructor(agentRef) {
36
+ super(agentRef, _constants.FEATURE_NAME);
41
37
  this.stackReported = {};
42
38
  this.observedAt = {};
43
39
  this.pageviewReported = {};
@@ -51,7 +47,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
51
47
  (0, _registerHandler.registerHandler)('ierr', (...args) => this.storeError(...args), this.featureName, this.ee);
52
48
  (0, _registerHandler.registerHandler)('softNavFlush', (interactionId, wasFinished, softNavAttrs) => this.onSoftNavNotification(interactionId, wasFinished, softNavAttrs), this.featureName, this.ee); // when an ixn is done or cancelled
53
49
 
54
- const harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
50
+ const harvestTimeSeconds = agentRef.init.jserrors.harvestTimeSeconds || 10;
55
51
 
56
52
  // 0 == off, 1 == on
57
53
  this.waitForFlags(['err']).then(([errFlag]) => {
@@ -64,13 +60,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
64
60
  this.drain();
65
61
  } else {
66
62
  this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
67
- (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
63
+ this.deregisterDrain();
68
64
  }
69
65
  });
70
66
  }
71
67
  onHarvestStarted(options) {
72
68
  // this gets rid of dependency in AJAX module
73
- var body = (0, _traverse.applyFnToProps)(this.aggregator.take(['err', 'ierr', 'xhr']), this.obfuscator.obfuscateString.bind(this.obfuscator), 'string');
69
+ var body = (0, _traverse.applyFnToProps)(this.agentRef.sharedAggregator.take(['err', 'ierr', 'xhr']), this.obfuscator.obfuscateString.bind(this.obfuscator), 'string');
74
70
  if (options.retry) {
75
71
  this.currentBody = body;
76
72
  }
@@ -78,7 +74,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
78
74
  body,
79
75
  qs: {}
80
76
  };
81
- var releaseIds = (0, _stringify.stringify)((0, _runtime.getRuntime)(this.agentIdentifier).releaseIds);
77
+ var releaseIds = (0, _stringify.stringify)(this.agentRef.runtime.releaseIds);
82
78
  if (releaseIds !== '{}') {
83
79
  payload.qs.ri = releaseIds;
84
80
  }
@@ -97,7 +93,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
97
93
  for (var i = 0; i < value.length; i++) {
98
94
  var bucket = value[i];
99
95
  var name = this.getBucketName(key, bucket.params, bucket.custom);
100
- this.aggregator.merge(key, name, bucket.metrics, bucket.params, bucket.custom);
96
+ this.agentRef.sharedAggregator.merge(key, name, bucket.metrics, bucket.params, bucket.custom);
101
97
  }
102
98
  });
103
99
  this.currentBody = null;
@@ -146,10 +142,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
146
142
  if (!err) return;
147
143
  // are we in an interaction
148
144
  time = time || (0, _now.now)();
149
- const agentRuntime = (0, _runtime.getRuntime)(this.agentIdentifier);
150
145
  let filterOutput;
151
- if (!internal && agentRuntime.onerror) {
152
- filterOutput = agentRuntime.onerror(err);
146
+ if (!internal && this.agentRef.runtime.onerror) {
147
+ filterOutput = this.agentRef.runtime.onerror(err);
153
148
  if (filterOutput && !(typeof filterOutput.group === 'string' && filterOutput.group.length)) {
154
149
  // All truthy values mean don't report (store) the error, per backwards-compatible usage,
155
150
  // - EXCEPT if a fingerprinting label is returned, via an object with key of 'group' and value of non-empty string
@@ -170,7 +165,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
170
165
  const params = {
171
166
  stackHash: (0, _stringHashCode.stringHashCode)(canonicalStackString),
172
167
  exceptionClass: stackInfo.name,
173
- request_uri: _runtime2.globalScope?.location.pathname
168
+ request_uri: _runtime.globalScope?.location.pathname
174
169
  };
175
170
  if (stackInfo.message) params.message = '' + stackInfo.message;
176
171
  // Notice if filterOutput isn't false|undefined OR our specified object, this func would've returned already (so it's unnecessary to req-check group).
@@ -187,11 +182,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
187
182
  if (!this.stackReported[bucketHash]) {
188
183
  this.stackReported[bucketHash] = true;
189
184
  params.stack_trace = (0, _formatStackTrace.truncateSize)(stackInfo.stackString);
190
- this.observedAt[bucketHash] = Math.floor(agentRuntime.timeKeeper.correctRelativeTimestamp(time));
185
+ this.observedAt[bucketHash] = Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(time));
191
186
  } else {
192
187
  params.browser_stack_hash = (0, _stringHashCode.stringHashCode)(stackInfo.stackString);
193
188
  }
194
- params.releaseIds = (0, _stringify.stringify)(agentRuntime.releaseIds);
189
+ params.releaseIds = (0, _stringify.stringify)(this.agentRef.runtime.releaseIds);
195
190
 
196
191
  // When debugging stack canonicalization/hashing, uncomment these lines for
197
192
  // more output in the test logs
@@ -203,7 +198,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
203
198
  this.pageviewReported[bucketHash] = true;
204
199
  }
205
200
  params.firstOccurrenceTimestamp = this.observedAt[bucketHash];
206
- params.timestamp = Math.floor(agentRuntime.timeKeeper.correctRelativeTimestamp(time));
201
+ params.timestamp = Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(time));
207
202
  var type = 'err';
208
203
  var newMetrics = {
209
204
  time
@@ -246,14 +241,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
246
241
  delete params._softNavFinished;
247
242
  } else {
248
243
  // interaction was cancelled -> error should not be associated OR there was no interaction
249
- Object.entries((0, _info.getInfo)(this.agentIdentifier).jsAttributes).forEach(([k, v]) => setCustom(k, v));
244
+ Object.entries(this.agentRef.info.jsAttributes).forEach(([k, v]) => setCustom(k, v));
250
245
  delete params.browserInteractionId;
251
246
  }
252
247
  if (localAttrs) Object.entries(localAttrs).forEach(([k, v]) => setCustom(k, v)); // local custom attrs are applied in either case with the highest precedence
253
248
 
254
249
  const jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
255
250
  const aggregateHash = bucketHash + ':' + jsAttributesHash;
256
- this.aggregator.store(type, aggregateHash, params, newMetrics, allCustomAttrs);
251
+ this.agentRef.sharedAggregator.store(type, aggregateHash, params, newMetrics, allCustomAttrs);
257
252
  function setCustom(key, val) {
258
253
  allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
259
254
  }
@@ -277,7 +272,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
277
272
  var hash = wasSaved ? item[1] + interaction.root.attrs.id : item[1];
278
273
  var jsAttributesHash = (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(allCustomAttrs));
279
274
  var aggregateHash = hash + ':' + jsAttributesHash;
280
- this.aggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs);
275
+ this.agentRef.sharedAggregator.store(item[0], aggregateHash, params, item[3], allCustomAttrs);
281
276
  function setCustom([key, val]) {
282
277
  allCustomAttrs[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
283
278
  }
@@ -20,8 +20,8 @@ var _castError = require("../shared/cast-error");
20
20
  class Instrument extends _instrumentBase.InstrumentBase {
21
21
  static featureName = _constants.FEATURE_NAME;
22
22
  #replayRunning = false;
23
- constructor(agentIdentifier, aggregator, auto = true) {
24
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
23
+ constructor(agentRef, auto = true) {
24
+ super(agentRef, _constants.FEATURE_NAME, auto);
25
25
  try {
26
26
  // this try-catch can be removed when IE11 is completely unsupported & gone
27
27
  this.removeOnAbort = new AbortController();
@@ -44,7 +44,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
44
44
  (0, _handle.handle)('err', [(0, _castError.castErrorEvent)(errorEvent), (0, _now.now)(), false, {}, this.#replayRunning], undefined, this.featureName, this.ee);
45
45
  }, (0, _eventListenerOpts.eventListenerOpts)(false, this.removeOnAbort?.signal));
46
46
  this.abortHandler = this.#abort; // we also use this as a flag to denote that the feature is active or on and handling errors
47
- this.importAggregator();
47
+ this.importAggregator(agentRef);
48
48
  }
49
49
 
50
50
  /** Restoration and resource release tasks to be done if JS error loader is being aborted. Unwind changes to globals. */
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Aggregate = void 0;
7
- var _info = require("../../../common/config/info");
8
- var _init = require("../../../common/config/init");
9
- var _runtime = require("../../../common/config/runtime");
10
7
  var _handle = require("../../../common/event-emitter/handle");
11
8
  var _registerHandler = require("../../../common/event-emitter/register-handler");
12
9
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
@@ -22,16 +19,12 @@ var _agentConstants = require("../../../common/constants/agent-constants");
22
19
  var _eventBuffer = require("../../utils/event-buffer");
23
20
  class Aggregate extends _aggregateBase.AggregateBase {
24
21
  static featureName = _constants2.FEATURE_NAME;
25
- #agentRuntime;
26
- #agentInfo;
27
- constructor(agentIdentifier, aggregator) {
28
- super(agentIdentifier, aggregator, _constants2.FEATURE_NAME);
22
+ constructor(agentRef) {
23
+ super(agentRef, _constants2.FEATURE_NAME);
29
24
 
30
25
  /** held logs before sending */
31
26
  this.bufferedLogs = new _eventBuffer.EventBuffer();
32
- this.#agentRuntime = (0, _runtime.getRuntime)(this.agentIdentifier);
33
- this.#agentInfo = (0, _info.getInfo)(this.agentIdentifier);
34
- this.harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'logging.harvestTimeSeconds');
27
+ this.harvestTimeSeconds = agentRef.init.logging.harvestTimeSeconds;
35
28
  this.waitForFlags([]).then(() => {
36
29
  this.scheduler = new _harvestScheduler.HarvestScheduler('browser/logs', {
37
30
  onFinished: this.onHarvestFinished.bind(this),
@@ -66,7 +59,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
66
59
  return;
67
60
  }
68
61
  if (typeof message !== 'string' || !message) return (0, _console.warn)(32);
69
- const log = new _log.Log(Math.floor(this.#agentRuntime.timeKeeper.correctRelativeTimestamp(timestamp)), message, attributes, level);
62
+ const log = new _log.Log(Math.floor(this.agentRef.runtime.timeKeeper.correctRelativeTimestamp(timestamp)), message, attributes, level);
70
63
  const logBytes = log.message.length + (0, _stringify.stringify)(log.attributes).length + log.level.length + 10; // timestamp == 10 chars
71
64
 
72
65
  if (!this.bufferedLogs.canMerge(logBytes)) {
@@ -87,34 +80,34 @@ class Aggregate extends _aggregateBase.AggregateBase {
87
80
  /** These attributes are evaluated and dropped at ingest processing time and do not get stored on NRDB */
88
81
  const unbilledAttributes = {
89
82
  'instrumentation.provider': 'browser',
90
- 'instrumentation.version': this.#agentRuntime.version,
91
- 'instrumentation.name': this.#agentRuntime.loaderType
83
+ 'instrumentation.version': this.agentRef.runtime.version,
84
+ 'instrumentation.name': this.agentRef.runtime.loaderType
92
85
  };
93
86
  /** see https://source.datanerd.us/agents/rum-specs/blob/main/browser/Log for logging spec */
94
87
  const payload = {
95
88
  qs: {
96
- browser_monitoring_key: this.#agentInfo.licenseKey
89
+ browser_monitoring_key: this.agentRef.info.licenseKey
97
90
  },
98
91
  body: [{
99
92
  common: {
100
93
  /** Attributes in the `common` section are added to `all` logs generated in the payload */
101
94
  attributes: {
102
- 'entity.guid': this.#agentRuntime.appMetadata?.agents?.[0]?.entityGuid,
95
+ 'entity.guid': this.agentRef.runtime.appMetadata?.agents?.[0]?.entityGuid,
103
96
  // browser entity guid as provided from RUM response
104
- session: this.#agentRuntime?.session?.state.value || '0',
97
+ session: this.agentRef.runtime.session?.state.value || '0',
105
98
  // The session ID that we generate and keep across page loads
106
- hasReplay: this.#agentRuntime?.session?.state.sessionReplayMode === 1,
99
+ hasReplay: this.agentRef.runtime.session?.state.sessionReplayMode === 1,
107
100
  // True if a session replay recording is running
108
- hasTrace: this.#agentRuntime?.session?.state.sessionTraceMode === 1,
101
+ hasTrace: this.agentRef.runtime.session?.state.sessionTraceMode === 1,
109
102
  // True if a session trace recording is running
110
- ptid: this.#agentRuntime.ptid,
103
+ ptid: this.agentRef.runtime.ptid,
111
104
  // page trace id
112
- appId: this.#agentInfo.applicationID,
105
+ appId: this.agentRef.info.applicationID,
113
106
  // Application ID from info object,
114
- standalone: Boolean(this.#agentInfo.sa),
107
+ standalone: Boolean(this.agentRef.info.sa),
115
108
  // copy paste (true) vs APM (false)
116
- agentVersion: this.#agentRuntime.version,
117
- // browser agent version,
109
+ agentVersion: this.agentRef.runtime.version,
110
+ // browser agent version
118
111
  ...unbilledAttributes
119
112
  }
120
113
  },
@@ -9,8 +9,8 @@ var _constants = require("../constants");
9
9
  var _utils = require("../shared/utils");
10
10
  class Instrument extends _instrumentBase.InstrumentBase {
11
11
  static featureName = _constants.FEATURE_NAME;
12
- constructor(agentIdentifier, aggregator, auto = true) {
13
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
12
+ constructor(agentRef, auto = true) {
13
+ super(agentRef, _constants.FEATURE_NAME, auto);
14
14
  const instanceEE = this.ee;
15
15
  /** emitted by wrap-logger function */
16
16
  this.ee.on('wrap-logger-end', function handleLog([message]) {
@@ -20,7 +20,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
20
20
  } = this;
21
21
  (0, _utils.bufferLog)(instanceEE, message, customAttributes, level);
22
22
  });
23
- this.importAggregator();
23
+ this.importAggregator(agentRef);
24
24
  }
25
25
  }
26
26
  exports.Instrument = Instrument;