Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(cloud): ask new users for referral source, SSO and email/pw (#831)

Marc Klingen8069fb7dddc7
diff --git a/src/components/layouts/layout.tsx b/src/components/layouts/layout.tsx
index 7202c46c8f..5599d69715 100644
--- a/src/components/layouts/layout.tsx
+++ b/src/components/layouts/layout.tsx
@@ -35,9 +35,9 @@ const userNavigation = [
},
];
-const pathsWithoutNavigation: string[] = [];
-const unauthenticatedPaths = ["/auth/sign-in", "/auth/sign-up"];
-const publishablePaths = [
+const pathsWithoutNavigation: string[] = ["/onboarding"];
+const unauthenticatedPaths: string[] = ["/auth/sign-in", "/auth/sign-up"];
+const publishablePaths: string[] = [
"/project/[projectId]/sessions/[sessionId]",
"/project/[projectId]/traces/[traceId]",
];
diff --git a/src/pages/auth/sign-up.tsx b/src/pages/auth/sign-up.tsx
index 046fe09f86..88ab1e7f85 100644
--- a/src/pages/auth/sign-up.tsx
+++ b/src/pages/auth/sign-up.tsx
@@ -18,7 +18,6 @@ import type * as z from "zod";
import { env } from "@/src/env.mjs";
import { useState } from "react";
import { LangfuseIcon } from "@/src/components/LangfuseLogo";
-import { usePostHog } from "posthog-js/react";
import { CloudPrivacyNotice } from "@/src/features/auth/components/AuthCloudPrivacyNotice";
import { CloudRegionSwitch } from "@/src/features/auth/components/AuthCloudRegionSwitch";
import { SSOButtons, type PageProps } from "@/src/pages/auth/sign-in";
@@ -28,7 +27,6 @@ import { PasswordInput } from "@/src/components/ui/password-input";
export { getServerSideProps } from "@/src/pages/auth/sign-in";
export default function SignIn({ authProviders }: PageProps) {
- const posthog = usePostHog();
const [formError, setFormError] = useState<string | null>(null);
const form = useForm<z.infer<typeof signupSchema>>({
resolver: zodResolver(signupSchema),
@@ -36,20 +34,12 @@ export default function SignIn({ authProviders }: PageProps) {
name: "",
email: "",
password: "",
- referralSource: "",
},
});
async function onSubmit(values: z.infer<typeof signupSchema>) {
try {
setFormError(null);
- if (values.referralSource !== "") {
- posthog.capture("survey sent", {
- $survey_id: "018ade05-4d8c-0000-36b7-fc390b221590",
- $survey_name: "Referral source",
- $survey_response: values.referralSource,
- });
- }
const res = await fetch("/api/auth/signup", {
method: "POST",
headers: { "Content-Type": "application/json" },
@@ -65,7 +55,9 @@ export default function SignIn({ authProviders }: PageProps) {
await signIn<"credentials">("credentials", {
email: values.email,
password: values.password,
- callbackUrl: "/?getStarted=1",
+ callbackUrl: env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
+ ? "/onboarding"
+ : "/?getStarted=1",
});
} catch (err) {
setFormError("An error occurred. Please try again.");
@@ -142,24 +134,6 @@ export default function SignIn({ authProviders }: PageProps) {
</FormItem>
)}
/>
- {env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ? (
- <FormField
- control={form.control}
- name="referralSource"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- Where did you hear about us?{" "}
- <span className="font-normal">(optional)</span>
- </FormLabel>
- <FormControl>
- <Input type="referralSource" {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- ) : null}
<Button
type="submit"
className="w-full"
diff --git a/src/pages/onboarding.tsx b/src/pages/onboarding.tsx
new file mode 100644
index 0000000000..93944436b7
--- /dev/null
+++ b/src/pages/onboarding.tsx
@@ -0,0 +1,93 @@
+// This page is currently only shown to Langfuse cloud users.
+// It might be expanded to everyone in the future when it does not only ask for the referral source.
+
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+import { Button } from "@/src/components/ui/button";
+import {
+ Form,
+ FormControl,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "@/src/components/ui/form";
+import { usePostHog } from "posthog-js/react";
+import { useRouter } from "next/router";
+import { LangfuseIcon } from "@/src/components/LangfuseLogo";
+import { Textarea } from "@/src/components/ui/textarea";
+
+const referralSourceSchema = z.object({
+ referralSource: z.string().optional(),
+});
+
+export default function ReferralSource() {
+ const posthog = usePostHog();
+ const router = useRouter();
+ const form = useForm<z.infer<typeof referralSourceSchema>>({
+ resolver: zodResolver(referralSourceSchema),
+ defaultValues: {
+ referralSource: "",
+ },
+ });
+
+ function onSubmit(values: z.infer<typeof referralSourceSchema>) {
+ if (values.referralSource && values.referralSource !== "") {
+ posthog.capture("survey sent", {
+ $survey_id: "018ade05-4d8c-0000-36b7-fc390b221590",
+ $survey_name: "Referral source",
+ $survey_response: values.referralSource,
+ });
+ }
+ void router.push("/?getStarted=1");
+ }
+
+ return (
+ <div className="flex flex-1 flex-col py-6 sm:min-h-full sm:justify-center sm:px-6 sm:py-12 lg:px-8">
+ <div className="sm:mx-auto sm:w-full sm:max-w-md">
+ <LangfuseIcon className="mx-auto" />
+ <h2 className="mt-4 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900">
+ Welcome to Langfuse
+ </h2>
+ </div>
+ <div className="mt-14 bg-white px-6 py-10 shadow sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-12">
+ <Form {...form}>
+ <form
+ className="space-y-6"
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ onSubmit={form.handleSubmit(onSubmit)}
+ >
+ <FormField
+ control={form.control}
+ name="referralSource"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>
+ Where did you hear about us?{" "}
+ <span className="font-normal">(optional)</span>
+ </FormLabel>
+ <FormControl>
+ <Textarea
+ placeholder="We're curious to know how you discovered the project! Thanks for sharing."
+ {...field}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <Button
+ type="submit"
+ variant={form.formState.isDirty ? "default" : "secondary"}
+ className="w-full"
+ loading={form.formState.isSubmitting}
+ >
+ {form.formState.isDirty ? "Continue" : "Skip"}
+ </Button>
+ </form>
+ </Form>
+ </div>
+ </div>
+ );
+}
diff --git a/src/server/auth.ts b/src/server/auth.ts
index 080ba83859..4c68d8bf14 100644
--- a/src/server/auth.ts
+++ b/src/server/auth.ts
@@ -211,6 +211,11 @@ export const authOptions: NextAuthOptions = {
providers,
pages: {
signIn: "/auth/sign-in",
+ ...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
+ ? {
+ newUser: "/onboarding",
+ }
+ : {}),
},
cookies: {
sessionToken: {