@newrelic/browser-agent 1.265.1 → 1.266.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 +12 -0
- package/dist/cjs/common/config/init.js +0 -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/vitals/constants.js +0 -1
- package/dist/cjs/features/metrics/aggregate/index.js +1 -3
- package/dist/cjs/features/page_view_timing/aggregate/index.js +0 -2
- package/dist/cjs/features/utils/event-buffer.js +1 -1
- package/dist/esm/common/config/init.js +0 -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/vitals/constants.js +0 -1
- package/dist/esm/features/metrics/aggregate/index.js +1 -3
- package/dist/esm/features/page_view_timing/aggregate/index.js +0 -2
- package/dist/esm/features/utils/event-buffer.js +1 -1
- package/dist/types/common/vitals/constants.d.ts +0 -1
- package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
- package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/config/init.js +1 -1
- package/src/common/vitals/constants.js +0 -1
- package/src/features/metrics/aggregate/index.js +1 -2
- package/src/features/page_view_timing/aggregate/index.js +0 -3
- package/src/features/utils/event-buffer.js +1 -1
- package/dist/cjs/common/vitals/long-task.js +0 -61
- package/dist/esm/common/vitals/long-task.js +0 -55
- package/dist/types/common/vitals/long-task.d.ts +0 -3
- package/dist/types/common/vitals/long-task.d.ts.map +0 -1
- package/src/common/vitals/long-task.js +0 -51
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.266.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.265.1...v1.266.0) (2024-09-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Removing long task ([#1153](https://github.com/newrelic/newrelic-browser-agent/issues/1153)) ([304e395](https://github.com/newrelic/newrelic-browser-agent/commit/304e3954df9639d6d61e545fcaa0c761346a5016))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* Remove nullish coalescing inside getter ([#1180](https://github.com/newrelic/newrelic-browser-agent/issues/1180)) ([e537359](https://github.com/newrelic/newrelic-browser-agent/commit/e537359f354270fcbd607445b6853c236f0fdbfc))
|
|
17
|
+
|
|
6
18
|
## [1.265.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.265.0...v1.265.1) (2024-09-06)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -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.266.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.266.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the build type of the agent
|
|
@@ -70,8 +70,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
70
70
|
} = (0, _runtime.getRuntime)(this.agentIdentifier);
|
|
71
71
|
const {
|
|
72
72
|
proxy,
|
|
73
|
-
privacy
|
|
74
|
-
page_view_timing
|
|
73
|
+
privacy
|
|
75
74
|
} = (0, _init.getConfiguration)(this.agentIdentifier);
|
|
76
75
|
if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
|
|
77
76
|
if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
|
|
@@ -89,7 +88,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
89
88
|
});
|
|
90
89
|
});
|
|
91
90
|
if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
|
|
92
|
-
if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled');
|
|
93
91
|
} else if (_runtime2.isWorkerScope) {
|
|
94
92
|
this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
|
|
95
93
|
} else {
|
|
@@ -20,7 +20,6 @@ var _firstPaint = require("../../../common/vitals/first-paint");
|
|
|
20
20
|
var _interactionToNextPaint = require("../../../common/vitals/interaction-to-next-paint");
|
|
21
21
|
var _largestContentfulPaint = require("../../../common/vitals/largest-contentful-paint");
|
|
22
22
|
var _timeToFirstByte = require("../../../common/vitals/time-to-first-byte");
|
|
23
|
-
var _longTask = require("../../../common/vitals/long-task");
|
|
24
23
|
var _pageVisibility = require("../../../common/window/page-visibility");
|
|
25
24
|
var _constants2 = require("../../../common/vitals/constants");
|
|
26
25
|
var _eventBuffer = require("../../utils/event-buffer");
|
|
@@ -42,7 +41,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
|
|
|
42
41
|
super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
|
|
43
42
|
this.timings = new _eventBuffer.EventBuffer();
|
|
44
43
|
this.curSessEndRecorded = false;
|
|
45
|
-
if ((0, _init.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.long_task') === true) _longTask.longTask.subscribe(this.#handleVitalMetric);
|
|
46
44
|
(0, _registerHandler.registerHandler)('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
47
45
|
(0, _registerHandler.registerHandler)('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
|
|
48
46
|
const harvestTimeSeconds = (0, _init.getConfigurationValue)(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
@@ -64,8 +64,7 @@ export class Aggregate extends AggregateBase {
|
|
|
64
64
|
} = getRuntime(this.agentIdentifier);
|
|
65
65
|
const {
|
|
66
66
|
proxy,
|
|
67
|
-
privacy
|
|
68
|
-
page_view_timing
|
|
67
|
+
privacy
|
|
69
68
|
} = getConfiguration(this.agentIdentifier);
|
|
70
69
|
if (loaderType) this.storeSupportabilityMetrics("Generic/LoaderType/".concat(loaderType, "/Detected"));
|
|
71
70
|
if (distMethod) this.storeSupportabilityMetrics("Generic/DistMethod/".concat(distMethod, "/Detected"));
|
|
@@ -83,7 +82,6 @@ export class Aggregate extends AggregateBase {
|
|
|
83
82
|
});
|
|
84
83
|
});
|
|
85
84
|
if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled');
|
|
86
|
-
if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled');
|
|
87
85
|
} else if (isWorkerScope) {
|
|
88
86
|
this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected');
|
|
89
87
|
} else {
|
|
@@ -19,7 +19,6 @@ import { firstPaint } from '../../../common/vitals/first-paint';
|
|
|
19
19
|
import { interactionToNextPaint } from '../../../common/vitals/interaction-to-next-paint';
|
|
20
20
|
import { largestContentfulPaint } from '../../../common/vitals/largest-contentful-paint';
|
|
21
21
|
import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte';
|
|
22
|
-
import { longTask } from '../../../common/vitals/long-task';
|
|
23
22
|
import { subscribeToVisibilityChange } from '../../../common/window/page-visibility';
|
|
24
23
|
import { VITAL_NAMES } from '../../../common/vitals/constants';
|
|
25
24
|
import { EventBuffer } from '../../utils/event-buffer';
|
|
@@ -36,7 +35,6 @@ export class Aggregate extends AggregateBase {
|
|
|
36
35
|
super(agentIdentifier, aggregator, FEATURE_NAME);
|
|
37
36
|
this.timings = new EventBuffer();
|
|
38
37
|
this.curSessEndRecorded = false;
|
|
39
|
-
if (getConfigurationValue(this.agentIdentifier, 'page_view_timing.long_task') === true) longTask.subscribe(this.#handleVitalMetric);
|
|
40
38
|
registerHandler('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee);
|
|
41
39
|
registerHandler('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee);
|
|
42
40
|
const harvestTimeSeconds = getConfigurationValue(this.agentIdentifier, 'page_view_timing.harvestTimeSeconds') || 30;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/index.js"],"names":[],"mappings":"AAeA;IACE,2BAAiC;IACjC,mDAsBC;IAED,wDAKC;IAED,iDAKC;IAED,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metrics/aggregate/index.js"],"names":[],"mappings":"AAeA;IACE,2BAAiC;IACjC,mDAsBC;IAED,wDAKC;IAED,iDAKC;IAED,qBAqEC;IAED,0BAOC;IAED,eAkCC;IA/BG,mCAAyB;CAgC9B;8BAhK6B,4BAA4B"}
|
|
@@ -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":"AAyBA;IACE,2BAAiC;IAMjC,mDAuCC;IApCC,qBAAgC;IAChC,4BAA+B;IAqCjC;;;OAGG;IACH,6BAFW,MAAM,QAOhB;IAED;;OAEG;IACH,uCAUC;IAED,mDAuBC;IAED,qCAGC;IAED,gDAWC;IAGD;;;;kBAUC;IAGD,8BAuBC;;CACF;8BAvK6B,4BAA4B;4BAU9B,0BAA0B"}
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@ const model = () => {
|
|
|
49
49
|
obfuscate: undefined,
|
|
50
50
|
page_action: { enabled: true },
|
|
51
51
|
page_view_event: { enabled: true, autoStart: true },
|
|
52
|
-
page_view_timing: { enabled: true, harvestTimeSeconds: 30,
|
|
52
|
+
page_view_timing: { enabled: true, harvestTimeSeconds: 30, autoStart: true },
|
|
53
53
|
privacy: { cookies_enabled: true }, // *cli - per discussion, default should be true
|
|
54
54
|
proxy: {
|
|
55
55
|
assets: undefined, // if this value is set, it will be used to overwrite the webpack asset path used to fetch assets
|
|
@@ -56,7 +56,7 @@ export class Aggregate extends AggregateBase {
|
|
|
56
56
|
singleChecks () {
|
|
57
57
|
// report loaderType
|
|
58
58
|
const { distMethod, loaderType } = getRuntime(this.agentIdentifier)
|
|
59
|
-
const { proxy, privacy
|
|
59
|
+
const { proxy, privacy } = getConfiguration(this.agentIdentifier)
|
|
60
60
|
|
|
61
61
|
if (loaderType) this.storeSupportabilityMetrics(`Generic/LoaderType/${loaderType}/Detected`)
|
|
62
62
|
if (distMethod) this.storeSupportabilityMetrics(`Generic/DistMethod/${distMethod}/Detected`)
|
|
@@ -77,7 +77,6 @@ export class Aggregate extends AggregateBase {
|
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
if (!privacy.cookies_enabled) this.storeSupportabilityMetrics('Config/SessionTracking/Disabled')
|
|
80
|
-
if (page_view_timing.long_task) this.storeSupportabilityMetrics('Config/LongTask/Enabled')
|
|
81
80
|
} else if (isWorkerScope) {
|
|
82
81
|
this.storeSupportabilityMetrics('Generic/Runtime/Worker/Detected')
|
|
83
82
|
} else {
|
|
@@ -19,7 +19,6 @@ import { firstPaint } from '../../../common/vitals/first-paint'
|
|
|
19
19
|
import { interactionToNextPaint } from '../../../common/vitals/interaction-to-next-paint'
|
|
20
20
|
import { largestContentfulPaint } from '../../../common/vitals/largest-contentful-paint'
|
|
21
21
|
import { timeToFirstByte } from '../../../common/vitals/time-to-first-byte'
|
|
22
|
-
import { longTask } from '../../../common/vitals/long-task'
|
|
23
22
|
import { subscribeToVisibilityChange } from '../../../common/window/page-visibility'
|
|
24
23
|
import { VITAL_NAMES } from '../../../common/vitals/constants'
|
|
25
24
|
import { EventBuffer } from '../../utils/event-buffer'
|
|
@@ -37,8 +36,6 @@ export class Aggregate extends AggregateBase {
|
|
|
37
36
|
this.timings = new EventBuffer()
|
|
38
37
|
this.curSessEndRecorded = false
|
|
39
38
|
|
|
40
|
-
if (getConfigurationValue(this.agentIdentifier, 'page_view_timing.long_task') === true) longTask.subscribe(this.#handleVitalMetric)
|
|
41
|
-
|
|
42
39
|
registerHandler('docHidden', msTimestamp => this.endCurrentSession(msTimestamp), this.featureName, this.ee)
|
|
43
40
|
registerHandler('winPagehide', msTimestamp => this.recordPageUnload(msTimestamp), this.featureName, this.ee)
|
|
44
41
|
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.longTask = void 0;
|
|
7
|
-
var _runtime = require("../constants/runtime");
|
|
8
|
-
var _eol = require("../unload/eol");
|
|
9
|
-
var _constants = require("./constants");
|
|
10
|
-
var _vitalMetric = require("./vital-metric");
|
|
11
|
-
const longTask = exports.longTask = new _vitalMetric.VitalMetric(_constants.VITAL_NAMES.LONG_TASK);
|
|
12
|
-
if (_runtime.isBrowserScope) {
|
|
13
|
-
const handleEntries = entries => {
|
|
14
|
-
entries.forEach(entry => {
|
|
15
|
-
longTask.update({
|
|
16
|
-
value: entry.duration,
|
|
17
|
-
attrs: {
|
|
18
|
-
ltFrame: entry.name,
|
|
19
|
-
// MDN: the browsing context or frame that can be attributed to the long task
|
|
20
|
-
ltStart: entry.startTime,
|
|
21
|
-
// MDN: a double representing the time (millisec) when the task started
|
|
22
|
-
ltCtr: entry.attribution[0].containerType,
|
|
23
|
-
// MDN: type of frame container: 'iframe', 'embed', or 'object' ... but this can also be 'window',
|
|
24
|
-
...(entry.attribution[0].containerType !== 'window' && {
|
|
25
|
-
ltCtrSrc: entry.attribution[0].containerSrc,
|
|
26
|
-
// MDN: container's 'src' attribute
|
|
27
|
-
ltCtrId: entry.attribution[0].containerId,
|
|
28
|
-
// MDN: container's 'id' attribute
|
|
29
|
-
ltCtrName: entry.attribution[0].containerName // MDN: container's 'name' attribute
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
let observer;
|
|
36
|
-
try {
|
|
37
|
-
if (PerformanceObserver.supportedEntryTypes.includes('longtask')) {
|
|
38
|
-
observer = new PerformanceObserver(list => {
|
|
39
|
-
// Delay by a microtask to workaround a bug in Safari where the
|
|
40
|
-
// callback is invoked immediately, rather than in a separate task.
|
|
41
|
-
// See: https://github.com/GoogleChrome/web-vitals/issues/277
|
|
42
|
-
Promise.resolve().then(() => {
|
|
43
|
-
handleEntries(list.getEntries());
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
observer.observe({
|
|
47
|
-
type: 'longtask',
|
|
48
|
-
buffered: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
// Do nothing.
|
|
53
|
-
}
|
|
54
|
-
if (observer) {
|
|
55
|
-
(0, _eol.subscribeToEOL)(() => {
|
|
56
|
-
handleEntries(observer.takeRecords());
|
|
57
|
-
}, true); // this bool is a temp arg under staged BFCache work that runs the func under the new page session logic -- tb removed w/ the feature flag later
|
|
58
|
-
|
|
59
|
-
/* No work needed on BFCache restore for long task. */
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { isBrowserScope } from '../constants/runtime';
|
|
2
|
-
import { subscribeToEOL } from '../unload/eol';
|
|
3
|
-
import { VITAL_NAMES } from './constants';
|
|
4
|
-
import { VitalMetric } from './vital-metric';
|
|
5
|
-
export const longTask = new VitalMetric(VITAL_NAMES.LONG_TASK);
|
|
6
|
-
if (isBrowserScope) {
|
|
7
|
-
const handleEntries = entries => {
|
|
8
|
-
entries.forEach(entry => {
|
|
9
|
-
longTask.update({
|
|
10
|
-
value: entry.duration,
|
|
11
|
-
attrs: {
|
|
12
|
-
ltFrame: entry.name,
|
|
13
|
-
// MDN: the browsing context or frame that can be attributed to the long task
|
|
14
|
-
ltStart: entry.startTime,
|
|
15
|
-
// MDN: a double representing the time (millisec) when the task started
|
|
16
|
-
ltCtr: entry.attribution[0].containerType,
|
|
17
|
-
// MDN: type of frame container: 'iframe', 'embed', or 'object' ... but this can also be 'window',
|
|
18
|
-
...(entry.attribution[0].containerType !== 'window' && {
|
|
19
|
-
ltCtrSrc: entry.attribution[0].containerSrc,
|
|
20
|
-
// MDN: container's 'src' attribute
|
|
21
|
-
ltCtrId: entry.attribution[0].containerId,
|
|
22
|
-
// MDN: container's 'id' attribute
|
|
23
|
-
ltCtrName: entry.attribution[0].containerName // MDN: container's 'name' attribute
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
let observer;
|
|
30
|
-
try {
|
|
31
|
-
if (PerformanceObserver.supportedEntryTypes.includes('longtask')) {
|
|
32
|
-
observer = new PerformanceObserver(list => {
|
|
33
|
-
// Delay by a microtask to workaround a bug in Safari where the
|
|
34
|
-
// callback is invoked immediately, rather than in a separate task.
|
|
35
|
-
// See: https://github.com/GoogleChrome/web-vitals/issues/277
|
|
36
|
-
Promise.resolve().then(() => {
|
|
37
|
-
handleEntries(list.getEntries());
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
observer.observe({
|
|
41
|
-
type: 'longtask',
|
|
42
|
-
buffered: true
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
} catch (e) {
|
|
46
|
-
// Do nothing.
|
|
47
|
-
}
|
|
48
|
-
if (observer) {
|
|
49
|
-
subscribeToEOL(() => {
|
|
50
|
-
handleEntries(observer.takeRecords());
|
|
51
|
-
}, true); // this bool is a temp arg under staged BFCache work that runs the func under the new page session logic -- tb removed w/ the feature flag later
|
|
52
|
-
|
|
53
|
-
/* No work needed on BFCache restore for long task. */
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"long-task.d.ts","sourceRoot":"","sources":["../../../../src/common/vitals/long-task.js"],"names":[],"mappings":"AAKA,mCAA8D;4BAFlC,gBAAgB"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isBrowserScope } from '../constants/runtime'
|
|
2
|
-
import { subscribeToEOL } from '../unload/eol'
|
|
3
|
-
import { VITAL_NAMES } from './constants'
|
|
4
|
-
import { VitalMetric } from './vital-metric'
|
|
5
|
-
|
|
6
|
-
export const longTask = new VitalMetric(VITAL_NAMES.LONG_TASK)
|
|
7
|
-
|
|
8
|
-
if (isBrowserScope) {
|
|
9
|
-
const handleEntries = (entries) => {
|
|
10
|
-
entries.forEach(entry => {
|
|
11
|
-
longTask.update({
|
|
12
|
-
value: entry.duration,
|
|
13
|
-
attrs: {
|
|
14
|
-
ltFrame: entry.name, // MDN: the browsing context or frame that can be attributed to the long task
|
|
15
|
-
ltStart: entry.startTime, // MDN: a double representing the time (millisec) when the task started
|
|
16
|
-
ltCtr: entry.attribution[0].containerType, // MDN: type of frame container: 'iframe', 'embed', or 'object' ... but this can also be 'window',
|
|
17
|
-
...(entry.attribution[0].containerType !== 'window' && {
|
|
18
|
-
ltCtrSrc: entry.attribution[0].containerSrc, // MDN: container's 'src' attribute
|
|
19
|
-
ltCtrId: entry.attribution[0].containerId, // MDN: container's 'id' attribute
|
|
20
|
-
ltCtrName: entry.attribution[0].containerName // MDN: container's 'name' attribute
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let observer
|
|
28
|
-
try {
|
|
29
|
-
if (PerformanceObserver.supportedEntryTypes.includes('longtask')) {
|
|
30
|
-
observer = new PerformanceObserver((list) => {
|
|
31
|
-
// Delay by a microtask to workaround a bug in Safari where the
|
|
32
|
-
// callback is invoked immediately, rather than in a separate task.
|
|
33
|
-
// See: https://github.com/GoogleChrome/web-vitals/issues/277
|
|
34
|
-
Promise.resolve().then(() => {
|
|
35
|
-
handleEntries(list.getEntries())
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
observer.observe({ type: 'longtask', buffered: true })
|
|
39
|
-
}
|
|
40
|
-
} catch (e) {
|
|
41
|
-
// Do nothing.
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (observer) {
|
|
45
|
-
subscribeToEOL(() => {
|
|
46
|
-
handleEntries(observer.takeRecords())
|
|
47
|
-
}, true) // this bool is a temp arg under staged BFCache work that runs the func under the new page session logic -- tb removed w/ the feature flag later
|
|
48
|
-
|
|
49
|
-
/* No work needed on BFCache restore for long task. */
|
|
50
|
-
}
|
|
51
|
-
}
|