aboutsummaryrefslogtreecommitdiff
path: root/R2R/r2r/telemetry/events.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /R2R/r2r/telemetry/events.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to 'R2R/r2r/telemetry/events.py')
-rwxr-xr-xR2R/r2r/telemetry/events.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/R2R/r2r/telemetry/events.py b/R2R/r2r/telemetry/events.py
new file mode 100755
index 00000000..5bd7528b
--- /dev/null
+++ b/R2R/r2r/telemetry/events.py
@@ -0,0 +1,59 @@
+import uuid
+from typing import Any, Dict
+
+
+class BaseTelemetryEvent:
+ def __init__(self, event_type: str, properties: Dict[str, Any]):
+ self.event_type = event_type
+ self.properties = properties
+ self.event_id = str(uuid.uuid4())
+
+
+class DailyActiveUserEvent(BaseTelemetryEvent):
+ def __init__(self, user_id: str):
+ super().__init__("DailyActiveUser", {"user_id": user_id})
+
+
+class FeatureUsageEvent(BaseTelemetryEvent):
+ def __init__(self, user_id: str, feature: str):
+ super().__init__(
+ "FeatureUsage", {"user_id": user_id, "feature": feature}
+ )
+
+
+class ErrorEvent(BaseTelemetryEvent):
+ def __init__(self, user_id: str, endpoint: str, error_message: str):
+ super().__init__(
+ "Error",
+ {
+ "user_id": user_id,
+ "endpoint": endpoint,
+ "error_message": error_message,
+ },
+ )
+
+
+class RequestLatencyEvent(BaseTelemetryEvent):
+ def __init__(self, endpoint: str, latency: float):
+ super().__init__(
+ "RequestLatency", {"endpoint": endpoint, "latency": latency}
+ )
+
+
+class GeographicDistributionEvent(BaseTelemetryEvent):
+ def __init__(self, user_id: str, country: str):
+ super().__init__(
+ "GeographicDistribution", {"user_id": user_id, "country": country}
+ )
+
+
+class SessionDurationEvent(BaseTelemetryEvent):
+ def __init__(self, user_id: str, duration: float):
+ super().__init__(
+ "SessionDuration", {"user_id": user_id, "duration": duration}
+ )
+
+
+class UserPathEvent(BaseTelemetryEvent):
+ def __init__(self, user_id: str, path: str):
+ super().__init__("UserPath", {"user_id": user_id, "path": path})