83 lines
2.7 KiB
JavaScript
83 lines
2.7 KiB
JavaScript
// WEVADS Universal Tracking System
|
|
(function() {
|
|
'use strict';
|
|
|
|
const WEVADS_Tracker = {
|
|
config: {
|
|
apiBase: '/api/screens/',
|
|
screenName: window.location.pathname,
|
|
enableLogging: true
|
|
},
|
|
|
|
init: function() {
|
|
this.logScreenAccess();
|
|
// KILLED: /* dashboard link killed */
|
|
this.startPerformanceMonitoring();
|
|
},
|
|
|
|
logScreenAccess: function() {
|
|
const startTime = performance.now();
|
|
|
|
fetch(this.config.apiBase + 'log.php', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
screen: this.config.screenName,
|
|
referrer: document.referrer,
|
|
timestamp: new Date().toISOString()
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (this.config.enableLogging) {
|
|
console.log('WEVADS: Screen access logged', data);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
if (this.config.enableLogging) {
|
|
console.warn('WEVADS: Failed to log access', err);
|
|
}
|
|
});
|
|
},
|
|
|
|
// KILLED: injectDashboardLink: function() { /* killed */ } : null,
|
|
timestamp: new Date().toISOString()
|
|
};
|
|
|
|
// Envoyer à l'API
|
|
fetch(this.config.apiBase + 'metrics.php', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify(perfData)
|
|
});
|
|
}, 30000); // Toutes les 30 secondes
|
|
},
|
|
|
|
// KILLED: getDashboardData: function(callback) {
|
|
fetch(this.config.apiBase + 'all.php')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (callback && typeof callback === 'function') {
|
|
callback(data);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
// KILLED: console.error('WEVADS: Failed to fetch dashboard data', err);
|
|
});
|
|
}
|
|
};
|
|
|
|
// Initialiser quand le DOM est chargé
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', () => WEVADS_Tracker.init());
|
|
} else {
|
|
WEVADS_Tracker.init();
|
|
}
|
|
|
|
// Exposer globalement
|
|
window.WEVADS_Tracker = WEVADS_Tracker;
|
|
})();
|
|
// Cache bust: 1770549903
|