feat(cmp): timezone→geo_country mapping + timezone parameter
Build + Deploy / build-admin-compliance (push) Successful in 2m10s
Build + Deploy / build-backend-compliance (push) Successful in 5m20s
Build + Deploy / build-ai-sdk (push) Successful in 57s
Build + Deploy / build-developer-portal (push) Successful in 1m15s
Build + Deploy / build-tts (push) Successful in 2m3s
Build + Deploy / build-document-crawler (push) Successful in 53s
Build + Deploy / build-dsms-gateway (push) Successful in 38s
Build + Deploy / build-dsms-node (push) Successful in 20s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 18s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m40s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 48s
CI / test-python-backend (push) Successful in 44s
CI / test-python-document-crawler (push) Successful in 26s
CI / test-python-dsms-gateway (push) Successful in 25s
CI / validate-canonical-controls (push) Successful in 15s
Build + Deploy / trigger-orca (push) Successful in 3m32s
Build + Deploy / build-admin-compliance (push) Successful in 2m10s
Build + Deploy / build-backend-compliance (push) Successful in 5m20s
Build + Deploy / build-ai-sdk (push) Successful in 57s
Build + Deploy / build-developer-portal (push) Successful in 1m15s
Build + Deploy / build-tts (push) Successful in 2m3s
Build + Deploy / build-document-crawler (push) Successful in 53s
Build + Deploy / build-dsms-gateway (push) Successful in 38s
Build + Deploy / build-dsms-node (push) Successful in 20s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 18s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m40s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 48s
CI / test-python-backend (push) Successful in 44s
CI / test-python-document-crawler (push) Successful in 26s
CI / test-python-dsms-gateway (push) Successful in 25s
CI / validate-canonical-controls (push) Successful in 15s
Build + Deploy / trigger-orca (push) Successful in 3m32s
Add _resolve_geo_from_timezone() with 35-country IANA timezone map. Accept timezone field in ConsentCreate schema and pass through to service. Populate geo_country automatically from browser timezone. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -90,6 +90,7 @@ async def record_consent(
|
|||||||
scripts_blocked=body.scripts_blocked,
|
scripts_blocked=body.scripts_blocked,
|
||||||
scripts_released=body.scripts_released,
|
scripts_released=body.scripts_released,
|
||||||
cookies_set=body.cookies_set,
|
cookies_set=body.cookies_set,
|
||||||
|
tz_name=body.timezone,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class ConsentCreate(BaseModel):
|
|||||||
screen_resolution: Optional[str] = None
|
screen_resolution: Optional[str] = None
|
||||||
session_id: Optional[str] = None
|
session_id: Optional[str] = None
|
||||||
consent_scope: Optional[str] = None
|
consent_scope: Optional[str] = None
|
||||||
|
timezone: Optional[str] = None
|
||||||
# Script/Cookie-Tracking (Migration 108)
|
# Script/Cookie-Tracking (Migration 108)
|
||||||
scripts_blocked: List[dict[str, Any]] = []
|
scripts_blocked: List[dict[str, Any]] = []
|
||||||
scripts_released: List[dict[str, Any]] = []
|
scripts_released: List[dict[str, Any]] = []
|
||||||
|
|||||||
@@ -62,6 +62,28 @@ class BannerConsentService:
|
|||||||
return None
|
return None
|
||||||
return hashlib.sha256(ip.encode()).hexdigest()[:16]
|
return hashlib.sha256(ip.encode()).hexdigest()[:16]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _resolve_geo_from_timezone(tz_name: Optional[str]) -> Optional[str]:
|
||||||
|
"""Map IANA timezone to ISO country code (best-effort, no external deps)."""
|
||||||
|
if not tz_name:
|
||||||
|
return None
|
||||||
|
tz_map: dict[str, str] = {
|
||||||
|
"Europe/Berlin": "DE", "Europe/Vienna": "AT", "Europe/Zurich": "CH",
|
||||||
|
"Europe/Amsterdam": "NL", "Europe/Brussels": "BE", "Europe/Paris": "FR",
|
||||||
|
"Europe/London": "GB", "Europe/Madrid": "ES", "Europe/Rome": "IT",
|
||||||
|
"Europe/Warsaw": "PL", "Europe/Prague": "CZ", "Europe/Stockholm": "SE",
|
||||||
|
"Europe/Copenhagen": "DK", "Europe/Helsinki": "FI", "Europe/Oslo": "NO",
|
||||||
|
"Europe/Dublin": "IE", "Europe/Lisbon": "PT", "Europe/Athens": "GR",
|
||||||
|
"Europe/Bucharest": "RO", "Europe/Budapest": "HU", "Europe/Sofia": "BG",
|
||||||
|
"Europe/Zagreb": "HR", "Europe/Ljubljana": "SI", "Europe/Bratislava": "SK",
|
||||||
|
"Europe/Tallinn": "EE", "Europe/Riga": "LV", "Europe/Vilnius": "LT",
|
||||||
|
"Europe/Luxembourg": "LU", "Europe/Valletta": "MT", "Europe/Nicosia": "CY",
|
||||||
|
"America/New_York": "US", "America/Chicago": "US", "America/Denver": "US",
|
||||||
|
"America/Los_Angeles": "US", "America/Toronto": "CA", "Asia/Tokyo": "JP",
|
||||||
|
"Asia/Shanghai": "CN", "Asia/Kolkata": "IN", "Australia/Sydney": "AU",
|
||||||
|
}
|
||||||
|
return tz_map.get(tz_name)
|
||||||
|
|
||||||
def _log(
|
def _log(
|
||||||
self,
|
self,
|
||||||
tenant_id: uuid.UUID,
|
tenant_id: uuid.UUID,
|
||||||
@@ -184,6 +206,7 @@ class BannerConsentService:
|
|||||||
scripts_blocked: Optional[list[dict]] = None,
|
scripts_blocked: Optional[list[dict]] = None,
|
||||||
scripts_released: Optional[list[dict]] = None,
|
scripts_released: Optional[list[dict]] = None,
|
||||||
cookies_set: Optional[list[dict]] = None,
|
cookies_set: Optional[list[dict]] = None,
|
||||||
|
tz_name: Optional[str] = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Upsert a device consent row for (tenant, site, device_fingerprint).
|
"""Upsert a device consent row for (tenant, site, device_fingerprint).
|
||||||
|
|
||||||
@@ -216,6 +239,7 @@ class BannerConsentService:
|
|||||||
"screen_resolution": screen_resolution,
|
"screen_resolution": screen_resolution,
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
"consent_scope": consent_scope or "domain",
|
"consent_scope": consent_scope or "domain",
|
||||||
|
"geo_country": self._resolve_geo_from_timezone(tz_name),
|
||||||
"scripts_blocked": scripts_blocked or [],
|
"scripts_blocked": scripts_blocked or [],
|
||||||
"scripts_released": scripts_released or [],
|
"scripts_released": scripts_released or [],
|
||||||
"cookies_set": cookies_set or [],
|
"cookies_set": cookies_set or [],
|
||||||
|
|||||||
Reference in New Issue
Block a user