The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
renamed a bunch of stuff
Steven Tey4ee7a30d93a1
diff --git a/apps/web/app/api/embed/token/route.ts b/apps/web/app/api/embed/referrals/token/route.tssimilarity index 75%rename from apps/web/app/api/embed/token/route.tsrename to apps/web/app/api/embed/referrals/token/route.tsindex 04548d508f..55d095b7ec 100644--- a/apps/web/app/api/embed/token/route.ts+++ b/apps/web/app/api/embed/referrals/token/route.ts@@ -1,7 +1,7 @@import { withEmbedToken } from "@/lib/embed/auth";import { NextResponse } from "next/server";-// GET /api/embed/token - get the embed token+// GET /api/embed/referrals/token - get the referrals embed tokenexport const GET = withEmbedToken(async ({ embedToken }) => {return NextResponse.json(embedToken);});diff --git a/apps/web/app/api/user/referrals-token/route.ts b/apps/web/app/api/user/referrals-token/route.tsindex 6832c524a7..ce3642969b 100644--- a/apps/web/app/api/user/referrals-token/route.ts+++ b/apps/web/app/api/user/referrals-token/route.ts@@ -17,6 +17,8 @@ export const GET = withSession(async ({ session }) => {name: session.user.name,email: session.user.email,image: session.user.image || null,+ // here we don't have to worry about duplicates since createEmbedToken takes care of this for us+ username: session.user.email.split("@")[0],tenantId: session.user.id,},};diff --git a/apps/web/app/app.dub.co/embed/referrals/activity.tsx b/apps/web/app/app.dub.co/embed/referrals/activity.tsxindex f25e27892f..bbfd248dc3 100644--- a/apps/web/app/app.dub.co/embed/referrals/activity.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/activity.tsx@@ -4,7 +4,7 @@ import { fetcher } from "@dub/utils/src/functions";import { AnalyticsTimeseries } from "dub/models/components";import useSWR from "swr";-export function EmbedActivity({+export function ReferralsEmbedActivity({clicks,leads,sales,diff --git a/apps/web/app/app.dub.co/embed/referrals/earnings.tsx b/apps/web/app/app.dub.co/embed/referrals/earnings.tsxindex 3df2691c38..316ea33ae7 100644--- a/apps/web/app/app.dub.co/embed/referrals/earnings.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/earnings.tsx@@ -12,7 +12,7 @@ import {import { motion } from "framer-motion";import useSWR from "swr";-export function EmbedEarnings({ salesCount }: { salesCount: number }) {+export function ReferralsEmbedEarnings({ salesCount }: { salesCount: number }) {const { pagination, setPagination } = usePagination(SALES_PAGE_SIZE);const { data: earnings, isLoading } = useSWR<PartnerEarningsResponse[]>(`/api/embed/referrals/commissions?page=${pagination.pageIndex}`,diff --git a/apps/web/app/app.dub.co/embed/referrals/faq.tsx b/apps/web/app/app.dub.co/embed/referrals/faq.tsxindex 4862930b07..ce8e3b33d5 100644--- a/apps/web/app/app.dub.co/embed/referrals/faq.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/faq.tsx@@ -11,7 +11,7 @@ import {import { TAB_ITEM_ANIMATION_SETTINGS } from "@dub/utils";import { motion } from "framer-motion";-export function EmbedFAQ({+export function ReferralsEmbedFAQ({program,reward,}: {diff --git a/apps/web/app/app.dub.co/embed/referrals/leaderboard.tsx b/apps/web/app/app.dub.co/embed/referrals/leaderboard.tsxindex b71731ea74..e221298eaf 100644--- a/apps/web/app/app.dub.co/embed/referrals/leaderboard.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/leaderboard.tsx@@ -11,7 +11,7 @@ import { cn } from "@dub/utils/src/functions";import { motion } from "framer-motion";import useSWR from "swr";-export function EmbedLeaderboard() {+export function ReferralsEmbedLeaderboard() {const { data: partners, isLoading } = useSWR<z.infer<typeof LeaderboardPartnerSchema>[]>("/api/embed/referrals/leaderboard", fetcher, {diff --git a/apps/web/app/app.dub.co/embed/referrals/page-client.tsx b/apps/web/app/app.dub.co/embed/referrals/page-client.tsxindex 4c4479cdc7..fd1294151b 100644--- a/apps/web/app/app.dub.co/embed/referrals/page-client.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/page-client.tsx@@ -16,13 +16,13 @@ import {import { cn, getPrettyUrl } from "@dub/utils";import { AnimatePresence } from "framer-motion";import { CSSProperties, useState } from "react";-import { LinkToken } from "../token";-import { EmbedActivity } from "./activity";-import { EmbedEarnings } from "./earnings";-import { EmbedFAQ } from "./faq";-import { EmbedLeaderboard } from "./leaderboard";-import { EmbedPayouts } from "./payouts";-import { EmbedQuickstart } from "./quickstart";+import { ReferralsEmbedActivity } from "./activity";+import { ReferralsEmbedEarnings } from "./earnings";+import { ReferralsEmbedFAQ } from "./faq";+import { ReferralsEmbedLeaderboard } from "./leaderboard";+import { ReferralsEmbedPayouts } from "./payouts";+import { ReferralsEmbedQuickstart } from "./quickstart";+import { ReferralsEmbedToken } from "./token";const tabs = ["Quickstart", "Earnings", "Leaderboard", "FAQ"];@@ -118,12 +118,12 @@ export function ReferralsEmbedPageClient({</div></div><div className="mt-4 grid gap-2 sm:h-32 sm:grid-cols-3">- <EmbedActivity+ <ReferralsEmbedActivityclicks={stats.clicks}leads={stats.leads}sales={stats.sales}/>- <EmbedPayouts payouts={payouts} />+ <ReferralsEmbedPayouts payouts={payouts} /></div><div className="mt-4"><ToggleGroup@@ -142,18 +142,18 @@ export function ReferralsEmbedPageClient({<div className="my-4"><AnimatePresence mode="wait">{selectedTab === "Quickstart" ? (- <EmbedQuickstart program={program} link={links[0]} />+ <ReferralsEmbedQuickstart program={program} link={links[0]} />) : selectedTab === "Earnings" ? (- <EmbedEarnings salesCount={stats.sales} />+ <ReferralsEmbedEarnings salesCount={stats.sales} />) : selectedTab === "Leaderboard" ? (- <EmbedLeaderboard />+ <ReferralsEmbedLeaderboard />) : selectedTab === "FAQ" ? (- <EmbedFAQ program={program} reward={reward} />+ <ReferralsEmbedFAQ program={program} reward={reward} />) : null}</AnimatePresence></div></div>- <LinkToken />+ <ReferralsEmbedToken /></div></div>);diff --git a/apps/web/app/app.dub.co/embed/referrals/payouts.tsx b/apps/web/app/app.dub.co/embed/referrals/payouts.tsxindex cd9c04fac1..1f6684681d 100644--- a/apps/web/app/app.dub.co/embed/referrals/payouts.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/payouts.tsx@@ -2,7 +2,7 @@ import { PayoutStatus } from "@dub/prisma/client";import { InfoTooltip } from "@dub/ui";import { currencyFormatter } from "@dub/utils";-export function EmbedPayouts({+export function ReferralsEmbedPayouts({payouts,}: {payouts: { status: PayoutStatus; amount: number }[];diff --git a/apps/web/app/app.dub.co/embed/referrals/quickstart.tsx b/apps/web/app/app.dub.co/embed/referrals/quickstart.tsxindex 57310e10ae..c2b32bcefd 100644--- a/apps/web/app/app.dub.co/embed/referrals/quickstart.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/quickstart.tsx@@ -15,7 +15,7 @@ import { motion } from "framer-motion";const BUTTON_CLASSNAME = "h-9 rounded-lg bg-neutral-900 hover:bg-neutral-800";-export function EmbedQuickstart({+export function ReferralsEmbedQuickstart({program,link,}: {diff --git a/apps/web/app/app.dub.co/embed/token.tsx b/apps/web/app/app.dub.co/embed/referrals/token.tsxsimilarity index 62%rename from apps/web/app/app.dub.co/embed/token.tsxrename to apps/web/app/app.dub.co/embed/referrals/token.tsxindex d94780024c..b106478c18 100644--- a/apps/web/app/app.dub.co/embed/token.tsx+++ b/apps/web/app/app.dub.co/embed/referrals/token.tsx@@ -4,12 +4,16 @@ import { fetcher } from "@dub/utils";import { useEffect } from "react";import useSWR from "swr";-export const LinkToken = () => {- const { error } = useSWR<{ token: number }>("/api/embed/token", fetcher, {- revalidateOnFocus: true,- dedupingInterval: 30000,- keepPreviousData: true,- });+export const ReferralsEmbedToken = () => {+ const { error } = useSWR<{ token: number }>(+ "/api/embed/referrals/token",+ fetcher,+ {+ revalidateOnFocus: true,+ dedupingInterval: 30000,+ keepPreviousData: true,+ },+ );// Inform the parent if there's an error (Eg: token is expired)useEffect(() => {diff --git a/packages/prisma/schema/schema.prisma b/packages/prisma/schema/schema.prismaindex 2f362ebb6b..a96823769f 100644--- a/packages/prisma/schema/schema.prisma+++ b/packages/prisma/schema/schema.prisma@@ -6,7 +6,7 @@ datasource db {generator client {provider = "prisma-client-js"- previewFeatures = ["fullTextSearch", "fullTextIndex", "driverAdapters", "prismaSchemaFolder", "omitApi"]+ previewFeatures = ["driverAdapters", "prismaSchemaFolder"]}model User {