-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.py
More file actions
38 lines (35 loc) · 1.1 KB
/
Copy pathanalytics.py
File metadata and controls
38 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Analytics event logging for the softphone backend.
Extracted from app.py to avoid circular imports.
"""
import json
from datetime import datetime
from database import get_db_connection
from tenant_context import current_tenant_id
def log_analytics_event(
greeting_type, greeting_name, event_type, phone_number=None, additional_data=None
):
"""Log analytics events"""
try:
conn = get_db_connection()
cur = conn.cursor()
cur.execute(
"""
INSERT INTO greeting_analytics
(tenant_id, greeting_type, greeting_name, event_type, phone_number, additional_data, timestamp)
VALUES (?, ?, ?, ?, ?, ?, ?)
""",
(
current_tenant_id(),
greeting_type,
greeting_name,
event_type,
phone_number,
json.dumps(additional_data) if additional_data else None,
datetime.now().isoformat(),
),
)
conn.commit()
conn.close()
except Exception as e:
print(f"Analytics logging error: {e}")