The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed coordinates bug
Steven Teyebf8f9dc3d01
diff --git a/components/home/globe.tsx b/components/home/globe.tsxindex 039c2cb3c3..c63a020bab 100644--- a/components/home/globe.tsx+++ b/components/home/globe.tsx@@ -13,7 +13,7 @@ interface MarkerProps {size: number;}-export default function Globe({ domain }: { domain?: string }) {+export default function Globe() {const divRef = useRef<any>();const entry = useIntersectionObserver(divRef, {});const isVisible = !!entry?.isIntersecting;@@ -30,7 +30,7 @@ export default function Globe({ domain }: { domain?: string }) {const [webglSupported, setWebglSupported] = useState(true);const { data: markers } = useSWR<MarkerProps[]>(- `/api/edge/coordinates${domain ? `?domain=${domain}` : ""}`,+ `/api/edge/coordinates`,fetcher,);@@ -55,20 +55,12 @@ export default function Globe({ domain }: { domain?: string }) {webglSupported ? "min-h-[500px] sm:min-h-[1000px]" : "min-h-[50px]"} h-full`}>- {webglSupported && showGlobe && (- <GlobeAnimation domain={domain} markers={markers} />- )}+ {webglSupported && showGlobe && <GlobeAnimation markers={markers} />}</div>);}-const GlobeAnimation = ({- domain,- markers,-}: {- domain?: string;- markers: MarkerProps[];-}) => {+const GlobeAnimation = ({ markers }: { markers: MarkerProps[] }) => {const canvasRef = useRef<any>();const pointerInteracting = useRef(null);const pointerInteractionMovement = useRef(0);@@ -145,25 +137,23 @@ const GlobeAnimation = ({This map shows the locations of the last 50 clicks on{" "}<aclassName="font-semibold text-blue-800"- href={domain ? `https://${domain}` : "https://dub.sh/github"}+ href="https://dub.sh/github"target="_blank"rel="noreferrer">- {domain || "dub.sh/github"}+ dub.sh/github</a>{" "}in real time.</p>- {!domain && (- <Link- href={{ pathname: "/", query: { key: "github" } }}- as="/stats/github"- shallow- scroll={false}- className="mx-auto mt-2 block max-w-fit rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white hover:bg-white hover:text-black sm:mt-4"- >- View all stats- </Link>- )}+ <Link+ href={{ pathname: "/", query: { key: "github" } }}+ as="/stats/github"+ shallow+ scroll={false}+ className="mx-auto mt-2 block max-w-fit rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white hover:bg-white hover:text-black sm:mt-4"+ >+ View all stats+ </Link></motion.div>)}</AnimatePresence>diff --git a/pages/api/edge/coordinates.ts b/pages/api/edge/coordinates.tsindex c3d1cc8861..35c51df176 100644--- a/pages/api/edge/coordinates.ts+++ b/pages/api/edge/coordinates.ts@@ -7,10 +7,9 @@ export const config = {export default async function handler(req: NextRequest) {if (req.method === "GET") {const count = 50;- const domain = req.nextUrl.searchParams.get("domain");const response = await fetch(- `https://api.us-east.tinybird.co/v0/pipes/coordinates.json?domain=${domain}&count=${count}`,+ `https://api.us-east.tinybird.co/v0/pipes/coordinates.json`,{headers: {Authorization: `Bearer ${process.env.TINYBIRD_API_KEY}`,@@ -26,7 +25,12 @@ export default async function handler(req: NextRequest) {size: 0.075 - (0.075 / count) * idx,};});- return new Response(JSON.stringify(latestCoordinates), { status: 200 });+ return new Response(JSON.stringify(latestCoordinates), {+ status: 200,+ headers: {+ "Cache-Control": "s-maxage=86400",+ },+ });} else {return new Response(`Method ${req.method} Not Allowed`, { status: 405 });}diff --git a/pages/placeholder/[[...domain]].tsx b/pages/placeholder/[[...domain]].tsxindex c0252b4a00..8ebeae2902 100644--- a/pages/placeholder/[[...domain]].tsx+++ b/pages/placeholder/[[...domain]].tsx@@ -6,7 +6,7 @@ import HomeLayout from "@/components/layout/home";export default function Placeholder({ domain }: { domain: string }) {return (<HomeLayout domain={domain}>- <Globe domain={domain} />+ <Globe /></HomeLayout>);}