|
|
|
@ -19,10 +19,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fetchSessionID() {
|
|
|
|
|
return fetch('https://ositcom.com/get-client-session/')
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(data => data.session_id)
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error('Error fetching session ID:', error);
|
|
|
|
|
return 'Unknown';
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initializeWebSocket() {
|
|
|
|
|
const referrer = document.referrer;
|
|
|
|
|
|
|
|
|
|
fetchClientData().then(({ client_ip, client_country }) => {
|
|
|
|
|
Promise.all([fetchClientData(), fetchSessionID()]).then(([clientData, session_id]) => {
|
|
|
|
|
const visitorsSocket = new WebSocket(visitorsSocketUrl);
|
|
|
|
|
|
|
|
|
|
visitorsSocket.onopen = () => {
|
|
|
|
@ -32,8 +42,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
'event_type': 'new_visitor',
|
|
|
|
|
'referrer': referrer,
|
|
|
|
|
'url': window.location.href,
|
|
|
|
|
'client_ip': client_ip,
|
|
|
|
|
'client_country': client_country
|
|
|
|
|
'client_ip': clientData.client_ip,
|
|
|
|
|
'client_country': clientData.client_country,
|
|
|
|
|
'session_id': session_id
|
|
|
|
|
};
|
|
|
|
|
visitorsSocket.send(JSON.stringify(event_message));
|
|
|
|
|
};
|
|
|
|
|