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:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user