3 go
This commit is contained in:
parent
6217ca412c
commit
6636f6698b
1 changed files with 24 additions and 12 deletions
36
index.html
36
index.html
|
|
@ -442,23 +442,35 @@ const videoObserver = new IntersectionObserver((entries, observer) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
window.addEventListener("load", () => {
|
||||||
const secret = "flat_secret_123"; // тот же, что в Netlify → SECRET_KEY
|
try {
|
||||||
const url = "/.netlify/functions/privateViewLogger?key=" + encodeURIComponent(secret) + "&t=" + Date.now();
|
if (sessionStorage.getItem("af_logged")) return; // не спамим: 1 раз за сессию
|
||||||
|
sessionStorage.setItem("af_logged", "1");
|
||||||
|
|
||||||
fetch(url, {
|
const secret = "flat_secret_123"; // тот же, что в Netlify → SECRET_KEY
|
||||||
method: "POST",
|
const url = "/.netlify/functions/privateViewLogger"
|
||||||
keepalive: true,
|
+ "?key=" + encodeURIComponent(secret)
|
||||||
headers: { "content-type": "application/json", "cache-control": "no-store" },
|
+ "&path=" + encodeURIComponent(location.pathname)
|
||||||
body: JSON.stringify({ path: location.pathname })
|
+ "&t=" + Date.now(); // ломаем кэш
|
||||||
})
|
|
||||||
.then(r => r.text().then(t => console.log("logger:", r.status, t)))
|
if (navigator.sendBeacon) {
|
||||||
.catch(e => console.log("logger error:", e));
|
const body = JSON.stringify({ path: location.pathname });
|
||||||
})();
|
navigator.sendBeacon(url, body);
|
||||||
|
} else {
|
||||||
|
fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
keepalive: true,
|
||||||
|
headers: { "content-type": "application/json" },
|
||||||
|
body: JSON.stringify({ path: location.pathname })
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<button id="scrollToTopBtn" title="Rewind">⇧</button>
|
<button id="scrollToTopBtn" title="Rewind">⇧</button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue