@newrelic/browser-agent 1.294.0-rc.2 → 1.294.0-rc.3
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/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +24 -4
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +24 -4
- package/dist/types/features/session_replay/aggregate/index.d.ts +9 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/session_replay/aggregate/index.js +18 -4
|
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the version of the agent
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = exports.VERSION = "1.294.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.294.0-rc.3";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the version of the agent
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = exports.VERSION = "1.294.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.294.0-rc.3";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -291,6 +291,24 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
291
291
|
if (node.__newrelic) return node.timestamp;
|
|
292
292
|
return this.timeKeeper.correctAbsoluteTimestamp(node.timestamp);
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* returns the timestamps for the earliest and latest nodes in the provided array, even if out of order
|
|
297
|
+
* @param {Object[]} [nodes] - the nodes to evaluate
|
|
298
|
+
* @returns {{ firstEvent: Object|undefined, lastEvent: Object|undefined }} - the earliest and latest nodes. Defaults to undefined if no nodes are provided or if no timestamps are found in the nodes.
|
|
299
|
+
*/
|
|
300
|
+
getFirstAndLastNodes(nodes = []) {
|
|
301
|
+
const output = {
|
|
302
|
+
firstEvent: nodes[0],
|
|
303
|
+
lastEvent: nodes[nodes.length - 1]
|
|
304
|
+
};
|
|
305
|
+
nodes.forEach(node => {
|
|
306
|
+
const timestamp = node?.timestamp;
|
|
307
|
+
if (!output.firstEvent?.timestamp || (timestamp || Infinity) < output.firstEvent.timestamp) output.firstEvent = node;
|
|
308
|
+
if (!output.lastEvent?.timestamp || (timestamp || -Infinity) > output.lastEvent.timestamp) output.lastEvent = node;
|
|
309
|
+
});
|
|
310
|
+
return output;
|
|
311
|
+
}
|
|
294
312
|
getHarvestContents(recorderEvents) {
|
|
295
313
|
recorderEvents ??= this.recorder.getEvents();
|
|
296
314
|
let events = recorderEvents.events;
|
|
@@ -315,11 +333,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
315
333
|
recorderEvents.hasMeta = !!events.find(x => x.type === _constants.RRWEB_EVENT_TYPES.Meta);
|
|
316
334
|
}
|
|
317
335
|
const relativeNow = (0, _now.now)();
|
|
318
|
-
const
|
|
319
|
-
|
|
336
|
+
const {
|
|
337
|
+
firstEvent,
|
|
338
|
+
lastEvent
|
|
339
|
+
} = this.getFirstAndLastNodes(events);
|
|
320
340
|
// from rrweb node || from when the harvest cycle started
|
|
321
|
-
const firstTimestamp =
|
|
322
|
-
const lastTimestamp =
|
|
341
|
+
const firstTimestamp = this.getCorrectedTimestamp(firstEvent) || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp));
|
|
342
|
+
const lastTimestamp = this.getCorrectedTimestamp(lastEvent) || Math.floor(this.timeKeeper.correctRelativeTimestamp(relativeNow));
|
|
323
343
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
|
|
324
344
|
return {
|
|
325
345
|
qs: {
|
|
@@ -286,6 +286,24 @@ export class Aggregate extends AggregateBase {
|
|
|
286
286
|
if (node.__newrelic) return node.timestamp;
|
|
287
287
|
return this.timeKeeper.correctAbsoluteTimestamp(node.timestamp);
|
|
288
288
|
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* returns the timestamps for the earliest and latest nodes in the provided array, even if out of order
|
|
292
|
+
* @param {Object[]} [nodes] - the nodes to evaluate
|
|
293
|
+
* @returns {{ firstEvent: Object|undefined, lastEvent: Object|undefined }} - the earliest and latest nodes. Defaults to undefined if no nodes are provided or if no timestamps are found in the nodes.
|
|
294
|
+
*/
|
|
295
|
+
getFirstAndLastNodes(nodes = []) {
|
|
296
|
+
const output = {
|
|
297
|
+
firstEvent: nodes[0],
|
|
298
|
+
lastEvent: nodes[nodes.length - 1]
|
|
299
|
+
};
|
|
300
|
+
nodes.forEach(node => {
|
|
301
|
+
const timestamp = node?.timestamp;
|
|
302
|
+
if (!output.firstEvent?.timestamp || (timestamp || Infinity) < output.firstEvent.timestamp) output.firstEvent = node;
|
|
303
|
+
if (!output.lastEvent?.timestamp || (timestamp || -Infinity) > output.lastEvent.timestamp) output.lastEvent = node;
|
|
304
|
+
});
|
|
305
|
+
return output;
|
|
306
|
+
}
|
|
289
307
|
getHarvestContents(recorderEvents) {
|
|
290
308
|
recorderEvents ??= this.recorder.getEvents();
|
|
291
309
|
let events = recorderEvents.events;
|
|
@@ -310,11 +328,13 @@ export class Aggregate extends AggregateBase {
|
|
|
310
328
|
recorderEvents.hasMeta = !!events.find(x => x.type === RRWEB_EVENT_TYPES.Meta);
|
|
311
329
|
}
|
|
312
330
|
const relativeNow = now();
|
|
313
|
-
const
|
|
314
|
-
|
|
331
|
+
const {
|
|
332
|
+
firstEvent,
|
|
333
|
+
lastEvent
|
|
334
|
+
} = this.getFirstAndLastNodes(events);
|
|
315
335
|
// from rrweb node || from when the harvest cycle started
|
|
316
|
-
const firstTimestamp =
|
|
317
|
-
const lastTimestamp =
|
|
336
|
+
const firstTimestamp = this.getCorrectedTimestamp(firstEvent) || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp));
|
|
337
|
+
const lastTimestamp = this.getCorrectedTimestamp(lastEvent) || Math.floor(this.timeKeeper.correctRelativeTimestamp(relativeNow));
|
|
318
338
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {};
|
|
319
339
|
return {
|
|
320
340
|
qs: {
|
|
@@ -31,6 +31,15 @@ export class Aggregate extends AggregateBase {
|
|
|
31
31
|
payload: undefined;
|
|
32
32
|
}[] | undefined;
|
|
33
33
|
getCorrectedTimestamp(node: any): any;
|
|
34
|
+
/**
|
|
35
|
+
* returns the timestamps for the earliest and latest nodes in the provided array, even if out of order
|
|
36
|
+
* @param {Object[]} [nodes] - the nodes to evaluate
|
|
37
|
+
* @returns {{ firstEvent: Object|undefined, lastEvent: Object|undefined }} - the earliest and latest nodes. Defaults to undefined if no nodes are provided or if no timestamps are found in the nodes.
|
|
38
|
+
*/
|
|
39
|
+
getFirstAndLastNodes(nodes?: Object[]): {
|
|
40
|
+
firstEvent: Object | undefined;
|
|
41
|
+
lastEvent: Object | undefined;
|
|
42
|
+
};
|
|
34
43
|
getHarvestContents(recorderEvents: any): {
|
|
35
44
|
qs: {
|
|
36
45
|
browser_monitoring_key: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/aggregate/index.js"],"names":[],"mappings":"AAyBA;IACE,2BAAiC;IAIjC,sCAsFC;IAzFD,aAAe;IAKb,iFAAiF;IACjF,qBAAwB;IAGxB,2CAA2C;IAC3C,sDAAwB;IACxB,6CAA6C;IAC7C,gDAAmB;IAEnB,0BAA0B;IAC1B,kBAAqB;IACrB,6CAA6C;IAC7C,gBAA2B;IAE3B,cAA8B;IAC9B,kBAA+C;IAG/C,kCAAqG;IAoEvG,0BAEC;IAED,0BAMC;IAED,qBAUC;IAED;;;;;OAKG;IACH,4BAJW,OAAO,iBACP,OAAO,GACL,IAAI,CAuDhB;IAED,2BASC;IAED;;;oBAuDC;IAED,sCAIC;IAED;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/session_replay/aggregate/index.js"],"names":[],"mappings":"AAyBA;IACE,2BAAiC;IAIjC,sCAsFC;IAzFD,aAAe;IAKb,iFAAiF;IACjF,qBAAwB;IAGxB,2CAA2C;IAC3C,sDAAwB;IACxB,6CAA6C;IAC7C,gDAAmB;IAEnB,0BAA0B;IAC1B,kBAAqB;IACrB,6CAA6C;IAC7C,gBAA2B;IAE3B,cAA8B;IAC9B,kBAA+C;IAG/C,kCAAqG;IAoEvG,0BAEC;IAED,0BAMC;IAED,qBAUC;IAED;;;;;OAKG;IACH,4BAJW,OAAO,iBACP,OAAO,GACL,IAAI,CAuDhB;IAED,2BASC;IAED;;;oBAuDC;IAED,sCAIC;IAED;;;;OAIG;IACH,6BAHW,MAAM,EAAE,GACN;QAAE,UAAU,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAC,SAAS,CAAA;KAAE,CAUzE;IAED;;;;;;;;;;MAsEC;IAED,sCAKC;IAED;;;;OAIG;IACH,mCAKC;IAED,yDAAyD;IACzD,+CASC;IAED,yCAIC;CACF;8BAtY6B,4BAA4B"}
|
package/package.json
CHANGED
|
@@ -275,6 +275,21 @@ export class Aggregate extends AggregateBase {
|
|
|
275
275
|
return this.timeKeeper.correctAbsoluteTimestamp(node.timestamp)
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
/**
|
|
279
|
+
* returns the timestamps for the earliest and latest nodes in the provided array, even if out of order
|
|
280
|
+
* @param {Object[]} [nodes] - the nodes to evaluate
|
|
281
|
+
* @returns {{ firstEvent: Object|undefined, lastEvent: Object|undefined }} - the earliest and latest nodes. Defaults to undefined if no nodes are provided or if no timestamps are found in the nodes.
|
|
282
|
+
*/
|
|
283
|
+
getFirstAndLastNodes (nodes = []) {
|
|
284
|
+
const output = { firstEvent: nodes[0], lastEvent: nodes[nodes.length - 1] }
|
|
285
|
+
nodes.forEach(node => {
|
|
286
|
+
const timestamp = node?.timestamp
|
|
287
|
+
if (!output.firstEvent?.timestamp || (timestamp || Infinity) < output.firstEvent.timestamp) output.firstEvent = node
|
|
288
|
+
if (!output.lastEvent?.timestamp || (timestamp || -Infinity) > output.lastEvent.timestamp) output.lastEvent = node
|
|
289
|
+
})
|
|
290
|
+
return output
|
|
291
|
+
}
|
|
292
|
+
|
|
278
293
|
getHarvestContents (recorderEvents) {
|
|
279
294
|
recorderEvents ??= this.recorder.getEvents()
|
|
280
295
|
let events = recorderEvents.events
|
|
@@ -301,11 +316,10 @@ export class Aggregate extends AggregateBase {
|
|
|
301
316
|
|
|
302
317
|
const relativeNow = now()
|
|
303
318
|
|
|
304
|
-
const
|
|
305
|
-
const lastEventTimestamp = this.getCorrectedTimestamp(events[events.length - 1]) // from rrweb node
|
|
319
|
+
const { firstEvent, lastEvent } = this.getFirstAndLastNodes(events)
|
|
306
320
|
// from rrweb node || from when the harvest cycle started
|
|
307
|
-
const firstTimestamp =
|
|
308
|
-
const lastTimestamp =
|
|
321
|
+
const firstTimestamp = this.getCorrectedTimestamp(firstEvent) || Math.floor(this.timeKeeper.correctAbsoluteTimestamp(recorderEvents.cycleTimestamp))
|
|
322
|
+
const lastTimestamp = this.getCorrectedTimestamp(lastEvent) || Math.floor(this.timeKeeper.correctRelativeTimestamp(relativeNow))
|
|
309
323
|
|
|
310
324
|
const agentMetadata = agentRuntime.appMetadata?.agents?.[0] || {}
|
|
311
325
|
|