3 go
This commit is contained in:
parent
6217ca412c
commit
6636f6698b
1 changed files with 24 additions and 12 deletions
28
index.html
28
index.html
|
|
@ -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">⇧</button>
|
||||
|
||||
<script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue