Skip to content

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

5.1 KB
Raw Blame
/* eslint-disable @repo/no-abstracted-overlay-trigger, @typescript-eslint/no-deprecated, @typescript-eslint/no-use-before-define -- Legacy UI usage retained during migration to design-system components. */
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 shadow-sm sm:mx-auto sm:w-full sm:max-w-[480px] 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>
);