Module supabase/functions/sgtm_access_logs_list

Fileoverview

SGTM Access Logs List Edge Function

Retrieves paginated access logs for a container with filtering options. Used by the access logs viewer in the dashboard.

Endpoint

GET /sgtm_access_logs_list

Auth

Required - JWT in Authorization header

Remarks

  • Validates user has access to the container via client_memberships
  • Supports filtering by status code, client, event type, domain, and search query
  • Returns paginated results with total count
  • Includes log_data field for detailed request information

Query Parameters:

  • container_id (required): Container UUID
  • from (required): Start date (ISO string)
  • to (required): End date (ISO string)
  • status: Filter by HTTP status code
  • client: Filter by client type (ga4, gtm, js)
  • event_type: Filter by event type
  • domain: Filter by domain
  • q: Search query for request_url
  • page: Page number (default 1)
  • page_size: Results per page (default 100)

Tables touched:

  • sgtm_containers (read - validation)
  • client_memberships (read - permission check)
  • sgtm_access_logs (read)

Returns

200 - { logs: [], total, page, page_size, has_more }

Returns

400 - Missing required parameters

Returns

401 - Unauthorized

Returns

403 - Insufficient permissions

Returns

404 - Container not found

Returns

500 - Database error