Skip to content

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

feat(ui): improved tracing setup, not in project onboarding, link to docs instead of code examples, not in API creation modal (#9727)

Marc Klingen710131525f4e
diff --git a/web/src/__e2e__/create-project.spec.ts b/web/src/__e2e__/create-project.spec.ts
index bfd5b3936f..c2dfe948a9 100644
--- a/web/src/__e2e__/create-project.spec.ts
+++ b/web/src/__e2e__/create-project.spec.ts
@@ -82,7 +82,7 @@ test.describe("Create project", () => {
await page.click('button[type="submit"]');
await page.waitForTimeout(5000);
expect(page.url()).toContain("/project/");
- expect(page.url()).toContain("/setup");
+ expect(page.url()).toContain("/traces");
const projectUrl = new URL(page.url());
const projectId = projectUrl.pathname.split("/")[2];
@@ -91,7 +91,6 @@ test.describe("Create project", () => {
await page.goto("/project/" + projectId);
await page.waitForTimeout(2000);
expect(page.url()).toContain("/project/" + projectId);
- expect(page.url()).not.toContain("/setup");
const headings = await page.locator("h2").allTextContents();
expect(headings).toContain("Home");
diff --git a/web/src/components/ActionButton.tsx b/web/src/components/ActionButton.tsx
index 17b8588d6a..1b7178f406 100644
--- a/web/src/components/ActionButton.tsx
+++ b/web/src/components/ActionButton.tsx
@@ -105,6 +105,14 @@ export const ActionButton = React.forwardRef<
return btnContent;
});
+const isExternalUrl = (url: string) => {
+ return (
+ url.startsWith("http://") ||
+ url.startsWith("https://") ||
+ url.startsWith("//")
+ );
+};
+
const ButtonContent = React.forwardRef<
HTMLButtonElement,
{
@@ -150,6 +158,7 @@ const ButtonContent = React.forwardRef<
);
const renderLink = href && !isDisabled;
+ const isExternal = href && isExternalUrl(href);
return (
<Button
@@ -160,7 +169,17 @@ const ButtonContent = React.forwardRef<
{...buttonProps}
asChild={renderLink ? true : undefined}
>
- {renderLink ? <Link href={href}>{content}</Link> : content}
+ {renderLink ? (
+ <Link
+ href={href}
+ target={isExternal ? "_blank" : undefined}
+ rel={isExternal ? "noopener noreferrer" : undefined}
+ >
+ {content}
+ </Link>
+ ) : (
+ content
+ )}
</Button>
);
});
diff --git a/web/src/components/ui/dialog.tsx b/web/src/components/ui/dialog.tsx
index 0b7b39f724..9dc04c674c 100644
--- a/web/src/components/ui/dialog.tsx
+++ b/web/src/components/ui/dialog.tsx
@@ -89,23 +89,26 @@ DialogContent.displayName = DialogPrimitive.Content.displayName;
const DialogHeader = ({
className,
+ children,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
- "dialog-header sticky top-0 z-30 flex flex-shrink-0 flex-col space-y-1.5 rounded-t-lg border-b bg-background p-6 pb-4 text-center sm:text-left",
+ "dialog-header sticky top-0 z-30 flex flex-shrink-0 flex-col space-y-1.5 rounded-t-lg border-b bg-background p-4",
className,
)}
{...props}
>
- <DialogPrimitive.Close
- className="absolute right-3 top-3 z-20 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
- tabIndex={-1}
- >
- <X className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
- {props.children}
+ <div className="flex w-full items-start justify-between gap-4 text-center sm:text-left">
+ <div className="min-w-0 flex-1">{children}</div>
+ <DialogPrimitive.Close
+ className="z-20 ml-4 mt-1 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
+ tabIndex={-1}
+ >
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </div>
</div>
);
DialogHeader.displayName = "DialogHeader";
@@ -116,10 +119,7 @@ const DialogBody = React.forwardRef<
>(({ className, ...props }, ref) => (
<div
ref={ref}
- className={cn(
- "flex flex-1 flex-col gap-4 overflow-y-auto px-6 py-4",
- className,
- )}
+ className={cn("flex flex-1 flex-col gap-4 overflow-y-auto p-4", className)}
{...props}
/>
));
diff --git a/web/src/features/organizations/components/NewOrganizationForm.tsx b/web/src/features/organizations/components/NewOrganizationForm.tsx
index 9e9492466c..2bff70cfdb 100644
--- a/web/src/features/organizations/components/NewOrganizationForm.tsx
+++ b/web/src/features/organizations/components/NewOrganizationForm.tsx
@@ -101,6 +101,12 @@ export const NewOrganizationForm = ({
onSubmit={form.handleSubmit(onSubmit)}
className="space-y-3"
data-testid="new-org-form"
+ onKeyDown={(e) => {
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
+ e.preventDefault();
+ void form.handleSubmit(onSubmit)();
+ }
+ }}
>
<FormField
control={form.control}
diff --git a/web/src/features/projects/components/NewProjectForm.tsx b/web/src/features/projects/components/NewProjectForm.tsx
index 6b44030bf5..e3dca20f43 100644
--- a/web/src/features/projects/components/NewProjectForm.tsx
+++ b/web/src/features/projects/components/NewProjectForm.tsx
@@ -64,6 +64,12 @@ export const NewProjectForm = ({
onSubmit={form.handleSubmit(onSubmit)}
className="space-y-3"
data-testid="new-project-form"
+ onKeyDown={(e) => {
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
+ e.preventDefault();
+ void form.handleSubmit(onSubmit)();
+ }
+ }}
>
<FormField
control={form.control}
diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsx
index b275f9eed3..ad007e7ca8 100644
--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx
+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx
@@ -13,10 +13,11 @@ import {
import { CodeView } from "@/src/components/ui/CodeJsonViewer";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
-import { QuickstartExamples } from "@/src/features/public-api/components/QuickstartExamples";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
import { env } from "@/src/env.mjs";
+import { cn } from "@/src/utils/tailwind";
+import { SubHeader } from "@/src/components/layouts/header";
type ApiKeyScope = "project" | "organization";
@@ -117,15 +118,6 @@ export function CreateApiKeyButton(props: {
scope={props.scope}
generatedKeys={generatedKeys ?? undefined}
/>
- {generatedKeys && props.scope === "project" && (
- <div className="mt-4 max-w-full">
- <div className="text-md my-2 font-semibold">Usage</div>
- <QuickstartExamples
- secretKey={generatedKeys.secretKey}
- publicKey={generatedKeys.publicKey}
- />
- </div>
- )}
</DialogBody>
</DialogContent>
</Dialog>
@@ -135,31 +127,40 @@ export function CreateApiKeyButton(props: {
export const ApiKeyRender = ({
scope,
generatedKeys,
+ className,
}: {
scope: ApiKeyScope;
generatedKeys?: { secretKey: string; publicKey: string };
+ className?: string;
}) => {
const uiCustomization = useUiCustomization();
return (
- <>
- <div className="mb-4">
- <div className="text-md font-semibold">Secret Key</div>
- <div className="my-2 text-sm">
+ <div className={cn("space-y-6", className)}>
+ <div>
+ <SubHeader title="Secret Key" />
+ <div className="text-sm text-muted-foreground">
This key can only be viewed once. You can always create new keys in
the {scope} settings.
</div>
- <CodeView content={generatedKeys?.secretKey ?? "Loading ..."} />
+ <CodeView
+ content={generatedKeys?.secretKey ?? "Loading ..."}
+ className="mt-2"
+ />
</div>
- <div className="mb-4">
- <div className="text-md mb-2 font-semibold">Public Key</div>
- <CodeView content={generatedKeys?.publicKey ?? "Loading ..."} />
+ <div>
+ <SubHeader title="Public Key" />
+ <CodeView
+ content={generatedKeys?.publicKey ?? "Loading ..."}
+ className="mt-2"
+ />
</div>
<div>
- <div className="text-md mb-2 font-semibold">Host</div>
+ <SubHeader title="Host" />
<CodeView
content={`${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`}
+ className="mt-2"
/>
</div>
- </>
+ </div>
);
};
diff --git a/web/src/features/public-api/components/QuickstartExamples.tsx b/web/src/features/public-api/components/QuickstartExamples.tsx
deleted file mode 100644
index 3bd09d1bde..0000000000
--- a/web/src/features/public-api/components/QuickstartExamples.tsx
+++ /dev/null
@@ -1,291 +0,0 @@
-import { CodeView } from "@/src/components/ui/CodeJsonViewer";
-import {
- Tabs,
- TabsList,
- TabsContent,
- TabsTrigger,
-} from "@/src/components/ui/tabs";
-import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
-import { env } from "@/src/env.mjs";
-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-import Link from "next/link";
-
-export const QuickstartExamples = (p: {
- secretKey?: string;
- publicKey?: string;
-}) => {
- const uiCustomization = useUiCustomization();
- const capture = usePostHogClientCapture();
- const tabs = [
- { value: "python", label: "Python" },
- { value: "js", label: "JS/TS" },
- { value: "openai", label: "OpenAI" },
- { value: "langchain", label: "Langchain" },
- { value: "langchain-js", label: "Langchain JS" },
- { value: "other", label: "Other" },
- ];
- const host = `${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`;
-
- const secretKey = p.secretKey ?? "<secret key>";
- const publicKey = p.publicKey ?? "<public key>";
-
- // if custom docs link, do not show quickstart examples but refer to docs
- if (uiCustomization?.documentationHref) {
- return (
- <p className="mb-2">
- See your{" "}
- <Link
- href={uiCustomization.documentationHref}
- target="_blank"
- className="underline"
- >
- internal documentation
- </Link>{" "}
- for details on how to set up Langfuse in your organization.
- </p>
- );
- }
-
- return (
- <div>
- <Tabs defaultValue="python" className="relative max-w-full">
- <div className="overflow-x-scroll">
- <TabsList>
- {tabs.map((tab) => (
- <TabsTrigger
- key={tab.value}
- value={tab.value}
- onClick={() =>
- capture("onboarding:code_example_tab_switch", {
- tabLabel: tab.value,
- })
- }
- >
- {tab.label}
- </TabsTrigger>
- ))}
- </TabsList>
- </div>
- <TabsContent value="python">
- <CodeView content="pip install langfuse" className="mb-2" />
- <CodeView
- content={`from langfuse import Langfuse\n\nlangfuse = Langfuse(\n secret_key="${secretKey}",\n public_key="${publicKey}",\n host="${host}"\n)`}
- />
- <p className="mt-3 text-xs text-muted-foreground">
- See{" "}
- <a
- href="https://langfuse.com/docs/observability/get-started"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- Quickstart
- </a>{" "}
- and{" "}
- <a
- href="https://langfuse.com/docs/sdk/python"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- Python docs
- </a>{" "}
- for more details and an end-to-end example.
- </p>
- </TabsContent>
- <TabsContent value="js">
- <CodeView content="npm install @langfuse/client" className="mb-2" />
- <CodeView
- content={`import { LangfuseClient } from "@langfuse/client";\n\nconst langfuse = new LangfuseClient({\n secretKey: "${secretKey}",\n publicKey: "${publicKey}",\n baseUrl: "${host}"\n});`}
- />
- <p className="mt-3 text-xs text-muted-foreground">
- See{" "}
- <a
- href="https://langfuse.com/docs/observability/get-started"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- Quickstart
- </a>{" "}
- and{" "}
- <a
- href="https://langfuse.com/docs/sdk/typescript"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- JS/TS docs
- </a>{" "}
- for more details and an end-to-end example.
- </p>
- </TabsContent>
- <TabsContent value="openai">
- <p className="mt-2 text-xs text-muted-foreground">
- The integration is a drop-in replacement for the OpenAI Python SDK.
- By changing the import, Langfuse will capture all LLM calls and send
- them to Langfuse asynchronously.
- </p>
- <CodeView content="pip install langfuse" className="my-2" />
- <CodeView
- title=".env"
- content={`LANGFUSE_SECRET_KEY=${secretKey}\nLANGFUSE_PUBLIC_KEY=${publicKey}\nLANGFUSE_HOST="${host}"`}
- className="my-2"
- />
- <CodeView
- content={`# remove: import openai\n\nfrom langfuse.openai import openai`}
- className="my-2"
- />
- <p className="mt-2 text-xs text-muted-foreground">
- Use the OpenAI SDK as you would normally. See the{" "}
- <a
- href="https://langfuse.com/integrations/model-providers/openai-py"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- OpenAI Integration docs
- </a>{" "}
- for more details and an end-to-end example.
- </p>
- </TabsContent>
- <TabsContent value="langchain">
- <p className="mt-2 text-xs text-muted-foreground">
- The integration uses the Langchain callback system to automatically
- capture detailed traces of your Langchain executions.
- </p>
- <CodeView content="pip install langfuse" className="my-2" />
- <CodeView
- content={LANGCHAIN_PYTHON_CODE({ publicKey, secretKey, host })}
- className="my-2"
- />
- <p className="mt-2 text-xs text-muted-foreground">
- See the{" "}
- <a
- href="https://langfuse.com/integrations/frameworks/langchain"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- Langchain Integration docs
- </a>{" "}
- for more details and an end-to-end example.
- </p>
- </TabsContent>
- <TabsContent value="langchain-js">
- <p className="mt-2 text-xs text-muted-foreground">
- The integration uses the Langchain callback system to automatically
- capture detailed traces of your Langchain executions.
- </p>
- <CodeView
- content="npm install @langfuse/langchain"
- className="my-2"
- />
- <CodeView content={LANGCHAIN_JS_CODE()} className="my-2" />
- <p className="mt-2 text-xs text-muted-foreground">
- See the{" "}
- <a
- href="https://langfuse.com/integrations/frameworks/langchain"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- Langchain Integration docs
- </a>{" "}
- for more details and an end-to-end example.
- </p>
- </TabsContent>
- <TabsContent value="other">
- <p className="mt-2 text-xs text-muted-foreground">
- Use the{" "}
- <a
- href="https://api.reference.langfuse.com/"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- API
- </a>{" "}
- or one of the{" "}
- <a
- href="https://langfuse.com/docs/integrations"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- native integrations
- </a>{" "}
- (e.g. LiteLLM, Flowise, and Langflow) to integrate with Langfuse.
- </p>
- </TabsContent>
- </Tabs>
- <span className="mt-4 text-xs text-muted-foreground">
- Do you have questions or issues? Check out this{" "}
- <a
- href="https://langfuse.com/faq/all/missing-traces"
- className="underline"
- target="_blank"
- rel="noopener noreferrer"
- >
- FAQ post
- </a>{" "}
- for common resolutions,{" "}
- <Link
- className="underline"
- href="https://langfuse.com/docs/ask-ai"
- target="_blank"
- rel="noopener noreferrer"
- >
- Ask AI
- </Link>{" "}
- or{" "}
- <Link
- className="underline"
- href="https://langfuse.com/support"
- target="_blank"
- rel="noopener noreferrer"
- >
- get support
- </Link>
- .
- </span>
- </div>
- );
-};
-const LANGCHAIN_PYTHON_CODE = (p: {
- publicKey: string;
- secretKey: string;
- host: string;
-}) => `from langfuse import Langfuse
-from langfuse.langchain import CallbackHandler
-
-langfuse = Langfuse(
- public_key="${p.publicKey}",
- secret_key="${p.secretKey}",
- host="${p.host}"
-)
-
-langfuse_handler = CallbackHandler()
-
-# <Your Langchain code here>
-
-# Add handler to run/invoke/call/chat
-chain.invoke({"input": "<user_input>"}, config={"callbacks": [langfuse_handler]})`;
-
-const LANGCHAIN_JS_CODE =
- () => `import { CallbackHandler } from "@langfuse/langchain";
-
-// Make sure you have OpenTelemetry set up
-// https://langfuse.com/docs/observability/sdk/typescript/setup#initialize-opentelemetry
-
-// Initialize Langfuse callback handler
-const langfuseHandler = new CallbackHandler();
-
-// Your Langchain implementation
-const chain = new LLMChain(...);
-
-// Add handler as callback when running the Langchain agent
-await chain.invoke(
- { input: "<user_input>" },
- { callbacks: [langfuseHandler] }
-);`;
diff --git a/web/src/features/setup/components/SetupPage.tsx b/web/src/features/setup/components/SetupPage.tsx
index 7607f450e7..24bfbe90e3 100644
--- a/web/src/features/setup/components/SetupPage.tsx
+++ b/web/src/features/setup/components/SetupPage.tsx
@@ -10,68 +10,37 @@ import {
import { Button } from "@/src/components/ui/button";
import { Card } from "@/src/components/ui/card";
import { NewOrganizationForm } from "@/src/features/organizations/components/NewOrganizationForm";
-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { NewProjectForm } from "@/src/features/projects/components/NewProjectForm";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
-import { ApiKeyRender } from "@/src/features/public-api/components/CreateApiKeyButton";
-import { QuickstartExamples } from "@/src/features/public-api/components/QuickstartExamples";
import { MembershipInvitesPage } from "@/src/features/rbac/components/MembershipInvitesPage";
import { MembersTable } from "@/src/features/rbac/components/MembersTable";
import {
createProjectRoute,
inviteMembersRoute,
- setupTracingRoute,
} from "@/src/features/setup/setupRoutes";
-import { api } from "@/src/utils/api";
import { cn } from "@/src/utils/tailwind";
-import { type RouterOutput } from "@/src/utils/types";
import { Check } from "lucide-react";
import { useRouter } from "next/router";
-import { useEffect, useState } from "react";
import { StringParam, useQueryParam } from "use-query-params";
// Multi-step setup process
// 1. Create Organization: /setup
// 2. Invite Members: /organization/:orgId/setup
// 3. Create Project: /organization/:orgId/setup?step=create-project
-// 4. Setup Tracing: /project/:projectId/setup
export function SetupPage() {
const { project, organization } = useQueryProjectOrOrganization();
const router = useRouter();
const [orgStep] = useQueryParam("orgstep", StringParam); // "invite-members" | "create-project"
- const queryProjectId = router.query.projectId as string | undefined;
// starts at 1 to align with breadcrumb
const stepInt = !organization
? 1
: project
- ? 4
+ ? 3
: orgStep === "create-project"
? 3
: 2;
- const hasTracingConfigured = api.traces.hasTracingConfigured.useQuery(
- { projectId: queryProjectId as string },
- {
- enabled: queryProjectId !== undefined && stepInt === 4,
- refetchInterval: 5000,
- trpc: {
- context: {
- skipBatch: true,
- },
- },
- },
- ).data;
-
- const capture = usePostHogClientCapture();
- useEffect(() => {
- if (hasTracingConfigured !== undefined) {
- capture("onboarding:tracing_check_active", {
- active: hasTracingConfigured,
- });
- }
- }, [hasTracingConfigured, capture]);
-
return (
<ContainerPage
headerProps={{
@@ -127,20 +96,6 @@ export function SetupPage() {
)}
>
3. Create Project
- {stepInt > 3 && <Check className="ml-1 inline-block h-3 w-3" />}
- </BreadcrumbPage>
- </BreadcrumbItem>
- <BreadcrumbSeparator />
- <BreadcrumbItem>
- <BreadcrumbPage
- className={cn(
- stepInt !== 4
- ? "text-muted-foreground"
- : "font-semibold text-foreground",
- )}
- >
- 4. Setup Tracing
- {stepInt === 4 && <Check className="ml-1 inline-block h-3 w-3" />}
</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
@@ -193,21 +148,12 @@ export function SetupPage() {
<NewProjectForm
orgId={organization.id}
onSuccess={(projectId) =>
- router.push(setupTracingRoute(projectId))
+ router.push(`/project/${projectId}/traces`)
}
/>
</div>
)
}
- {
- // 4. Setup Tracing
- stepInt === 4 && project && organization && (
- <TracingSetup
- projectId={project.id}
- hasTracingConfigured={hasTracingConfigured ?? false}
- />
- )
- }
</Card>
{stepInt === 2 && organization && (
@@ -219,88 +165,6 @@ export function SetupPage() {
Next
</Button>
)}
- {
- // 4. Setup Tracing
- stepInt === 4 && project && (
- <Button
- className="mt-4 self-start"
- onClick={() => router.push(`/project/${project.id}`)}
- variant={hasTracingConfigured ? "default" : "secondary"}
- >
- {hasTracingConfigured ? "Open Dashboard" : "Skip for now"}
- </Button>
- )
- }
</ContainerPage>
);
}
-
-const TracingSetup = ({
- projectId,
- hasTracingConfigured,
-}: {
- projectId: string;
- hasTracingConfigured?: boolean;
-}) => {
- const [apiKeys, setApiKeys] = useState<
- RouterOutput["projectApiKeys"]["create"] | null
- >(null);
- const utils = api.useUtils();
- const mutCreateApiKey = api.projectApiKeys.create.useMutation({
- onSuccess: (data) => {
- utils.projectApiKeys.invalidate();
- setApiKeys(data);
- },
- });
-
- const createApiKey = async () => {
- try {
- await mutCreateApiKey.mutateAsync({ projectId });
- } catch (error) {
- console.error("Error creating API key:", error);
- }
- };
-
- return (
- <div className="space-y-8">
- <div>
- <Header title="API Keys" />
- <p className="mb-4 text-sm text-muted-foreground">
- These keys are used to authenticate your API requests. You can create
- more keys later in the project settings.
- </p>
- {apiKeys ? (
- <ApiKeyRender generatedKeys={apiKeys} scope={"project"} />
- ) : (
- <div className="flex flex-col gap-4">
- <p className="text-sm text-muted-foreground">
- You need to create an API key to start tracing your application.
- </p>
- <Button
- onClick={createApiKey}
- loading={mutCreateApiKey.isPending}
- className="self-start"
- >
- Create API Key
- </Button>
- </div>
- )}
- </div>
-
- <div>
- <Header
- title="Setup Tracing"
- status={hasTracingConfigured ? "active" : "pending"}
- />
- <p className="mb-4 text-sm text-muted-foreground">
- Tracing is used to track and analyze your LLM calls. You can always
- skip this step and setup tracing later.
- </p>
- <QuickstartExamples
- secretKey={apiKeys?.secretKey}
- publicKey={apiKeys?.publicKey}
- />
- </div>
- </div>
- );
-};
diff --git a/web/src/features/setup/setupRoutes.ts b/web/src/features/setup/setupRoutes.ts
index ea40c48fdc..fa13e89480 100644
--- a/web/src/features/setup/setupRoutes.ts
+++ b/web/src/features/setup/setupRoutes.ts
@@ -7,4 +7,4 @@ export const inviteMembersRoute = (orgId: string) =>
`/organization/${orgId}/setup?orgstep=invite-members`;
export const setupTracingRoute = (projectId: string) =>
- `/project/${projectId}/setup`;
+ `/project/${projectId}/traces/setup`;
diff --git a/web/src/pages/project/[projectId]/traces.tsx b/web/src/pages/project/[projectId]/traces.tsx
index f3a100d3c3..e01c53f6fe 100644
--- a/web/src/pages/project/[projectId]/traces.tsx
+++ b/web/src/pages/project/[projectId]/traces.tsx
@@ -30,6 +30,24 @@ export default function Traces() {
const showOnboarding = !isLoading && !hasTracingConfigured;
+ if (showOnboarding) {
+ return (
+ <Page
+ headerProps={{
+ title: "Tracing",
+ help: {
+ description:
+ "A trace represents a single function/api invocation. Traces contain observations. See docs to learn more.",
+ href: "https://langfuse.com/docs/observability/data-model",
+ },
+ }}
+ scrollable
+ >
+ <TracesOnboarding projectId={projectId} />
+ </Page>
+ );
+ }
+
return (
<Page
headerProps={{
@@ -44,14 +62,8 @@ export default function Traces() {
activeTab: TRACING_TABS.TRACES,
},
}}
- scrollable={showOnboarding}
>
- {/* Show onboarding screen if user has no traces */}
- {showOnboarding ? (
- <TracesOnboarding projectId={projectId} />
- ) : (
- <TracesTable projectId={projectId} />
- )}
+ <TracesTable projectId={projectId} />
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/traces/setup.tsx b/web/src/pages/project/[projectId]/traces/setup.tsx
new file mode 100644
index 0000000000..a6c3c0bbc5
--- /dev/null
+++ b/web/src/pages/project/[projectId]/traces/setup.tsx
@@ -0,0 +1,140 @@
+import React, { useEffect } from "react";
+import { useRouter } from "next/router";
+import { api } from "@/src/utils/api";
+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import ContainerPage from "@/src/components/layouts/container-page";
+import { ActionButton } from "@/src/components/ActionButton";
+import { SubHeader } from "@/src/components/layouts/header";
+import { Button } from "@/src/components/ui/button";
+import { ApiKeyRender } from "@/src/features/public-api/components/CreateApiKeyButton";
+import { type RouterOutput } from "@/src/utils/types";
+import { useState } from "react";
+
+const TracingSetup = ({
+ projectId,
+ hasTracingConfigured,
+}: {
+ projectId: string;
+ hasTracingConfigured?: boolean;
+}) => {
+ const [apiKeys, setApiKeys] = useState<
+ RouterOutput["projectApiKeys"]["create"] | null
+ >(null);
+ const utils = api.useUtils();
+ const mutCreateApiKey = api.projectApiKeys.create.useMutation({
+ onSuccess: (data) => {
+ utils.projectApiKeys.invalidate();
+ setApiKeys(data);
+ },
+ });
+
+ const createApiKey = async () => {
+ try {
+ await mutCreateApiKey.mutateAsync({ projectId });
+ } catch (error) {
+ console.error("Error creating API key:", error);
+ }
+ };
+
+ return (
+ <div className="space-y-8">
+ <div>
+ <SubHeader title="1. Get API Keys" />
+ {apiKeys ? (
+ <ApiKeyRender
+ generatedKeys={apiKeys}
+ scope={"project"}
+ className="mt-4"
+ />
+ ) : (
+ <div className="flex flex-col gap-4">
+ <p className="text-sm text-muted-foreground">
+ You need to create an API key to start tracing your application.
+ You can create more keys later in the project settings.
+ </p>
+ <div className="flex gap-2">
+ <Button
+ onClick={createApiKey}
+ loading={mutCreateApiKey.isPending}
+ className="self-start"
+ >
+ Create new API key
+ </Button>
+ <ActionButton
+ href={`/project/${projectId}/settings/api-keys`}
+ variant="secondary"
+ >
+ Manage API keys
+ </ActionButton>
+ </div>
+ </div>
+ )}
+ </div>
+
+ <div>
+ <SubHeader
+ title="2. Instrument Your Application"
+ status={hasTracingConfigured ? "active" : "pending"}
+ />
+ <p className="mb-4 text-sm text-muted-foreground">
+ Langfuse relies on OpenTelemetry to instrument your application and
+ export LLM application/agent traces to Langfuse. You can use one of
+ our SDKs or 50+ framework integrations. Please follow the quickstart
+ in the documentation to add Langfuse to your application.
+ </p>
+ <ActionButton href="https://langfuse.com/docs/observability/get-started">
+ Instrumentation Quickstart
+ </ActionButton>
+ </div>
+ </div>
+ );
+};
+
+export default function TracesSetupPage() {
+ const router = useRouter();
+ const projectId = router.query.projectId as string;
+
+ // Check if the user has tracing configured
+ const { data: hasTracingConfigured } =
+ api.traces.hasTracingConfigured.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ refetchInterval: 5000,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+
+ const capture = usePostHogClientCapture();
+ useEffect(() => {
+ if (hasTracingConfigured !== undefined) {
+ capture("onboarding:tracing_check_active", {
+ active: hasTracingConfigured,
+ });
+ }
+ }, [hasTracingConfigured, capture]);
+
+ return (
+ <ContainerPage
+ headerProps={{
+ title: "Tracing Setup",
+ help: {
+ description:
+ "Setup tracing to track and analyze your LLM calls. You can create API keys and integrate Langfuse with your application.",
+ href: "https://langfuse.com/docs/observability/overview",
+ },
+ }}
+ >
+ <div className="flex flex-col gap-4">
+ <TracingSetup
+ projectId={projectId}
+ hasTracingConfigured={hasTracingConfigured ?? false}
+ />
+ </div>
+ </ContainerPage>
+ );
+}