🪢 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
fix(web): render selected cloud region in picker (#15225)
Tobias Wochingerb491c6ddc1fb
diff --git a/web/src/components/ui/select.tsx b/web/src/components/ui/select.tsxindex d050d69f78..606f073b2c 100644--- a/web/src/components/ui/select.tsx+++ b/web/src/components/ui/select.tsx@@ -17,24 +17,31 @@ const SelectTrigger = React.forwardRef<React.ComponentRef<typeof SelectPrimitive.Trigger>,React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {hideDownIcon?: boolean;+ disableValueLineClamp?: boolean;}->(({ className, children, ...props }, ref) => (- <SelectPrimitive.Trigger- ref={ref}- className={cn(- "border-input bg-background ring-offset-background placeholder:text-foreground-tertiary focus:ring-ring disabled:bg-muted/50 flex h-8 w-full items-center justify-between gap-1 rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",- className,- )}- {...props}- >- {children}- {props.hideDownIcon ? null : (- <SelectPrimitive.Icon asChild>- <ChevronDown className="h-4 w-4 opacity-50" />- </SelectPrimitive.Icon>- )}- </SelectPrimitive.Trigger>-));+>(+ (+ { className, children, hideDownIcon, disableValueLineClamp, ...props },+ ref,+ ) => (+ <SelectPrimitive.Trigger+ ref={ref}+ className={cn(+ "border-input bg-background ring-offset-background placeholder:text-foreground-tertiary focus:ring-ring disabled:bg-muted/50 flex h-8 w-full items-center justify-between gap-1 rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50",+ disableValueLineClamp ? null : "[&>span]:line-clamp-1",+ className,+ )}+ {...props}+ >+ {children}+ {hideDownIcon ? null : (+ <SelectPrimitive.Icon asChild>+ <ChevronDown className="h-4 w-4 opacity-50" />+ </SelectPrimitive.Icon>+ )}+ </SelectPrimitive.Trigger>+ ),+);SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;const SelectScrollUpButton = React.forwardRef<diff --git a/web/src/features/auth/components/AuthCloudRegionSwitch.tsx b/web/src/features/auth/components/AuthCloudRegionSwitch.tsxindex 35e8807768..b5967c9bc2 100644--- a/web/src/features/auth/components/AuthCloudRegionSwitch.tsx+++ b/web/src/features/auth/components/AuthCloudRegionSwitch.tsx@@ -1,23 +1,8 @@import { env } from "@/src/env.mjs";-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from "@/src/components/ui/select";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";-import {- Dialog,- DialogBody,- DialogContent,- DialogDescription,- DialogHeader,- DialogTitle,- DialogTrigger,-} from "@/src/components/ui/dialog";-import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { CloudRegionPicker } from "@/src/features/auth/components/CloudRegionPicker";import { getAvailableCloudRegionOptions } from "@/src/features/organizations/cloudRegions";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function CloudRegionSwitch({isSignUpPage,@@ -35,143 +20,26 @@ export function CloudRegionSwitch({const currentRegion = regions.find((region) => region.name === cloudRegion);return (- <div className="bg-card mt-8 -mb-10 rounded-lg px-6 py-6 text-sm sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-10">- <div className="flex w-full flex-col gap-2">- <div>- <span className="text-sm leading-none font-bold">- Data Region- <DataRegionInfo />- </span>- {isSignUpPage && cloudRegion === "HIPAA" ? (- <p className="text-muted-foreground text-xs">- Demo project is not available in the HIPAA data region.- </p>- ) : null}- </div>- <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) => (- <SelectItem key={region.name} value={region.name}>- <span className="flex items-center gap-2">- <span- className={- // The HIPAA symbol glyph sits lower than flag emojis in the same font.- region.name === "HIPAA"- ? "translate-y-[-3px] text-xl leading-none"- : "-translate-y-px text-xl leading-none"- }- >- {region.flag}- </span>- <span>{region.name}</span>- </span>- </SelectItem>- ))}- </SelectContent>- </Select>-- {cloudRegion === "HIPAA" && (- <div className="bg-muted/50 text-muted-foreground mt-2 rounded-md p-3 text-xs">- <p>- The Business Associate Agreement (BAA) is only effective on the- Cloud Pro and Teams plans.{" "}- <a- href="https://langfuse.com/security/hipaa"- target="_blank"- rel="noopener noreferrer"- className="text-link hover:text-link-hover underline"- >- Learn more about HIPAA compliance →- </a>- </p>- </div>- )}- </div>- </div>+ <CloudRegionPicker+ regions={regions}+ selectedRegion={currentRegion}+ 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;+ }+ }}+ isSignUpPage={isSignUpPage}+ />);}--const DataRegionInfo = () => (- <Dialog>- <DialogTrigger asChild>- <a- href="#"- className="text-link hover:text-link-hover ml-1 text-xs"- title="What is this?"- tabIndex={-1}- >- (what is this?)- </a>- </DialogTrigger>- <DialogContent>- <DialogHeader>- <DialogTitle>Data Regions</DialogTitle>- </DialogHeader>- <DialogBody>- <DialogDescription className="flex flex-col gap-2">- <p>Langfuse Cloud is available in four data regions:</p>- <ul className="list-disc pl-5">- <li>US: Oregon (AWS us-west-2)</li>- <li>EU: Ireland (AWS eu-west-1)</li>- <li>JP: Tokyo (AWS ap-northeast-1)</li>- <li>- HIPAA: Oregon (AWS us-west-2) - HIPAA-compliant region (available- with Pro and Teams plans)- </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 multiple regions. Each region requires a- separate subscription.- </p>- <p>- Learn more about{" "}- <a- href="https://langfuse.com/security/data-regions"- target="_blank"- rel="noopener noreferrer"- className="text-link hover:text-link-hover underline"- >- data regions- </a>{" "}- and{" "}- <a- href="https://langfuse.com/docs/data-security-privacy"- target="_blank"- rel="noopener noreferrer"- className="text-link hover:text-link-hover underline"- >- data security & privacy- </a>- .- </p>- </DialogDescription>- </DialogBody>- </DialogContent>- </Dialog>-);diff --git a/web/src/features/auth/components/CloudRegionPicker.stories.tsx b/web/src/features/auth/components/CloudRegionPicker.stories.tsxnew file mode 100644index 0000000000..ffe9b209f6--- /dev/null+++ b/web/src/features/auth/components/CloudRegionPicker.stories.tsx@@ -0,0 +1,40 @@+import preview from "../../../../.storybook/preview";+import { getAvailableCloudRegionOptions } from "@/src/features/organizations/cloudRegions";+import { useState } from "react";+import { CloudRegionPicker } from "./CloudRegionPicker";++const regions = getAvailableCloudRegionOptions();++const meta = preview.meta({+ component: CloudRegionPicker,+});++function StatefulCloudRegionPicker({+ initialRegion,+ isSignUpPage,+}: {+ initialRegion: (typeof regions)[number]["name"];+ isSignUpPage?: boolean;+}) {+ const [regionName, setRegionName] = useState(initialRegion);+ const selectedRegion = regions.find((region) => region.name === regionName);++ return (+ <CloudRegionPicker+ regions={regions}+ selectedRegion={selectedRegion}+ onValueChange={setRegionName}+ isSignUpPage={isSignUpPage}+ />+ );+}++export const Default = meta.story({+ render: () => <StatefulCloudRegionPicker initialRegion="EU" />,+});++export const HipaaSignUp = meta.story({+ render: () => (+ <StatefulCloudRegionPicker initialRegion="HIPAA" isSignUpPage />+ ),+});diff --git a/web/src/features/auth/components/CloudRegionPicker.tsx b/web/src/features/auth/components/CloudRegionPicker.tsxnew file mode 100644index 0000000000..d0c4e511da--- /dev/null+++ b/web/src/features/auth/components/CloudRegionPicker.tsx@@ -0,0 +1,164 @@+import {+ Dialog,+ DialogBody,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from "@/src/components/ui/dialog";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+} from "@/src/components/ui/select";+import type { CloudRegion } from "@/src/features/organizations/cloudRegions";++export function CloudRegionPicker({+ regions,+ selectedRegion,+ onValueChange,+ isSignUpPage,+}: {+ regions: CloudRegion[];+ selectedRegion?: CloudRegion;+ onValueChange: (value: CloudRegion["name"]) => void;+ isSignUpPage?: boolean;+}) {+ return (+ <div className="bg-card mt-8 -mb-10 rounded-lg px-6 py-6 text-sm sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-10">+ <div className="flex w-full flex-col gap-2">+ <div>+ <span className="text-sm leading-none font-bold">+ Data Region+ <DataRegionInfo />+ </span>+ {isSignUpPage && selectedRegion?.name === "HIPAA" ? (+ <p className="text-muted-foreground text-xs">+ Demo project is not available in the HIPAA data region.+ </p>+ ) : null}+ </div>+ <Select value={selectedRegion?.name} onValueChange={onValueChange}>+ <SelectTrigger+ className="w-full"+ disableValueLineClamp+ aria-label={+ selectedRegion ? `${selectedRegion.name} data region` : undefined+ }+ >+ {selectedRegion ? (+ <CloudRegionLabel region={selectedRegion} />+ ) : null}+ </SelectTrigger>+ <SelectContent>+ {regions.map((region) => (+ <SelectItem key={region.name} value={region.name}>+ <CloudRegionLabel region={region} />+ </SelectItem>+ ))}+ </SelectContent>+ </Select>++ {selectedRegion?.name === "HIPAA" && (+ <div className="bg-muted/50 text-muted-foreground mt-2 rounded-md p-3 text-xs">+ <p>+ The Business Associate Agreement (BAA) is only effective on the+ Cloud Pro and Teams plans.{" "}+ <a+ href="https://langfuse.com/security/hipaa"+ target="_blank"+ rel="noopener noreferrer"+ className="text-link hover:text-link-hover underline"+ >+ Learn more about HIPAA compliance →+ </a>+ </p>+ </div>+ )}+ </div>+ </div>+ );+}++function CloudRegionLabel({ region }: { region: CloudRegion }) {+ return (+ <span className="flex items-center gap-2">+ <span+ className={+ region.name === "HIPAA"+ ? "translate-y-[-3px] text-xl leading-none"+ : "-translate-y-px text-xl leading-none"+ }+ >+ {region.flag}+ </span>+ <span>{region.name}</span>+ </span>+ );+}++const DataRegionInfo = () => (+ <Dialog>+ <DialogTrigger asChild>+ <a+ href="#"+ className="text-link hover:text-link-hover ml-1 text-xs"+ title="What is this?"+ tabIndex={-1}+ >+ (what is this?)+ </a>+ </DialogTrigger>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>Data Regions</DialogTitle>+ </DialogHeader>+ <DialogBody>+ <DialogDescription className="flex flex-col gap-2">+ <p>Langfuse Cloud is available in four data regions:</p>+ <ul className="list-disc pl-5">+ <li>US: Oregon (AWS us-west-2)</li>+ <li>EU: Ireland (AWS eu-west-1)</li>+ <li>JP: Tokyo (AWS ap-northeast-1)</li>+ <li>+ HIPAA: Oregon (AWS us-west-2) - HIPAA-compliant region (available+ with Pro and Teams plans)+ </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 multiple regions. Each region requires a+ separate subscription.+ </p>+ <p>+ Learn more about{" "}+ <a+ href="https://langfuse.com/security/data-regions"+ target="_blank"+ rel="noopener noreferrer"+ className="text-link hover:text-link-hover underline"+ >+ data regions+ </a>{" "}+ and{" "}+ <a+ href="https://langfuse.com/docs/data-security-privacy"+ target="_blank"+ rel="noopener noreferrer"+ className="text-link hover:text-link-hover underline"+ >+ data security & privacy+ </a>+ .+ </p>+ </DialogDescription>+ </DialogBody>+ </DialogContent>+ </Dialog>+);diff --git a/web/src/features/organizations/cloudRegions.ts b/web/src/features/organizations/cloudRegions.tsindex c4dd859716..4032552390 100644--- a/web/src/features/organizations/cloudRegions.ts+++ b/web/src/features/organizations/cloudRegions.ts@@ -43,6 +43,8 @@ const cloudRegions = [},] as const;+export type CloudRegion = (typeof cloudRegions)[number];+const availableRegionsByCurrentRegion = {STAGING: ["STAGING"],DEV: ["DEV"],