next-facebook-tracking
Version:
A simple package to help you integrate Facebook Pixel and Conversions API with Next.js
2 lines (1 loc) • 897 B
JavaScript
export*from"parse-full-name";import{cookies as i,headers as n}from"next/headers";async function o(){const e="0.0.0.0",t=await n(),r=t.get("x-forwarded-for");return r?r.split(",")[0]??e:t.get("x-real-ip")??e}async function a(){const e=await n();return e.get("x-vercel-ip-city")??e.get("cf-ipcity")??e.get("x-city")??void 0}async function s(){const e=await n();return e.get("x-vercel-ip-country-region")??e.get("cf-region")??e.get("x-region")??void 0}async function c(){const e=await n();return e.get("x-vercel-ip-country")??e.get("cf-ipcountry")??e.get("x-country")??void 0}async function g(){const e=await i(),t=await n();return{user_data:{city:await a(),state:await s(),country:await c(),fbp:e.get("_fbp")?.value,fbc:e.get("_fbc")?.value,client_ip_address:await o(),client_user_agent:t.get("user-agent")??void 0},event_source_url:t.get("referer")??void 0}}export{o as getIp,g as getRequestData};