"use client"; import {useRef} from "react"; import {Button} from "@heroui/react"; import {usePostHog} from "posthog-js/react"; export const CustomButton = () => { const buttonRef = useRef(null); const posthog = usePostHog(); const handleConfetti = async () => { const {clientWidth, clientHeight} = document.documentElement; const boundingBox = buttonRef.current?.getBoundingClientRect?.(); const targetY = boundingBox?.y ?? 0; const targetX = boundingBox?.x ?? 0; const targetWidth = boundingBox?.width ?? 0; const targetCenterX = targetX + targetWidth / 2; const confetti = (await import("canvas-confetti")).default; confetti({ zIndex: 999, particleCount: 100, spread: 70, origin: { y: targetY / clientHeight, x: targetCenterX / clientWidth, }, }); posthog.capture("LandingPage - Confetti Button", { action: "press", category: "landing-page", }); }; return ( ); };