Fixed queries, mutations and JSON parse (#626)

* Fixed queries ond mutations

* Fixed JSON.parse in analytics
This commit is contained in:
yuri-sakharov
2025-11-27 11:44:50 +02:00
committed by GitHub
parent f01c19f330
commit 3f623458b3
10 changed files with 124 additions and 115 deletions

View File

@@ -13,8 +13,24 @@ const BASE_ANALYTIC_MSG = {
referrerPolicy: "no-referrer"
};
xhr.onload = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
const status = JSON.parse(xhr.responseText);
if (xhr.readyState !== XMLHttpRequest.DONE) {
return;
}
const responseTxt = xhr.responseText?.trim();
if (!responseTxt) {
console.warn("Analytics response is empty");
return;
}
let status;
try {
status = JSON.parse(responseTxt);
} catch (e) {
console.error("Failed to parse JSON: ", xhr.responseText, e);
return;
}
const version = status.CurVer;
if (status.Analytics) {
enableDD(version);
@@ -23,7 +39,6 @@ xhr.onload = function() {
} else {
console.log("Analytics is disabled in this session");
}
}
};
xhr.open("GET", "/status", true);
xhr.send(null);