@newrelic/browser-agent 1.253.0 → 1.254.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/cdn/polyfills.js +2 -1
  4. package/dist/cjs/common/config/state/runtime.js +4 -1
  5. package/dist/cjs/common/constants/env.cdn.js +1 -1
  6. package/dist/cjs/common/constants/env.npm.js +1 -1
  7. package/dist/cjs/common/drain/drain.js +41 -27
  8. package/dist/cjs/common/event-emitter/contextual-ee.js +24 -22
  9. package/dist/cjs/common/harvest/harvest.js +5 -1
  10. package/dist/cjs/common/timing/time-keeper.js +94 -0
  11. package/dist/cjs/common/util/feature-flags.js +14 -31
  12. package/dist/cjs/common/wrap/wrap-events.js +2 -2
  13. package/dist/cjs/common/wrap/wrap-fetch.js +1 -2
  14. package/dist/cjs/common/wrap/wrap-function.js +7 -5
  15. package/dist/cjs/common/wrap/wrap-promise.js +1 -2
  16. package/dist/cjs/features/ajax/aggregate/index.js +7 -13
  17. package/dist/cjs/features/jserrors/aggregate/index.js +25 -24
  18. package/dist/cjs/features/metrics/aggregate/index.js +25 -24
  19. package/dist/cjs/features/page_action/aggregate/index.js +6 -4
  20. package/dist/cjs/features/page_view_event/aggregate/index.js +22 -2
  21. package/dist/cjs/features/page_view_timing/aggregate/index.js +15 -16
  22. package/dist/cjs/features/session_replay/aggregate/index.js +12 -4
  23. package/dist/cjs/features/session_trace/aggregate/index.js +11 -8
  24. package/dist/cjs/features/soft_navigations/aggregate/index.js +17 -12
  25. package/dist/cjs/features/spa/aggregate/index.js +19 -14
  26. package/dist/cjs/features/utils/aggregate-base.js +18 -5
  27. package/dist/cjs/features/utils/feature-base.js +2 -0
  28. package/dist/cjs/features/utils/instrument-base.js +1 -0
  29. package/dist/cjs/loaders/agent-base.js +2 -7
  30. package/dist/cjs/loaders/agent.js +4 -4
  31. package/dist/cjs/loaders/api/api.js +1 -1
  32. package/dist/cjs/loaders/configure/configure.js +1 -1
  33. package/dist/cjs/loaders/configure/nonce.cdn.js +13 -0
  34. package/dist/cjs/loaders/configure/nonce.js +2 -13
  35. package/dist/cjs/loaders/configure/public-path.cdn.js +16 -0
  36. package/dist/cjs/loaders/configure/public-path.js +2 -8
  37. package/dist/esm/cdn/polyfills.js +2 -1
  38. package/dist/esm/common/config/state/runtime.js +4 -1
  39. package/dist/esm/common/constants/env.cdn.js +1 -1
  40. package/dist/esm/common/constants/env.npm.js +1 -1
  41. package/dist/esm/common/drain/drain.js +40 -27
  42. package/dist/esm/common/event-emitter/contextual-ee.js +24 -22
  43. package/dist/esm/common/harvest/harvest.js +5 -1
  44. package/dist/esm/common/timing/time-keeper.js +88 -0
  45. package/dist/esm/common/util/feature-flags.js +14 -31
  46. package/dist/esm/common/wrap/wrap-events.js +3 -3
  47. package/dist/esm/common/wrap/wrap-fetch.js +2 -3
  48. package/dist/esm/common/wrap/wrap-function.js +5 -4
  49. package/dist/esm/common/wrap/wrap-promise.js +2 -3
  50. package/dist/esm/features/ajax/aggregate/index.js +7 -13
  51. package/dist/esm/features/jserrors/aggregate/index.js +25 -24
  52. package/dist/esm/features/metrics/aggregate/index.js +25 -24
  53. package/dist/esm/features/page_action/aggregate/index.js +6 -4
  54. package/dist/esm/features/page_view_event/aggregate/index.js +22 -2
  55. package/dist/esm/features/page_view_timing/aggregate/index.js +15 -16
  56. package/dist/esm/features/session_replay/aggregate/index.js +12 -4
  57. package/dist/esm/features/session_trace/aggregate/index.js +11 -8
  58. package/dist/esm/features/soft_navigations/aggregate/index.js +17 -12
  59. package/dist/esm/features/spa/aggregate/index.js +19 -14
  60. package/dist/esm/features/utils/aggregate-base.js +18 -5
  61. package/dist/esm/features/utils/feature-base.js +2 -0
  62. package/dist/esm/features/utils/instrument-base.js +1 -0
  63. package/dist/esm/loaders/agent-base.js +2 -7
  64. package/dist/esm/loaders/agent.js +4 -4
  65. package/dist/esm/loaders/api/api.js +1 -1
  66. package/dist/esm/loaders/configure/configure.js +1 -1
  67. package/dist/esm/loaders/configure/nonce.cdn.js +11 -0
  68. package/dist/esm/loaders/configure/nonce.js +1 -11
  69. package/dist/esm/loaders/configure/public-path.cdn.js +9 -0
  70. package/dist/esm/loaders/configure/public-path.js +2 -8
  71. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  72. package/dist/types/common/drain/drain.d.ts +6 -0
  73. package/dist/types/common/drain/drain.d.ts.map +1 -1
  74. package/dist/types/common/event-emitter/contextual-ee.d.ts +4 -3
  75. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
  76. package/dist/types/common/event-emitter/event-context.d.ts.map +1 -0
  77. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  78. package/dist/types/common/timing/time-keeper.d.ts +31 -0
  79. package/dist/types/common/timing/time-keeper.d.ts.map +1 -0
  80. package/dist/types/common/util/feature-flags.d.ts +11 -2
  81. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  82. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  83. package/dist/types/common/wrap/wrap-function.d.ts +1 -0
  84. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
  85. package/dist/types/common/wrap/wrap-promise.d.ts.map +1 -1
  86. package/dist/types/features/ajax/aggregate/index.d.ts +5 -5
  87. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  88. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  89. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  90. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  91. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  92. package/dist/types/features/page_view_timing/aggregate/index.d.ts +0 -2
  93. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  94. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  95. package/dist/types/features/soft_navigations/aggregate/index.d.ts +0 -2
  96. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  97. package/dist/types/features/spa/aggregate/index.d.ts +2 -0
  98. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  99. package/dist/types/features/utils/aggregate-base.d.ts +2 -2
  100. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  101. package/dist/types/features/utils/feature-base.d.ts +1 -0
  102. package/dist/types/features/utils/feature-base.d.ts.map +1 -1
  103. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  104. package/dist/types/loaders/agent-base.d.ts +2 -2
  105. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  106. package/dist/types/loaders/configure/public-path.d.ts +1 -1
  107. package/dist/types/loaders/configure/public-path.d.ts.map +1 -1
  108. package/package.json +1 -1
  109. package/src/cdn/polyfills.js +1 -0
  110. package/src/common/config/state/runtime.js +4 -1
  111. package/src/common/drain/drain.js +41 -28
  112. package/src/common/event-emitter/contextual-ee.js +29 -31
  113. package/src/common/harvest/harvest.js +4 -1
  114. package/src/common/timing/time-keeper.js +96 -0
  115. package/src/common/util/feature-flags.js +13 -31
  116. package/src/common/wrap/wrap-events.js +3 -3
  117. package/src/common/wrap/wrap-fetch.js +2 -3
  118. package/src/common/wrap/wrap-function.js +6 -4
  119. package/src/common/wrap/wrap-promise.js +2 -3
  120. package/src/features/ajax/aggregate/index.js +8 -16
  121. package/src/features/jserrors/aggregate/index.js +12 -14
  122. package/src/features/metrics/aggregate/index.js +18 -17
  123. package/src/features/page_action/aggregate/index.js +6 -5
  124. package/src/features/page_view_event/aggregate/index.js +18 -2
  125. package/src/features/page_view_timing/aggregate/index.js +15 -15
  126. package/src/features/session_replay/aggregate/index.js +10 -4
  127. package/src/features/session_trace/aggregate/index.js +2 -2
  128. package/src/features/soft_navigations/aggregate/index.js +14 -12
  129. package/src/features/spa/aggregate/index.js +15 -13
  130. package/src/features/utils/aggregate-base.js +16 -8
  131. package/src/features/utils/feature-base.js +3 -0
  132. package/src/features/utils/instrument-base.js +1 -0
  133. package/src/loaders/agent-base.js +2 -7
  134. package/src/loaders/agent.js +2 -2
  135. package/src/loaders/api/api.js +1 -1
  136. package/src/loaders/configure/nonce.cdn.js +12 -0
  137. package/src/loaders/configure/nonce.js +1 -12
  138. package/src/loaders/configure/public-path.cdn.js +9 -0
  139. package/src/loaders/configure/public-path.js +2 -8
  140. package/dist/cjs/common/context/observation-context-manager.js +0 -56
  141. package/dist/cjs/loaders/configure/nonce.npm.js +0 -2
  142. package/dist/cjs/loaders/configure/public-path.npm.js +0 -10
  143. package/dist/esm/common/context/observation-context-manager.js +0 -49
  144. package/dist/esm/loaders/configure/nonce.npm.js +0 -1
  145. package/dist/esm/loaders/configure/public-path.npm.js +0 -3
  146. package/dist/types/common/context/event-context.d.ts.map +0 -1
  147. package/dist/types/common/context/observation-context-manager.d.ts +0 -28
  148. package/dist/types/common/context/observation-context-manager.d.ts.map +0 -1
  149. package/dist/types/loaders/configure/nonce.npm.d.ts +0 -1
  150. package/dist/types/loaders/configure/nonce.npm.d.ts.map +0 -1
  151. package/dist/types/loaders/configure/public-path.npm.d.ts +0 -2
  152. package/dist/types/loaders/configure/public-path.npm.d.ts.map +0 -1
  153. package/src/common/context/observation-context-manager.js +0 -55
  154. package/src/loaders/configure/nonce.npm.js +0 -1
  155. package/src/loaders/configure/public-path.npm.js +0 -3
  156. /package/dist/cjs/common/{context → event-emitter}/event-context.js +0 -0
  157. /package/dist/esm/common/{context → event-emitter}/event-context.js +0 -0
  158. /package/dist/types/common/{context → event-emitter}/event-context.d.ts +0 -0
  159. /package/src/common/{context → event-emitter}/event-context.js +0 -0
@@ -20,6 +20,7 @@ var _constants = require("../constants");
20
20
  var _features = require("../../../loaders/features/features");
21
21
  var _aggregateBase = require("../../utils/aggregate-base");
22
22
  var _nreum = require("../../../common/window/nreum");
23
+ var _drain = require("../../../common/drain/drain");
23
24
  /*
24
25
  * Copyright 2020 New Relic Corporation. All rights reserved.
25
26
  * SPDX-License-Identifier: Apache-2.0
@@ -53,26 +54,26 @@ class Aggregate extends _aggregateBase.AggregateBase {
53
54
  (0, _registerHandler.registerHandler)('softNavFlush', (interactionId, wasFinished, softNavAttrs) => this.onSoftNavNotification(interactionId, wasFinished, softNavAttrs), this.featureName, this.ee); // when an ixn is done or cancelled
54
55
 
55
56
  const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'jserrors.harvestTimeSeconds') || 10;
56
- const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
57
- onFinished: function () {
58
- return _this.onHarvestFinished(...arguments);
59
- }
60
- }, this);
61
- scheduler.harvest.on('jserrors', function () {
62
- return _this.onHarvestStarted(...arguments);
63
- });
64
57
 
65
- // Don't start harvesting until "drain" for this feat has been called (which currently requires RUM response).
66
- this.ee.on("drain-".concat(this.featureName), () => {
67
- if (!this.blocked) scheduler.startTimer(harvestTimeSeconds); // and only if ingest will accept jserror payloads
58
+ // 0 == off, 1 == on
59
+ this.waitForFlags(['err']).then(_ref => {
60
+ let [errFlag] = _ref;
61
+ if (errFlag) {
62
+ const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
63
+ onFinished: function () {
64
+ return _this.onHarvestFinished(...arguments);
65
+ }
66
+ }, this);
67
+ scheduler.harvest.on('jserrors', function () {
68
+ return _this.onHarvestStarted(...arguments);
69
+ });
70
+ scheduler.startTimer(harvestTimeSeconds);
71
+ this.drain();
72
+ } else {
73
+ this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
74
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
75
+ }
68
76
  });
69
-
70
- // If RUM-call's response determines that customer lacks entitlements for the /jserror ingest endpoint, don't harvest at all.
71
- (0, _registerHandler.registerHandler)('block-err', () => {
72
- this.blocked = true;
73
- scheduler.stopTimer(true);
74
- }, this.featureName, this.ee);
75
- this.drain();
76
77
  }
77
78
  onHarvestStarted(options) {
78
79
  // this gets rid of dependency in AJAX module
@@ -222,8 +223,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
222
223
  let [type, bucketHash, params, newMetrics, localAttrs] = errorInfoArr;
223
224
  const allCustomAttrs = {};
224
225
  if (softNavOccurredFinished) {
225
- Object.entries(softNavCustomAttrs).forEach(_ref => {
226
- let [k, v] = _ref;
226
+ Object.entries(softNavCustomAttrs).forEach(_ref2 => {
227
+ let [k, v] = _ref2;
227
228
  return setCustom(k, v);
228
229
  }); // when an ixn finishes, it'll include stuff in jsAttributes + attrs specific to the ixn
229
230
  bucketHash += params.browserInteractionId;
@@ -231,14 +232,14 @@ class Aggregate extends _aggregateBase.AggregateBase {
231
232
  delete params._softNavFinished;
232
233
  } else {
233
234
  // interaction was cancelled -> error should not be associated OR there was no interaction
234
- Object.entries((0, _config.getInfo)(this.agentIdentifier).jsAttributes).forEach(_ref2 => {
235
- let [k, v] = _ref2;
235
+ Object.entries((0, _config.getInfo)(this.agentIdentifier).jsAttributes).forEach(_ref3 => {
236
+ let [k, v] = _ref3;
236
237
  return setCustom(k, v);
237
238
  });
238
239
  delete params.browserInteractionId;
239
240
  }
240
- if (localAttrs) Object.entries(localAttrs).forEach(_ref3 => {
241
- let [k, v] = _ref3;
241
+ if (localAttrs) Object.entries(localAttrs).forEach(_ref4 => {
242
+ let [k, v] = _ref4;
242
243
  return setCustom(k, v);
243
244
  }); // local custom attrs are applied in either case with the highest precedence
244
245
 
@@ -15,35 +15,34 @@ var _load = require("../../../common/window/load");
15
15
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
16
16
  var _runtime = require("../../../common/constants/runtime");
17
17
  var _aggregateBase = require("../../utils/aggregate-base");
18
+ var _drain = require("../../../common/drain/drain");
18
19
  class Aggregate extends _aggregateBase.AggregateBase {
19
20
  static featureName = _constants.FEATURE_NAME;
20
21
  constructor(agentIdentifier, aggregator) {
21
22
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
22
- let scheduler;
23
-
24
- // If RUM-call's response determines that customer lacks entitlements for the /jserror ingest endpoint, don't harvest at all.
25
- (0, _registerHandler.registerHandler)('block-err', () => {
26
- this.blocked = true;
27
- if (scheduler) scheduler.aborted = true; // RUM response may or may not have happened already before scheduler initialization below
28
- }, this.featureName, this.ee);
23
+ this.waitForFlags(['err']).then(_ref => {
24
+ let [errFlag] = _ref;
25
+ if (errFlag) {
26
+ // *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
27
+ const scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
28
+ onUnload: () => this.unload()
29
+ }, this);
30
+ // this is needed to ensure EoL is "on" and sent
31
+ scheduler.harvest.on('jserrors', () => ({
32
+ body: this.aggregator.take(['cm', 'sm'])
33
+ }));
34
+ this.drain();
35
+ } else {
36
+ this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
37
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
38
+ }
39
+ });
29
40
 
30
41
  // Allow features external to the metrics feature to capture SMs and CMs through the event emitter
31
42
  (0, _registerHandler.registerHandler)(_constants.SUPPORTABILITY_METRIC_CHANNEL, this.storeSupportabilityMetrics.bind(this), this.featureName, this.ee);
32
43
  (0, _registerHandler.registerHandler)(_constants.CUSTOM_METRIC_CHANNEL, this.storeEventMetrics.bind(this), this.featureName, this.ee);
33
44
  this.singleChecks(); // checks that are run only one time, at script load
34
45
  this.eachSessionChecks(); // the start of every time user engages with page
35
-
36
- this.ee.on("drain-".concat(this.featureName), () => {
37
- // *cli, Mar 23 - Per NR-94597, this feature should only harvest ONCE at the (potential) EoL time of the page.
38
- scheduler = new _harvestScheduler.HarvestScheduler('jserrors', {
39
- onUnload: () => this.unload()
40
- }, this);
41
- scheduler.harvest.on('jserrors', () => ({
42
- body: this.aggregator.take(['cm', 'sm'])
43
- }));
44
- }); // this is needed to ensure EoL is "on" and sent
45
-
46
- this.drain();
47
46
  }
48
47
  storeSupportabilityMetrics(name, value) {
49
48
  if (this.blocked) return;
@@ -67,6 +66,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
67
66
  distMethod,
68
67
  loaderType
69
68
  } = (0, _config.getRuntime)(this.agentIdentifier);
69
+ const {
70
+ proxy,
71
+ privacy,
72
+ page_view_timing
73
+ } = (0, _config.getConfiguration)(this.agentIdentifier);
70
74
  if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
71
75
  if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
72
76
  if (_runtime.isBrowserScope) {
@@ -82,6 +86,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
82
86
  this.storeSupportabilityMetrics('Framework/' + framework + '/Detected');
83
87
  });
84
88
  });
89
+ if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
90
+ if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled');
85
91
  } else if (_runtime.isWorkerScope) {
86
92
  this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
87
93
  } else {
@@ -100,13 +106,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
100
106
  if (rules.length > 0 && !(0, _obfuscate.validateRules)(rules)) this.storeSupportabilityMetrics('Generic/Obfuscate/Invalid');
101
107
 
102
108
  // Check if proxy for either chunks or beacon is being used
103
- const {
104
- proxy,
105
- privacy
106
- } = (0, _config.getConfiguration)(this.agentIdentifier);
107
109
  if (proxy.assets) this.storeSupportabilityMetrics('Config/AssetsUrl/Changed');
108
110
  if (proxy.beacon) this.storeSupportabilityMetrics('Config/BeaconUrl/Changed');
109
- if (!(_runtime.isBrowserScope && privacy.cookies_enabled)) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
110
111
  }
111
112
  eachSessionChecks() {
112
113
  if (!_runtime.isBrowserScope) return;
@@ -13,6 +13,7 @@ var _config = require("../../../common/config/config");
13
13
  var _constants = require("../constants");
14
14
  var _runtime = require("../../../common/constants/runtime");
15
15
  var _aggregateBase = require("../../utils/aggregate-base");
16
+ var _drain = require("../../../common/drain/drain");
16
17
  /*
17
18
  * Copyright 2020 New Relic Corporation. All rights reserved.
18
19
  * SPDX-License-Identifier: Apache-2.0
@@ -37,8 +38,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
37
38
  return _this.addPageAction(...arguments);
38
39
  }, this.featureName, this.ee);
39
40
  this.waitForFlags(['ins']).then(_ref => {
40
- let [enabled] = _ref;
41
- if (enabled) {
41
+ let [insFlag] = _ref;
42
+ if (insFlag) {
42
43
  const scheduler = new _harvestScheduler.HarvestScheduler('ins', {
43
44
  onFinished: function () {
44
45
  return _this.onHarvestFinished(...arguments);
@@ -48,11 +49,12 @@ class Aggregate extends _aggregateBase.AggregateBase {
48
49
  return _this.onHarvestStarted(...arguments);
49
50
  });
50
51
  scheduler.startTimer(this.harvestTimeSeconds, 0);
52
+ this.drain();
51
53
  } else {
52
- this.blocked = true;
54
+ this.blocked = true; // if rum response determines that customer lacks entitlements for ins endpoint, this feature shouldn't harvest
55
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
53
56
  }
54
57
  });
55
- this.drain();
56
58
  }
57
59
  onHarvestStarted(options) {
58
60
  const {
@@ -17,6 +17,10 @@ var _aggregateBase = require("../../utils/aggregate-base");
17
17
  var _firstContentfulPaint = require("../../../common/vitals/first-contentful-paint");
18
18
  var _firstPaint = require("../../../common/vitals/first-paint");
19
19
  var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
20
+ var _drain = require("../../../common/drain/drain");
21
+ var _features = require("../../../loaders/features/features");
22
+ var _handle = require("../../../common/event-emitter/handle");
23
+ var _constants2 = require("../../metrics/constants");
20
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
26
  class Aggregate extends _aggregateBase.AggregateBase {
@@ -125,7 +129,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
125
129
  cbFinished: _ref3 => {
126
130
  let {
127
131
  status,
128
- responseText
132
+ responseText,
133
+ xhr,
134
+ fullUrl
129
135
  } = _ref3;
130
136
  if (status >= 400 || status === 0) {
131
137
  // Adding retry logic for the rum call will be a separate change
@@ -133,7 +139,21 @@ class Aggregate extends _aggregateBase.AggregateBase {
133
139
  return;
134
140
  }
135
141
  try {
136
- (0, _featureFlags.activateFeatures)(JSON.parse(responseText), this.agentIdentifier);
142
+ this.timeKeeper.processRumRequest(xhr, fullUrl);
143
+ } catch (error) {
144
+ (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['PVE/NRTime/Calculation/Failed'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
145
+ (0, _drain.drain)(this.agentIdentifier, _features.FEATURE_NAMES.metrics, true);
146
+ this.ee.abort();
147
+ (0, _console.warn)('Could not calculate New Relic server time. Agent shutting down.');
148
+ return;
149
+ }
150
+ try {
151
+ const {
152
+ app,
153
+ ...flags
154
+ } = JSON.parse(responseText);
155
+ agentRuntime.appMetadata = app;
156
+ (0, _featureFlags.activateFeatures)(flags, this.agentIdentifier);
137
157
  this.drain();
138
158
  } catch (err) {
139
159
  this.ee.abort();
@@ -43,17 +43,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
43
43
  this.timings = [];
44
44
  this.timingsSent = [];
45
45
  this.curSessEndRecorded = false;
46
- _firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
47
- _firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
48
- _firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
49
- _largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
50
- _interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
51
- _timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
52
- let {
53
- entries
54
- } = _ref2;
55
- this.addTiming('load', Math.round(entries[0].loadEventEnd));
56
- });
57
46
  if ((0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
58
47
 
59
48
  /* It's important that CWV api, like "onLCP", is called before this scheduler is initialized. The reason is because they listen to the same
@@ -63,9 +52,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
63
52
  (0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
64
53
  const initialHarvestSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.initialHarvestSeconds') || 10;
65
54
  const harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
66
- // send initial data sooner, then start regular
67
- this.ee.on("drain-".concat(this.featureName), () => {
68
- this.scheduler = new _harvestScheduler.HarvestScheduler('events', {
55
+ this.waitForFlags([]).then(() => {
56
+ _firstPaint.firstPaint.subscribe(this.#handleVitalMetric);
57
+ _firstContentfulPaint.firstContentfulPaint.subscribe(this.#handleVitalMetric);
58
+ _firstInputDelay.firstInputDelay.subscribe(this.#handleVitalMetric);
59
+ _largestContentfulPaint.largestContentfulPaint.subscribe(this.#handleVitalMetric);
60
+ _interactionToNextPaint.interactionToNextPaint.subscribe(this.#handleVitalMetric);
61
+ _timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
62
+ let {
63
+ entries
64
+ } = _ref2;
65
+ this.addTiming('load', Math.round(entries[0].loadEventEnd));
66
+ });
67
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
69
68
  onFinished: function () {
70
69
  return _this.onHarvestFinished(...arguments);
71
70
  },
@@ -73,9 +72,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
73
72
  return _this.prepareHarvest(...arguments);
74
73
  }
75
74
  }, this);
76
- this.scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
75
+ scheduler.startTimer(harvestTimeSeconds, initialHarvestSeconds);
76
+ this.drain();
77
77
  });
78
- this.drain();
79
78
  }
80
79
 
81
80
  /**
@@ -21,6 +21,7 @@ var _now = require("../../../common/timing/now");
21
21
  var _constants3 = require("../../../common/session/constants");
22
22
  var _stringify = require("../../../common/util/stringify");
23
23
  var _stylesheetEvaluator = require("../shared/stylesheet-evaluator");
24
+ var _drain = require("../../../common/drain/drain");
24
25
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
26
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /*
26
27
  * Copyright 2023 New Relic Corporation. All rights reserved.
@@ -130,11 +131,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
130
131
  this.waitForFlags(['sr']).then(_ref => {
131
132
  let [flagOn] = _ref;
132
133
  this.entitled = flagOn;
133
- if (!this.entitled && this.recorder?.recording) {
134
- this.abort(_constants.ABORT_REASONS.ENTITLEMENTS);
135
- (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/EnabledNotEntitled/Detected'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
134
+ if (!this.entitled) {
135
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
136
+ if (this.recorder?.recording) {
137
+ this.abort(_constants.ABORT_REASONS.ENTITLEMENTS);
138
+ (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['SessionReplay/EnabledNotEntitled/Detected'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
139
+ }
136
140
  return;
137
141
  }
142
+ this.drain();
138
143
  this.initializeRecording(Math.random() * 100 < error_sampling_rate, Math.random() * 100 < sampling_rate);
139
144
  }).then(() => {
140
145
  if (this.mode === _constants3.MODE.OFF) args?.recorder?.stopRecording(); // stop any conservative preload recording launched by instrument
@@ -151,7 +156,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
151
156
  if (mask_text_selector !== '*') (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/MaskTextSelector/Modified'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
152
157
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/SamplingRate/Value', sampling_rate], undefined, _features.FEATURE_NAMES.metrics, this.ee);
153
158
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ['Config/SessionReplay/ErrorSamplingRate/Value', error_sampling_rate], undefined, _features.FEATURE_NAMES.metrics, this.ee);
154
- this.drain();
155
159
  }
156
160
  switchToFull() {
157
161
  this.mode = _constants3.MODE.FULL;
@@ -322,6 +326,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
322
326
  const lastEventTimestamp = events[events.length - 1]?.timestamp; // from rrweb node
323
327
  const firstTimestamp = firstEventTimestamp || recorderEvents.cycleTimestamp; // from rrweb node || from when the harvest cycle started
324
328
  const lastTimestamp = lastEventTimestamp || agentOffset + relativeNow;
329
+ const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
325
330
  return {
326
331
  qs: {
327
332
  browser_monitoring_key: info.licenseKey,
@@ -334,6 +339,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
334
339
  ...(!!this.gzipper && !!this.u8 && {
335
340
  content_encoding: 'gzip'
336
341
  }),
342
+ ...(agentMetadata.entityGuid && {
343
+ entityGuid: agentMetadata.entityGuid
344
+ }),
337
345
  'replay.firstTimestamp': firstTimestamp,
338
346
  'replay.firstTimestampOffset': firstTimestamp - agentOffset,
339
347
  'replay.lastTimestamp': lastTimestamp,
@@ -123,7 +123,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
123
123
  if (!sessionEntity) {
124
124
  // Since session manager isn't around, do the old Trace behavior of waiting for RUM response to decide feature activation.
125
125
  this.isStandalone = true;
126
- (0, _registerHandler.registerHandler)('rumresp-stn', on => controlTraceOp(on), this.featureName, this.ee);
126
+ this.waitForFlags(['stn']).then(_ref => {
127
+ let [on] = _ref;
128
+ return controlTraceOp(on);
129
+ }, this.featureName, this.ee);
127
130
  } else {
128
131
  (0, _registerHandler.registerHandler)('errorAgg', () => {
129
132
  seenAnError = true;
@@ -140,8 +143,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
140
143
  };
141
144
 
142
145
  // CAUTION: everything inside this promise runs post-load; event subscribers must be pre-load aka synchronous with constructor
143
- this.waitForFlags(['stn', 'sr']).then(async _ref => {
144
- let [traceOn, replayOn] = _ref;
146
+ this.waitForFlags(['stn', 'sr']).then(async _ref2 => {
147
+ let [traceOn, replayOn] = _ref2;
145
148
  if (!replayOn) {
146
149
  // When sr = 0 from BCS, also do the old Trace behavior:
147
150
  this.isStandalone = true;
@@ -171,7 +174,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
171
174
  if (replayMode === _constants2.MODE.OFF) this.isStandalone = true; // without SR, Traces are still subject to old harvest limits
172
175
 
173
176
  let startingMode;
174
- if (traceOn === true) {
177
+ if (traceOn) {
175
178
  // CASE: both trace (entitlement+sampling) & replay (entitlement) flags are true from RUM
176
179
  startingMode = _constants2.MODE.FULL; // always full capture regardless of replay sampling decisions
177
180
  } else {
@@ -259,8 +262,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
259
262
  }
260
263
  if (result.sent && result.retry && this.sentTrace) {
261
264
  // merge previous trace back into buffer to retry for next harvest
262
- Object.entries(this.sentTrace).forEach(_ref2 => {
263
- let [name, listOfSTNodes] = _ref2;
265
+ Object.entries(this.sentTrace).forEach(_ref3 => {
266
+ let [name, listOfSTNodes] = _ref3;
264
267
  if (this.nodeCount >= this.maxNodesPerHarvest) return;
265
268
  this.nodeCount += listOfSTNodes.length;
266
269
  this.trace[name] = this.trace[name] ? listOfSTNodes.concat(this.trace[name]) : listOfSTNodes;
@@ -506,8 +509,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
506
509
  this.storeResources(window.performance.getEntriesByType('resource'));
507
510
  }
508
511
  let earliestTimeStamp = Infinity;
509
- const stns = Object.entries(this.trace).flatMap(_ref3 => {
510
- let [name, listOfSTNodes] = _ref3;
512
+ const stns = Object.entries(this.trace).flatMap(_ref4 => {
513
+ let [name, listOfSTNodes] = _ref4;
511
514
  // basically take the "this.trace" map-obj and concat all the list-type values
512
515
  const oldestNodeTS = listOfSTNodes.reduce((acc, next) => !acc || next.s < acc ? next.s : acc, undefined);
513
516
  if (oldestNodeTS < earliestTimeStamp) earliestTimeStamp = oldestNodeTS;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Aggregate = void 0;
7
7
  var _config = require("../../../common/config/config");
8
+ var _drain = require("../../../common/drain/drain");
8
9
  var _handle = require("../../../common/event-emitter/handle");
9
10
  var _registerHandler = require("../../../common/event-emitter/register-handler");
10
11
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
@@ -28,15 +29,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
28
29
  this.interactionsToHarvest = [];
29
30
  this.interactionsAwaitingRetry = [];
30
31
  this.domObserver = domObserver;
31
- this.scheduler = new _harvestScheduler.HarvestScheduler('events', {
32
- onFinished: this.onHarvestFinished.bind(this),
33
- retryDelay: harvestTimeSeconds,
34
- onUnload: () => this.interactionInProgress?.done() // return any held ajax or jserr events so they can be sent with EoL harvest
35
- }, {
36
- agentIdentifier,
37
- ee: this.ee
38
- });
39
- this.scheduler.harvest.on('events', this.onHarvestStarted.bind(this));
40
32
  this.initialPageLoadInteraction = new _initialPageLoadInteraction.InitialPageLoadInteraction(agentIdentifier);
41
33
  _timeToFirstByte.timeToFirstByte.subscribe(_ref2 => {
42
34
  let {
@@ -56,7 +48,22 @@ class Aggregate extends _aggregateBase.AggregateBase {
56
48
  this.blocked = false;
57
49
  this.waitForFlags(['spa']).then(_ref3 => {
58
50
  let [spaOn] = _ref3;
59
- if (spaOn) this.scheduler.startTimer(harvestTimeSeconds, 0);else this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
51
+ if (spaOn) {
52
+ this.drain();
53
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
54
+ onFinished: this.onHarvestFinished.bind(this),
55
+ retryDelay: harvestTimeSeconds,
56
+ onUnload: () => this.interactionInProgress?.done() // return any held ajax or jserr events so they can be sent with EoL harvest
57
+ }, {
58
+ agentIdentifier,
59
+ ee: this.ee
60
+ });
61
+ scheduler.harvest.on('events', this.onHarvestStarted.bind(this));
62
+ scheduler.startTimer(harvestTimeSeconds, 0);
63
+ } else {
64
+ this.blocked = true; // if rum response determines that customer lacks entitlements for spa endpoint, this feature shouldn't harvest
65
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
66
+ }
60
67
  });
61
68
 
62
69
  // By default, a complete UI driven interaction requires event -> URL change -> DOM mod in that exact order.
@@ -69,11 +76,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
69
76
  this.#registerApiHandlers();
70
77
  (0, _registerHandler.registerHandler)('ajax', this.#handleAjaxEvent.bind(this), this.featureName, this.ee);
71
78
  (0, _registerHandler.registerHandler)('jserror', this.#handleJserror.bind(this), this.featureName, this.ee);
72
- this.drain();
73
79
  }
74
80
  onHarvestStarted(options) {
75
81
  if (this.interactionsToHarvest.length === 0 || this.blocked) return;
76
-
77
82
  // The payload depacker takes the first ixn of a payload (if there are multiple ixns) and positively offset the subsequent ixns timestamps by that amount.
78
83
  // In order to accurately portray the real start & end times of the 2nd & onward ixns, we hence need to negatively offset their start timestamps with that of the 1st ixn.
79
84
  let firstIxnStartTime = 0; // the very 1st ixn does not require any offsetting
@@ -25,6 +25,7 @@ var _bundleId = require("../../../common/ids/bundle-id");
25
25
  var _runtime = require("../../../common/constants/runtime");
26
26
  var _handle = require("../../../common/event-emitter/handle");
27
27
  var _constants2 = require("../../metrics/constants");
28
+ var _drain = require("../../../common/drain/drain");
28
29
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
29
30
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
30
31
  /*
@@ -74,6 +75,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
74
75
  // The below feature flag is used to disable the SPA ajax fix for specific customers, see https://new-relic.atlassian.net/browse/NR-172169
75
76
  disableSpaFix: ((0, _config.getConfigurationValue)(agentIdentifier, 'feature_flags') || []).indexOf('disable-spa-fix') > -1
76
77
  };
78
+ let scheduler;
77
79
  this.serializer = new _serializer.Serializer(this);
78
80
  const {
79
81
  state,
@@ -92,14 +94,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
92
94
  const jsonpEE = baseEE.get('jsonp');
93
95
  const xhrEE = baseEE.get('xhr');
94
96
  const tracerEE = baseEE.get('tracer');
95
- const scheduler = new _harvestScheduler.HarvestScheduler('events', {
96
- onFinished: onHarvestFinished,
97
- retryDelay: state.harvestTimeSeconds
98
- }, {
99
- agentIdentifier,
100
- ee: baseEE
101
- });
102
- scheduler.harvest.on('events', onHarvestStarted);
103
97
 
104
98
  // childTime is used when calculating exclusive time for a cb duration.
105
99
  //
@@ -133,11 +127,23 @@ class Aggregate extends _aggregateBase.AggregateBase {
133
127
  // | click ending: | 65 | 50 | | | |
134
128
  // click fn-end | 70 | 0 | 0 | 70 | 20 |
135
129
 
136
- // if rum response determines that customer lacks entitlements for spa endpoint, block it
137
- (0, _registerHandler.registerHandler)('block-spa', () => {
138
- blocked = true;
139
- scheduler.stopTimer(true);
140
- }, this.featureName, baseEE);
130
+ this.waitForFlags(['spa']).then(_ref => {
131
+ let [spaFlag] = _ref;
132
+ if (spaFlag) {
133
+ scheduler = this.scheduler = new _harvestScheduler.HarvestScheduler('events', {
134
+ onFinished: onHarvestFinished,
135
+ retryDelay: state.harvestTimeSeconds
136
+ }, {
137
+ agentIdentifier,
138
+ ee: baseEE
139
+ });
140
+ this.scheduler.harvest.on('events', onHarvestStarted);
141
+ this.drain();
142
+ } else {
143
+ this.blocked = true;
144
+ (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
145
+ }
146
+ });
141
147
  if (!isEnabled()) return;
142
148
  state.initialPageLoad = new _interaction.Interaction('initialPageLoad', 0, state.lastSeenUrl, state.lastSeenRouteName, onInteractionFinished, agentIdentifier);
143
149
  state.initialPageLoad.save = true;
@@ -683,7 +689,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
683
689
  var enabled = (0, _config.getConfigurationValue)(agentIdentifier, 'spa.enabled');
684
690
  return enabled !== false;
685
691
  }
686
- this.drain();
687
692
  }
688
693
  }
689
694
  exports.Aggregate = Aggregate;
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AggregateBase = void 0;
7
- var _registerHandler = require("../../common/event-emitter/register-handler");
8
7
  var _featureBase = require("./feature-base");
9
8
  var _config = require("../../common/config/config");
10
9
  var _configure = require("../../loaders/configure/configure");
11
10
  var _nreum = require("../../common/window/nreum");
12
11
  var _drain = require("../../common/drain/drain");
12
+ var _featureFlags = require("../../common/util/feature-flags");
13
13
  class AggregateBase extends _featureBase.FeatureBase {
14
14
  constructor() {
15
15
  super(...arguments);
@@ -19,13 +19,26 @@ class AggregateBase extends _featureBase.FeatureBase {
19
19
  /**
20
20
  * New handler for waiting for multiple flags. Useful when expecting multiple flags simultaneously (ex. stn vs sr)
21
21
  * @param {string[]} flagNames
22
- * @returns
22
+ * @returns {Promise}
23
23
  */
24
24
  waitForFlags() {
25
25
  let flagNames = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
26
- return Promise.all(flagNames.map(fName => new Promise(resolve => {
27
- (0, _registerHandler.registerHandler)("rumresp-".concat(fName), isOn => resolve(isOn), this.featureName, this.ee);
28
- })));
26
+ return new Promise((resolve, reject) => {
27
+ if (_featureFlags.activatedFeatures[this.agentIdentifier]) {
28
+ resolve(buildOutput(_featureFlags.activatedFeatures[this.agentIdentifier]));
29
+ } else {
30
+ this.ee.on('rumresp', function () {
31
+ let resp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
+ resolve(buildOutput(resp));
33
+ });
34
+ }
35
+ function buildOutput(ref) {
36
+ return flagNames.map(flag => {
37
+ if (!ref[flag]) return 0;
38
+ return ref[flag];
39
+ });
40
+ }
41
+ });
29
42
  }
30
43
  drain() {
31
44
  (0, _drain.drain)(this.agentIdentifier, this.featureName);
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.FeatureBase = void 0;
7
7
  var _contextualEe = require("../../common/event-emitter/contextual-ee");
8
+ var _timeKeeper = require("../../common/timing/time-keeper");
8
9
  class FeatureBase {
9
10
  constructor(agentIdentifier, aggregator, featureName) {
10
11
  /** @type {string} */
@@ -21,6 +22,7 @@ class FeatureBase {
21
22
  * @type {boolean}
22
23
  */
23
24
  this.blocked = false;
25
+ this.timeKeeper = _timeKeeper.TimeKeeper.getTimeKeeperByAgentIdentifier(this.agentIdentifier);
24
26
  }
25
27
  }
26
28
  exports.FeatureBase = FeatureBase;
@@ -122,6 +122,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
122
122
  // not supported yet but nice to do: "abort" this agent's EE for this feature specifically
123
123
  (0, _drain.drain)(this.agentIdentifier, this.featureName, true);
124
124
  loadedSuccessfully(false);
125
+ if (this.ee) this.ee.abort();
125
126
  }
126
127
  };
127
128
 
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.AgentBase = void 0;
7
7
  var _console = require("../common/util/console");
8
8
  var _constants = require("../features/session_replay/constants");
9
- var _observationContextManager = require("../common/context/observation-context-manager");
10
9
  var _uniqueId = require("../common/ids/unique-id");
11
- var _contextualEe = require("../common/event-emitter/contextual-ee");
10
+ var _timeKeeper = require("../common/timing/time-keeper");
12
11
  /* eslint-disable n/handle-callback-err */
13
12
 
14
13
  /**
@@ -17,14 +16,10 @@ var _contextualEe = require("../common/event-emitter/contextual-ee");
17
16
 
18
17
  class AgentBase {
19
18
  agentIdentifier;
20
- observationContext = new _observationContextManager.ObservationContextManager();
19
+ timeKeeper = new _timeKeeper.TimeKeeper(this);
21
20
  constructor() {
22
21
  let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _uniqueId.generateRandomHexString)(16);
23
22
  this.agentIdentifier = agentIdentifier;
24
-
25
- // Assign the observation context to the event emitter, so it knows how to create observation contexts
26
- const eventEmitter = _contextualEe.ee.get(agentIdentifier);
27
- eventEmitter.observationContext = this.observationContext;
28
23
  }
29
24
 
30
25
  /**