new
parent
ada7c209e2
commit
32ea7a408f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2024-07-21 17:09
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('osichat', '0010_visitor_left_date_visitor_visit_date'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='visitor',
|
||||||
|
name='country',
|
||||||
|
field=models.CharField(max_length=15, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2024-07-21 17:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('osichat', '0011_visitor_country'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='visitor',
|
||||||
|
name='reference',
|
||||||
|
field=models.URLField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
const visitors_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
|
||||||
|
const my_domain = "192.168.1.111:8000";
|
||||||
|
const session_id = document.getElementById('session_id').textContent.trim();
|
||||||
|
const client_ip = document.getElementById('client_ip').textContent.trim();
|
||||||
|
const client_country = document.getElementById('client_country').textContent.trim();
|
||||||
|
const current_url = document.getElementById('current_url').textContent.trim();
|
||||||
|
const visitorsSocketUrl = `${chat_ws_scheme}://${domain}/ws/osichat/visitors/`;
|
||||||
|
const visitorsSocket = new WebSocket(visitorsSocketUrl);
|
||||||
|
|
||||||
|
|
||||||
|
visitorsSocket.onopen = () => {
|
||||||
|
console.log('WebSocket connection to visitors established');
|
||||||
|
const event_message = {
|
||||||
|
'event_type': 'new_visitor',
|
||||||
|
'session_id': session_id,
|
||||||
|
'ip_address': client_ip,
|
||||||
|
'country': client_country,
|
||||||
|
'url': current_url
|
||||||
|
};
|
||||||
|
visitorsSocket.send(JSON.stringify(event_message));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
visitorsSocket.onclose = () => {
|
||||||
|
console.log('WebSocket connection to visitors closed');
|
||||||
|
};
|
||||||
|
|
||||||
|
visitorsSocket.onerror = (error) => {
|
||||||
|
console.log('WebSocket error:', error);
|
||||||
|
};
|
Loading…
Reference in New Issue