digital-identity-platform-docs
digital-identity-platform-docs / supabase/functions/log_sgtm_access
supabase/functions/log_sgtm_access
Fileoverview
Log SGTM Access Edge Function
Logs access events from SGTM containers for analytics and recovery tracking. Called by the Cloudflare GTM Worker for each request processed.
Endpoint
POST /log_sgtm_access
Auth
None - Uses container validation instead of JWT
Remarks
- Validates that the container ID exists before inserting
- Tracks recovery status for requests that would have been blocked
- Supports various clients (ga4, gtm, js) and event types
- Used for billing, analytics, and tracking prevention metrics
Tables touched:
- sgtm_containers (read - validation)
- sgtm_access_logs (insert)
Example
json
{
"sgtm_container_id": "uuid",
"status_code": 200,
"client": "ga4",
"event_type": "page_view",
"request_url": "https://...",
"domain": "example.com",
"is_recovered": true,
"recovery_reasons": ["adblock", "itp"],
"client_session_id": "optional-session-id"
}