export function trackEvent(name, params = {}) {
  if (typeof window === "undefined") return;
  if (typeof window.gtag !== "function") return;
  window.gtag("event", name, params);
}

export function trackPageView(path, title) {
  if (typeof window === "undefined") return;
  const pagePath = path || window.location.pathname || "/";
  const pageTitle = title || document.title || "SocioWire";
  trackEvent("page_view", { page_path: pagePath, page_title: pageTitle });
}

export function trackSection(section, params = {}) {
  if (!section) return;
  trackEvent("section_view", { section, ...params });
}
