🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(cloud): add data region switch (#558)
Marc Klingen160b4d528c71
diff --git a/src/features/auth/components/AuthCloudPrivacyNotice.tsx b/src/features/auth/components/AuthCloudPrivacyNotice.tsxnew file mode 100644index 0000000000..7b88fd0e78--- /dev/null+++ b/src/features/auth/components/AuthCloudPrivacyNotice.tsx@@ -0,0 +1,32 @@+import { env } from "@/src/env.mjs";++export const CloudPrivacyNotice = ({ action }: { action: string }) =>+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ? (+ <div className="mt-10 text-center text-xs text-gray-500">+ By {action} you are agreeing to our{" "}+ <a+ href="https://langfuse.com/tos"+ target="_blank"+ rel="noopener noreferrer"+ className="italic"+ >+ Terms of Service+ </a>+ ,{" "}+ <a+ href="https://langfuse.com/privacy"+ rel="noopener noreferrer"+ className="italic"+ >+ Privacy Policy+ </a>+ , and{" "}+ <a+ href="https://langfuse.com/cookie-policy"+ rel="noopener noreferrer"+ className="italic"+ >+ Cookie Policy+ </a>+ </div>+ ) : null;diff --git a/src/features/auth/components/AuthCloudRegionSwitch.tsx b/src/features/auth/components/AuthCloudRegionSwitch.tsxnew file mode 100644index 0000000000..b4df71a1b0--- /dev/null+++ b/src/features/auth/components/AuthCloudRegionSwitch.tsx@@ -0,0 +1,67 @@+import { env } from "@/src/env.mjs";+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";+import { Divider } from "@tremor/react";+import { usePostHog } from "posthog-js/react";++const regions = [+ {+ name: "US",+ hostname: "us.cloud.langfuse.com",+ flag: "🇺🇸",+ },+ {+ name: "EU",+ hostname: "cloud.langfuse.com",+ flag: "🇪🇺",+ },+];++export function CloudRegionSwitch() {+ const posthog = usePostHog();++ if (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === undefined) return null;++ return (+ <div>+ <div className="flex w-full items-center justify-between">+ <div>+ <span className="text-sm font-medium leading-none">Data Region</span>+ <p className="text-xs text-gray-500">+ Regions are strictly separated.+ </p>+ {env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "US" ? (+ <p className="text-xs text-gray-500">+ Demo only available in EU region.+ </p>+ ) : null}+ </div>+ <Tabs value={env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION}>+ <TabsList>+ {regions.map((region) => (+ <TabsTrigger+ key={region.name}+ value={region.name}+ onClick={() => {+ posthog.capture(+ "cloud_region_switch",+ {+ region: region.name,+ },+ {+ send_instantly: true,+ },+ );+ window.location.hostname = region.hostname;+ }}+ >+ <span className="mr-2 text-xl leading-none">{region.flag}</span>+ {region.name}+ </TabsTrigger>+ ))}+ </TabsList>+ </Tabs>+ </div>+ <Divider className="text-gray-400" />+ </div>+ );+}diff --git a/src/features/public-api/components/CreateApiKeyButton.tsx b/src/features/public-api/components/CreateApiKeyButton.tsxindex 06cf3bb76a..3daee50e60 100644--- a/src/features/public-api/components/CreateApiKeyButton.tsx+++ b/src/features/public-api/components/CreateApiKeyButton.tsx@@ -5,13 +5,13 @@ import { PlusIcon } from "lucide-react";import {Dialog,DialogContent,- DialogHeader,DialogTitle,DialogTrigger,} from "@/src/components/ui/dialog";import { CodeView } from "@/src/components/ui/code";import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";import { usePostHog } from "posthog-js/react";+import { env } from "@/src/env.mjs";export function CreateApiKeyButton(props: { projectId: string }) {const utils = api.useUtils();@@ -21,6 +21,9 @@ export function CreateApiKeyButton(props: { projectId: string }) {scope: "apiKeys:create",});+ const hostname =+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== "EU" ? window.origin : undefined;+const mutCreateApiKey = api.apiKeys.create.useMutation({onSuccess: () => utils.apiKeys.invalidate(),});@@ -64,9 +67,19 @@ export function CreateApiKeyButton(props: { projectId: string }) {</Button></DialogTrigger><DialogContent onPointerDownOutside={(e) => e.preventDefault()}>- <DialogHeader>- <DialogTitle>API Keys</DialogTitle>- </DialogHeader>+ {hostname ? (+ <>+ <DialogTitle>Hostname</DialogTitle>+ <div className="mb-6">+ <div className="my-2">+ When connecting to Langfuse, use this hostname / baseurl.+ </div>+ <CodeView content={hostname} />+ </div>+ </>+ ) : null}++ <DialogTitle>API Keys</DialogTitle><div className="mb-2"><div className="text-md font-semibold">Secret Key</div><div className="my-2">diff --git a/src/pages/auth/sign-in.tsx b/src/pages/auth/sign-in.tsxindex 34861570db..445e52ab4c 100644--- a/src/pages/auth/sign-in.tsx+++ b/src/pages/auth/sign-in.tsx@@ -21,8 +21,9 @@ import { useState } from "react";import { useForm } from "react-hook-form";import * as z from "zod";import { usePostHog } from "posthog-js/react";-import { CloudPrivacyNotice } from "@/src/pages/auth/sign-up";import { Divider } from "@tremor/react";+import { CloudPrivacyNotice } from "@/src/features/auth/components/AuthCloudPrivacyNotice";+import { CloudRegionSwitch } from "@/src/features/auth/components/AuthCloudRegionSwitch";const credentialAuthForm = z.object({email: z.string().email(),@@ -102,6 +103,7 @@ export default function SignIn(props: PageProps) {<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"><div className="mt-2 space-y-8">+ <CloudRegionSwitch />{props.authProviders.credentials ? (<Form {...credentialsForm}><formdiff --git a/src/pages/auth/sign-up.tsx b/src/pages/auth/sign-up.tsxindex 7ce68af75b..9c3df4f6fd 100644--- a/src/pages/auth/sign-up.tsx+++ b/src/pages/auth/sign-up.tsx@@ -19,6 +19,8 @@ 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";export default function SignIn() {const posthog = usePostHog();@@ -89,6 +91,7 @@ export default function SignIn() {) : null}<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">+ <CloudRegionSwitch /><Form {...form}><formclassName="space-y-6"@@ -182,34 +185,3 @@ export default function SignIn() {</>);}--export const CloudPrivacyNotice = ({ action }: { action: string }) =>- env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ? (- <div className="mt-10 text-center text-xs text-gray-500">- By {action} you are agreeing to our{" "}- <a- href="https://langfuse.com/tos"- target="_blank"- rel="noopener noreferrer"- className="italic"- >- Terms of Service- </a>- ,{" "}- <a- href="https://langfuse.com/privacy"- rel="noopener noreferrer"- className="italic"- >- Privacy Policy- </a>- , and{" "}- <a- href="https://langfuse.com/cookie-policy"- rel="noopener noreferrer"- className="italic"- >- Cookie Policy- </a>- </div>- ) : null;