import{TELEMETRY_ENDPOINT as a}from"../../../constants/index.js";import{getClientIp as i}from"../utils/get-client-ip.js";async function c(e){const n=await e.req.json();if(typeof n.event!="string")return e.newResponse(null,400,{});try{const{remoteAddr:t}=e.req.raw.context,r=e.get("auth"),s=i(e.req.raw)||t?.hostname,o=r?.claims?.sub;await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,ipAddress:s,userId:o,anonymousId:o?void 0:"ANONYMOUS",orgSlug:process.env.ORG_ID,projectSlug:process.env.PORTAL_ID})})}catch{}return e.newResponse(null,200,{})}export{c as telemetryHandler};
