feat: utm supports. (#2181)

This commit is contained in:
Garfield Dai
2024-01-24 20:14:02 +08:00
committed by GitHub
parent 3c13c4f3ee
commit 95ad06c8c3
4 changed files with 66 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
import os
import requests
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')
@classmethod
def _send_request(cls, method, endpoint, json=None, params=None):
headers = {
"Content-Type": "application/json",
"Billing-Api-Secret-Key": cls.secret_key
}
url = f"{cls.base_url}{endpoint}"
response = requests.request(method, url, json=json, params=params, headers=headers)
return response.json()
@classmethod
def record_utm(cls, tenant_id, args):
params = {
'tenant_id': tenant_id,
'utm_source': args['utm_source'],
'utm_medium': args['utm_medium'],
'utm_campaign': args['utm_campaign'],
'utm_content': args['utm_content'],
'utm_term': args['utm_term']
}
return cls._send_request('POST', '/tenant_utms', params=params)