Module supabase/functions/mark-session-detection

Fileoverview

Mark Session Detection Edge Function

Updates loader sessions with adblock and ITP detection flags. Called by the client-side loader when tracking prevention is detected.

Endpoint

POST /mark-session-detection

Auth

None - Uses loader_token validation instead of JWT

Remarks

  • Validates loader_token against sgtm_containers table
  • Updates loader_sessions with detection timestamps and methods
  • Only updates fields when detection is true (doesn't clear existing flags)
  • Used for tracking prevention analytics and recovery metrics

Tables touched:

  • sgtm_containers (read - token validation)
  • loader_sessions (update)

Example: Request body

{
"loader_token": "abc12345",
"client_session_id": "uuid",
"adblock_detected": true,
"adblock_method": "bait",
"itp_detected": false,
"itp_method": null
}

Returns

200 - { success: true, updated: count }

Returns

400 - Missing required fields

Returns

401 - Invalid loader_token

Returns

500 - Database error