@newrelic/browser-agent 1.314.0-rc.5 → 1.314.0-rc.7
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/agent-constants.js +1 -2
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +2 -3
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +2 -3
- package/dist/cjs/common/vitals/largest-contentful-paint.js +1 -2
- package/dist/cjs/common/vitals/vital-metric.js +4 -7
- package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -27
- package/dist/esm/common/constants/agent-constants.js +1 -2
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/vitals/cumulative-layout-shift.js +2 -3
- package/dist/esm/common/vitals/interaction-to-next-paint.js +2 -3
- package/dist/esm/common/vitals/largest-contentful-paint.js +1 -2
- package/dist/esm/common/vitals/vital-metric.js +4 -7
- package/dist/esm/features/page_view_timing/aggregate/index.js +6 -27
- package/dist/types/common/constants/agent-constants.d.ts +0 -1
- package/dist/types/common/constants/agent-constants.d.ts.map +1 -1
- package/dist/types/common/vitals/vital-metric.d.ts +2 -3
- package/dist/types/common/vitals/vital-metric.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/constants/agent-constants.js +1 -2
- package/src/common/vitals/cumulative-layout-shift.js +2 -2
- package/src/common/vitals/interaction-to-next-paint.js +2 -2
- package/src/common/vitals/largest-contentful-paint.js +1 -1
- package/src/common/vitals/vital-metric.js +4 -6
- package/src/features/page_view_timing/aggregate/index.js +6 -14
|
@@ -18,6 +18,5 @@ const SUPPORTS_REGISTERED_ENTITIES = exports.SUPPORTS_REGISTERED_ENTITIES = {
|
|
|
18
18
|
[_features.FEATURE_NAMES.logging]: true,
|
|
19
19
|
[_features.FEATURE_NAMES.genericEvents]: true,
|
|
20
20
|
[_features.FEATURE_NAMES.jserrors]: true,
|
|
21
|
-
[_features.FEATURE_NAMES.ajax]: true
|
|
22
|
-
[_features.FEATURE_NAMES.pageViewTiming]: true
|
|
21
|
+
[_features.FEATURE_NAMES.ajax]: true
|
|
23
22
|
};
|
|
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the version of the agent
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = exports.VERSION = "1.314.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.314.0-rc.7";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the version of the agent
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = exports.VERSION = "1.314.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.314.0-rc.7";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -9,7 +9,7 @@ var _constants = require("./constants");
|
|
|
9
9
|
var _vitalMetric = require("./vital-metric");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
11
|
/**
|
|
12
|
-
* Copyright 2020-
|
|
12
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
14
14
|
*/
|
|
15
15
|
|
|
@@ -29,8 +29,7 @@ if (_runtime.isBrowserScope) {
|
|
|
29
29
|
};
|
|
30
30
|
cumulativeLayoutShift.update({
|
|
31
31
|
value,
|
|
32
|
-
attrs
|
|
33
|
-
element: attribution.largestShiftSource?.node
|
|
32
|
+
attrs
|
|
34
33
|
});
|
|
35
34
|
}, {
|
|
36
35
|
reportAllChanges: true
|
|
@@ -9,7 +9,7 @@ var _vitalMetric = require("./vital-metric");
|
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
11
|
/**
|
|
12
|
-
* Copyright 2020-
|
|
12
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
13
13
|
* SPDX-License-Identifier: Apache-2.0
|
|
14
14
|
*/
|
|
15
15
|
|
|
@@ -38,8 +38,7 @@ if (_runtime.isBrowserScope) {
|
|
|
38
38
|
};
|
|
39
39
|
interactionToNextPaint.update({
|
|
40
40
|
value,
|
|
41
|
-
attrs
|
|
42
|
-
element: attribution.interactionTargetElement
|
|
41
|
+
attrs
|
|
43
42
|
});
|
|
44
43
|
});
|
|
45
44
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.VitalMetric = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* Copyright 2020-
|
|
8
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
9
9
|
* SPDX-License-Identifier: Apache-2.0
|
|
10
10
|
*/
|
|
11
11
|
class VitalMetric {
|
|
@@ -18,15 +18,13 @@ class VitalMetric {
|
|
|
18
18
|
}
|
|
19
19
|
update({
|
|
20
20
|
value,
|
|
21
|
-
attrs = {}
|
|
22
|
-
element
|
|
21
|
+
attrs = {}
|
|
23
22
|
}) {
|
|
24
23
|
if (value === undefined || value === null || value < 0) return;
|
|
25
24
|
const state = {
|
|
26
25
|
value: this.roundingMethod(value),
|
|
27
26
|
name: this.name,
|
|
28
|
-
attrs
|
|
29
|
-
element
|
|
27
|
+
attrs
|
|
30
28
|
};
|
|
31
29
|
this.history.push(state);
|
|
32
30
|
this.#subscribers.forEach(cb => {
|
|
@@ -41,8 +39,7 @@ class VitalMetric {
|
|
|
41
39
|
return this.history[this.history.length - 1] || {
|
|
42
40
|
value: undefined,
|
|
43
41
|
name: this.name,
|
|
44
|
-
attrs: {}
|
|
45
|
-
element: undefined
|
|
42
|
+
attrs: {}
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
45
|
get isValid() {
|
|
@@ -21,8 +21,6 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
21
21
|
var _eventOrigin = require("../../../common/util/event-origin");
|
|
22
22
|
var _loadTime = require("../../../common/vitals/load-time");
|
|
23
23
|
var _webdriverDetection = require("../../../common/util/webdriver-detection");
|
|
24
|
-
var _selectorPath = require("../../../common/dom/selector-path");
|
|
25
|
-
var _utils = require("../../../common/v2/utils");
|
|
26
24
|
var _cleanUrl = require("../../../common/url/clean-url");
|
|
27
25
|
/**
|
|
28
26
|
* Copyright 2020-2026 New Relic, Inc. All rights reserved.
|
|
@@ -34,10 +32,9 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
34
32
|
#handleVitalMetric = ({
|
|
35
33
|
name,
|
|
36
34
|
value,
|
|
37
|
-
attrs
|
|
38
|
-
element
|
|
35
|
+
attrs
|
|
39
36
|
}) => {
|
|
40
|
-
this.addTiming(name, value, attrs
|
|
37
|
+
this.addTiming(name, value, attrs);
|
|
41
38
|
};
|
|
42
39
|
constructor(agentRef) {
|
|
43
40
|
super(agentRef, _constants.FEATURE_NAME);
|
|
@@ -65,11 +62,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
65
62
|
const {
|
|
66
63
|
name,
|
|
67
64
|
value,
|
|
68
|
-
attrs
|
|
69
|
-
element
|
|
65
|
+
attrs
|
|
70
66
|
} = _cumulativeLayoutShift.cumulativeLayoutShift.current;
|
|
71
67
|
if (value === undefined) return;
|
|
72
|
-
this.addTiming(name, value * 1000, attrs
|
|
68
|
+
this.addTiming(name, value * 1000, attrs);
|
|
73
69
|
}, true, true); // CLS node should only reports on vis change rather than on every change
|
|
74
70
|
|
|
75
71
|
this.drain();
|
|
@@ -87,7 +83,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
87
83
|
this.curSessEndRecorded = true;
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
|
-
addTiming(name, value, attrs
|
|
86
|
+
addTiming(name, value, attrs) {
|
|
91
87
|
attrs = attrs || {};
|
|
92
88
|
attrs.pageUrl = (0, _cleanUrl.cleanURL)((0, _runtime.getNavigationEntry)()?.name || _runtime.initialLocation);
|
|
93
89
|
addConnectionAttributes(attrs); // network conditions may differ from the actual for VitalMetrics when they were captured
|
|
@@ -108,24 +104,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
108
104
|
value,
|
|
109
105
|
attrs
|
|
110
106
|
};
|
|
111
|
-
|
|
112
|
-
if (!targets.length) targets.push(undefined);
|
|
113
|
-
targets.forEach(target => {
|
|
114
|
-
this.events.add({
|
|
115
|
-
...timing,
|
|
116
|
-
attrs: {
|
|
117
|
-
...attrs,
|
|
118
|
-
...(0, _utils.getVersion2Attributes)(target, this)
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
if ((0, _utils.shouldDuplicate)(target, this.agentRef)) this.events.add({
|
|
122
|
-
...timing,
|
|
123
|
-
attrs: {
|
|
124
|
-
...attrs,
|
|
125
|
-
...(0, _utils.getVersion2DuplicationAttributes)(target, this)
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
107
|
+
this.events.add(timing);
|
|
129
108
|
(0, _handle.handle)('pvtAdded', [name, value, attrs], undefined, _features.FEATURE_NAMES.sessionTrace, this.ee);
|
|
130
109
|
this.checkForFirstInteraction();
|
|
131
110
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { onCLS } from 'web-vitals/attribution';
|
|
@@ -22,8 +22,7 @@ if (isBrowserScope) {
|
|
|
22
22
|
};
|
|
23
23
|
cumulativeLayoutShift.update({
|
|
24
24
|
value,
|
|
25
|
-
attrs
|
|
26
|
-
element: attribution.largestShiftSource?.node
|
|
25
|
+
attrs
|
|
27
26
|
});
|
|
28
27
|
}, {
|
|
29
28
|
reportAllChanges: true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { onINP } from 'web-vitals/attribution';
|
|
@@ -31,8 +31,7 @@ if (isBrowserScope) {
|
|
|
31
31
|
};
|
|
32
32
|
interactionToNextPaint.update({
|
|
33
33
|
value,
|
|
34
|
-
attrs
|
|
35
|
-
element: attribution.interactionTargetElement
|
|
34
|
+
attrs
|
|
36
35
|
});
|
|
37
36
|
});
|
|
38
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
export class VitalMetric {
|
|
@@ -12,15 +12,13 @@ export class VitalMetric {
|
|
|
12
12
|
}
|
|
13
13
|
update({
|
|
14
14
|
value,
|
|
15
|
-
attrs = {}
|
|
16
|
-
element
|
|
15
|
+
attrs = {}
|
|
17
16
|
}) {
|
|
18
17
|
if (value === undefined || value === null || value < 0) return;
|
|
19
18
|
const state = {
|
|
20
19
|
value: this.roundingMethod(value),
|
|
21
20
|
name: this.name,
|
|
22
|
-
attrs
|
|
23
|
-
element
|
|
21
|
+
attrs
|
|
24
22
|
};
|
|
25
23
|
this.history.push(state);
|
|
26
24
|
this.#subscribers.forEach(cb => {
|
|
@@ -35,8 +33,7 @@ export class VitalMetric {
|
|
|
35
33
|
return this.history[this.history.length - 1] || {
|
|
36
34
|
value: undefined,
|
|
37
35
|
name: this.name,
|
|
38
|
-
attrs: {}
|
|
39
|
-
element: undefined
|
|
36
|
+
attrs: {}
|
|
40
37
|
};
|
|
41
38
|
}
|
|
42
39
|
get isValid() {
|
|
@@ -20,18 +20,15 @@ import { initiallyHidden, getNavigationEntry, initialLocation } from '../../../c
|
|
|
20
20
|
import { eventOrigin } from '../../../common/util/event-origin';
|
|
21
21
|
import { loadTime } from '../../../common/vitals/load-time';
|
|
22
22
|
import { webdriverDetected } from '../../../common/util/webdriver-detection';
|
|
23
|
-
import { analyzeElemPath } from '../../../common/dom/selector-path';
|
|
24
|
-
import { getVersion2Attributes, getVersion2DuplicationAttributes, shouldDuplicate } from '../../../common/v2/utils';
|
|
25
23
|
import { cleanURL } from '../../../common/url/clean-url';
|
|
26
24
|
export class Aggregate extends AggregateBase {
|
|
27
25
|
static featureName = FEATURE_NAME;
|
|
28
26
|
#handleVitalMetric = ({
|
|
29
27
|
name,
|
|
30
28
|
value,
|
|
31
|
-
attrs
|
|
32
|
-
element
|
|
29
|
+
attrs
|
|
33
30
|
}) => {
|
|
34
|
-
this.addTiming(name, value, attrs
|
|
31
|
+
this.addTiming(name, value, attrs);
|
|
35
32
|
};
|
|
36
33
|
constructor(agentRef) {
|
|
37
34
|
super(agentRef, FEATURE_NAME);
|
|
@@ -59,11 +56,10 @@ export class Aggregate extends AggregateBase {
|
|
|
59
56
|
const {
|
|
60
57
|
name,
|
|
61
58
|
value,
|
|
62
|
-
attrs
|
|
63
|
-
element
|
|
59
|
+
attrs
|
|
64
60
|
} = cumulativeLayoutShift.current;
|
|
65
61
|
if (value === undefined) return;
|
|
66
|
-
this.addTiming(name, value * 1000, attrs
|
|
62
|
+
this.addTiming(name, value * 1000, attrs);
|
|
67
63
|
}, true, true); // CLS node should only reports on vis change rather than on every change
|
|
68
64
|
|
|
69
65
|
this.drain();
|
|
@@ -81,7 +77,7 @@ export class Aggregate extends AggregateBase {
|
|
|
81
77
|
this.curSessEndRecorded = true;
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
|
-
addTiming(name, value, attrs
|
|
80
|
+
addTiming(name, value, attrs) {
|
|
85
81
|
attrs = attrs || {};
|
|
86
82
|
attrs.pageUrl = cleanURL(getNavigationEntry()?.name || initialLocation);
|
|
87
83
|
addConnectionAttributes(attrs); // network conditions may differ from the actual for VitalMetrics when they were captured
|
|
@@ -102,24 +98,7 @@ export class Aggregate extends AggregateBase {
|
|
|
102
98
|
value,
|
|
103
99
|
attrs
|
|
104
100
|
};
|
|
105
|
-
|
|
106
|
-
if (!targets.length) targets.push(undefined);
|
|
107
|
-
targets.forEach(target => {
|
|
108
|
-
this.events.add({
|
|
109
|
-
...timing,
|
|
110
|
-
attrs: {
|
|
111
|
-
...attrs,
|
|
112
|
-
...getVersion2Attributes(target, this)
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
if (shouldDuplicate(target, this.agentRef)) this.events.add({
|
|
116
|
-
...timing,
|
|
117
|
-
attrs: {
|
|
118
|
-
...attrs,
|
|
119
|
-
...getVersion2DuplicationAttributes(target, this)
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
101
|
+
this.events.add(timing);
|
|
123
102
|
handle('pvtAdded', [name, value, attrs], undefined, FEATURE_NAMES.sessionTrace, this.ee);
|
|
124
103
|
this.checkForFirstInteraction();
|
|
125
104
|
|
|
@@ -7,7 +7,6 @@ export const SUPPORTS_REGISTERED_ENTITIES: {
|
|
|
7
7
|
[FEATURE_NAMES.genericEvents]: boolean;
|
|
8
8
|
[FEATURE_NAMES.jserrors]: boolean;
|
|
9
9
|
[FEATURE_NAMES.ajax]: boolean;
|
|
10
|
-
[FEATURE_NAMES.pageViewTiming]: boolean;
|
|
11
10
|
};
|
|
12
11
|
import { FEATURE_NAMES } from '../../loaders/features/features';
|
|
13
12
|
//# sourceMappingURL=agent-constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-constants.d.ts","sourceRoot":"","sources":["../../../../src/common/constants/agent-constants.js"],"names":[],"mappings":"AAMA,iCAAkC,KAAK,CAAA;AACvC,+BAAgC,OAAO,CAAA;AACvC,0BAA2B,oBAAoB,CAAA;AAC/C,4BAA6B,eAAe,CAAA;AAE5C;IACE,CAAC,aAAa,CAAC,OAAO,CAAC,UAAM;IAC7B,CAAC,aAAa,CAAC,aAAa,CAAC,UAAM;IACnC,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAM;IAC9B,CAAC,aAAa,CAAC,IAAI,CAAC,UAAM;
|
|
1
|
+
{"version":3,"file":"agent-constants.d.ts","sourceRoot":"","sources":["../../../../src/common/constants/agent-constants.js"],"names":[],"mappings":"AAMA,iCAAkC,KAAK,CAAA;AACvC,+BAAgC,OAAO,CAAA;AACvC,0BAA2B,oBAAoB,CAAA;AAC/C,4BAA6B,eAAe,CAAA;AAE5C;IACE,CAAC,aAAa,CAAC,OAAO,CAAC,UAAM;IAC7B,CAAC,aAAa,CAAC,aAAa,CAAC,UAAM;IACnC,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAM;IAC9B,CAAC,aAAa,CAAC,IAAI,CAAC,UAAM;EAC3B;8BAZ6B,iCAAiC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
export class VitalMetric {
|
|
@@ -8,10 +8,9 @@ export class VitalMetric {
|
|
|
8
8
|
name: any;
|
|
9
9
|
attrs: {};
|
|
10
10
|
roundingMethod: any;
|
|
11
|
-
update({ value, attrs
|
|
11
|
+
update({ value, attrs }: {
|
|
12
12
|
value: any;
|
|
13
13
|
attrs?: {} | undefined;
|
|
14
|
-
element: any;
|
|
15
14
|
}): void;
|
|
16
15
|
get current(): any;
|
|
17
16
|
get isValid(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vital-metric.d.ts","sourceRoot":"","sources":["../../../../src/common/vitals/vital-metric.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IAIE,4CAIC;IAND,eAAY;IAGV,UAAgB;IAChB,UAAe;IACf,oBAAwF;IAG1F
|
|
1
|
+
{"version":3,"file":"vital-metric.d.ts","sourceRoot":"","sources":["../../../../src/common/vitals/vital-metric.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IAIE,4CAIC;IAND,eAAY;IAGV,UAAgB;IAChB,UAAe;IACf,oBAAwF;IAG1F;;;aAgBC;IAED,mBAMC;IAED,uBAEC;IAED,uEAMC;;CACF"}
|
|
@@ -8,7 +8,7 @@ export class Aggregate extends AggregateBase {
|
|
|
8
8
|
* @param {number} timestamp
|
|
9
9
|
*/
|
|
10
10
|
endCurrentSession(timestamp: number): void;
|
|
11
|
-
addTiming(name: any, value: any, attrs: any
|
|
11
|
+
addTiming(name: any, value: any, attrs: any): {
|
|
12
12
|
name: any;
|
|
13
13
|
value: any;
|
|
14
14
|
attrs: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_timing/aggregate/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/page_view_timing/aggregate/index.js"],"names":[],"mappings":"AAwBA;IACE,2BAAiC;IAMjC,2BA4BC;IA1BC,4BAA+B;IAC/B,0BAA6B;IA2B/B;;;OAGG;IACH,6BAFW,MAAM,QAOhB;IAED;;;;MA+BC;IAED;;;OAGG;IACH,4BAFa,IAAI,CAahB;IAED,gDAWC;IAED,4BAGC;IAGD,qCAwBC;;CACF;8BA5J6B,4BAA4B"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { onCLS } from 'web-vitals/attribution'
|
|
@@ -18,6 +18,6 @@ if (isBrowserScope) {
|
|
|
18
18
|
largestShiftValue: attribution.largestShiftValue,
|
|
19
19
|
loadState: attribution.loadState
|
|
20
20
|
}
|
|
21
|
-
cumulativeLayoutShift.update({ value, attrs
|
|
21
|
+
cumulativeLayoutShift.update({ value, attrs })
|
|
22
22
|
}, { reportAllChanges: true })
|
|
23
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { onINP } from 'web-vitals/attribution'
|
|
@@ -25,6 +25,6 @@ if (isBrowserScope) {
|
|
|
25
25
|
presentationDelay: attribution.presentationDelay,
|
|
26
26
|
loadState: attribution.loadState
|
|
27
27
|
}
|
|
28
|
-
interactionToNextPaint.update({ value, attrs
|
|
28
|
+
interactionToNextPaint.update({ value, attrs })
|
|
29
29
|
})
|
|
30
30
|
}
|
|
@@ -31,6 +31,6 @@ if (isBrowserScope) {
|
|
|
31
31
|
if (attribution.element) attrs.element = attribution.element
|
|
32
32
|
if (attribution.url) attrs.elUrl = cleanURL(attribution.url)
|
|
33
33
|
|
|
34
|
-
largestContentfulPaint.update({ value, attrs
|
|
34
|
+
largestContentfulPaint.update({ value, attrs })
|
|
35
35
|
})
|
|
36
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
export class VitalMetric {
|
|
@@ -12,13 +12,12 @@ export class VitalMetric {
|
|
|
12
12
|
this.roundingMethod = typeof roundingMethod === 'function' ? roundingMethod : Math.floor
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
update ({ value, attrs = {}
|
|
15
|
+
update ({ value, attrs = {} }) {
|
|
16
16
|
if (value === undefined || value === null || value < 0) return
|
|
17
17
|
const state = {
|
|
18
18
|
value: this.roundingMethod(value),
|
|
19
19
|
name: this.name,
|
|
20
|
-
attrs
|
|
21
|
-
element
|
|
20
|
+
attrs
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
this.history.push(state)
|
|
@@ -35,8 +34,7 @@ export class VitalMetric {
|
|
|
35
34
|
return this.history[this.history.length - 1] || {
|
|
36
35
|
value: undefined,
|
|
37
36
|
name: this.name,
|
|
38
|
-
attrs: {}
|
|
39
|
-
element: undefined
|
|
37
|
+
attrs: {}
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -20,15 +20,13 @@ import { initiallyHidden, getNavigationEntry, initialLocation } from '../../../c
|
|
|
20
20
|
import { eventOrigin } from '../../../common/util/event-origin'
|
|
21
21
|
import { loadTime } from '../../../common/vitals/load-time'
|
|
22
22
|
import { webdriverDetected } from '../../../common/util/webdriver-detection'
|
|
23
|
-
import { analyzeElemPath } from '../../../common/dom/selector-path'
|
|
24
|
-
import { getVersion2Attributes, getVersion2DuplicationAttributes, shouldDuplicate } from '../../../common/v2/utils'
|
|
25
23
|
import { cleanURL } from '../../../common/url/clean-url'
|
|
26
24
|
|
|
27
25
|
export class Aggregate extends AggregateBase {
|
|
28
26
|
static featureName = FEATURE_NAME
|
|
29
27
|
|
|
30
|
-
#handleVitalMetric = ({ name, value, attrs
|
|
31
|
-
this.addTiming(name, value, attrs
|
|
28
|
+
#handleVitalMetric = ({ name, value, attrs }) => {
|
|
29
|
+
this.addTiming(name, value, attrs)
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
constructor (agentRef) {
|
|
@@ -52,9 +50,9 @@ export class Aggregate extends AggregateBase {
|
|
|
52
50
|
/* Downstream, the event consumer interprets all timing node value as ms-unit and converts it to seconds via division by 1000. CLS is unitless so this normally is a problem.
|
|
53
51
|
bel.6 schema also doesn't support decimal values, of which cls within [0,1). However, the two nicely cancels out, and we can multiply cls by 1000 to both negate the division
|
|
54
52
|
and send an integer > 1. We effectively lose some precision down to 3 decimal places for this workaround. E.g. (real) 0.749132... -> 749.132...-> 749 -> 0.749 (final) */
|
|
55
|
-
const { name, value, attrs
|
|
53
|
+
const { name, value, attrs } = cumulativeLayoutShift.current
|
|
56
54
|
if (value === undefined) return
|
|
57
|
-
this.addTiming(name, value * 1000, attrs
|
|
55
|
+
this.addTiming(name, value * 1000, attrs)
|
|
58
56
|
}, true, true) // CLS node should only reports on vis change rather than on every change
|
|
59
57
|
|
|
60
58
|
this.drain()
|
|
@@ -72,7 +70,7 @@ export class Aggregate extends AggregateBase {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
addTiming (name, value, attrs
|
|
73
|
+
addTiming (name, value, attrs) {
|
|
76
74
|
attrs = attrs || {}
|
|
77
75
|
attrs.pageUrl = cleanURL(getNavigationEntry()?.name || initialLocation)
|
|
78
76
|
|
|
@@ -95,13 +93,7 @@ export class Aggregate extends AggregateBase {
|
|
|
95
93
|
value,
|
|
96
94
|
attrs
|
|
97
95
|
}
|
|
98
|
-
|
|
99
|
-
const targets = analyzeElemPath(element, [], this.agentRef).targets
|
|
100
|
-
if (!targets.length) targets.push(undefined)
|
|
101
|
-
targets.forEach(target => {
|
|
102
|
-
this.events.add({ ...timing, attrs: { ...attrs, ...getVersion2Attributes(target, this) } })
|
|
103
|
-
if (shouldDuplicate(target, this.agentRef)) this.events.add({ ...timing, attrs: { ...attrs, ...getVersion2DuplicationAttributes(target, this) } })
|
|
104
|
-
})
|
|
96
|
+
this.events.add(timing)
|
|
105
97
|
|
|
106
98
|
handle('pvtAdded', [name, value, attrs], undefined, FEATURE_NAMES.sessionTrace, this.ee)
|
|
107
99
|
|