"use client"; import {Icon} from "@iconify/react/dist/offline"; import arrowRightIcon from "@iconify/icons-solar/arrow-right-linear"; import {usePathname} from "next/navigation"; import {useEffect} from "react"; import {usePostHog} from "posthog-js/react"; import emitter from "@/libs/emitter"; const hideOnPaths = ["examples"]; export const HeroUIChatBanner = () => { const posthog = usePostHog(); const handleClick = () => { posthog.capture("HeroUI Chat Banner", { action: "click", category: "landing-page", }); }; const pathname = usePathname(); const shouldBeVisible = !hideOnPaths.some((path) => pathname.includes(path)); useEffect(() => { if (!shouldBeVisible) return; // listen to scroll event, dispatch an event when scroll is at the top < 48 px const handleScroll = () => { if (window.scrollY < 48) { emitter.emit("proBannerVisibilityChange", "visible"); } else { emitter.emit("proBannerVisibilityChange", "hidden"); } }; window.addEventListener("scroll", handleScroll); return () => { window.removeEventListener("scroll", handleScroll); }; }, [shouldBeVisible]); if (!shouldBeVisible) return null; return (
); };