This commit is contained in:
andreyflat 2025-08-19 03:58:16 +08:00
parent 6217ca412c
commit 6636f6698b

View file

@ -442,23 +442,35 @@ const videoObserver = new IntersectionObserver((entries, observer) => {
</script>
<script>
(function () {
const secret = "flat_secret_123"; // тот же, что в Netlify → SECRET_KEY
const url = "/.netlify/functions/privateViewLogger?key=" + encodeURIComponent(secret) + "&t=" + Date.now();
window.addEventListener("load", () => {
try {
if (sessionStorage.getItem("af_logged")) return; // не спамим: 1 раз за сессию
sessionStorage.setItem("af_logged", "1");
const secret = "flat_secret_123"; // тот же, что в Netlify → SECRET_KEY
const url = "/.netlify/functions/privateViewLogger"
+ "?key=" + encodeURIComponent(secret)
+ "&path=" + encodeURIComponent(location.pathname)
+ "&t=" + Date.now(); // ломаем кэш
if (navigator.sendBeacon) {
const body = JSON.stringify({ path: location.pathname });
navigator.sendBeacon(url, body);
} else {
fetch(url, {
method: "POST",
keepalive: true,
headers: { "content-type": "application/json", "cache-control": "no-store" },
headers: { "content-type": "application/json" },
body: JSON.stringify({ path: location.pathname })
})
.then(r => r.text().then(t => console.log("logger:", r.status, t)))
.catch(e => console.log("logger error:", e));
})();
}).catch(() => {});
}
} catch {}
});
</script>
<button id="scrollToTopBtn" title="Rewind">&#8679;</button>
<script>