@newrelic/browser-agent 1.278.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
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.278.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.278.0...v1.278.1) (2025-01-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Make Metrics harvest only on EoL for new Harvester ([#1311](https://github.com/newrelic/newrelic-browser-agent/issues/1311)) ([5cecedc](https://github.com/newrelic/newrelic-browser-agent/commit/5cecedcad6af7a14ec0e6777eba059ff1a5c008d))
12
+
6
13
  ## [1.278.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.277.0...v1.278.0) (2025-01-07)
7
14
 
8
15
 
@@ -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.278.0";
15
+ const VERSION = exports.VERSION = "1.278.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.278.0";
15
+ const VERSION = exports.VERSION = "1.278.1";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -64,7 +64,7 @@ class Harvester {
64
64
  let ranSend = false;
65
65
  if (!localOpts.directSend) {
66
66
  // primarily used by rum call to bypass makeHarvestPayload by providing payload directly
67
- dataToSendArr = aggregateInst.makeHarvestPayload(shouldRetryOnFail); // be sure the 'this' of makeHarvestPayload is the aggregate w/ access to its harvestOpts
67
+ dataToSendArr = aggregateInst.makeHarvestPayload(shouldRetryOnFail, localOpts); // be sure the 'this' of makeHarvestPayload is the aggregate w/ access to its harvestOpts
68
68
  if (!dataToSendArr) return false; // can be undefined if storage is empty or preharvest checks failed
69
69
  } else dataToSendArr = [localOpts.directSend];
70
70
  dataToSendArr.forEach(({
@@ -38,9 +38,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
38
38
  this.singleChecks(); // checks that are run only one time, at script load
39
39
  this.eachSessionChecks(); // the start of every time user engages with page
40
40
  }
41
- preHarvestChecks() {
42
- return this.drained;
43
- } // only allow any metrics to be sent if we know for sure it has gotten the go-ahead RUM flag
41
+ preHarvestChecks(opts) {
42
+ return this.drained && opts.isFinalHarvest;
43
+ } // only allow any metrics to be sent after we get the right RUM flag and only on EoL
44
44
 
45
45
  storeSupportabilityMetrics(name, value) {
46
46
  if (this.blocked) return;
@@ -75,17 +75,17 @@ class AggregateBase extends _featureBase.FeatureBase {
75
75
  /**
76
76
  * Return harvest payload. A "serializer" function can be defined on a derived class to format the payload.
77
77
  * @param {Boolean} shouldRetryOnFail - harvester flag to backup payload for retry later if harvest request fails; this should be moved to harvester logic
78
- * @param {object|undefined} 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
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
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.
80
80
  */
81
- makeHarvestPayload(shouldRetryOnFail = false, target) {
82
- if (this.events.isEmpty(this.harvestOpts, target)) return;
81
+ makeHarvestPayload(shouldRetryOnFail = false, opts = {}) {
82
+ if (this.events.isEmpty(this.harvestOpts, opts.target)) return;
83
83
  // Other conditions and things to do when preparing harvest that is required.
84
- if (this.preHarvestChecks && !this.preHarvestChecks()) return;
85
- if (shouldRetryOnFail) this.events.save(this.harvestOpts, target);
86
- const returnedDataArr = this.events.get(this.harvestOpts, target);
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
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, target);
88
+ this.events.clear(this.harvestOpts, opts.target);
89
89
  return returnedDataArr.map(({
90
90
  targetApp,
91
91
  data
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Exposes the version of the agent
8
8
  */
9
- export const VERSION = "1.278.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.278.0";
9
+ export const VERSION = "1.278.1";
10
10
 
11
11
  /**
12
12
  * Exposes the build type of the agent
@@ -58,7 +58,7 @@ export class Harvester {
58
58
  let ranSend = false;
59
59
  if (!localOpts.directSend) {
60
60
  // primarily used by rum call to bypass makeHarvestPayload by providing payload directly
61
- dataToSendArr = aggregateInst.makeHarvestPayload(shouldRetryOnFail); // be sure the 'this' of makeHarvestPayload is the aggregate w/ access to its harvestOpts
61
+ dataToSendArr = aggregateInst.makeHarvestPayload(shouldRetryOnFail, localOpts); // be sure the 'this' of makeHarvestPayload is the aggregate w/ access to its harvestOpts
62
62
  if (!dataToSendArr) return false; // can be undefined if storage is empty or preharvest checks failed
63
63
  } else dataToSendArr = [localOpts.directSend];
64
64
  dataToSendArr.forEach(({
@@ -32,9 +32,9 @@ export class Aggregate extends AggregateBase {
32
32
  this.singleChecks(); // checks that are run only one time, at script load
33
33
  this.eachSessionChecks(); // the start of every time user engages with page
34
34
  }
35
- preHarvestChecks() {
36
- return this.drained;
37
- } // only allow any metrics to be sent if we know for sure it has gotten the go-ahead RUM flag
35
+ preHarvestChecks(opts) {
36
+ return this.drained && opts.isFinalHarvest;
37
+ } // only allow any metrics to be sent after we get the right RUM flag and only on EoL
38
38
 
39
39
  storeSupportabilityMetrics(name, value) {
40
40
  if (this.blocked) return;
@@ -69,17 +69,17 @@ export class AggregateBase extends FeatureBase {
69
69
  /**
70
70
  * Return harvest payload. A "serializer" function can be defined on a derived class to format the payload.
71
71
  * @param {Boolean} shouldRetryOnFail - harvester flag to backup payload for retry later if harvest request fails; this should be moved to harvester logic
72
- * @param {object|undefined} 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
72
+ * @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
73
73
  * @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.
74
74
  */
75
- makeHarvestPayload(shouldRetryOnFail = false, target) {
76
- if (this.events.isEmpty(this.harvestOpts, target)) return;
75
+ makeHarvestPayload(shouldRetryOnFail = false, opts = {}) {
76
+ if (this.events.isEmpty(this.harvestOpts, opts.target)) return;
77
77
  // Other conditions and things to do when preparing harvest that is required.
78
- if (this.preHarvestChecks && !this.preHarvestChecks()) return;
79
- if (shouldRetryOnFail) this.events.save(this.harvestOpts, target);
80
- const returnedDataArr = this.events.get(this.harvestOpts, target);
78
+ if (this.preHarvestChecks && !this.preHarvestChecks(opts)) return;
79
+ if (shouldRetryOnFail) this.events.save(this.harvestOpts, opts.target);
80
+ const returnedDataArr = this.events.get(this.harvestOpts, opts.target);
81
81
  if (!returnedDataArr.length) throw new Error('Unexpected problem encountered. There should be at least one app for harvest!');
82
- this.events.clear(this.harvestOpts, target);
82
+ this.events.clear(this.harvestOpts, opts.target);
83
83
  return returnedDataArr.map(({
84
84
  targetApp,
85
85
  data
@@ -1,7 +1,7 @@
1
1
  export class Aggregate extends AggregateBase {
2
2
  static featureName: string;
3
3
  constructor(agentRef: any);
4
- preHarvestChecks(): boolean | undefined;
4
+ preHarvestChecks(opts: any): any;
5
5
  storeSupportabilityMetrics(name: any, value: any): void;
6
6
  storeEventMetrics(name: any, metrics: any): void;
7
7
  singleChecks(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/index.js"],"names":[],"mappings":"AAYA;IACE,2BAAiC;IACjC,2BAoBC;IAED,wCAA2C;IAE3C,wDAKC;IAED,iDAKC;IAED,qBAqEC;IAED,0BAOC;CACF;8BA5H6B,4BAA4B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/index.js"],"names":[],"mappings":"AAYA;IACE,2BAAiC;IACjC,2BAoBC;IAED,iCAAsE;IAEtE,wDAKC;IAED,iDAKC;IAED,qBAqEC;IAED,0BAOC;CACF;8BA5H6B,4BAA4B"}
@@ -13,10 +13,10 @@ export class AggregateBase extends FeatureBase {
13
13
  /**
14
14
  * Return harvest payload. A "serializer" function can be defined on a derived class to format the payload.
15
15
  * @param {Boolean} shouldRetryOnFail - harvester flag to backup payload for retry later if harvest request fails; this should be moved to harvester logic
16
- * @param {object|undefined} 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
16
+ * @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
17
17
  * @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.
18
18
  */
19
- makeHarvestPayload(shouldRetryOnFail: boolean | undefined, target: object | undefined): any[];
19
+ makeHarvestPayload(shouldRetryOnFail?: boolean, opts?: {}): any[];
20
20
  /**
21
21
  * Cleanup task after a harvest.
22
22
  * @param {object} result - the cbResult object from the harvester's send method
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/aggregate-base.js"],"names":[],"mappings":"AAWA;IAGI,cAAwB;IAcpB,YAAuC;IAM3C,gBAAqB;IAGvB;;;;OAIG;IACH,yBAHW,MAAM,EAAE,gBAwBlB;IAED,cAGC;IADC,6BAAmB;IAGrB;;;;;OAKG;IACH,mEAHW,MAAM,GAAC,SAAS,SAwB1B;IAED;;;OAGG;IACH,4BAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,6CAsBC;IAED;;;OAGG;IACH,2CASC;IAPC,gBAA6C;CAQhD;4BAvJ2B,gBAAgB"}
1
+ {"version":3,"file":"aggregate-base.d.ts","sourceRoot":"","sources":["../../../../src/features/utils/aggregate-base.js"],"names":[],"mappings":"AAWA;IAGI,cAAwB;IAcpB,YAAuC;IAM3C,gBAAqB;IAGvB;;;;OAIG;IACH,yBAHW,MAAM,EAAE,gBAwBlB;IAED,cAGC;IADC,6BAAmB;IAGrB;;;;;OAKG;IACH,kEAqBC;IAED;;;OAGG;IACH,4BAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,6CAsBC;IAED;;;OAGG;IACH,2CASC;IAPC,gBAA6C;CAQhD;4BAvJ2B,gBAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newrelic/browser-agent",
3
- "version": "1.278.0",
3
+ "version": "1.278.1",
4
4
  "private": false,
5
5
  "author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
6
6
  "description": "New Relic Browser Agent",
@@ -57,7 +57,7 @@ export class Harvester {
57
57
  const shouldRetryOnFail = !localOpts.isFinalHarvest && submitMethod === xhrMethod // always retry all features harvests except for final
58
58
  let dataToSendArr; let ranSend = false
59
59
  if (!localOpts.directSend) { // primarily used by rum call to bypass makeHarvestPayload by providing payload directly
60
- dataToSendArr = aggregateInst.makeHarvestPayload(shouldRetryOnFail) // be sure the 'this' of makeHarvestPayload is the aggregate w/ access to its harvestOpts
60
+ dataToSendArr = aggregateInst.makeHarvestPayload(shouldRetryOnFail, localOpts) // be sure the 'this' of makeHarvestPayload is the aggregate w/ access to its harvestOpts
61
61
  if (!dataToSendArr) return false // can be undefined if storage is empty or preharvest checks failed
62
62
  } else dataToSendArr = [localOpts.directSend]
63
63
 
@@ -34,7 +34,7 @@ export class Aggregate extends AggregateBase {
34
34
  this.eachSessionChecks() // the start of every time user engages with page
35
35
  }
36
36
 
37
- preHarvestChecks () { return this.drained } // only allow any metrics to be sent if we know for sure it has gotten the go-ahead RUM flag
37
+ preHarvestChecks (opts) { return this.drained && opts.isFinalHarvest } // only allow any metrics to be sent after we get the right RUM flag and only on EoL
38
38
 
39
39
  storeSupportabilityMetrics (name, value) {
40
40
  if (this.blocked) return
@@ -71,18 +71,18 @@ export class AggregateBase extends FeatureBase {
71
71
  /**
72
72
  * Return harvest payload. A "serializer" function can be defined on a derived class to format the payload.
73
73
  * @param {Boolean} shouldRetryOnFail - harvester flag to backup payload for retry later if harvest request fails; this should be moved to harvester logic
74
- * @param {object|undefined} 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
74
+ * @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
75
75
  * @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.
76
76
  */
77
- makeHarvestPayload (shouldRetryOnFail = false, target) {
78
- if (this.events.isEmpty(this.harvestOpts, target)) return
77
+ makeHarvestPayload (shouldRetryOnFail = false, opts = {}) {
78
+ if (this.events.isEmpty(this.harvestOpts, opts.target)) return
79
79
  // Other conditions and things to do when preparing harvest that is required.
80
- if (this.preHarvestChecks && !this.preHarvestChecks()) return
80
+ if (this.preHarvestChecks && !this.preHarvestChecks(opts)) return
81
81
 
82
- if (shouldRetryOnFail) this.events.save(this.harvestOpts, target)
83
- const returnedDataArr = this.events.get(this.harvestOpts, target)
82
+ if (shouldRetryOnFail) this.events.save(this.harvestOpts, opts.target)
83
+ const returnedDataArr = this.events.get(this.harvestOpts, opts.target)
84
84
  if (!returnedDataArr.length) throw new Error('Unexpected problem encountered. There should be at least one app for harvest!')
85
- this.events.clear(this.harvestOpts, target)
85
+ this.events.clear(this.harvestOpts, opts.target)
86
86
 
87
87
  return returnedDataArr.map(({ targetApp, data }) => {
88
88
  // A serializer or formatter assists in creating the payload `body` from stored events on harvest when defined by derived feature class.