Global remote logging for all operations, stop tracking runtime files
This commit is contained in:
@@ -9,6 +9,12 @@ data/*.db-shm
|
||||
data/bring_token.json
|
||||
data/bring_catalog.json
|
||||
|
||||
# DupliClick token cache
|
||||
data/dupliclick_token.json
|
||||
|
||||
# Client debug log (runtime only)
|
||||
data/client_debug.log
|
||||
|
||||
# SSL CA cert (local only)
|
||||
ca.crt
|
||||
|
||||
|
||||
+61
-7
@@ -3,6 +3,54 @@
|
||||
* Complete pantry management with barcode scanning and AI identification
|
||||
*/
|
||||
|
||||
// ===== REMOTE LOGGING =====
|
||||
// Global remote logger: captures all errors, warnings and key operations
|
||||
const _remoteLogBuffer = [];
|
||||
let _remoteLogTimer = null;
|
||||
const _origConsoleError = console.error.bind(console);
|
||||
const _origConsoleWarn = console.warn.bind(console);
|
||||
|
||||
function remoteLog(level, ...args) {
|
||||
const msg = args.map(a => {
|
||||
if (a instanceof Error) return `${a.name}: ${a.message}`;
|
||||
if (typeof a === 'object') try { return JSON.stringify(a); } catch { return String(a); }
|
||||
return String(a);
|
||||
}).join(' ');
|
||||
_remoteLogBuffer.push(`[${level}] ${msg}`);
|
||||
if (!_remoteLogTimer) {
|
||||
_remoteLogTimer = setTimeout(flushRemoteLog, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function flushRemoteLog() {
|
||||
_remoteLogTimer = null;
|
||||
if (_remoteLogBuffer.length === 0) return;
|
||||
const msgs = _remoteLogBuffer.splice(0);
|
||||
fetch(`api/index.php?action=client_log`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ messages: msgs })
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
// Override console.error and console.warn to also send remotely
|
||||
console.error = function(...args) {
|
||||
_origConsoleError(...args);
|
||||
remoteLog('ERROR', ...args);
|
||||
};
|
||||
console.warn = function(...args) {
|
||||
_origConsoleWarn(...args);
|
||||
remoteLog('WARN', ...args);
|
||||
};
|
||||
|
||||
// Catch unhandled errors
|
||||
window.addEventListener('error', function(e) {
|
||||
remoteLog('UNCAUGHT', `${e.message} at ${e.filename}:${e.lineno}:${e.colno}`);
|
||||
});
|
||||
window.addEventListener('unhandledrejection', function(e) {
|
||||
remoteLog('UNHANDLED_PROMISE', e.reason);
|
||||
});
|
||||
|
||||
// ===== CONFIGURATION =====
|
||||
const API_BASE = 'api/index.php';
|
||||
const LOCATIONS = {
|
||||
@@ -537,7 +585,14 @@ async function api(action, params = {}, method = 'GET', body = null) {
|
||||
opts.body = JSON.stringify(body);
|
||||
}
|
||||
const res = await fetch(url, opts);
|
||||
return res.json();
|
||||
if (!res.ok) {
|
||||
remoteLog('API_ERROR', `${action} HTTP ${res.status}`);
|
||||
}
|
||||
const data = await res.json();
|
||||
if (data && data.error) {
|
||||
remoteLog('API_FAIL', `${action}: ${data.error}`);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// ===== PAGE NAVIGATION =====
|
||||
@@ -1245,12 +1300,11 @@ function scanLog(msg) {
|
||||
function flushScanLog() {
|
||||
_scanLogTimer = null;
|
||||
if (_scanLogBuffer.length === 0) return;
|
||||
const msgs = _scanLogBuffer.splice(0);
|
||||
fetch(`${API_BASE}?action=client_log`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ messages: msgs })
|
||||
}).catch(() => {});
|
||||
const msgs = _scanLogBuffer.splice(0).map(m => `[SCAN] ${m}`);
|
||||
_remoteLogBuffer.push(...msgs);
|
||||
if (!_remoteLogTimer) {
|
||||
_remoteLogTimer = setTimeout(flushRemoteLog, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleScanDebug() {
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
[2026-03-12 17:30:05] [desktop] Camera mode: environment
|
||||
[2026-03-12 17:30:05] [desktop] BarcodeDetector: NO (Quagga fallback)
|
||||
[2026-03-12 17:30:05] [desktop] Constraints: {"width":{"ideal":1280},"height":{"ideal":720},"facingMode":"environment"}
|
||||
[2026-03-12 17:30:05] [desktop] Stream OK — track: HP TrueVision HD Camera (30c9:002c)
|
||||
[2026-03-12 17:30:05] [desktop] Resolution: 1280x720, facing: user
|
||||
[2026-03-12 17:30:05] [desktop] Video playing — videoWidth: 1280, videoHeight: 720
|
||||
[2026-03-12 17:30:05] [desktop] Quagga starting — frontCam: false
|
||||
[2026-03-12 17:30:05] [desktop] Frame #1 — video: 1280x720
|
||||
[2026-03-12 17:30:11] [desktop] Scanning... f20, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:15] [desktop] Scanning... f40, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:20] [desktop] Scanning... f60, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:21] [phone] Camera mode: user
|
||||
[2026-03-12 17:30:21] [phone] BarcodeDetector: YES (native)
|
||||
[2026-03-12 17:30:21] [phone] Constraints: {"width":{"ideal":640},"height":{"ideal":480},"facingMode":"user"}
|
||||
[2026-03-12 17:30:21] [phone] Stream OK — track: camera 1, facing front
|
||||
[2026-03-12 17:30:21] [phone] Resolution: 480x640, facing: user
|
||||
[2026-03-12 17:30:21] [phone] Video playing — videoWidth: 480, videoHeight: 640
|
||||
[2026-03-12 17:30:21] [phone] Native BarcodeDetector started
|
||||
[2026-03-12 17:30:23] [phone] Native detect #1 [f3]: 4003608024917 (ean_13)
|
||||
[2026-03-12 17:30:23] [phone] Native detect #2 [f6]: 8003000024917 (ean_13)
|
||||
[2026-03-12 17:30:23] [phone] Native detect #3 [f16]: 8003000024917 (ean_13)
|
||||
[2026-03-12 17:30:23] [phone] CONFIRMED: 8003000024917 after 16 frames
|
||||
[2026-03-12 17:30:25] [desktop] Scanning... f80, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:30] [desktop] Scanning... f100, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:35] [desktop] Scanning... f120, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:40] [desktop] Scanning... f140, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:44] [desktop] Scanning... f160, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:49] [desktop] Scanning... f180, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:54] [desktop] Scanning... f200, partials: 0, pass: 0
|
||||
[2026-03-12 17:30:59] [desktop] Scanning... f220, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:04] [desktop] Scanning... f240, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:07] [desktop] Camera mode: user
|
||||
[2026-03-12 17:31:07] [desktop] BarcodeDetector: YES (native)
|
||||
[2026-03-12 17:31:07] [desktop] Constraints: {"width":{"ideal":640},"height":{"ideal":480},"facingMode":"user"}
|
||||
[2026-03-12 17:31:07] [desktop] Stream OK — track: camera 1, facing front
|
||||
[2026-03-12 17:31:07] [desktop] Resolution: 480x640, facing: user
|
||||
[2026-03-12 17:31:07] [desktop] Video playing — videoWidth: 480, videoHeight: 640
|
||||
[2026-03-12 17:31:07] [desktop] Native BarcodeDetector started
|
||||
[2026-03-12 17:31:09] [desktop] Scanning... f260, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:14] [desktop] Native scanning... f30, partials: 0
|
||||
[2026-03-12 17:31:14] [desktop] Native detect #1 [f31]: 8003000024917 (ean_13)
|
||||
[2026-03-12 17:31:14] [desktop] Native detect #2 [f33]: 8003000024917 (ean_13)
|
||||
[2026-03-12 17:31:14] [desktop] CONFIRMED: 8003000024917 after 33 frames
|
||||
[2026-03-12 17:31:14] [desktop] Scanning... f280, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:19] [desktop] Scanning... f300, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:22] [desktop] Camera mode: user
|
||||
[2026-03-12 17:31:22] [desktop] BarcodeDetector: YES (native)
|
||||
[2026-03-12 17:31:22] [desktop] Constraints: {"width":{"ideal":640},"height":{"ideal":480},"facingMode":"user"}
|
||||
[2026-03-12 17:31:22] [desktop] Stream OK — track: camera 1, facing front
|
||||
[2026-03-12 17:31:22] [desktop] Resolution: 480x640, facing: user
|
||||
[2026-03-12 17:31:22] [desktop] Video playing — videoWidth: 480, videoHeight: 640
|
||||
[2026-03-12 17:31:22] [desktop] Native BarcodeDetector started
|
||||
[2026-03-12 17:31:24] [desktop] Scanning... f320, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:26] [desktop] Native scanning... f30, partials: 0
|
||||
[2026-03-12 17:31:28] [desktop] Scanning... f340, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:30] [desktop] Native detect #1 [f49]: 016418230816 (upc_a)
|
||||
[2026-03-12 17:31:30] [desktop] Native detect #2 [f54]: 003418230816 (upc_a)
|
||||
[2026-03-12 17:31:33] [desktop] Scanning... f360, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:33] [desktop] Native scanning... f60, partials: 2
|
||||
[2026-03-12 17:31:33] [desktop] Native detect #3 [f63]: 9019489230816 (ean_13)
|
||||
[2026-03-12 17:31:38] [desktop] Scanning... f380, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:42] [desktop] Native scanning... f90, partials: 3
|
||||
[2026-03-12 17:31:43] [desktop] Scanning... f400, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:48] [desktop] Scanning... f420, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:49] [desktop] Native scanning... f120, partials: 3
|
||||
[2026-03-12 17:31:53] [desktop] Scanning... f440, partials: 0, pass: 0
|
||||
[2026-03-12 17:31:58] [desktop] Native scanning... f150, partials: 3
|
||||
[2026-03-12 17:31:58] [desktop] Scanning... f460, partials: 0, pass: 0
|
||||
[2026-03-12 17:32:03] [desktop] Native scanning... f180, partials: 3
|
||||
[2026-03-12 17:32:03] [desktop] Native detect #4 [f188]: 8000300337396 (ean_13)
|
||||
[2026-03-12 17:32:03] [desktop] Native detect #5 [f189]: 8000300337396 (ean_13)
|
||||
[2026-03-12 17:32:03] [desktop] CONFIRMED: 8000300337396 after 189 frames
|
||||
[2026-03-12 17:32:03] [desktop] Scanning... f480, partials: 0, pass: 0
|
||||
[2026-03-12 17:32:08] [desktop] Scanning... f500, partials: 0, pass: 0
|
||||
[2026-03-12 17:32:11] [desktop] Camera mode: user
|
||||
[2026-03-12 17:32:11] [desktop] BarcodeDetector: YES (native)
|
||||
[2026-03-12 17:32:11] [desktop] Constraints: {"width":{"ideal":640},"height":{"ideal":480},"facingMode":"user"}
|
||||
[2026-03-12 17:32:11] [desktop] Stream OK — track: camera 1, facing front
|
||||
[2026-03-12 17:32:11] [desktop] Resolution: 480x640, facing: user
|
||||
[2026-03-12 17:32:11] [desktop] Video playing — videoWidth: 480, videoHeight: 640
|
||||
[2026-03-12 17:32:11] [desktop] Native BarcodeDetector started
|
||||
[2026-03-12 17:32:13] [desktop] Scanning... f520, partials: 0, pass: 0
|
||||
@@ -1,118 +0,0 @@
|
||||
{
|
||||
"token": "eyJraWQiOiJzdGQiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJkYWRhbG9vcDgyQGdtYWlsLmNvbSIsImV4cCI6MTc3NDU5NjkzMywianRpIjoiMjM0NzIxNDUzVkJLR0hBSFlDUUxITjdIWFVNREJWIn0.97ZRFe3i0-0sCoVe_lG5Li2YVXkEyyPTfTr6tck984HKQryUf_12BidPe23aL_2eUeUiuMbd8HJfkyumlfOvmA",
|
||||
"email": "dadaloop82@gmail.com",
|
||||
"logged_at": "2026-03-12T06:35:33+00:00",
|
||||
"user": {
|
||||
"userId": 234721,
|
||||
"firstName": "Daniel",
|
||||
"lastName": "Stimpfl",
|
||||
"fidelityCard": "0401011000247",
|
||||
"email": "dadaloop82@gmail.com",
|
||||
"login": "dadaloop82@gmail.com",
|
||||
"phone": "+393490726254",
|
||||
"userType": {
|
||||
"userTypeId": "1"
|
||||
},
|
||||
"companyId": 0,
|
||||
"hasFavorites": true,
|
||||
"defaultStoreAddress": {
|
||||
"addressId": null,
|
||||
"addressName": null
|
||||
},
|
||||
"codInt": "2167695",
|
||||
"profile": {
|
||||
"level": 2,
|
||||
"confirmed": true
|
||||
},
|
||||
"hrAgent": {
|
||||
"hrId": null,
|
||||
"name": "",
|
||||
"internalCode": ""
|
||||
},
|
||||
"giftCertificatesReceived": [],
|
||||
"legals": [
|
||||
{
|
||||
"legalId": 1
|
||||
}
|
||||
],
|
||||
"userPointsCounters": [
|
||||
{
|
||||
"codInt": "0",
|
||||
"name": "Fidelity",
|
||||
"value": 0,
|
||||
"pointsUsed": 0
|
||||
}
|
||||
],
|
||||
"userPoints": [
|
||||
{
|
||||
"codInt": "0",
|
||||
"name": "Fidelity",
|
||||
"value": 0,
|
||||
"pointsUsed": 0
|
||||
}
|
||||
],
|
||||
"person": {
|
||||
"personId": "8116672",
|
||||
"firstName": "Daniel",
|
||||
"lastName": "Stimpfl",
|
||||
"gender": "",
|
||||
"birthDate": "1982-06-19",
|
||||
"birthPlace": "",
|
||||
"company": "",
|
||||
"fiscalCode": "",
|
||||
"vatCode": "",
|
||||
"vatFiscalCode": "",
|
||||
"codInt": "",
|
||||
"active": "1",
|
||||
"industryId": null,
|
||||
"industryName": null,
|
||||
"emailCertified": "",
|
||||
"vatSdiCode": "",
|
||||
"personTypeId": null,
|
||||
"personInfos": []
|
||||
},
|
||||
"billingAddress": {
|
||||
"addressId": 605113,
|
||||
"addressTypeId": 1,
|
||||
"addressType": "billing",
|
||||
"zoneId": -1,
|
||||
"active": 1,
|
||||
"deliveryAddressId": 605113,
|
||||
"shippingAddressId": 605113,
|
||||
"addressName": "residenza",
|
||||
"address1": "VIA PETER ROSEGGER",
|
||||
"address2": "",
|
||||
"addressNumber": "20\/C",
|
||||
"city": "LAIVES",
|
||||
"postalcode": "",
|
||||
"floor": "",
|
||||
"doorbellName": "",
|
||||
"province": "BZ",
|
||||
"apartmentNumber": "",
|
||||
"maxDistance": 0.4,
|
||||
"country": {
|
||||
"countryId": 1,
|
||||
"name": "Italia",
|
||||
"iso": "IT",
|
||||
"codInt": ""
|
||||
},
|
||||
"doorbellNumber": "",
|
||||
"referencePhoneNumber": "",
|
||||
"referenceMobileNumber": "",
|
||||
"referenceEMail": "",
|
||||
"addressNote": "",
|
||||
"ztl": null,
|
||||
"elevator": null,
|
||||
"countryId": "1"
|
||||
},
|
||||
"contact": {
|
||||
"contactId": "56730212",
|
||||
"email1": "dadaloop82@gmail.com",
|
||||
"email2": "",
|
||||
"homePhone": "",
|
||||
"workPhone": ""
|
||||
},
|
||||
"crmUserSegments": []
|
||||
},
|
||||
"cart_id": 1476245
|
||||
}
|
||||
+1
-1
@@ -858,6 +858,6 @@
|
||||
<div class="modal-content" id="modal-content" onclick="event.stopPropagation()"></div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/app.js?v=20260312w"></script>
|
||||
<script src="assets/js/app.js?v=20260312x"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user