diff --git a/assets/modules/analytics.js b/assets/modules/analytics.js index 0a4a2ec..f515047 100644 --- a/assets/modules/analytics.js +++ b/assets/modules/analytics.js @@ -20,7 +20,7 @@ async function encrypt(data) { const combined = new Uint8Array(12 + buf.length) combined.set(iv) combined.set(buf, 12) - return globalThis.btoa(String.fromCharCode(...combined)) + return globalThis.btoa(String.fromCodePoint(...combined)) } async function decrypt(b64) { @@ -68,8 +68,8 @@ async function send(data, expectResponse = false) { } async function getOrCreateVisitor() { - let uid = sessionStorage.getItem(SK_UID) - let hash = sessionStorage.getItem(SK_HASH) + const uid = sessionStorage.getItem(SK_UID) + const hash = sessionStorage.getItem(SK_HASH) if (uid && hash) return { uid, hash } const resp = await send({ @@ -78,7 +78,7 @@ async function getOrCreateVisitor() { l: navigator.language || null, }, true) - if (!resp || !resp.uid || !resp.h) return null + if (!resp?.uid || !resp?.h) return null sessionStorage.setItem(SK_UID, resp.uid) sessionStorage.setItem(SK_HASH, resp.h) @@ -121,7 +121,7 @@ export async function initAnalytics() { const authUserId = document.body.dataset.uid if (authUserId) { - await setAuth(parseInt(authUserId, 10)) + await setAuth(Number.parseInt(authUserId, 10)) } }