= ({
+ defaultValue,
+}) => {
+ const [referralSource, setReferralSource] = useState(defaultValue);
+
+ const referralOptions = [
+ { value: "search", label: "Search Engine (Google/Bing)" },
+ { value: "friend", label: "Friend/Colleague" },
+ { value: "linkedin", label: "LinkedIn" },
+ { value: "twitter", label: "Twitter" },
+ { value: "hackernews", label: "HackerNews" },
+ { value: "reddit", label: "Reddit" },
+ { value: "youtube", label: "YouTube" },
+ { value: "podcast", label: "Podcast" },
+ { value: "blog", label: "Article/Blog" },
+ { value: "ads", label: "Advertisements" },
+ { value: "other", label: "Other" },
+ ];
+
+ const handleChange = (value: string) => {
+ setReferralSource(value);
+ const cookies = require("js-cookie");
+ cookies.set("referral_source", value, {
+ expires: 365,
+ path: "/",
+ sameSite: "strict",
+ });
+ };
+
+ return (
+
+
+
+
+ );
+};
+
+export default ReferralSourceSelector;
diff --git a/web/src/app/auth/signup/page.tsx b/web/src/app/auth/signup/page.tsx
index 29c2f97ea16f..223faff331d8 100644
--- a/web/src/app/auth/signup/page.tsx
+++ b/web/src/app/auth/signup/page.tsx
@@ -12,6 +12,8 @@ import Text from "@/components/ui/text";
import Link from "next/link";
import { SignInButton } from "../login/SignInButton";
import AuthFlowContainer from "@/components/auth/AuthFlowContainer";
+import ReferralSourceSelector from "./ReferralSourceSelector";
+import { Separator } from "@/components/ui/separator";
const Page = async () => {
// catch cases where the backend is completely unreachable here
@@ -62,6 +64,13 @@ const Page = async () => {
{cloud ? "Complete your sign up" : "Sign Up for Danswer"}
+ {cloud && (
+ <>
+
+
+
+ >
+ )}
{cloud && authUrl && (
diff --git a/web/src/lib/user.ts b/web/src/lib/user.ts
index 10d426c1ec9b..d540366f5196 100644
--- a/web/src/lib/user.ts
+++ b/web/src/lib/user.ts
@@ -43,7 +43,11 @@ export const basicLogin = async (
return response;
};
-export const basicSignup = async (email: string, password: string) => {
+export const basicSignup = async (
+ email: string,
+ password: string,
+ referralSource?: string
+) => {
const response = await fetch("/api/auth/register", {
method: "POST",
credentials: "include",
@@ -54,6 +58,7 @@ export const basicSignup = async (email: string, password: string) => {
email,
username: email,
password,
+ referral_source: referralSource,
}),
});
return response;
diff --git a/web/src/lib/userSS.ts b/web/src/lib/userSS.ts
index 55b916d34b37..906f23fa8b2b 100644
--- a/web/src/lib/userSS.ts
+++ b/web/src/lib/userSS.ts
@@ -63,7 +63,11 @@ const getOIDCAuthUrlSS = async (nextUrl: string | null): Promise => {
};
const getGoogleOAuthUrlSS = async (): Promise => {
- const res = await fetch(buildUrl(`/auth/oauth/authorize`));
+ const res = await fetch(buildUrl(`/auth/oauth/authorize`), {
+ headers: {
+ cookie: processCookies(await cookies()),
+ },
+ });
if (!res.ok) {
throw new Error("Failed to fetch data");
}