@newrelic/browser-agent 1.254.0 → 1.255.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.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/common/config/state/runtime.js +2 -1
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/context/shared-context.js +1 -1
- package/dist/cjs/common/harvest/harvest.js +1 -1
- package/dist/cjs/common/timing/time-keeper.js +28 -28
- package/dist/cjs/common/vitals/cumulative-layout-shift.js +12 -5
- package/dist/cjs/common/vitals/first-contentful-paint.js +10 -6
- package/dist/cjs/common/vitals/first-input-delay.js +12 -10
- package/dist/cjs/common/vitals/first-paint.js +1 -2
- package/dist/cjs/common/vitals/interaction-to-next-paint.js +11 -7
- package/dist/cjs/common/vitals/largest-contentful-paint.js +19 -17
- package/dist/cjs/common/vitals/long-task.js +0 -1
- package/dist/cjs/common/vitals/time-to-first-byte.js +11 -6
- package/dist/cjs/common/vitals/vital-metric.js +1 -4
- package/dist/cjs/common/window/nreum.js +1 -1
- package/dist/cjs/features/ajax/aggregate/index.js +3 -2
- package/dist/cjs/features/ajax/instrument/index.js +1 -1
- package/dist/cjs/features/jserrors/aggregate/index.js +3 -2
- package/dist/cjs/features/jserrors/instrument/index.js +1 -1
- package/dist/cjs/features/page_action/aggregate/index.js +3 -2
- package/dist/cjs/features/page_view_event/aggregate/index.js +11 -5
- package/dist/cjs/features/page_view_timing/aggregate/index.js +21 -7
- package/dist/cjs/features/page_view_timing/instrument/index.js +1 -1
- package/dist/cjs/features/session_replay/aggregate/index.js +14 -9
- package/dist/cjs/features/session_replay/shared/recorder-events.js +9 -1
- package/dist/cjs/features/session_replay/shared/recorder.js +56 -12
- package/dist/cjs/features/session_trace/aggregate/index.js +1 -1
- package/dist/cjs/features/session_trace/instrument/index.js +1 -1
- package/dist/cjs/features/soft_navigations/aggregate/index.js +2 -2
- package/dist/cjs/features/soft_navigations/instrument/index.js +1 -1
- package/dist/cjs/features/spa/aggregate/index.js +19 -10
- package/dist/cjs/features/spa/instrument/index.js +1 -1
- package/dist/cjs/features/utils/feature-base.js +0 -2
- package/dist/cjs/loaders/agent-base.js +0 -2
- package/dist/cjs/loaders/agent.js +1 -1
- package/dist/cjs/loaders/api/api.js +1 -1
- package/dist/cjs/loaders/micro-agent.js +4 -7
- package/dist/esm/common/config/state/runtime.js +2 -1
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/context/shared-context.js +1 -1
- package/dist/esm/common/harvest/harvest.js +1 -1
- package/dist/esm/common/timing/time-keeper.js +28 -28
- package/dist/esm/common/vitals/cumulative-layout-shift.js +11 -4
- package/dist/esm/common/vitals/first-contentful-paint.js +9 -5
- package/dist/esm/common/vitals/first-input-delay.js +11 -9
- package/dist/esm/common/vitals/first-paint.js +1 -2
- package/dist/esm/common/vitals/interaction-to-next-paint.js +10 -6
- package/dist/esm/common/vitals/largest-contentful-paint.js +18 -16
- package/dist/esm/common/vitals/long-task.js +0 -1
- package/dist/esm/common/vitals/time-to-first-byte.js +10 -5
- package/dist/esm/common/vitals/vital-metric.js +1 -4
- package/dist/esm/common/window/nreum.js +1 -1
- package/dist/esm/features/ajax/aggregate/index.js +3 -2
- package/dist/esm/features/ajax/instrument/index.js +1 -1
- package/dist/esm/features/jserrors/aggregate/index.js +3 -2
- package/dist/esm/features/jserrors/instrument/index.js +1 -1
- package/dist/esm/features/page_action/aggregate/index.js +3 -2
- package/dist/esm/features/page_view_event/aggregate/index.js +11 -5
- package/dist/esm/features/page_view_timing/aggregate/index.js +21 -7
- package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
- package/dist/esm/features/session_replay/aggregate/index.js +14 -9
- package/dist/esm/features/session_replay/shared/recorder-events.js +9 -1
- package/dist/esm/features/session_replay/shared/recorder.js +56 -12
- package/dist/esm/features/session_trace/aggregate/index.js +1 -1
- package/dist/esm/features/session_trace/instrument/index.js +1 -1
- package/dist/esm/features/soft_navigations/aggregate/index.js +2 -2
- package/dist/esm/features/soft_navigations/instrument/index.js +1 -1
- package/dist/esm/features/spa/aggregate/index.js +19 -10
- package/dist/esm/features/spa/instrument/index.js +1 -1
- package/dist/esm/features/utils/feature-base.js +0 -2
- package/dist/esm/loaders/agent-base.js +0 -2
- package/dist/esm/loaders/agent.js +1 -1
- package/dist/esm/loaders/api/api.js +1 -1
- package/dist/esm/loaders/micro-agent.js +4 -7
- package/dist/types/common/config/state/runtime.d.ts.map +1 -1
- package/dist/types/common/harvest/harvest.d.ts.map +1 -1
- package/dist/types/common/timing/time-keeper.d.ts +7 -6
- package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
- package/dist/types/common/vitals/vital-metric.d.ts +1 -2
- package/dist/types/common/vitals/vital-metric.d.ts.map +1 -1
- package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
- package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/instrument/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/aggregate/index.d.ts +4 -0
- package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder-events.d.ts +8 -0
- package/dist/types/features/session_replay/shared/recorder-events.d.ts.map +1 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts +17 -1
- package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
- package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
- package/dist/types/features/soft_navigations/instrument/index.d.ts.map +1 -1
- package/dist/types/features/spa/aggregate/index.d.ts +0 -2
- package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/utils/feature-base.d.ts +0 -1
- package/dist/types/features/utils/feature-base.d.ts.map +1 -1
- package/dist/types/loaders/agent-base.d.ts +0 -2
- package/dist/types/loaders/agent-base.d.ts.map +1 -1
- package/dist/types/loaders/micro-agent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/config/state/runtime.js +2 -1
- package/src/common/context/__mocks__/shared-context.js +3 -0
- package/src/common/context/shared-context.js +1 -1
- package/src/common/harvest/harvest.js +1 -1
- package/src/common/timing/__mocks__/time-keeper.js +2 -0
- package/src/common/timing/time-keeper.js +30 -31
- package/src/common/vitals/cumulative-layout-shift.js +10 -4
- package/src/common/vitals/first-contentful-paint.js +9 -4
- package/src/common/vitals/first-input-delay.js +11 -6
- package/src/common/vitals/first-paint.js +1 -1
- package/src/common/vitals/interaction-to-next-paint.js +10 -3
- package/src/common/vitals/largest-contentful-paint.js +19 -15
- package/src/common/vitals/long-task.js +0 -1
- package/src/common/vitals/time-to-first-byte.js +5 -4
- package/src/common/vitals/vital-metric.js +2 -4
- package/src/common/window/nreum.js +1 -1
- package/src/features/ajax/aggregate/index.js +3 -2
- package/src/features/ajax/instrument/index.js +1 -1
- package/src/features/jserrors/aggregate/index.js +3 -2
- package/src/features/jserrors/instrument/index.js +1 -1
- package/src/features/page_action/aggregate/index.js +3 -2
- package/src/features/page_view_event/aggregate/index.js +13 -4
- package/src/features/page_view_timing/aggregate/index.js +16 -6
- package/src/features/page_view_timing/instrument/index.js +1 -1
- package/src/features/session_replay/aggregate/index.js +13 -9
- package/src/features/session_replay/shared/recorder-events.js +6 -1
- package/src/features/session_replay/shared/recorder.js +33 -9
- package/src/features/session_trace/aggregate/index.js +1 -1
- package/src/features/session_trace/instrument/index.js +1 -1
- package/src/features/soft_navigations/aggregate/index.js +2 -2
- package/src/features/soft_navigations/instrument/index.js +1 -1
- package/src/features/spa/aggregate/index.js +19 -8
- package/src/features/spa/instrument/index.js +1 -1
- package/src/features/utils/feature-base.js +0 -3
- package/src/loaders/agent-base.js +0 -2
- package/src/loaders/agent.js +1 -1
- package/src/loaders/api/api.js +1 -1
- package/src/loaders/micro-agent.js +4 -6
- package/src/common/vitals/__mocks__/web-vitals.js +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.255.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.254.1...v1.255.0) (2024-04-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Adjust SR Timestamps to NR Server Time ([#939](https://github.com/newrelic/newrelic-browser-agent/issues/939)) ([94f0dee](https://github.com/newrelic/newrelic-browser-agent/commit/94f0deed02a8f5e9d668f3fe5a68ada86cecc439))
|
|
12
|
+
* Send CLS as timing node additionally ([#935](https://github.com/newrelic/newrelic-browser-agent/issues/935)) ([88e71da](https://github.com/newrelic/newrelic-browser-agent/commit/88e71da521f1a58af28ae17fee13f648affd262a))
|
|
13
|
+
* Switch web vitals library to attribution build ([#919](https://github.com/newrelic/newrelic-browser-agent/issues/919)) ([f36acbc](https://github.com/newrelic/newrelic-browser-agent/commit/f36acbc03c4f4d51e65431a270a008e65bb2cfff))
|
|
14
|
+
* Update agent to use new relic server time ([#918](https://github.com/newrelic/newrelic-browser-agent/issues/918)) ([8a4831c](https://github.com/newrelic/newrelic-browser-agent/commit/8a4831cd1f2d32d97daa8788967b15d7f2f723d3))
|
|
15
|
+
|
|
16
|
+
## [1.254.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.254.0...v1.254.1) (2024-03-26)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* Server Timing - Remove reliance on performance API ([#930](https://github.com/newrelic/newrelic-browser-agent/issues/930)) ([250efcd](https://github.com/newrelic/newrelic-browser-agent/commit/250efcd3bf0a730adbb9d5c45be0bf2f71189664))
|
|
22
|
+
|
|
6
23
|
## [1.254.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.253.0...v1.254.0) (2024-03-25)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -30,7 +30,8 @@ const model = {
|
|
|
30
30
|
xhrWrappable: typeof _runtime.globalScope.XMLHttpRequest?.prototype?.addEventListener === 'function',
|
|
31
31
|
version: _env.VERSION,
|
|
32
32
|
denyList: undefined,
|
|
33
|
-
harvestCount: 0
|
|
33
|
+
harvestCount: 0,
|
|
34
|
+
timeKeeper: undefined
|
|
34
35
|
};
|
|
35
36
|
const _cache = {};
|
|
36
37
|
function getRuntime(id) {
|
|
@@ -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.
|
|
15
|
+
const VERSION = exports.VERSION = "1.255.0";
|
|
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.
|
|
15
|
+
const VERSION = exports.VERSION = "1.255.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -20,7 +20,7 @@ class SharedContext {
|
|
|
20
20
|
if (Object.keys(model).includes(key)) this.sharedContext[key] = value;
|
|
21
21
|
});
|
|
22
22
|
} catch (err) {
|
|
23
|
-
(0, _console.warn)('An error
|
|
23
|
+
(0, _console.warn)('An error occurred while setting SharedContext', err);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -10,7 +10,6 @@ var submitData = _interopRequireWildcard(require("../util/submit-data"));
|
|
|
10
10
|
var _location = require("../url/location");
|
|
11
11
|
var _config = require("../config/config");
|
|
12
12
|
var _cleanUrl = require("../url/clean-url");
|
|
13
|
-
var _now = require("../timing/now");
|
|
14
13
|
var _eventListenerOpts = require("../event-listener/event-listener-opts");
|
|
15
14
|
var _obfuscate = require("../util/obfuscate");
|
|
16
15
|
var _traverse = require("../util/traverse");
|
|
@@ -18,6 +17,7 @@ var _sharedContext = require("../context/shared-context");
|
|
|
18
17
|
var _env = require("../constants/env.npm");
|
|
19
18
|
var _runtime = require("../constants/runtime");
|
|
20
19
|
var _console = require("../util/console");
|
|
20
|
+
var _now = require("../timing/now");
|
|
21
21
|
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); }
|
|
22
22
|
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; }
|
|
23
23
|
/*
|
|
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TimeKeeper = void 0;
|
|
7
|
-
var _nreum = require("../window/nreum");
|
|
8
7
|
var _runtime = require("../constants/runtime");
|
|
9
|
-
var _config = require("../config/config");
|
|
10
8
|
/**
|
|
11
9
|
* Class used to adjust the timestamp of harvested data to New Relic server time. This
|
|
12
10
|
* is done by tracking the performance timings of the RUM call and applying a calculation
|
|
13
11
|
* to the harvested data event offset time.
|
|
14
12
|
*/
|
|
15
13
|
class TimeKeeper {
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Represents the browser origin time.
|
|
16
|
+
* @type {number}
|
|
17
|
+
*/
|
|
18
|
+
#originTime;
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Represents the browser origin time corrected to NR server time.
|
|
@@ -27,56 +29,54 @@ class TimeKeeper {
|
|
|
27
29
|
* @type {number}
|
|
28
30
|
*/
|
|
29
31
|
#localTimeDiff;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents whether the timekeeper is in a state that it can accurately convert
|
|
35
|
+
* timestamps.
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
#ready = false;
|
|
39
|
+
constructor() {
|
|
40
|
+
this.#originTime = _runtime.globalScope.performance.timeOrigin || _runtime.globalScope.performance.timing.navigationStart;
|
|
41
|
+
}
|
|
42
|
+
get ready() {
|
|
43
|
+
return this.#ready;
|
|
32
44
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return Object.keys(nr?.initializedAgents || {}).indexOf(agentIdentifier) > -1 ? nr.initializedAgents[agentIdentifier].timeKeeper : undefined;
|
|
45
|
+
get originTime() {
|
|
46
|
+
return this.#originTime;
|
|
36
47
|
}
|
|
37
|
-
get
|
|
48
|
+
get correctedOriginTime() {
|
|
38
49
|
return this.#correctedOriginTime;
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
/**
|
|
42
53
|
* Process a rum request to calculate NR server time.
|
|
43
54
|
* @param rumRequest {XMLHttpRequest} The xhr for the rum request
|
|
44
|
-
* @param
|
|
55
|
+
* @param startTime {number} The start time of the RUM request
|
|
56
|
+
* @param endTime {number} The end time of the RUM request
|
|
45
57
|
*/
|
|
46
|
-
processRumRequest(rumRequest,
|
|
58
|
+
processRumRequest(rumRequest, startTime, endTime) {
|
|
47
59
|
const responseDateHeader = rumRequest.getResponseHeader('Date');
|
|
48
60
|
if (!responseDateHeader) {
|
|
49
61
|
throw new Error('Missing date header on rum response.');
|
|
50
62
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
throw new Error('Missing rum request performance entry.');
|
|
54
|
-
}
|
|
55
|
-
let medianRumOffset = 0;
|
|
56
|
-
let serverOffset = 0;
|
|
57
|
-
if (typeof resourceEntries[0].responseStart === 'number' && resourceEntries[0].responseStart !== 0) {
|
|
58
|
-
// Cors is enabled and we can make a more accurate calculation of NR server time
|
|
59
|
-
medianRumOffset = (resourceEntries[0].responseStart - resourceEntries[0].requestStart) / 2;
|
|
60
|
-
serverOffset = Math.floor(resourceEntries[0].requestStart + medianRumOffset);
|
|
61
|
-
} else {
|
|
62
|
-
// Cors is disabled or erred, we need to use a less accurate calculation
|
|
63
|
-
medianRumOffset = (resourceEntries[0].responseEnd - resourceEntries[0].fetchStart) / 2;
|
|
64
|
-
serverOffset = Math.floor(resourceEntries[0].fetchStart + medianRumOffset);
|
|
65
|
-
}
|
|
63
|
+
const medianRumOffset = (endTime - startTime) / 2;
|
|
64
|
+
const serverOffset = Math.floor(startTime + medianRumOffset);
|
|
66
65
|
|
|
67
66
|
// Corrected page origin time
|
|
68
67
|
this.#correctedOriginTime = Math.floor(Date.parse(responseDateHeader) - serverOffset);
|
|
69
|
-
this.#localTimeDiff =
|
|
68
|
+
this.#localTimeDiff = this.#originTime - this.#correctedOriginTime;
|
|
70
69
|
if (Number.isNaN(this.#correctedOriginTime)) {
|
|
71
70
|
throw new Error('Date header invalid format.');
|
|
72
71
|
}
|
|
72
|
+
this.#ready = true;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Converts a page origin relative time to an absolute timestamp
|
|
77
77
|
* corrected to NR server time.
|
|
78
78
|
* @param relativeTime {number} The relative time of the event in milliseconds
|
|
79
|
-
* @returns {number}
|
|
79
|
+
* @returns {number} Corrected unix/epoch timestamp
|
|
80
80
|
*/
|
|
81
81
|
convertRelativeTimestamp(relativeTime) {
|
|
82
82
|
return this.#correctedOriginTime + relativeTime;
|
|
@@ -4,21 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.cumulativeLayoutShift = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _attribution = require("web-vitals/attribution");
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
var _vitalMetric = require("./vital-metric");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
11
|
const cumulativeLayoutShift = exports.cumulativeLayoutShift = new _vitalMetric.VitalMetric(_constants.VITAL_NAMES.CUMULATIVE_LAYOUT_SHIFT, x => x);
|
|
12
12
|
if (_runtime.isBrowserScope) {
|
|
13
|
-
(0,
|
|
13
|
+
(0, _attribution.onCLS)(_ref => {
|
|
14
14
|
let {
|
|
15
15
|
value,
|
|
16
|
-
|
|
16
|
+
attribution,
|
|
17
|
+
id
|
|
17
18
|
} = _ref;
|
|
18
|
-
|
|
19
|
+
const attrs = {
|
|
20
|
+
metricId: id,
|
|
21
|
+
largestShiftTarget: attribution.largestShiftTarget,
|
|
22
|
+
largestShiftTime: attribution.largestShiftTime,
|
|
23
|
+
largestShiftValue: attribution.largestShiftValue,
|
|
24
|
+
loadState: attribution.loadState
|
|
25
|
+
};
|
|
19
26
|
cumulativeLayoutShift.update({
|
|
20
27
|
value,
|
|
21
|
-
|
|
28
|
+
attrs
|
|
22
29
|
});
|
|
23
30
|
}, {
|
|
24
31
|
reportAllChanges: true
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.firstContentfulPaint = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _attribution = require("web-vitals/attribution");
|
|
8
8
|
var _runtime = require("../constants/runtime");
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _vitalMetric = require("./vital-metric");
|
|
@@ -23,8 +23,7 @@ if (_runtime.isBrowserScope) {
|
|
|
23
23
|
paintEntries.forEach(entry => {
|
|
24
24
|
if (entry.name === 'first-contentful-paint') {
|
|
25
25
|
firstContentfulPaint.update({
|
|
26
|
-
value: Math.floor(entry.startTime)
|
|
27
|
-
entries: paintEntries
|
|
26
|
+
value: Math.floor(entry.startTime)
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
29
|
});
|
|
@@ -33,15 +32,20 @@ if (_runtime.isBrowserScope) {
|
|
|
33
32
|
// ignore
|
|
34
33
|
}
|
|
35
34
|
} else {
|
|
36
|
-
(0,
|
|
35
|
+
(0, _attribution.onFCP)(_ref => {
|
|
37
36
|
let {
|
|
38
37
|
value,
|
|
39
|
-
|
|
38
|
+
attribution
|
|
40
39
|
} = _ref;
|
|
41
40
|
if (_runtime.initiallyHidden || firstContentfulPaint.isValid) return;
|
|
41
|
+
const attrs = {
|
|
42
|
+
timeToFirstByte: attribution.timeToFirstByte,
|
|
43
|
+
firstByteToFCP: attribution.firstByteToFCP,
|
|
44
|
+
loadState: attribution.loadState
|
|
45
|
+
};
|
|
42
46
|
firstContentfulPaint.update({
|
|
43
47
|
value,
|
|
44
|
-
|
|
48
|
+
attrs
|
|
45
49
|
});
|
|
46
50
|
});
|
|
47
51
|
}
|
|
@@ -4,27 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.firstInputDelay = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _attribution = require("web-vitals/attribution");
|
|
8
8
|
var _vitalMetric = require("./vital-metric");
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
11
|
const firstInputDelay = exports.firstInputDelay = new _vitalMetric.VitalMetric(_constants.VITAL_NAMES.FIRST_INPUT_DELAY);
|
|
12
12
|
if (_runtime.isBrowserScope) {
|
|
13
|
-
(0,
|
|
13
|
+
(0, _attribution.onFID)(_ref => {
|
|
14
14
|
let {
|
|
15
15
|
value,
|
|
16
|
-
|
|
16
|
+
attribution
|
|
17
17
|
} = _ref;
|
|
18
|
-
if (_runtime.initiallyHidden || firstInputDelay.isValid
|
|
18
|
+
if (_runtime.initiallyHidden || firstInputDelay.isValid) return;
|
|
19
|
+
const attrs = {
|
|
20
|
+
type: attribution.eventType,
|
|
21
|
+
fid: Math.round(value),
|
|
22
|
+
eventTarget: attribution.eventTarget,
|
|
23
|
+
loadState: attribution.loadState
|
|
24
|
+
};
|
|
19
25
|
|
|
20
26
|
// CWV will only report one (THE) first-input entry to us; fid isn't reported if there are no user interactions occurs before the *first* page hiding.
|
|
21
27
|
firstInputDelay.update({
|
|
22
|
-
value:
|
|
23
|
-
|
|
24
|
-
attrs: {
|
|
25
|
-
type: entries[0].name,
|
|
26
|
-
fid: Math.round(value)
|
|
27
|
-
}
|
|
28
|
+
value: attribution.eventTime,
|
|
29
|
+
attrs
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
}
|
|
@@ -4,25 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.interactionToNextPaint = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _attribution = require("web-vitals/attribution");
|
|
8
8
|
var _vitalMetric = require("./vital-metric");
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
11
|
const interactionToNextPaint = exports.interactionToNextPaint = new _vitalMetric.VitalMetric(_constants.VITAL_NAMES.INTERACTION_TO_NEXT_PAINT);
|
|
12
12
|
if (_runtime.isBrowserScope) {
|
|
13
13
|
/* Interaction-to-Next-Paint */
|
|
14
|
-
(0,
|
|
14
|
+
(0, _attribution.onINP)(_ref => {
|
|
15
15
|
let {
|
|
16
16
|
value,
|
|
17
|
-
|
|
17
|
+
attribution,
|
|
18
18
|
id
|
|
19
19
|
} = _ref;
|
|
20
|
+
const attrs = {
|
|
21
|
+
metricId: id,
|
|
22
|
+
eventTarget: attribution.eventTarget,
|
|
23
|
+
eventType: attribution.eventType,
|
|
24
|
+
eventTime: attribution.eventTime,
|
|
25
|
+
loadState: attribution.loadState
|
|
26
|
+
};
|
|
20
27
|
interactionToNextPaint.update({
|
|
21
28
|
value,
|
|
22
|
-
|
|
23
|
-
attrs: {
|
|
24
|
-
metricId: id
|
|
25
|
-
}
|
|
29
|
+
attrs
|
|
26
30
|
});
|
|
27
31
|
});
|
|
28
32
|
}
|
|
@@ -4,36 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.largestContentfulPaint = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _attribution = require("web-vitals/attribution");
|
|
8
8
|
var _vitalMetric = require("./vital-metric");
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _runtime = require("../constants/runtime");
|
|
11
11
|
var _cleanUrl = require("../url/clean-url");
|
|
12
12
|
const largestContentfulPaint = exports.largestContentfulPaint = new _vitalMetric.VitalMetric(_constants.VITAL_NAMES.LARGEST_CONTENTFUL_PAINT);
|
|
13
13
|
if (_runtime.isBrowserScope) {
|
|
14
|
-
(0,
|
|
14
|
+
(0, _attribution.onLCP)(_ref => {
|
|
15
15
|
let {
|
|
16
16
|
value,
|
|
17
|
-
|
|
17
|
+
attribution
|
|
18
18
|
} = _ref;
|
|
19
19
|
/* Largest Contentful Paint - As of WV v3, it still imperfectly tries to detect document vis state asap and isn't supposed to report if page starts hidden. */
|
|
20
20
|
if (_runtime.initiallyHidden || largestContentfulPaint.isValid) return;
|
|
21
|
-
|
|
21
|
+
let attrs;
|
|
22
|
+
const lcpEntry = attribution.lcpEntry;
|
|
23
|
+
if (lcpEntry) {
|
|
24
|
+
attrs = {
|
|
25
|
+
size: lcpEntry.size,
|
|
26
|
+
eid: lcpEntry.id,
|
|
27
|
+
element: attribution.element,
|
|
28
|
+
timeToFirstByte: attribution.timeToFirstByte,
|
|
29
|
+
resourceLoadDelay: attribution.resourceLoadDelay,
|
|
30
|
+
resourceLoadTime: attribution.resourceLoadTime,
|
|
31
|
+
elementRenderDelay: attribution.elementRenderDelay
|
|
32
|
+
};
|
|
33
|
+
if (attribution.url) attrs.elUrl = (0, _cleanUrl.cleanURL)(attribution.url);
|
|
34
|
+
if (lcpEntry.element?.tagName) attrs.elTag = lcpEntry.element.tagName;
|
|
35
|
+
}
|
|
22
36
|
largestContentfulPaint.update({
|
|
23
37
|
value,
|
|
24
|
-
|
|
25
|
-
...(entries.length > 0 && {
|
|
26
|
-
attrs: {
|
|
27
|
-
size: lcpEntry.size,
|
|
28
|
-
eid: lcpEntry.id,
|
|
29
|
-
...(!!lcpEntry.url && {
|
|
30
|
-
elUrl: (0, _cleanUrl.cleanURL)(lcpEntry.url)
|
|
31
|
-
}),
|
|
32
|
-
...(!!lcpEntry.element?.tagName && {
|
|
33
|
-
elTag: lcpEntry.element.tagName
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
})
|
|
38
|
+
attrs
|
|
37
39
|
});
|
|
38
40
|
});
|
|
39
41
|
}
|
|
@@ -7,17 +7,20 @@ exports.timeToFirstByte = void 0;
|
|
|
7
7
|
var _runtime = require("../constants/runtime");
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
var _vitalMetric = require("./vital-metric");
|
|
10
|
-
var
|
|
10
|
+
var _attribution = require("web-vitals/attribution");
|
|
11
11
|
const timeToFirstByte = exports.timeToFirstByte = new _vitalMetric.VitalMetric(_constants.VITAL_NAMES.TIME_TO_FIRST_BYTE);
|
|
12
12
|
if (_runtime.isBrowserScope && typeof PerformanceNavigationTiming !== 'undefined' && !_runtime.isiOS) {
|
|
13
|
-
(0,
|
|
13
|
+
(0, _attribution.onTTFB)(_ref => {
|
|
14
14
|
let {
|
|
15
15
|
value,
|
|
16
|
-
|
|
16
|
+
attribution
|
|
17
17
|
} = _ref;
|
|
18
|
-
if (
|
|
18
|
+
if (timeToFirstByte.isValid) return;
|
|
19
|
+
timeToFirstByte.update({
|
|
19
20
|
value,
|
|
20
|
-
|
|
21
|
+
attrs: {
|
|
22
|
+
navigationEntry: attribution.navigationEntry
|
|
23
|
+
}
|
|
21
24
|
});
|
|
22
25
|
});
|
|
23
26
|
} else {
|
|
@@ -29,7 +32,9 @@ if (_runtime.isBrowserScope && typeof PerformanceNavigationTiming !== 'undefined
|
|
|
29
32
|
// ttfb is equiv to document's responseStart property in timing API --> https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/responseStart
|
|
30
33
|
timeToFirstByte.update({
|
|
31
34
|
value: entry.responseStart,
|
|
32
|
-
|
|
35
|
+
attrs: {
|
|
36
|
+
navigationEntry: entry
|
|
37
|
+
}
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
40
|
}
|
|
@@ -15,20 +15,18 @@ class VitalMetric {
|
|
|
15
15
|
update(_ref) {
|
|
16
16
|
let {
|
|
17
17
|
value,
|
|
18
|
-
entries = [],
|
|
19
18
|
attrs = {}
|
|
20
19
|
} = _ref;
|
|
21
20
|
if (value < 0) return;
|
|
22
21
|
const state = {
|
|
23
22
|
value: this.roundingMethod(value),
|
|
24
23
|
name: this.name,
|
|
25
|
-
entries,
|
|
26
24
|
attrs
|
|
27
25
|
};
|
|
28
26
|
this.history.push(state);
|
|
29
27
|
this.#subscribers.forEach(cb => {
|
|
30
28
|
try {
|
|
31
|
-
cb(
|
|
29
|
+
cb(state);
|
|
32
30
|
} catch (e) {
|
|
33
31
|
// ignore errors
|
|
34
32
|
}
|
|
@@ -38,7 +36,6 @@ class VitalMetric {
|
|
|
38
36
|
return this.history[this.history.length - 1] || {
|
|
39
37
|
value: undefined,
|
|
40
38
|
name: this.name,
|
|
41
|
-
entries: [],
|
|
42
39
|
attrs: {}
|
|
43
40
|
};
|
|
44
41
|
}
|
|
@@ -14,8 +14,8 @@ exports.gosNREUMInit = gosNREUMInit;
|
|
|
14
14
|
exports.gosNREUMLoaderConfig = gosNREUMLoaderConfig;
|
|
15
15
|
exports.gosNREUMOriginals = gosNREUMOriginals;
|
|
16
16
|
exports.setNREUMInitializedAgent = setNREUMInitializedAgent;
|
|
17
|
-
var _now = require("../timing/now");
|
|
18
17
|
var _runtime = require("../constants/runtime");
|
|
18
|
+
var _now = require("../timing/now");
|
|
19
19
|
const defaults = exports.defaults = {
|
|
20
20
|
beacon: 'bam.nr-data.net',
|
|
21
21
|
errorBeacon: 'bam.nr-data.net'
|
|
@@ -36,7 +36,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
36
36
|
scheduler.startTimer(harvestTimeSeconds);
|
|
37
37
|
this.drain();
|
|
38
38
|
});
|
|
39
|
-
const
|
|
39
|
+
const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
|
|
40
|
+
const denyList = agentRuntime.denyList;
|
|
40
41
|
(0, _denyList.setDenyList)(denyList);
|
|
41
42
|
let ajaxEvents = [];
|
|
42
43
|
let spaAjaxEvents = {};
|
|
@@ -122,7 +123,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
122
123
|
if (xhrContext.dt) {
|
|
123
124
|
event.spanId = xhrContext.dt.spanId;
|
|
124
125
|
event.traceId = xhrContext.dt.traceId;
|
|
125
|
-
event.spanTimestamp = xhrContext.dt.timestamp;
|
|
126
|
+
event.spanTimestamp = agentRuntime.timeKeeper.correctAbsoluteTimestamp(xhrContext.dt.timestamp);
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
// parsed from the AJAX body, looking for operationName param & parsing query for operationType
|
|
@@ -10,7 +10,6 @@ var _id = require("../../../common/ids/id");
|
|
|
10
10
|
var _runtime = require("../../../common/constants/runtime");
|
|
11
11
|
var _dataSize = require("../../../common/util/data-size");
|
|
12
12
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
13
|
-
var _now = require("../../../common/timing/now");
|
|
14
13
|
var _wrap = require("../../../common/wrap");
|
|
15
14
|
var _parseUrl = require("../../../common/url/parse-url");
|
|
16
15
|
var _distributedTracing = require("./distributed-tracing");
|
|
@@ -19,6 +18,7 @@ var _instrumentBase = require("../../utils/instrument-base");
|
|
|
19
18
|
var _constants = require("../constants");
|
|
20
19
|
var _features = require("../../../loaders/features/features");
|
|
21
20
|
var _constants2 = require("../../metrics/constants");
|
|
21
|
+
var _now = require("../../../common/timing/now");
|
|
22
22
|
/*
|
|
23
23
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
24
24
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -14,13 +14,13 @@ var _stringify = require("../../../common/util/stringify");
|
|
|
14
14
|
var _handle = require("../../../common/event-emitter/handle");
|
|
15
15
|
var _mapOwn = require("../../../common/util/map-own");
|
|
16
16
|
var _config = require("../../../common/config/config");
|
|
17
|
-
var _now = require("../../../common/timing/now");
|
|
18
17
|
var _runtime = require("../../../common/constants/runtime");
|
|
19
18
|
var _constants = require("../constants");
|
|
20
19
|
var _features = require("../../../loaders/features/features");
|
|
21
20
|
var _aggregateBase = require("../../utils/aggregate-base");
|
|
22
21
|
var _nreum = require("../../../common/window/nreum");
|
|
23
22
|
var _drain = require("../../../common/drain/drain");
|
|
23
|
+
var _now = require("../../../common/timing/now");
|
|
24
24
|
/*
|
|
25
25
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
26
26
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -172,7 +172,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
172
172
|
if (!this.stackReported[bucketHash]) {
|
|
173
173
|
this.stackReported[bucketHash] = true;
|
|
174
174
|
params.stack_trace = (0, _formatStackTrace.truncateSize)(stackInfo.stackString);
|
|
175
|
-
this.observedAt[bucketHash] = agentRuntime.
|
|
175
|
+
this.observedAt[bucketHash] = agentRuntime.timeKeeper.convertRelativeTimestamp(time);
|
|
176
176
|
} else {
|
|
177
177
|
params.browser_stack_hash = (0, _stringHashCode.stringHashCode)(stackInfo.stackString);
|
|
178
178
|
}
|
|
@@ -189,6 +189,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
189
189
|
}
|
|
190
190
|
if (agentRuntime?.session?.state?.sessionReplayMode) params.hasReplay = true;
|
|
191
191
|
params.firstOccurrenceTimestamp = this.observedAt[bucketHash];
|
|
192
|
+
params.timestamp = this.observedAt[bucketHash];
|
|
192
193
|
var type = internal ? 'ierr' : 'err';
|
|
193
194
|
var newMetrics = {
|
|
194
195
|
time
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Instrument = void 0;
|
|
7
7
|
var _handle = require("../../../common/event-emitter/handle");
|
|
8
|
-
var _now = require("../../../common/timing/now");
|
|
9
8
|
var _instrumentBase = require("../../utils/instrument-base");
|
|
10
9
|
var _constants = require("../constants");
|
|
11
10
|
var _features = require("../../../loaders/features/features");
|
|
@@ -13,6 +12,7 @@ var _runtime = require("../../../common/constants/runtime");
|
|
|
13
12
|
var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
|
|
14
13
|
var _stringify = require("../../../common/util/stringify");
|
|
15
14
|
var _uncaughtError = require("./uncaught-error");
|
|
15
|
+
var _now = require("../../../common/timing/now");
|
|
16
16
|
/*
|
|
17
17
|
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
@@ -95,14 +95,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
95
95
|
width = window.document.documentElement.clientWidth;
|
|
96
96
|
height = window.document.documentElement.clientHeight;
|
|
97
97
|
}
|
|
98
|
+
const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
|
|
98
99
|
var defaults = {
|
|
99
|
-
timestamp:
|
|
100
|
+
timestamp: agentRuntime.timeKeeper.convertRelativeTimestamp(t),
|
|
100
101
|
timeSinceLoad: t / 1000,
|
|
101
102
|
browserWidth: width,
|
|
102
103
|
browserHeight: height,
|
|
103
104
|
referrerUrl: this.referrerUrl,
|
|
104
105
|
currentUrl: (0, _cleanUrl.cleanURL)('' + location),
|
|
105
|
-
pageUrl: (0, _cleanUrl.cleanURL)(
|
|
106
|
+
pageUrl: (0, _cleanUrl.cleanURL)(agentRuntime.origin),
|
|
106
107
|
eventType: 'PageAction'
|
|
107
108
|
};
|
|
108
109
|
(0, _mapOwn.mapOwn)(defaults, set);
|