Something went wrong. Try again.
React blog kit backed by AT Protocol. Provides filtering UI, pagination, Bluesky comments/embeds, subscribe widget, and markdown rendering.
Something went wrong. Try again.
864 B · 29 lines
TSX
at main
123456789101112131415161718192021222324252627282930"use client";
import { useEffect, useRef } from "react";import { useBlogTelemetry } from "../telemetry";
interface ScrollLoggerProps { eventName: string; data: Record<string, unknown>;}
// Fires a single client telemetry event on the user's first scroll. Renders nothing.export default function ScrollLogger({ eventName, data }: ScrollLoggerProps) { const telemetry = useBlogTelemetry(); const fired = useRef(false); const eventNameRef = useRef(eventName); const dataRef = useRef(data);
useEffect(() => { const onScroll = () => { if (fired.current) return; fired.current = true; telemetry.logClientEvent(eventNameRef.current, dataRef.current); }; window.addEventListener("scroll", onScroll, { passive: true }); return () => window.removeEventListener("scroll", onScroll); }, [telemetry]);
return null;}