Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dub refer embed #20258

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

feat: dub refer embed #20258

wants to merge 13 commits into from

Conversation

Amit91848
Copy link
Contributor

What does this PR do?

  • Created a clean /refer page with proper loading states and dub embed
  • Set up the API endpoint to generate user-specific referral tokens
  • Implemented theme support so it looks good in both light/dark modes
  • This PR adds the ability for users to earn affiliate commissions through a Dub-powered referral system.

Demo

https://www.loom.com/share/86aadaaf8fef486387fde9ebfae73305
Screenshot 2025-03-06 at 1 35 24 PM

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Go to /refer (bottom of sidebar)
  • See Dub.co embed pop up
  • Have a shareable affiliate link

@Amit91848 Amit91848 requested a review from a team as a code owner March 20, 2025 14:47
@graphite-app graphite-app bot requested a review from a team March 20, 2025 14:47
@github-actions github-actions bot added the ❗️ .env changes contains changes to env variables label Mar 20, 2025
@keithwillcode keithwillcode added the core area: core, team members only label Mar 20, 2025
@dosubot dosubot bot added embed area: embed, widget, react embed ✨ feature New feature or request labels Mar 20, 2025
@Amit91848 Amit91848 mentioned this pull request Mar 20, 2025
3 tasks
Copy link

graphite-app bot commented Mar 20, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (03/20/25)

1 reviewer was added to this PR based on Keith Williams's automation.

import ReferralClient from "@calcom/features/dub/ReferralClient";
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SkeletonAvatar, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/skeleton";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { SkeletonAvatar, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/skeleton";
import { SkeletonAvatar, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";

import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SkeletonAvatar, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/skeleton";
import { showToast } from "@calcom/ui/toast";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { showToast } from "@calcom/ui/toast";
import { showToast } from "@calcom/ui/components/toast";

};

// The enabled referrals page implementation
const EnabledReferralsPage = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would move this to refer/EnabledReferralsPage.tsx

};

// Export the appropriate component based on the feature flag
export default function ReferralsPage() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be async


// Export the appropriate component based on the feature flag
export default function ReferralsPage() {
const { t } = useLocale();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be const t = await getTranslate();

Copy link

vercel bot commented Mar 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Mar 24, 2025 9:30am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Mar 24, 2025 9:30am

}

try {
const session = await getServerSession({ req: buildLegacyRequest(headers(), cookies()) });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const session = await getServerSession({ req: buildLegacyRequest(headers(), cookies()) });
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we're merging Next.js 15 in a moment


import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";

const ReferralClientImpl = ({ publicToken }: { publicToken: string }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if this is used in apps/web/app only, it can exist there. better be in refer dir
  • that also means @dub/embed-react can only be in apps/web/package.json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@github-actions github-actions bot marked this pull request as draft March 20, 2025 21:59
@Amit91848 Amit91848 marked this pull request as ready for review March 21, 2025 07:25
@Amit91848 Amit91848 requested a review from hbjORbj March 21, 2025 07:29
Copy link
Contributor

github-actions bot commented Mar 21, 2025

E2E results are ready!

return null;
}

if (loading || !token) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use loading.tsx Pattern instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loader for Shell Sidebar and Page loads differently so it looks weird??

Screencast.from.2025-03-24.14-28-14.webm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of loading.tsx, should I wrap the DubReferralsPage is Suspense? @zomars

Copy link

socket-security bot commented Mar 21, 2025

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only embed area: embed, widget, react embed ❗️ .env changes contains changes to env variables ✨ feature New feature or request ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants