@newrelic/browser-agent 1.277.0 → 1.278.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 (133) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/common/aggregate/event-aggregator.js +1 -1
  3. package/dist/cjs/common/config/init.js +1 -10
  4. package/dist/cjs/common/config/runtime.js +2 -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/harvest/harvester.js +255 -0
  8. package/dist/cjs/common/harvest/types.js +5 -21
  9. package/dist/cjs/features/ajax/aggregate/index.js +2 -11
  10. package/dist/cjs/features/generic_events/aggregate/index.js +3 -10
  11. package/dist/cjs/features/jserrors/aggregate/index.js +3 -14
  12. package/dist/cjs/features/logging/aggregate/index.js +4 -12
  13. package/dist/cjs/features/metrics/aggregate/index.js +7 -15
  14. package/dist/cjs/features/page_view_event/aggregate/index.js +46 -48
  15. package/dist/cjs/features/page_view_timing/aggregate/index.js +0 -9
  16. package/dist/cjs/features/session_replay/aggregate/index.js +21 -43
  17. package/dist/cjs/features/session_replay/instrument/index.js +2 -1
  18. package/dist/cjs/features/session_replay/shared/recorder.js +6 -6
  19. package/dist/cjs/features/session_trace/aggregate/index.js +9 -24
  20. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +8 -2
  21. package/dist/cjs/features/soft_navigations/aggregate/index.js +4 -11
  22. package/dist/cjs/features/spa/aggregate/index.js +7 -10
  23. package/dist/cjs/features/utils/aggregate-base.js +66 -27
  24. package/dist/cjs/features/utils/event-buffer.js +0 -1
  25. package/dist/cjs/features/utils/event-store-manager.js +109 -0
  26. package/dist/cjs/features/utils/instrument-base.js +1 -10
  27. package/dist/cjs/loaders/features/features.js +16 -10
  28. package/dist/cjs/loaders/micro-agent.js +1 -0
  29. package/dist/esm/common/aggregate/event-aggregator.js +1 -1
  30. package/dist/esm/common/config/init.js +1 -10
  31. package/dist/esm/common/config/runtime.js +2 -1
  32. package/dist/esm/common/constants/env.cdn.js +1 -1
  33. package/dist/esm/common/constants/env.npm.js +1 -1
  34. package/dist/esm/common/harvest/harvester.js +249 -0
  35. package/dist/esm/common/harvest/types.js +5 -21
  36. package/dist/esm/features/ajax/aggregate/index.js +3 -12
  37. package/dist/esm/features/generic_events/aggregate/index.js +3 -10
  38. package/dist/esm/features/jserrors/aggregate/index.js +4 -15
  39. package/dist/esm/features/logging/aggregate/index.js +4 -12
  40. package/dist/esm/features/metrics/aggregate/index.js +7 -15
  41. package/dist/esm/features/page_view_event/aggregate/index.js +46 -48
  42. package/dist/esm/features/page_view_timing/aggregate/index.js +1 -10
  43. package/dist/esm/features/session_replay/aggregate/index.js +22 -44
  44. package/dist/esm/features/session_replay/instrument/index.js +2 -1
  45. package/dist/esm/features/session_replay/shared/recorder.js +6 -6
  46. package/dist/esm/features/session_trace/aggregate/index.js +9 -24
  47. package/dist/esm/features/session_trace/aggregate/trace/storage.js +8 -2
  48. package/dist/esm/features/soft_navigations/aggregate/index.js +5 -12
  49. package/dist/esm/features/spa/aggregate/index.js +8 -11
  50. package/dist/esm/features/utils/aggregate-base.js +66 -27
  51. package/dist/esm/features/utils/event-buffer.js +0 -1
  52. package/dist/esm/features/utils/event-store-manager.js +103 -0
  53. package/dist/esm/features/utils/instrument-base.js +1 -10
  54. package/dist/esm/loaders/features/features.js +15 -9
  55. package/dist/esm/loaders/micro-agent.js +1 -0
  56. package/dist/types/common/aggregate/event-aggregator.d.ts +1 -1
  57. package/dist/types/common/aggregate/event-aggregator.d.ts.map +1 -1
  58. package/dist/types/common/config/init.d.ts.map +1 -1
  59. package/dist/types/common/config/runtime.d.ts.map +1 -1
  60. package/dist/types/common/harvest/harvester.d.ts +16 -0
  61. package/dist/types/common/harvest/harvester.d.ts.map +1 -0
  62. package/dist/types/common/harvest/types.d.ts +8 -45
  63. package/dist/types/common/harvest/types.d.ts.map +1 -1
  64. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  65. package/dist/types/features/generic_events/aggregate/index.d.ts +0 -3
  66. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -1
  67. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  68. package/dist/types/features/logging/aggregate/index.d.ts +0 -3
  69. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  70. package/dist/types/features/metrics/aggregate/index.d.ts +1 -1
  71. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  72. package/dist/types/features/page_view_event/aggregate/index.d.ts +6 -2
  73. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  74. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  75. package/dist/types/features/session_replay/aggregate/index.d.ts +12 -15
  76. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  77. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  78. package/dist/types/features/session_trace/aggregate/index.d.ts +0 -5
  79. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  80. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts +8 -5
  81. package/dist/types/features/session_trace/aggregate/trace/storage.d.ts.map +1 -1
  82. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  83. package/dist/types/features/spa/aggregate/index.d.ts +0 -1
  84. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  85. package/dist/types/features/utils/aggregate-base.d.ts +12 -7
  86. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  87. package/dist/types/features/utils/event-buffer.d.ts +1 -2
  88. package/dist/types/features/utils/event-buffer.d.ts.map +1 -1
  89. package/dist/types/features/utils/event-store-manager.d.ts +43 -0
  90. package/dist/types/features/utils/event-store-manager.d.ts.map +1 -0
  91. package/dist/types/features/utils/instrument-base.d.ts +0 -1
  92. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  93. package/dist/types/loaders/features/features.d.ts +15 -12
  94. package/dist/types/loaders/features/features.d.ts.map +1 -1
  95. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  96. package/package.json +6 -6
  97. package/src/common/aggregate/event-aggregator.js +1 -1
  98. package/src/common/config/init.js +9 -10
  99. package/src/common/config/runtime.js +2 -1
  100. package/src/common/harvest/__mocks__/harvester.js +6 -0
  101. package/src/common/harvest/harvester.js +230 -0
  102. package/src/common/harvest/types.js +5 -21
  103. package/src/features/ajax/aggregate/index.js +3 -14
  104. package/src/features/generic_events/aggregate/index.js +3 -13
  105. package/src/features/jserrors/aggregate/index.js +4 -11
  106. package/src/features/logging/aggregate/index.js +4 -12
  107. package/src/features/metrics/aggregate/index.js +5 -12
  108. package/src/features/page_view_event/aggregate/index.js +38 -38
  109. package/src/features/page_view_timing/aggregate/index.js +1 -12
  110. package/src/features/session_replay/aggregate/index.js +19 -42
  111. package/src/features/session_replay/instrument/index.js +1 -1
  112. package/src/features/session_replay/shared/recorder.js +6 -6
  113. package/src/features/session_trace/aggregate/index.js +8 -25
  114. package/src/features/session_trace/aggregate/trace/storage.js +5 -2
  115. package/src/features/soft_navigations/aggregate/index.js +4 -12
  116. package/src/features/spa/aggregate/index.js +8 -11
  117. package/src/features/utils/aggregate-base.js +59 -27
  118. package/src/features/utils/event-buffer.js +0 -1
  119. package/src/features/utils/event-store-manager.js +101 -0
  120. package/src/features/utils/instrument-base.js +2 -8
  121. package/src/loaders/features/features.js +16 -9
  122. package/src/loaders/micro-agent.js +1 -0
  123. package/dist/cjs/common/harvest/harvest-scheduler.js +0 -168
  124. package/dist/cjs/common/harvest/harvest.js +0 -295
  125. package/dist/esm/common/harvest/harvest-scheduler.js +0 -160
  126. package/dist/esm/common/harvest/harvest.js +0 -286
  127. package/dist/types/common/harvest/harvest-scheduler.d.ts +0 -50
  128. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +0 -1
  129. package/dist/types/common/harvest/harvest.d.ts +0 -65
  130. package/dist/types/common/harvest/harvest.d.ts.map +0 -1
  131. package/src/common/harvest/__mocks__/harvest.js +0 -13
  132. package/src/common/harvest/harvest-scheduler.js +0 -166
  133. package/src/common/harvest/harvest.js +0 -282
@@ -11,7 +11,6 @@ var _navTiming = require("../../../common/timing/nav-timing");
11
11
  var _uniqueId = require("../../../common/ids/unique-id");
12
12
  var _interaction = require("./interaction");
13
13
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
14
- var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
15
14
  var _serializer = require("./serializer");
16
15
  var _contextualEe = require("../../../common/event-emitter/contextual-ee");
17
16
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
@@ -67,13 +66,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
67
66
  pageLoaded: false,
68
67
  childTime: 0,
69
68
  depth: 0,
70
- harvestTimeSeconds: agentRef.init.spa.harvestTimeSeconds || 10,
71
69
  // The below feature flag is used to disable the SPA ajax fix for specific customers, see https://new-relic.atlassian.net/browse/NR-172169
72
70
  disableSpaFix: (agentRef.init.feature_flags || []).indexOf('disable-spa-fix') > -1
73
71
  };
74
72
  this.spaSerializerClass = new _serializer.Serializer(this);
75
73
  const classThis = this;
76
- let scheduler;
77
74
  const baseEE = _contextualEe.ee.get(agentRef.agentIdentifier); // <-- parent baseEE
78
75
  const mutationEE = baseEE.get('mutation');
79
76
  const promiseEE = baseEE.get('promise');
@@ -117,13 +114,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
117
114
  // | click ending: | 65 | 50 | | | |
118
115
  // click fn-end | 70 | 0 | 0 | 70 | 20 |
119
116
 
117
+ let harvester;
120
118
  this.waitForFlags(['spa']).then(([spaFlag]) => {
121
119
  if (spaFlag) {
122
- scheduler = new _harvestScheduler.HarvestScheduler(_features.FEATURE_TO_ENDPOINT[this.featureName], {
123
- onFinished: result => this.postHarvestCleanup(result.sent && result.retry),
124
- getPayload: options => this.makeHarvestPayload(options.retry),
125
- retryDelay: state.harvestTimeSeconds
126
- }, this);
120
+ harvester = agentRef.runtime.harvester; // since this is after RUM call, PVE would've initialized harvester by now
127
121
  this.drain();
128
122
  } else {
129
123
  this.blocked = true;
@@ -664,8 +658,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
664
658
  let smCategory;
665
659
  if (interaction.root?.attrs?.trigger === 'initialPageLoad') smCategory = 'InitialPageLoad';else if (interaction.routeChange) smCategory = 'RouteChange';else smCategory = 'Custom';
666
660
  (0, _handle.handle)(_constants2.SUPPORTABILITY_METRIC_CHANNEL, ["Spa/Interaction/".concat(smCategory, "/Duration/Ms"), Math.max((interaction.root?.end || 0) - (interaction.root?.start || 0), 0)], undefined, _features.FEATURE_NAMES.metrics, baseEE);
667
- scheduler?.scheduleHarvest(0);
668
- if (!scheduler) (0, _console.warn)(19);
661
+ if (!harvester) {
662
+ (0, _console.warn)(19);
663
+ return;
664
+ }
665
+ harvester.triggerHarvestFor(classThis);
669
666
  }
670
667
  }
671
668
  serializer(eventBuffer) {
@@ -11,18 +11,33 @@ var _nreum = require("../../common/window/nreum");
11
11
  var _drain = require("../../common/drain/drain");
12
12
  var _featureFlags = require("../../common/util/feature-flags");
13
13
  var _obfuscate = require("../../common/util/obfuscate");
14
- var _eventBuffer = require("./event-buffer");
15
14
  var _features = require("../../loaders/features/features");
15
+ var _eventStoreManager = require("./event-store-manager");
16
+ var _harvester = require("../../common/harvest/harvester");
16
17
  class AggregateBase extends _featureBase.FeatureBase {
17
18
  constructor(agentRef, featureName) {
18
19
  super(agentRef.agentIdentifier, featureName);
19
20
  this.agentRef = agentRef;
20
- // Jserror and Metric features uses a singleton EventAggregator instead of a regular EventBuffer.
21
- if ([_features.FEATURE_NAMES.jserrors, _features.FEATURE_NAMES.metrics].includes(this.featureName)) this.events = agentRef.sharedAggregator;
22
- // PVE has no need for eventBuffer, and SessionTrace has its own storage mechanism.
23
- else if (![_features.FEATURE_NAMES.pageViewEvent, _features.FEATURE_NAMES.sessionTrace].includes(this.featureName)) this.events = new _eventBuffer.EventBuffer();
24
21
  this.checkConfiguration(agentRef);
25
- this.obfuscator = agentRef.runtime.obfuscator;
22
+ this.doOnceForAllAggregate(agentRef);
23
+
24
+ // This switch needs to be after doOnceForAllAggregate which may new sharedAggregator and reset mainAppKey.
25
+ switch (this.featureName) {
26
+ // PVE has no need for eventBuffer, and SessionTrace + Replay have their own storage mechanisms.
27
+ case _features.FEATURE_NAMES.pageViewEvent:
28
+ case _features.FEATURE_NAMES.sessionTrace:
29
+ case _features.FEATURE_NAMES.sessionReplay:
30
+ break;
31
+ // Jserror and Metric features uses a singleton EventAggregator instead of a regular EventBuffer.
32
+ case _features.FEATURE_NAMES.jserrors:
33
+ case _features.FEATURE_NAMES.metrics:
34
+ this.events = agentRef.sharedAggregator;
35
+ break;
36
+ default:
37
+ this.events = new _eventStoreManager.EventStoreManager(agentRef.mainAppKey, 1);
38
+ break;
39
+ }
40
+ this.harvestOpts = {}; // features aggregate classes can define custom opts for when their harvest is called
26
41
  }
27
42
 
28
43
  /**
@@ -60,32 +75,43 @@ class AggregateBase extends _featureBase.FeatureBase {
60
75
  /**
61
76
  * Return harvest payload. A "serializer" function can be defined on a derived class to format the payload.
62
77
  * @param {Boolean} shouldRetryOnFail - harvester flag to backup payload for retry later if harvest request fails; this should be moved to harvester logic
63
- * @returns final payload, or undefined if there are no pending events
78
+ * @param {object|undefined} opts.target - the target app passed onto the event store manager to determine which app's data to return; if none provided, all apps data will be returned
79
+ * @returns {Array} Final payload tagged with their targeting browser app. The value of `payload` can be undefined if there are no pending events for an app. This should be a minimum length of 1.
64
80
  */
65
81
  makeHarvestPayload(shouldRetryOnFail = false, opts = {}) {
66
- if (this.events.isEmpty(opts)) return;
82
+ if (this.events.isEmpty(this.harvestOpts, opts.target)) return;
67
83
  // Other conditions and things to do when preparing harvest that is required.
68
- if (this.preHarvestChecks && !this.preHarvestChecks()) return;
69
- if (shouldRetryOnFail) this.events.save(opts);
70
- const returnedData = this.events.get(opts);
71
- // A serializer or formatter assists in creating the payload `body` from stored events on harvest when defined by derived feature class.
72
- const body = this.serializer ? this.serializer(returnedData) : returnedData;
73
- this.events.clear(opts);
74
- const payload = {
75
- body
76
- };
77
- // Constructs the payload `qs` for relevant features on harvest.
78
- if (this.queryStringsBuilder) payload.qs = this.queryStringsBuilder(returnedData);
79
- return payload;
84
+ if (this.preHarvestChecks && !this.preHarvestChecks(opts)) return;
85
+ if (shouldRetryOnFail) this.events.save(this.harvestOpts, opts.target);
86
+ const returnedDataArr = this.events.get(this.harvestOpts, opts.target);
87
+ if (!returnedDataArr.length) throw new Error('Unexpected problem encountered. There should be at least one app for harvest!');
88
+ this.events.clear(this.harvestOpts, opts.target);
89
+ return returnedDataArr.map(({
90
+ targetApp,
91
+ data
92
+ }) => {
93
+ // A serializer or formatter assists in creating the payload `body` from stored events on harvest when defined by derived feature class.
94
+ const body = this.serializer ? this.serializer(data) : data;
95
+ const payload = {
96
+ body
97
+ };
98
+ // Constructs the payload `qs` for relevant features on harvest.
99
+ if (this.queryStringsBuilder) payload.qs = this.queryStringsBuilder(data);
100
+ return {
101
+ targetApp,
102
+ payload
103
+ };
104
+ });
80
105
  }
81
106
 
82
107
  /**
83
108
  * Cleanup task after a harvest.
84
- * @param {Boolean} harvestFailed - harvester flag to restore events in main buffer for retry later if request failed
109
+ * @param {object} result - the cbResult object from the harvester's send method
85
110
  */
86
- postHarvestCleanup(harvestFailed = false, opts = {}) {
87
- if (harvestFailed) this.events.reloadSave(opts);
88
- this.events.clearSave(opts);
111
+ postHarvestCleanup(result = {}) {
112
+ const harvestFailed = result.sent && result.retry;
113
+ if (harvestFailed) this.events.reloadSave(this.harvestOpts, result.targetApp);
114
+ this.events.clearSave(this.harvestOpts, result.targetApp);
89
115
  }
90
116
 
91
117
  /**
@@ -118,9 +144,22 @@ class AggregateBase extends _featureBase.FeatureBase {
118
144
  runtime: existingAgent.runtime
119
145
  });
120
146
  }
121
- if (!existingAgent.runtime.obfuscator) {
122
- existingAgent.runtime.obfuscator = new _obfuscate.Obfuscator(this.agentIdentifier);
123
- }
147
+ }
148
+
149
+ /**
150
+ * These are actions related to shared resources that should be initialized once by whichever feature Aggregate subclass loads first.
151
+ * This method should run after checkConfiguration, which may reset the agent's info/runtime object that is used here.
152
+ */
153
+ doOnceForAllAggregate(agentRef) {
154
+ if (!agentRef.runtime.obfuscator) agentRef.runtime.obfuscator = new _obfuscate.Obfuscator(this.agentIdentifier);
155
+ this.obfuscator = agentRef.runtime.obfuscator;
156
+ if (!agentRef.mainAppKey) agentRef.mainAppKey = {
157
+ licenseKey: agentRef.info.licenseKey,
158
+ appId: agentRef.info.applicationID
159
+ };
160
+ // Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
161
+ if (!agentRef.sharedAggregator) agentRef.sharedAggregator = new _eventStoreManager.EventStoreManager(agentRef.mainAppKey, 2);
162
+ if (!agentRef.runtime.harvester) agentRef.runtime.harvester = new _harvester.Harvester(agentRef);
124
163
  }
125
164
  }
126
165
  exports.AggregateBase = AggregateBase;
@@ -54,7 +54,6 @@ class EventBuffer {
54
54
 
55
55
  /**
56
56
  * Backup the buffered data and clear the main buffer
57
- * @returns {Array} the events being backed up
58
57
  */
59
58
  save() {
60
59
  this.#bufferBackup = this.#buffer;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EventStoreManager = void 0;
7
+ var _eventAggregator = require("../../common/aggregate/event-aggregator");
8
+ var _eventBuffer = require("./event-buffer");
9
+ /**
10
+ * This layer allows multiple browser entity apps, or "target", to each have their own segregated storage instance.
11
+ * The purpose is so the harvester can send data to different apps within the same agent. Each feature should have a manager if it needs this capability.
12
+ */
13
+ class EventStoreManager {
14
+ /**
15
+ * @param {object} defaultTarget - should contain licenseKey and appId of the main app from NREUM.info at startup
16
+ * @param {1|2} storageChoice - the type of storage to use in this manager; 'EventBuffer' (1), 'EventAggregator' (2)
17
+ */
18
+ constructor(defaultTarget, storageChoice) {
19
+ this.mainApp = defaultTarget;
20
+ this.StorageClass = storageChoice === 1 ? _eventBuffer.EventBuffer : _eventAggregator.EventAggregator;
21
+ this.appStorageMap = new Map();
22
+ this.appStorageMap.set(defaultTarget, new this.StorageClass());
23
+ }
24
+
25
+ // This class must contain an union of all methods from all supported storage classes and conceptualize away the target app argument.
26
+
27
+ /**
28
+ * @param {object} optsIfPresent - exists if called during harvest interval, @see AggregateBase.makeHarvestPayload
29
+ * @param {object} target - specific app's storage to check; if not provided, this method takes into account all apps recorded by this manager
30
+ * @returns {boolean} True if the target's storage is empty, or target does not exist in map (defaults to all storages)
31
+ */
32
+ isEmpty(optsIfPresent, target) {
33
+ if (target) {
34
+ if (!this.appStorageMap.has(target)) return true;else return this.appStorageMap.get(target).isEmpty(optsIfPresent);
35
+ }
36
+ for (const eventStore of this.appStorageMap.values()) {
37
+ if (!eventStore.isEmpty(optsIfPresent)) return false;
38
+ }
39
+ return true;
40
+ }
41
+
42
+ /**
43
+ * @param {string} event - the event element to store
44
+ * @param {object} target - the app to store event under; if not provided, this method adds to the main app from NREUM.info
45
+ * @returns {boolean} True if the event was successfully added
46
+ */
47
+ add(event, target) {
48
+ if (target && !this.appStorageMap.has(target)) this.appStorageMap.set(target, new this.StorageClass());
49
+ return this.appStorageMap.get(target || this.mainApp).add(event);
50
+ }
51
+
52
+ /** This is only used by the Metrics feature which has no need to add metric under a different app atm. */
53
+ addMetric(type, name, params, value) {
54
+ return this.appStorageMap.get(this.mainApp).addMetric(type, name, params, value);
55
+ }
56
+
57
+ /**
58
+ * @param {object} optsIfPresent - exists if called during harvest interval, @see AggregateBase.makeHarvestPayload
59
+ * @param {object} target - specific app to fetch; if not provided, this method fetches from all apps
60
+ * @returns {Array} Objects of `data` labeled with their respective `target` app to be sent to
61
+ */
62
+ get(optsIfPresent, target) {
63
+ if (target) return [{
64
+ targetApp: target,
65
+ data: this.appStorageMap.get(target)?.get(optsIfPresent)
66
+ }];
67
+ const allPayloads = [];
68
+ this.appStorageMap.forEach((eventStore, recordedTarget) => {
69
+ allPayloads.push({
70
+ targetApp: recordedTarget,
71
+ data: eventStore.get(optsIfPresent)
72
+ });
73
+ });
74
+ return allPayloads;
75
+ }
76
+ byteSize(target) {
77
+ return this.appStorageMap.get(target || this.mainApp).byteSize();
78
+ }
79
+ wouldExceedMaxSize(incomingSize, target) {
80
+ return this.appStorageMap.get(target || this.mainApp).wouldExceedMaxSize(incomingSize);
81
+ }
82
+ save(optsIfPresent, target) {
83
+ if (target) return this.appStorageMap.get(target)?.save(optsIfPresent);
84
+ this.appStorageMap.forEach(eventStore => eventStore.save(optsIfPresent));
85
+ }
86
+ clear(optsIfPresent, target) {
87
+ if (target) return this.appStorageMap.get(target)?.clear(optsIfPresent);
88
+ this.appStorageMap.forEach(eventStore => eventStore.clear(optsIfPresent));
89
+ }
90
+
91
+ // Unlike the methods above, the following will have a target as they are called by AggregateBase.postHarvestCleanup callback on harvest finish after getting & sending the data.
92
+ reloadSave(optsIfPresent, target) {
93
+ if (!target) {
94
+ // -- remove this block once the old harvest.js & harvest-schedule.js are deleted!
95
+ this.appStorageMap.forEach(eventStore => eventStore.reloadSave(optsIfPresent));
96
+ return;
97
+ }
98
+ return this.appStorageMap.get(target)?.reloadSave(optsIfPresent);
99
+ }
100
+ clearSave(optsIfPresent, target) {
101
+ if (!target) {
102
+ // -- remove this block once the old harvest.js & harvest-schedule.js are deleted!
103
+ this.appStorageMap.forEach(eventStore => eventStore.clearSave(optsIfPresent));
104
+ return;
105
+ }
106
+ return this.appStorageMap.get(target)?.clearSave(optsIfPresent);
107
+ }
108
+ }
109
+ exports.EventStoreManager = EventStoreManager;
@@ -48,7 +48,6 @@ class InstrumentBase extends _featureBase.FeatureBase {
48
48
  /**
49
49
  * @type {Promise} Assigned immediately after @see importAggregator runs. Serves as a signal for when the inner async fn finishes execution. Useful for features to await
50
50
  * one another if there are inter-features dependencies.
51
- * TODO: This is only used for the SPA feature component tests and should be refactored out.
52
51
  */
53
52
  this.onAggregateImported = undefined;
54
53
 
@@ -100,15 +99,6 @@ class InstrumentBase extends _featureBase.FeatureBase {
100
99
  * it's only responsible for aborting its one specific feature, rather than all.
101
100
  */
102
101
  try {
103
- // Create a single Aggregator for this agent if DNE yet; to be used by jserror endpoint features.
104
- if (!agentRef.sharedAggregator) {
105
- agentRef.sharedAggregator = Promise.resolve().then(() => _interopRequireWildcard(require(/* webpackChunkName: "shared-aggregator" */'../../common/aggregate/event-aggregator')));
106
- const {
107
- EventAggregator
108
- } = await agentRef.sharedAggregator;
109
- agentRef.sharedAggregator = new EventAggregator();
110
- } else await agentRef.sharedAggregator; // if another feature is already importing the aggregator, wait for it to finish
111
-
112
102
  if (!this.#shouldImportAgg(this.featureName, session)) {
113
103
  (0, _drain.drain)(this.agentIdentifier, this.featureName);
114
104
  loadedSuccessfully(false); // aggregate module isn't loaded at all
@@ -121,6 +111,7 @@ class InstrumentBase extends _featureBase.FeatureBase {
121
111
  Aggregate
122
112
  } = await lazyFeatureLoader(this.featureName, 'aggregate');
123
113
  this.featAggregate = new Aggregate(agentRef, argsObjFromInstrument);
114
+ agentRef.runtime.harvester.initializedAggregates.push(this.featAggregate); // "subscribe" the feature to future harvest intervals (PVE will start the timer)
124
115
  loadedSuccessfully(true);
125
116
  } catch (e) {
126
117
  (0, _console.warn)(34, e);
@@ -3,11 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.featurePriority = exports.FEATURE_TO_ENDPOINT = exports.FEATURE_NAMES = void 0;
6
+ exports.featurePriority = exports.RUM = exports.JSERRORS = exports.FEATURE_TO_ENDPOINT = exports.FEATURE_NAMES = exports.EVENTS = void 0;
7
+ // To reduce build size a bit:
8
+ const EVENTS = exports.EVENTS = 'events';
9
+ const JSERRORS = exports.JSERRORS = 'jserrors';
10
+ const BLOBS = 'browser/blobs';
11
+ const RUM = exports.RUM = 'rum';
7
12
  const FEATURE_NAMES = exports.FEATURE_NAMES = {
8
13
  ajax: 'ajax',
9
14
  genericEvents: 'generic_events',
10
- jserrors: 'jserrors',
15
+ jserrors: JSERRORS,
11
16
  logging: 'logging',
12
17
  metrics: 'metrics',
13
18
  /**
@@ -40,14 +45,15 @@ const featurePriority = exports.featurePriority = {
40
45
  [FEATURE_NAMES.genericEvents]: 11
41
46
  };
42
47
  const FEATURE_TO_ENDPOINT = exports.FEATURE_TO_ENDPOINT = {
43
- [FEATURE_NAMES.pageViewTiming]: 'events',
44
- [FEATURE_NAMES.ajax]: 'events',
45
- [FEATURE_NAMES.spa]: 'events',
46
- [FEATURE_NAMES.softNav]: 'events',
47
- [FEATURE_NAMES.metrics]: 'jserrors',
48
- [FEATURE_NAMES.jserrors]: 'jserrors',
49
- [FEATURE_NAMES.sessionTrace]: 'browser/blobs',
50
- [FEATURE_NAMES.sessionReplay]: 'browser/blobs',
48
+ [FEATURE_NAMES.pageViewEvent]: RUM,
49
+ [FEATURE_NAMES.pageViewTiming]: EVENTS,
50
+ [FEATURE_NAMES.ajax]: EVENTS,
51
+ [FEATURE_NAMES.spa]: EVENTS,
52
+ [FEATURE_NAMES.softNav]: EVENTS,
53
+ [FEATURE_NAMES.metrics]: JSERRORS,
54
+ [FEATURE_NAMES.jserrors]: JSERRORS,
55
+ [FEATURE_NAMES.sessionTrace]: BLOBS,
56
+ [FEATURE_NAMES.sessionReplay]: BLOBS,
51
57
  [FEATURE_NAMES.logging]: 'browser/logs',
52
58
  [FEATURE_NAMES.genericEvents]: 'ins'
53
59
  };
@@ -68,6 +68,7 @@ class MicroAgent extends _microAgentBase.MicroAgentBase {
68
68
  Aggregate
69
69
  }) => {
70
70
  this.features[f] = new Aggregate(this);
71
+ this.runtime.harvester.initializedAggregates.push(this.features[f]); // so that harvester will poll this feature agg on interval
71
72
  }).catch(err => (0, _console.warn)(25, err));
72
73
  }
73
74
  });
@@ -13,7 +13,7 @@ export class EventAggregator {
13
13
  if (!aggregatorTypes) return Object.keys(this.#aggregator.aggregatedData).length === 0;
14
14
  return aggregatorTypes.every(type => !this.#aggregator.aggregatedData[type]); // no bucket exist for any of the types we're looking for
15
15
  }
16
- add(type, name, params, newMetrics, customParams) {
16
+ add([type, name, params, newMetrics, customParams]) {
17
17
  // Do we need to track byte size here like EventBuffer?
18
18
  this.#aggregator.store(type, name, params, newMetrics, customParams);
19
19
  return true;
@@ -41,7 +41,6 @@ const model = () => {
41
41
  deny_list: undefined,
42
42
  block_internal: true,
43
43
  enabled: true,
44
- harvestTimeSeconds: 10,
45
44
  autoStart: true
46
45
  },
47
46
  distributed_tracing: {
@@ -59,20 +58,17 @@ const model = () => {
59
58
  },
60
59
  generic_events: {
61
60
  enabled: true,
62
- harvestTimeSeconds: 30,
63
61
  autoStart: true
64
62
  },
65
63
  harvest: {
66
- tooManyRequestsDelay: 60
64
+ interval: 30
67
65
  },
68
66
  jserrors: {
69
67
  enabled: true,
70
- harvestTimeSeconds: 10,
71
68
  autoStart: true
72
69
  },
73
70
  logging: {
74
71
  enabled: true,
75
- harvestTimeSeconds: 10,
76
72
  autoStart: true,
77
73
  level: LOG_LEVELS.INFO
78
74
  },
@@ -90,7 +86,6 @@ const model = () => {
90
86
  },
91
87
  page_view_timing: {
92
88
  enabled: true,
93
- harvestTimeSeconds: 30,
94
89
  autoStart: true
95
90
  },
96
91
  performance: {
@@ -138,7 +133,6 @@ const model = () => {
138
133
  // feature settings
139
134
  autoStart: true,
140
135
  enabled: false,
141
- harvestTimeSeconds: 60,
142
136
  preload: false,
143
137
  // if true, enables the agent to load rrweb immediately instead of waiting to do so after the window.load event
144
138
  sampling_rate: 10,
@@ -191,17 +185,14 @@ const model = () => {
191
185
  },
192
186
  session_trace: {
193
187
  enabled: true,
194
- harvestTimeSeconds: 10,
195
188
  autoStart: true
196
189
  },
197
190
  soft_navigations: {
198
191
  enabled: true,
199
- harvestTimeSeconds: 10,
200
192
  autoStart: true
201
193
  },
202
194
  spa: {
203
195
  enabled: true,
204
- harvestTimeSeconds: 10,
205
196
  autoStart: true
206
197
  },
207
198
  ssl: undefined,
@@ -28,7 +28,8 @@ const model = {
28
28
  session: undefined,
29
29
  denyList: undefined,
30
30
  timeKeeper: undefined,
31
- obfuscator: undefined
31
+ obfuscator: undefined,
32
+ harvester: undefined
32
33
  };
33
34
  const _cache = {};
34
35
  export function getRuntime(id) {
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.277.0";
9
+ export const VERSION = "1.278.1";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.277.0";
9
+ export const VERSION = "1.278.1";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent