feat: associate generation calls with devices
This commit is contained in:
@@ -68,12 +68,21 @@ def build_generation_route_usage_event(
|
||||
) -> dict[str, Any]:
|
||||
api_key = getattr(request, "auth", None)
|
||||
user = getattr(request, "user", None)
|
||||
client_device = getattr(request, "client_device", None)
|
||||
return {
|
||||
"event": EVENT_NAME,
|
||||
"route_type": normalize_text(route_type, 16),
|
||||
"api_key_id": getattr(api_key, "id", None),
|
||||
"api_key_prefix": normalize_text(getattr(api_key, "key_prefix", ""), 32),
|
||||
"user_id": getattr(user, "id", None),
|
||||
"product_code": normalize_text(
|
||||
getattr(client_device, "product_code", ""),
|
||||
32,
|
||||
),
|
||||
"client_device_id": getattr(client_device, "id", None),
|
||||
"device_session_present": bool(
|
||||
getattr(request, "device_session_present", False)
|
||||
),
|
||||
"client_version": normalize_text(
|
||||
request.headers.get("X-Client-Version", ""),
|
||||
MAX_CLIENT_VERSION_LENGTH,
|
||||
|
||||
Reference in New Issue
Block a user