Skip to content

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

feat(cloud): data region select and info modal (#2085)

Marc Klingena2b6b7a14bcd
diff --git a/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx b/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx
index be73e8baf1..fcb2d5b763 100644
--- a/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx
+++ b/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx
@@ -2,7 +2,7 @@ import { env } from "@/src/env.mjs";
export const CloudPrivacyNotice = ({ action }: { action: string }) =>
env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ? (
- <div className="mt-5 text-center text-xs text-gray-500">
+ <div className="mx-auto mt-10 max-w-lg text-center text-xs text-gray-500">
By {action} you are agreeing to our{" "}
<a
href="https://langfuse.com/terms"
diff --git a/web/src/features/auth/components/AuthCloudRegionSwitch.tsx b/web/src/features/auth/components/AuthCloudRegionSwitch.tsx
index 09679d20ab..a975c217a0 100644
--- a/web/src/features/auth/components/AuthCloudRegionSwitch.tsx
+++ b/web/src/features/auth/components/AuthCloudRegionSwitch.tsx
@@ -1,13 +1,25 @@
import { env } from "@/src/env.mjs";
-import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
-import { Divider } from "@tremor/react";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/src/components/ui/select";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/src/components/ui/dialog";
const regions =
env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "STAGING"
? [
{
- name: "EU (Staging)",
+ name: "STAGING",
hostname: "staging.langfuse.com",
flag: "🇪🇺",
},
@@ -16,6 +28,7 @@ const regions =
? [
{
name: "DEV",
+ hostname: null,
flag: "🚧",
},
]
@@ -41,50 +54,103 @@ export function CloudRegionSwitch({
if (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === undefined) return null;
+ const currentRegion = regions.find(
+ (region) => region.name === env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION,
+ );
+
return (
<div>
- <div className="flex w-full flex-col justify-between gap-3 md:flex-row md:items-center">
+ <div className="mb-6 flex w-full flex-col gap-3">
<div>
- <span className="text-sm font-medium leading-none">Data Region</span>
- <p className="text-xs text-gray-500">
- Regions are strictly separated.
- </p>
- {isSignUpPage ? (
+ <span className="text-sm font-medium leading-none">
+ Data Region
+ <DataRegionInfo />
+ </span>
+ {isSignUpPage && env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "US" ? (
<p className="text-xs text-gray-500">
- {env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "EU"
- ? "✅ Demo project available"
- : "❌ Choose EU for demo project access"}
+ Demo project is only available in the EU region.
</p>
) : null}
</div>
- <Tabs value={env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION}>
- <TabsList>
+ <Select
+ value={currentRegion?.name}
+ onValueChange={(value) => {
+ const region = regions.find((region) => region.name === value);
+ if (!region) return;
+ capture(
+ "sign_in:cloud_region_switch",
+ {
+ region: region.name,
+ },
+ {
+ send_instantly: true,
+ },
+ );
+ if (region.hostname) {
+ window.location.hostname = region.hostname;
+ }
+ }}
+ >
+ <SelectTrigger className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
{regions.map((region) => (
- <TabsTrigger
- key={region.name}
- value={region.name}
- onClick={() => {
- capture(
- "sign_in:cloud_region_switch",
- {
- region: region.name,
- },
- {
- send_instantly: true,
- },
- );
- if ("hostname" in region)
- window.location.hostname = region.hostname;
- }}
- >
+ <SelectItem key={region.name} value={region.name}>
<span className="mr-2 text-xl leading-none">{region.flag}</span>
{region.name}
- </TabsTrigger>
+ </SelectItem>
))}
- </TabsList>
- </Tabs>
+ </SelectContent>
+ </Select>
</div>
- <Divider className="text-gray-400" />
</div>
);
}
+
+const DataRegionInfo = () => (
+ <Dialog>
+ <DialogTrigger asChild>
+ <a
+ href="#"
+ className="ml-1 text-xs text-indigo-600 hover:text-indigo-500"
+ title="What is this?"
+ >
+ (what is this?)
+ </a>
+ </DialogTrigger>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Data Regions</DialogTitle>
+ </DialogHeader>
+ <div className="flex flex-col gap-2">
+ <p>Langfuse Cloud is available in two data regions:</p>
+ <ul className="list-disc pl-5">
+ <li>US: Northern California (us-west-1)</li>
+ <li>EU: Frankfurt, Germany (eu-central-1)</li>
+ </ul>
+ <p>
+ Regions are strictly separated, and no data is shared across regions.
+ Choosing a region close to you can help improve speed and comply with
+ local data residency laws and privacy regulations.
+ </p>
+ <p>
+ You can have accounts in both regions and data migrations are
+ available on Team plans.
+ </p>
+ <p>
+ For more information, visit{" "}
+ <a
+ href="https://langfuse.com/docs/data-security-privacy"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-500 underline"
+ >
+ langfuse.com/security
+ </a>
+ .
+ </p>
+ </div>
+ </DialogContent>
+ </Dialog>
+);
diff --git a/web/src/pages/auth/sign-in.tsx b/web/src/pages/auth/sign-in.tsx
index 43181e5759..e1f8f3c237 100644
--- a/web/src/pages/auth/sign-in.tsx
+++ b/web/src/pages/auth/sign-in.tsx
@@ -90,7 +90,7 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async () => {
// Also used in src/pages/auth/sign-up.tsx
export function SSOButtons({
authProviders,
- action = "Sign in",
+ action = "sign in",
}: {
authProviders: PageProps["authProviders"];
action?: string;
@@ -103,7 +103,9 @@ export function SSOButtons({
([name, enabled]) => enabled && name !== "credentials",
) ? (
<div>
- {authProviders.credentials && <Divider className="text-gray-400" />}
+ {authProviders.credentials && (
+ <Divider className="text-gray-400">or {action} with</Divider>
+ )}
<div className="flex flex-row flex-wrap items-center justify-center gap-4">
{authProviders.google && (
<Button
@@ -114,7 +116,7 @@ export function SSOButtons({
variant="secondary"
>
<FcGoogle className="mr-3" size={18} />
- {action} with Google
+ Google
</Button>
)}
{authProviders.github && (
@@ -126,7 +128,7 @@ export function SSOButtons({
variant="secondary"
>
<FaGithub className="mr-3" size={18} />
- {action} with Github
+ Github
</Button>
)}
{authProviders.azureAd && (
@@ -140,7 +142,7 @@ export function SSOButtons({
variant="secondary"
>
<TbBrandAzure className="mr-3" size={18} />
- {action} with Azure AD
+ Azure AD
</Button>
)}
{authProviders.okta && (
@@ -152,7 +154,7 @@ export function SSOButtons({
variant="secondary"
>
<SiOkta className="mr-3" size={18} />
- {action} with Okta
+ Okta
</Button>
)}
{authProviders.auth0 && (
@@ -164,7 +166,7 @@ export function SSOButtons({
variant="secondary"
>
<SiAuth0 className="mr-3" size={18} />
- {action} with Auth0
+ Auth0
</Button>
)}
</div>
@@ -288,7 +290,7 @@ export default function SignIn({ authProviders, signUpDisabled }: PageProps) {
</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">
- <div className="space-y-8">
+ <div className="space-y-6">
<CloudRegionSwitch />
{authProviders.credentials ? (
<Form {...credentialsForm}>
@@ -393,22 +395,22 @@ export default function SignIn({ authProviders, signUpDisabled }: PageProps) {
</>
)
}
- <CloudPrivacyNotice action="signing in" />
- </div>
- {!signUpDisabled &&
- env.NEXT_PUBLIC_SIGN_UP_DISABLED !== "true" &&
- authProviders.credentials ? (
- <p className="mt-10 text-center text-sm text-gray-500">
- No account yet?{" "}
- <Link
- href="/auth/sign-up"
- className="font-semibold leading-6 text-indigo-600 hover:text-indigo-500"
- >
- Sign up
- </Link>
- </p>
- ) : null}
+ {!signUpDisabled &&
+ env.NEXT_PUBLIC_SIGN_UP_DISABLED !== "true" &&
+ authProviders.credentials ? (
+ <p className="mt-10 text-center text-sm text-gray-500">
+ No account yet?{" "}
+ <Link
+ href="/auth/sign-up"
+ className="font-semibold leading-6 text-indigo-600 hover:text-indigo-500"
+ >
+ Sign up
+ </Link>
+ </p>
+ ) : null}
+ </div>
+ <CloudPrivacyNotice action="signing in" />
</div>
</>
);
diff --git a/web/src/pages/auth/sign-up.tsx b/web/src/pages/auth/sign-up.tsx
index 659b6c8f58..381862970e 100644
--- a/web/src/pages/auth/sign-up.tsx
+++ b/web/src/pages/auth/sign-up.tsx
@@ -170,7 +170,7 @@ export default function SignIn({ authProviders }: PageProps) {
) : null}
</form>
</Form>
- <SSOButtons authProviders={authProviders} action="Sign up" />
+ <SSOButtons authProviders={authProviders} action="sign up" />
{
// Turnstile exists copy-paste also on sign-up.tsx
env.NEXT_PUBLIC_TURNSTILE_SITE_KEY !== undefined && (
@@ -189,18 +189,18 @@ export default function SignIn({ authProviders }: PageProps) {
</>
)
}
- <CloudPrivacyNotice action="creating an account" />
+ <p className="mt-10 text-center text-sm text-gray-500">
+ Already have an account?{" "}
+ <Link
+ href="/auth/sign-in"
+ className="font-semibold leading-6 text-indigo-600 hover:text-indigo-500"
+ >
+ Sign in
+ </Link>
+ </p>
</div>
- <p className="mt-10 text-center text-sm text-gray-500">
- Already have an account?{" "}
- <Link
- href="/auth/sign-in"
- className="font-semibold leading-6 text-indigo-600 hover:text-indigo-500"
- >
- Sign in
- </Link>
- </p>
+ <CloudPrivacyNotice action="creating an account" />
</div>
</>
);