refactor: replace bare dict with UtmInfo TypedDict in operation_service (#35055)

This commit is contained in:
wdeveloper16
2026-04-13 15:05:47 +02:00
committed by GitHub
parent 671c5cdd84
commit d412cddf39
2 changed files with 17 additions and 3 deletions

View File

@ -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", ""),