featurely-site-manager 1.1.22 → 1.1.23
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/index.js +33 -2
- package/dist/index.mjs +33 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1089,18 +1089,49 @@ var _SiteManager = class _SiteManager {
|
|
|
1089
1089
|
setupWebVitals() {
|
|
1090
1090
|
if (typeof PerformanceObserver === "undefined") return;
|
|
1091
1091
|
try {
|
|
1092
|
+
let lcpValue = 0;
|
|
1093
|
+
let lcpReported = false;
|
|
1092
1094
|
const lcpObs = new PerformanceObserver((list) => {
|
|
1093
1095
|
const entries = list.getEntries();
|
|
1094
1096
|
const last = entries[entries.length - 1];
|
|
1095
1097
|
if (last) {
|
|
1098
|
+
lcpValue = Math.round(last.startTime);
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
lcpObs.observe({ type: "largest-contentful-paint", buffered: true });
|
|
1102
|
+
const reportLcp = () => {
|
|
1103
|
+
if (lcpValue > 0 && !lcpReported) {
|
|
1104
|
+
lcpReported = true;
|
|
1096
1105
|
this.trackEvent("web_vital", {
|
|
1097
1106
|
metric: "LCP",
|
|
1098
|
-
valueMs:
|
|
1107
|
+
valueMs: lcpValue,
|
|
1099
1108
|
path: window.location.pathname
|
|
1100
1109
|
});
|
|
1101
1110
|
}
|
|
1111
|
+
};
|
|
1112
|
+
const interactionTypes = [
|
|
1113
|
+
"click",
|
|
1114
|
+
"keydown",
|
|
1115
|
+
"scroll",
|
|
1116
|
+
"pointerdown",
|
|
1117
|
+
"touchstart"
|
|
1118
|
+
];
|
|
1119
|
+
const onFirstInteraction = () => {
|
|
1120
|
+
reportLcp();
|
|
1121
|
+
interactionTypes.forEach(
|
|
1122
|
+
(t) => window.removeEventListener(t, onFirstInteraction)
|
|
1123
|
+
);
|
|
1124
|
+
};
|
|
1125
|
+
interactionTypes.forEach(
|
|
1126
|
+
(t) => window.addEventListener(t, onFirstInteraction, {
|
|
1127
|
+
once: true,
|
|
1128
|
+
passive: true
|
|
1129
|
+
})
|
|
1130
|
+
);
|
|
1131
|
+
window.addEventListener("visibilitychange", () => {
|
|
1132
|
+
if (document.visibilityState === "hidden") reportLcp();
|
|
1102
1133
|
});
|
|
1103
|
-
|
|
1134
|
+
window.addEventListener("pagehide", reportLcp);
|
|
1104
1135
|
} catch {
|
|
1105
1136
|
}
|
|
1106
1137
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -1054,18 +1054,49 @@ var _SiteManager = class _SiteManager {
|
|
|
1054
1054
|
setupWebVitals() {
|
|
1055
1055
|
if (typeof PerformanceObserver === "undefined") return;
|
|
1056
1056
|
try {
|
|
1057
|
+
let lcpValue = 0;
|
|
1058
|
+
let lcpReported = false;
|
|
1057
1059
|
const lcpObs = new PerformanceObserver((list) => {
|
|
1058
1060
|
const entries = list.getEntries();
|
|
1059
1061
|
const last = entries[entries.length - 1];
|
|
1060
1062
|
if (last) {
|
|
1063
|
+
lcpValue = Math.round(last.startTime);
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
lcpObs.observe({ type: "largest-contentful-paint", buffered: true });
|
|
1067
|
+
const reportLcp = () => {
|
|
1068
|
+
if (lcpValue > 0 && !lcpReported) {
|
|
1069
|
+
lcpReported = true;
|
|
1061
1070
|
this.trackEvent("web_vital", {
|
|
1062
1071
|
metric: "LCP",
|
|
1063
|
-
valueMs:
|
|
1072
|
+
valueMs: lcpValue,
|
|
1064
1073
|
path: window.location.pathname
|
|
1065
1074
|
});
|
|
1066
1075
|
}
|
|
1076
|
+
};
|
|
1077
|
+
const interactionTypes = [
|
|
1078
|
+
"click",
|
|
1079
|
+
"keydown",
|
|
1080
|
+
"scroll",
|
|
1081
|
+
"pointerdown",
|
|
1082
|
+
"touchstart"
|
|
1083
|
+
];
|
|
1084
|
+
const onFirstInteraction = () => {
|
|
1085
|
+
reportLcp();
|
|
1086
|
+
interactionTypes.forEach(
|
|
1087
|
+
(t) => window.removeEventListener(t, onFirstInteraction)
|
|
1088
|
+
);
|
|
1089
|
+
};
|
|
1090
|
+
interactionTypes.forEach(
|
|
1091
|
+
(t) => window.addEventListener(t, onFirstInteraction, {
|
|
1092
|
+
once: true,
|
|
1093
|
+
passive: true
|
|
1094
|
+
})
|
|
1095
|
+
);
|
|
1096
|
+
window.addEventListener("visibilitychange", () => {
|
|
1097
|
+
if (document.visibilityState === "hidden") reportLcp();
|
|
1067
1098
|
});
|
|
1068
|
-
|
|
1099
|
+
window.addEventListener("pagehide", reportLcp);
|
|
1069
1100
|
} catch {
|
|
1070
1101
|
}
|
|
1071
1102
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "featurely-site-manager",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"description": "Complete site management SDK for maintenance mode, status messages, feature flags, version checking, and analytics",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|