Skip to content

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

Guided self-signup onboarding (#36)

Marc Klingenfa512452abb4
diff --git a/src/components/layouts/layout.tsx b/src/components/layouts/layout.tsx
index 918c0c910d..339edd3360 100644
--- a/src/components/layouts/layout.tsx
+++ b/src/components/layouts/layout.tsx
@@ -12,7 +12,7 @@ import {
import Link from "next/link";
import { useRouter } from "next/router";
import clsx from "clsx";
-import { Code, LineChart, MessageSquarePlus } from "lucide-react";
+import { Code, HelpingHand, LineChart, MessageSquarePlus } from "lucide-react";
import { signOut, useSession } from "next-auth/react";
import { ChevronDownIcon } from "@heroicons/react/20/solid";
import { cn } from "@/src/utils/tailwind";
@@ -65,6 +65,11 @@ export default function Layout(props: PropsWithChildren) {
pathname: "/project/[projectId]/setup",
icon: Cog6ToothIcon,
},
+ {
+ name: "Talk to founder",
+ pathname: "https://cal.com/marc-kl/langfuse-cloud",
+ icon: HelpingHand,
+ },
]
.filter((nav) => projectId || !nav.pathname.includes("[projectId]"))
.map((nav) => ({
diff --git a/src/features/publicApi/components/CreateApiKeyButton.tsx b/src/features/publicApi/components/CreateApiKeyButton.tsx
index 62dc6697a2..ff1378dfbb 100644
--- a/src/features/publicApi/components/CreateApiKeyButton.tsx
+++ b/src/features/publicApi/components/CreateApiKeyButton.tsx
@@ -6,34 +6,18 @@ import { PlusIcon } from "lucide-react";
import {
Dialog,
DialogContent,
+ DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/src/components/ui/dialog";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useForm } from "react-hook-form";
-import {
- Form,
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/src/components/ui/form";
-import { Input } from "@/src/components/ui/input";
import { CodeView } from "@/src/components/ui/code";
-const formSchema = z.object({
- note: z.string().optional(),
-});
-
export function CreateApiKeyButton(props: { projectId: string }) {
const utils = api.useContext();
const mutCreateApiKey = api.apiKeys.create.useMutation({
onSuccess: () => utils.apiKeys.invalidate(),
- onError: (error) => form.setError("root", { message: error.message }),
});
const [open, setOpen] = useState(false);
const [generatedKeys, setGeneratedKeys] = useState<{
@@ -41,108 +25,55 @@ export function CreateApiKeyButton(props: { projectId: string }) {
publishableKey: string;
} | null>(null);
- const form = useForm<z.infer<typeof formSchema>>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- note: "",
- },
- });
-
- function onSubmit(values: z.infer<typeof formSchema>) {
- mutCreateApiKey
- .mutateAsync({
- projectId: props.projectId,
- note:
- values.note && values.note.trim() !== ""
- ? values.note.trim()
- : undefined,
- })
- .then(({ secretKey, publishableKey }) => {
- setGeneratedKeys({
- secretKey,
- publishableKey,
+ const createApiKey = () => {
+ if (open) {
+ setOpen(false);
+ setGeneratedKeys(null);
+ } else {
+ mutCreateApiKey
+ .mutateAsync({
+ projectId: props.projectId,
+ })
+ .then(({ secretKey, publishableKey }) => {
+ setGeneratedKeys({
+ secretKey,
+ publishableKey,
+ });
+ setOpen(true);
+ })
+ .catch((error) => {
+ console.error(error);
});
- })
- .catch((error) => {
- console.error(error);
- });
- }
-
- const handleOpenChange = (open: boolean) => {
- setOpen(open);
- form.reset();
- if (!open) setGeneratedKeys(null);
+ }
};
return (
- <Dialog open={open} onOpenChange={handleOpenChange}>
+ <Dialog open={open} onOpenChange={createApiKey}>
<DialogTrigger>
- <Button variant="secondary">
+ <Button variant="secondary" loading={mutCreateApiKey.isLoading}>
<PlusIcon className="-ml-0.5 mr-1.5 h-5 w-5" aria-hidden="true" />
Create new API keys
</Button>
</DialogTrigger>
<DialogContent>
- {generatedKeys === null ? (
- <>
- <DialogHeader>
- <DialogTitle className="mb-5">New API keys</DialogTitle>
- </DialogHeader>
- <Form {...form}>
- <form
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- onSubmit={form.handleSubmit(onSubmit)}
- className="space-y-8"
- >
- <FormField
- control={form.control}
- name="note"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Note</FormLabel>
- <FormControl>
- <Input {...field} />
- </FormControl>
- <FormDescription>
- Optional. A note to help you identify this API key.
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- </form>
- </Form>
- <DialogFooter>
- <Button
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- onClick={form.handleSubmit(onSubmit)}
- loading={mutCreateApiKey.isLoading}
- >
- Create
- </Button>
- </DialogFooter>
- </>
- ) : (
- <div>
- <div>
- <div>
- <div className="mb-2 text-lg font-semibold">Public Key</div>
- <CodeView content={generatedKeys.publishableKey} />
- </div>
- <div className="mt-6">
- <div className="text-lg font-semibold">Secret Key</div>
- <div className="my-2">
- Please save this secret key.{" "}
- <span className="font-semibold">
- You will not be able to view it again
- </span>
- . If you lose it, you will need to generate a new one.
- </div>
- <CodeView content={generatedKeys.secretKey} />
- </div>
- </div>
+ <DialogHeader>
+ <DialogTitle>API Keys</DialogTitle>
+ </DialogHeader>
+ <div className="mb-2">
+ <div className="text-md font-semibold">Secret Key</div>
+ <div className="my-2">
+ Please save this secret key.{" "}
+ <span className="font-semibold">
+ You will not be able to view it again
+ </span>
+ . If you lose it, you will need to generate a new one.
</div>
- )}
+ <CodeView content={generatedKeys?.secretKey ?? "Loading ..."} />
+ </div>
+ <div>
+ <div className="text-md mb-2 font-semibold">Public Key</div>
+ <CodeView content={generatedKeys?.publishableKey ?? "Loading ..."} />
+ </div>
</DialogContent>
</Dialog>
);
diff --git a/src/pages/auth/sign-in.tsx b/src/pages/auth/sign-in.tsx
index 610e743973..a9baa6b423 100644
--- a/src/pages/auth/sign-in.tsx
+++ b/src/pages/auth/sign-in.tsx
@@ -30,8 +30,8 @@ export default function SignIn() {
},
});
- function onSubmit(values: z.infer<typeof formSchema>) {
- return signIn("credentials", {
+ async function onSubmit(values: z.infer<typeof formSchema>) {
+ await signIn("credentials", {
email: values.email,
password: values.password,
callbackUrl: "/",
diff --git a/src/pages/auth/sign-up.tsx b/src/pages/auth/sign-up.tsx
index 383d4b4c8c..c579e8e8a0 100644
--- a/src/pages/auth/sign-up.tsx
+++ b/src/pages/auth/sign-up.tsx
@@ -25,30 +25,29 @@ export default function SignIn() {
},
});
- function onSubmit(values: z.infer<typeof signupSchema>) {
- fetch("/api/auth/signup", {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify(values),
- })
- .then(async (res) => {
- if (!res.ok) {
- const payload = (await res.json()) as { message: string };
- throw new Error(payload.message);
- }
- })
- .then(async () => {
- await signIn<"credentials">("credentials", {
- email: values.email,
- password: values.password,
- callbackUrl: "/",
- });
- })
- .catch((err) => {
- form.setError("root", {
- message: (err as { message: string }).message,
- });
+ async function onSubmit(values: z.infer<typeof signupSchema>) {
+ try {
+ const res = await fetch("/api/auth/signup", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(values),
});
+
+ if (!res.ok) {
+ const payload = (await res.json()) as { message: string };
+ throw new Error(payload.message);
+ }
+
+ await signIn<"credentials">("credentials", {
+ email: values.email,
+ password: values.password,
+ callbackUrl: "/",
+ });
+ } catch (err) {
+ form.setError("root", {
+ message: (err as { message: string }).message,
+ });
+ }
}
return (
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 792f4f6958..4e68ddd7b5 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,11 +1,76 @@
-import ProjectList from "@/src/features/projects/components/ProjectList";
+import { Button } from "@/src/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/src/components/ui/card";
+import Link from "next/link";
+import { NewProjectButton } from "@/src/features/projects/components/NewProjectButton";
import Header from "@/src/components/layouts/header";
+import { api } from "@/src/utils/api";
+import { useRouter } from "next/router";
+import { useState, useEffect } from "react";
export default function GetStartedPage() {
+ const projects = api.projects.all.useQuery();
+ const router = useRouter();
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ if (projects.data) {
+ if (projects.data.length > 0)
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ void router.push(`/project/${projects.data[0]!.id}`);
+ else setLoading(false);
+ }
+ }, [projects.data, router]);
+
+ if (loading || projects.status === "loading") {
+ return <div>Loading...</div>;
+ }
+
return (
- <>
- <Header title="Projects" />
- <ProjectList />
- </>
+ <div className="md:container">
+ <Header title="Get started" />
+ <div className="flex flex-col gap-5 md:flex-row">
+ <Card className="flex-1">
+ <CardHeader>
+ <CardTitle>Create new project</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <p>
+ Get started by yourself. You can always reach out to us later or
+ get help in the discord community.
+ </p>
+ </CardContent>
+ <CardFooter>
+ <NewProjectButton />
+ </CardFooter>
+ </Card>
+ <Card className="flex-1">
+ <CardHeader>
+ <CardTitle>Guided onboarding</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <p>If you prefer 1:1 support, we are happy to help.</p>
+ </CardContent>
+ <CardFooter className="flex flex-wrap gap-2">
+ <Button asChild variant="secondary">
+ <Link href="https://cal.com/marc-kl/langfuse-cloud">
+ Schedule call with founder
+ </Link>
+ </Button>
+ <Button asChild variant="secondary">
+ <Link href="https://discord.gg/7NXusRtqYU">Discord</Link>
+ </Button>
+ <Button asChild variant="secondary">
+ <Link href="mailto:[email protected]">Email</Link>
+ </Button>
+ </CardFooter>
+ </Card>
+ </div>
+ </div>
);
}