The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed /domains cron, improved background, added customers
Steven Teyf442fd44133d
diff --git a/components/home/background.module.css b/components/home/background.module.cssindex 2d1cdc4d34..64ea49093f 100644--- a/components/home/background.module.css+++ b/components/home/background.module.css@@ -1,7 +1,7 @@.main {width: 100vw;min-height: 100vh;- position: relative;+ position: fixed;display: flex;justify-content: center;padding: 120px 24px 160px 24px;@@ -9,7 +9,7 @@}.main:before {- background: radial-gradient(circle, rgba(2, 0, 36, 0) 0, var(--gray1) 100%);+ background: radial-gradient(circle, rgba(2, 0, 36, 0) 0, #f9f9f9 100%);position: absolute;content: "";z-index: 2;@@ -20,12 +20,37 @@.main:after {content: "";- background-image: url("/grid.svg");- z-index: -1;+ background-image: url("/_static/grid.svg");+ z-index: 1;position: absolute;width: 100%;height: 100%;top: 0;- opacity: 1;+ opacity: 0.5;filter: invert(1);}++.content {+ height: fit-content;+ z-index: 3;+ width: 100%;+ max-width: 640px;+ background-image: radial-gradient(+ at 27% 37%,+ hsla(215, 98%, 61%, 1) 0px,+ transparent 0%+ ),+ radial-gradient(at 97% 21%, hsla(256, 98%, 72%, 1) 0px, transparent 50%),+ radial-gradient(at 52% 99%, hsla(354, 98%, 61%, 1) 0px, transparent 50%),+ radial-gradient(at 10% 29%, hsla(133, 96%, 67%, 1) 0px, transparent 50%),+ radial-gradient(at 97% 96%, hsla(38, 60%, 74%, 1) 0px, transparent 50%),+ radial-gradient(at 33% 50%, hsla(222, 67%, 73%, 1) 0px, transparent 50%),+ radial-gradient(at 79% 53%, hsla(343, 68%, 79%, 1) 0px, transparent 50%);+ position: absolute;+ content: "";+ width: 100%;+ height: 100%;+ filter: blur(100px) saturate(150%);+ top: 80px;+ opacity: 0.2;+}diff --git a/components/home/background.tsx b/components/home/background.tsxindex 834ac0a2ef..07a49593f2 100644--- a/components/home/background.tsx+++ b/components/home/background.tsx@@ -1,5 +1,11 @@+// the styles for this gradient grid background is+// inspired by Paco & Rauno's amazing CMDK site (https://cmdk.paco.me)+import styles from "./background.module.css";+export default function Background() {return (- <div className="fixed w-[532px] h-[834px] left-10 top-10 bg-gradient-to-r from-red-200 to-amber-200 blur-[100px] pointer-events-none" />+ <div className={styles.main}>+ <div className={styles.content} />+ </div>);}diff --git a/components/home/hero.tsx b/components/home/hero.tsxindex 4d1493cd5b..b16c15cdd4 100644--- a/components/home/hero.tsx+++ b/components/home/hero.tsx@@ -36,7 +36,7 @@ const Hero = () => {</Link><aclassName="flex justify-center items-center space-x-2 py-2 px-5 bg-white rounded-full border border-gray-300 hover:border-gray-800 transition-all"- href="https://github.com/steven-tey/dub"+ href="https://dub.sh/github"target="_blank"rel="noreferrer">diff --git a/components/home/logos.tsx b/components/home/logos.tsxindex 1e3d723929..15a3d33da3 100644--- a/components/home/logos.tsx+++ b/components/home/logos.tsx@@ -4,10 +4,10 @@ import MaxWidthWrapper from "../shared/max-width-wrapper";export default function Logos() {return (<div className="mt-20">- <p className="text-gray-500 text-lg text-center">+ <p className="text-gray-600 text-lg text-center">Giving superpowers to marketing teams at world-class companies</p>- <div className="w-full max-w-screen-lg px-5 sm:px-0 mx-auto mt-10 grid grid-cols-2 sm:grid-cols-4 gap-5 items-center">+ <div className="w-full max-w-screen-lg px-5 sm:px-0 mx-auto mt-8 grid grid-cols-2 sm:grid-cols-4 gap-5 items-center"><BlurImagesrc="/_static/clients/vercel.svg"alt="Vercel"@@ -30,11 +30,11 @@ export default function Logos() {className="col-span-1 h-8 sm:h-10"/><BlurImage- src="/_static/clients/testimonial.svg"- alt="Testimonial"+ src="/_static/clients/lugg.svg"+ alt="Lugg"width={2418}height={512}- className="col-span-1 h-10 sm:h-12"+ className="col-span-1 h-10 sm:h-24"/></div></div>diff --git a/components/layout/home/index.tsx b/components/layout/home/index.tsxindex bac21aaee5..27a1cf0bd2 100644--- a/components/layout/home/index.tsx+++ b/components/layout/home/index.tsx@@ -66,7 +66,7 @@ export default function HomeLayout({</div></div>{children}- <div className="border-t border-gray-200 h-20 flex items-center justify-center space-x-12">+ <div className="border-t border-gray-200 h-20 flex items-center justify-center space-x-12 z-10"><a href="https://twitter.com/dubdotsh" target="_blank" rel="noreferrer"><span className="sr-only">Twitter</span><Twitter className="w-6 h-6 text-gray-600" />diff --git a/lib/cron/domains.tsx b/lib/cron/domains.tsxindex f558af2382..bb6d24c858 100644--- a/lib/cron/domains.tsx+++ b/lib/cron/domains.tsx@@ -3,6 +3,7 @@ import InvalidDomain from "emails/InvalidDomain";import ProjectDeleted from "emails/ProjectDeleted";import { log } from "@/lib/cron/utils";import { removeDomain } from "@/lib/domains";+import prisma from "@/lib/prisma";import { deleteProject, redis } from "@/lib/upstash";export const handleDomainUpdates = async (diff --git a/lib/cron/usage.tsx b/lib/cron/usage.tsxindex 2555e7b8d2..96422a530b 100644--- a/lib/cron/usage.tsx+++ b/lib/cron/usage.tsx@@ -180,26 +180,6 @@ const getUsage = async (});results = await pipeline.exec();}-- const updateLinks = await Promise.all(- links.map(({ key }, index) => {- return prisma.link.update({- where: {- domain_key: {- domain,- key,- },- },- data: {- clicks: results[index],- clicksUpdatedAt: new Date(),- },- });- }),- );-- console.log(updateLinks.length, "links updated for", domain);-const usage = results.reduce((acc, curr) => acc + curr, 0);return usage;};diff --git a/pages/api/cron/links.ts b/pages/api/cron/links.tsnew file mode 100644index 0000000000..8f15eb5a64--- /dev/null+++ b/pages/api/cron/links.ts@@ -0,0 +1,68 @@+import type { NextApiRequest, NextApiResponse } from "next";+import { verifySignature } from "@upstash/qstash/nextjs";+import prisma from "@/lib/prisma";+import { redis } from "@/lib/upstash";++/**+ * Cron to update link count+ * Runs every 15 minutes (we'll increase this as number of links increase)+ **/++async function handler(_req: NextApiRequest, res: NextApiResponse) {+ try {+ const links = await prisma.link.findMany({+ select: {+ id: true,+ domain: true,+ key: true,+ clicks: true,+ },+ orderBy: {+ clicksUpdatedAt: "asc",+ },+ take: 100,+ });+ const start = Date.now() - 2629746000; // 30 days ago+ const pipeline = redis.pipeline();+ for (const { domain, key } of links) {+ pipeline.zcount(`${domain}:clicks:${key}`, start, Date.now());+ }+ const results = await pipeline.exec();+ const response = await Promise.all(+ links.map(({ domain, key, clicks }, index) => {+ const newClicks = results[index];+ console.log(domain, key, clicks, newClicks);+ return prisma.link.update({+ where: {+ domain_key: {+ domain,+ key,+ },+ },+ data: {+ clicks: newClicks,+ clicksUpdatedAt: new Date(),+ },+ });+ }),+ );++ res.status(200).json(response);+ } catch (error) {+ res.status(500).json({ error: error.message });+ }+}++/**+ * verifySignature will try to load `QSTASH_CURRENT_SIGNING_KEY` and `QSTASH_NEXT_SIGNING_KEY` from the environment.++ * To test out the endpoint manually (wihtout using QStash), you can do `export default handler` instead and+ * hit this endpoint via http://localhost:3000/api/cron/domains+ */+export default verifySignature(handler);++export const config = {+ api: {+ bodyParser: false,+ },+};diff --git a/pages/api/edge/coordinates.ts b/pages/api/edge/coordinates.tsindex 70f8287b76..e03a922840 100644--- a/pages/api/edge/coordinates.ts+++ b/pages/api/edge/coordinates.ts@@ -20,7 +20,7 @@ export default async function handler(req: NextRequest) {const { latitude, longitude } = data.geo;return {location: [latitude, longitude],- size: 0.05 - (0.05 / numPoints) * idx,+ size: 0.075 - (0.075 / numPoints) * idx,};});return new Response(JSON.stringify(latestCoordinates), { status: 200 });diff --git a/pages/index.tsx b/pages/index.tsxindex 56cada4cf6..7a89e16dc0 100644--- a/pages/index.tsx+++ b/pages/index.tsx@@ -45,27 +45,28 @@ export default function Home({ stars }: { stars: number }) {<Features stars={stars} /><Pricing /></div>+ <Background /></HomeLayout>);}export async function getStaticProps() {- const { stargazers_count: stars } = await fetch(- "https://api.github.com/repos/steven-tey/dub",- {- // optional – feel free to remove if you don't want to display star count- ...(process.env.GITHUB_OAUTH_TOKEN && {- headers: {- Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,- "Content-Type": "application/json",- },- }),- },- ).then((res) => res.json());+ // const { stargazers_count: stars } = await fetch(+ // "https://api.github.com/repos/steven-tey/dub",+ // {+ // // optional – feel free to remove if you don't want to display star count+ // ...(process.env.GITHUB_OAUTH_TOKEN && {+ // headers: {+ // Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,+ // "Content-Type": "application/json",+ // },+ // }),+ // },+ // ).then((res) => res.json());return {props: {- stars,+ stars: 10000,},revalidate: 10,};diff --git a/public/_static/clients/lugg.svg b/public/_static/clients/lugg.svgnew file mode 100644index 0000000000..7a3d6c1945--- /dev/null+++ b/public/_static/clients/lugg.svg@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->+<svg version="1.1" id="layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"+ viewBox="-153 -46 652 652" style="enable-background:new -153 -46 652 652;" xml:space="preserve">+<style type="text/css">+ .st0{fill:#2E3340;}+</style>+<path id="Logo" class="st0" d="M454.3,171.7c-5.9,1.8-16.7,4.8-33.6,6.3c-13.5,1.2-34.9,0.5-35.5,0.5c-58.9,0.1-74.4,36.7-74.4,59.1+ c0,11.1,3.3,24,12.5,34.6c-5.7,5.4-13.5,15.5-13.5,30.2c0,19.2,12.2,29,12.2,29s-13.2,15.5-13.2,34.6c0,36.3,28.5,50.2,76.4,50.2+ c45,0,76.5-15,76.5-52.4c0-39.8-27.1-54.9-58.2-54.9c-8,0-34.6,0-44,0c-5.5,0-10.8-4.6-10.8-10.9c0-3.6,1.6-6.2,3.7-8.1+ c8.4,2.5,18.4,3.9,30.3,3.9h5.2c56.4,0,71.8-32.4,71.8-56.2c0-8.4-2.2-18.7-8-28.4c5.3-1.4,9.8-2.7,12.9-4.1+ c2.1-0.9,4.1-3.1,3.4-6.1c-2.1-8-6.5-22.6-6.8-23.6C460.4,173,457.9,170.6,454.3,171.7z M361.5,236.2c0-18.3,11.7-28.2,24.5-28.3+ c12.8,0.1,22.8,10,22.8,28.3c0,17.1-9.5,28.1-23.6,28.2C371.1,264.3,361.5,253.2,361.5,236.2z M397.7,343.7+ c12.7,0,18.8,8.2,18.8,18.7c0,9.4-4.9,20-29.9,20c-25.9,0-30.8-9.5-30.8-17.8c0-13.5,8-20.9,8-20.9S376,343.7,397.7,343.7z+ M283.1,171.7c-5.9,1.8-16.7,4.8-33.6,6.3c-13.5,1.2-34.9,0.5-35.5,0.5c-58.9,0.1-74.4,36.7-74.4,59.1c0,11.1,3.3,24,12.5,34.6+ c-5.7,5.4-13.5,15.5-13.5,30.2c0,19.2,12.2,29,12.2,29s-13.2,15.5-13.2,34.6c0,36.3,28.5,50.2,76.4,50.2c45,0,76.5-15,76.5-52.4+ c0-39.8-27.1-54.9-58.2-54.9c-8,0-34.6,0-44,0c-5.5,0-10.8-4.6-10.8-10.9c0-3.6,1.6-6.2,3.7-8.1c8.4,2.5,18.4,3.9,30.3,3.9h5.2+ c56.4,0,71.8-32.4,71.8-56.2c0-8.4-2.2-18.7-8-28.4c5.3-1.4,9.8-2.7,12.9-4.1c2.1-0.9,4.1-3.1,3.4-6.1c-2.1-8-6.5-22.6-6.8-23.6+ C289.2,173,286.6,170.6,283.1,171.7z M190.3,236.2c0-18.3,11.7-28.2,24.5-28.3c12.8,0.1,22.8,10,22.8,28.3+ c0,17.1-9.5,28.1-23.6,28.2C199.9,264.3,190.3,253.2,190.3,236.2z M226.5,343.7c12.7,0,18.8,8.2,18.8,18.7c0,9.4-4.9,20-29.9,20+ c-25.9,0-30.8-9.5-30.8-17.8c0-13.5,8-20.9,8-20.9S204.8,343.7,226.5,343.7z M-66,299c-9.3,0-14.9-3.3-14.9-13.4V139+ c0-3.3-2.9-5.7-6.2-5.2c-12.3,2-38.9,6.1-40.6,6.3c-2.1,0.3-4.4,2.2-4.4,5c0,20.2,0,107,0,146.3c0,44.6,33.6,48.8,52.5,48.8+ c12,0,20.4-1.6,24.9-2.8c2.6-0.7,3.9-2.8,3.9-5v-29.2c0-2.7-2.4-5.7-6.1-5.1C-59.3,298.7-62.3,299-66,299z M67.8,181.4+ c-3.2,0-5.3,2.6-5.3,4.9c0,1.7,0,96.5,0,96.5c-3.7,4-15.8,15.9-30.2,15.9c-9.1,0-13.1-4.4-13.1-16.1v-96c0-2.9-2.4-5.1-5.4-5.1+ h-40.7c-2.4,0-5.1,2-5.1,5.1v104.4c0,25.1,7.4,49.5,42.6,49.5c22.3,0,41.8-14.5,53-24.8c1.8,6,5.1,17.2,5.4,18.3+ c0.4,1.4,1.9,3.7,5,3.7h34.5c1.8,0,5.2-1.4,5.2-5.3V186.3c0-2.6-2.3-5-5.3-5H67.8z"/>+</svg>