Backend additions: - UserConnectService, ScanConnectService: connection logging - ToBetCommonService, ToBetBaccaratService: bet rejection/success logging - ResetBoot, ResetNumberTab, ResetBaccarat, ResetDt: reset event logging - handle/Index: log_report controller method (fixes route for dealer端) - index/Log: log_report controller for player端 (no auth required) Frontend: - error-report.js: fix report URL to /index/log_report (matches handle controller) Total: 21 backend files with 60 Logger calls across 5 categories
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
(function() {
|
|
var reportUrl = '/index/log_report';
|
|
var queue = [];
|
|
var sending = false;
|
|
|
|
function send(data) {
|
|
if (queue.length >= 10) return;
|
|
data.source = 'handle';
|
|
data.time = new Date().toISOString();
|
|
data.url = location.href;
|
|
queue.push(data);
|
|
flush();
|
|
}
|
|
|
|
function flush() {
|
|
if (sending || queue.length === 0) return;
|
|
sending = true;
|
|
var item = queue.shift();
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', reportUrl);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.onloadend = function() { sending = false; flush(); };
|
|
xhr.onerror = function() { sending = false; };
|
|
xhr.timeout = 3000;
|
|
xhr.send(JSON.stringify(item));
|
|
}
|
|
|
|
window.onerror = function(message, source, lineno, colno, error) {
|
|
send({
|
|
type: 'error',
|
|
message: String(message),
|
|
stack: error && error.stack ? error.stack.substring(0, 2000) : '',
|
|
file: source,
|
|
line: lineno,
|
|
col: colno
|
|
});
|
|
};
|
|
|
|
window.addEventListener('unhandledrejection', function(event) {
|
|
var reason = event.reason;
|
|
send({
|
|
type: 'unhandledrejection',
|
|
message: reason && reason.message ? reason.message : String(reason),
|
|
stack: reason && reason.stack ? reason.stack.substring(0, 2000) : ''
|
|
});
|
|
});
|
|
})();
|