mirror of
https://github.com/langgenius/dify.git
synced 2026-06-08 09:27:39 +08:00
refactor: replace bare dict with UtmInfo TypedDict in operation_service (#35055)
This commit is contained in:
@ -1,8 +1,22 @@
|
||||
import os
|
||||
from typing import TypedDict
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
class UtmInfo(TypedDict, total=False):
|
||||
"""Expected shape of the utm_info dict passed to record_utm.
|
||||
|
||||
All fields are optional; missing keys default to an empty string.
|
||||
"""
|
||||
|
||||
utm_source: str
|
||||
utm_medium: str
|
||||
utm_campaign: str
|
||||
utm_content: str
|
||||
utm_term: str
|
||||
|
||||
|
||||
class OperationService:
|
||||
base_url = os.environ.get("BILLING_API_URL", "BILLING_API_URL")
|
||||
secret_key = os.environ.get("BILLING_API_SECRET_KEY", "BILLING_API_SECRET_KEY")
|
||||
@ -17,7 +31,7 @@ class OperationService:
|
||||
return response.json()
|
||||
|
||||
@classmethod
|
||||
def record_utm(cls, tenant_id: str, utm_info: dict):
|
||||
def record_utm(cls, tenant_id: str, utm_info: UtmInfo):
|
||||
params = {
|
||||
"tenant_id": tenant_id,
|
||||
"utm_source": utm_info.get("utm_source", ""),
|
||||
|
||||
Reference in New Issue
Block a user