Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

referralLinkId → dubPartnerId

Steven Teyd46e8025fea3
diff --git a/apps/web/app/api/embed/analytics/route.ts b/apps/web/app/api/embed/analytics/route.ts
index a41bb5f6d7..dedf6865f7 100644
--- a/apps/web/app/api/embed/analytics/route.ts
+++ b/apps/web/app/api/embed/analytics/route.ts
@@ -11,6 +11,7 @@ export const GET = withEmbedToken(async ({ programId, tenantId }) => {
programId,
tenantId,
});
+ console.log("analytics", analytics);
return NextResponse.json(analytics);
});
diff --git a/apps/web/app/api/user/route.ts b/apps/web/app/api/user/route.ts
index 4c2a531d2d..efeec3b6c0 100644
--- a/apps/web/app/api/user/route.ts
+++ b/apps/web/app/api/user/route.ts
@@ -36,7 +36,7 @@ export const GET = withSession(async ({ session }) => {
source: true,
defaultWorkspace: true,
defaultPartnerId: true,
- referralLinkId: true,
+ dubPartnerId: true,
passwordHash: true,
createdAt: true,
},
diff --git a/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page-client.tsx
index 62d78e8e35..5e6ee064bc 100644
--- a/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page-client.tsx
@@ -6,15 +6,22 @@ import { DubEmbed } from "@dub/embed-react";
import { CursorRays, Hyperlink, InvoiceDollar, UserCheck } from "@dub/ui/icons";
import { fetcher } from "@dub/utils";
import { useSession } from "next-auth/react";
+import { useEffect } from "react";
import useSWRImmutable from "swr/immutable";
export function ReferralsPageClient() {
- const { data: session, status } = useSession();
- const referralLinkId = session?.user?.["referralLinkId"];
+ const { data: session, status, update } = useSession();
+ const dubPartnerId = session?.user?.["dubPartnerId"];
+
+ useEffect(() => {
+ if (dubPartnerId) {
+ update();
+ }
+ }, [dubPartnerId]);
const { data: { publicToken } = {}, isLoading } = useSWRImmutable<{
publicToken: string;
- }>(referralLinkId && "/api/user/embed-tokens", fetcher, {
+ }>(dubPartnerId && "/api/user/embed-tokens", fetcher, {
keepPreviousData: true,
});
@@ -22,7 +29,7 @@ export function ReferralsPageClient() {
return <LayoutLoader />;
}
- if (!referralLinkId || !publicToken) {
+ if (!dubPartnerId || !publicToken) {
return (
<AnimatedEmptyState
title="Refer a friend"
diff --git a/apps/web/lib/auth/utils.ts b/apps/web/lib/auth/utils.ts
index ad373b05ac..3df3a157d2 100644
--- a/apps/web/lib/auth/utils.ts
+++ b/apps/web/lib/auth/utils.ts
@@ -12,7 +12,7 @@ export interface Session {
isMachine: boolean;
defaultWorkspace?: string;
defaultPartnerId?: string;
- referralLinkId?: string;
+ dubPartnerId?: string;
};
}
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 3bcb770b12..9556ffa7a7 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -155,7 +155,7 @@ export interface UserProps {
source: string | null;
defaultWorkspace?: string;
defaultPartnerId?: string;
- referralLinkId?: string;
+ dubPartnerId?: string;
isMachine: boolean;
hasPassword: boolean;
provider: string | null;
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index e88a0b1aa0..702ce521ee 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -219,7 +219,7 @@ const NAV_AREAS: SidebarNavAreas<{
icon: ShieldCheck,
href: "/account/settings/security",
},
- ...(session?.user?.["referralLinkId"]
+ ...(session?.user?.["dubPartnerId"]
? [
{
name: "Referrals",
diff --git a/apps/web/ui/layout/sidebar/refer-button.tsx b/apps/web/ui/layout/sidebar/refer-button.tsx
index 5a5660060c..43064caa94 100644
--- a/apps/web/ui/layout/sidebar/refer-button.tsx
+++ b/apps/web/ui/layout/sidebar/refer-button.tsx
@@ -10,7 +10,7 @@ export function ReferButton() {
const { data: session } = useSession();
if (
- !session?.user?.["referralLinkId"] ||
+ !session?.user?.["dubPartnerId"] ||
pathname === "/account/settings/referrals"
) {
return null;
diff --git a/apps/web/ui/layout/sidebar/user-dropdown.tsx b/apps/web/ui/layout/sidebar/user-dropdown.tsx
index 47f9fb0755..bd105b01d9 100644
--- a/apps/web/ui/layout/sidebar/user-dropdown.tsx
+++ b/apps/web/ui/layout/sidebar/user-dropdown.tsx
@@ -37,7 +37,7 @@ export default function UserDropdown() {
href="/account/settings"
onClick={() => setOpenPopover(false)}
/>
- {session?.user?.["referralLinkId"] && (
+ {session?.user?.["dubPartnerId"] && (
<UserOption
as={Link}
label="Refer and earn"
diff --git a/packages/prisma/schema/schema.prisma b/packages/prisma/schema/schema.prisma
index 19baa4cf09..657f75036f 100644
--- a/packages/prisma/schema/schema.prisma
+++ b/packages/prisma/schema/schema.prisma
@@ -27,7 +27,8 @@ model User {
source String? // where the user came from
defaultWorkspace String? // slug of the user's default workspace
defaultPartnerId String? // the user's default partner ID
- referralLinkId String? // this user's referral link ID
+ referralLinkId String? // TODO: remove this
+ dubPartnerId String? // this user's dub partner ID
// relational data
accounts Account[]