UNPKG

better-analytics

Version:

Zero-dependency micro-analytics JavaScript SDK < 3KB gzipped with React/Next.js/Expo support

2 lines (1 loc) 1.07 kB
import{a as i,b as s,c as a,d as c,e as l}from"../chunk-PWYIOQWX.mjs";var v=!1;function o(){if(v)return;let e=process.env.NEXT_PUBLIC_BA_SITE||process.env.BA_SITE,r=process.env.NEXT_PUBLIC_BA_URL||process.env.BA_URL,t=process.env.BA_API_KEY,n=process.env.BA_DEBUG==="true";if(!e){(n||process.env.NODE_ENV==="development")&&console.warn("Better Analytics Next.js Server: No site identifier found. Set NEXT_PUBLIC_BA_SITE or BA_SITE environment variable.");return}let p={site:e,debug:n,...r&&{endpoint:r},...t&&{apiKey:t}};try{i(p),v=!0,n&&(console.log("\u{1F680} Better Analytics Next.js Server auto-initialized"),console.log("\u{1F4CD} Endpoint:",r||"https://better-analytics.app/api/collect (default)"),console.log("\u{1F3F7}\uFE0F Site:",e))}catch(S){n&&console.error("Failed to auto-initialize Better Analytics Next.js Server:",S)}}async function y(e,r,t){return o(),s(e,r,t)}async function u(e,r){return o(),a(e,r)}async function d(e,r,t){return o(),c(e,r,t)}export{d as identifyServer,i as initServer,l as stitchSession,u as trackPageviewServer,y as trackServer};