Fix linter warnings in analytics module: codePoint, const, optional chaining, Number.parseInt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-26 21:34:22 +01:00
parent 20a6be0504
commit 59cf8dccde

View File

@@ -20,7 +20,7 @@ async function encrypt(data) {
const combined = new Uint8Array(12 + buf.length) const combined = new Uint8Array(12 + buf.length)
combined.set(iv) combined.set(iv)
combined.set(buf, 12) combined.set(buf, 12)
return globalThis.btoa(String.fromCharCode(...combined)) return globalThis.btoa(String.fromCodePoint(...combined))
} }
async function decrypt(b64) { async function decrypt(b64) {
@@ -68,8 +68,8 @@ async function send(data, expectResponse = false) {
} }
async function getOrCreateVisitor() { async function getOrCreateVisitor() {
let uid = sessionStorage.getItem(SK_UID) const uid = sessionStorage.getItem(SK_UID)
let hash = sessionStorage.getItem(SK_HASH) const hash = sessionStorage.getItem(SK_HASH)
if (uid && hash) return { uid, hash } if (uid && hash) return { uid, hash }
const resp = await send({ const resp = await send({
@@ -78,7 +78,7 @@ async function getOrCreateVisitor() {
l: navigator.language || null, l: navigator.language || null,
}, true) }, 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_UID, resp.uid)
sessionStorage.setItem(SK_HASH, resp.h) sessionStorage.setItem(SK_HASH, resp.h)
@@ -121,7 +121,7 @@ export async function initAnalytics() {
const authUserId = document.body.dataset.uid const authUserId = document.body.dataset.uid
if (authUserId) { if (authUserId) {
await setAuth(parseInt(authUserId, 10)) await setAuth(Number.parseInt(authUserId, 10))
} }
} }