Skip to content

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

chore(cloud): improved pricing/packaging (#5664)

Marc Klingen998984b9ed53
diff --git a/.env.prod.example b/.env.prod.example
index 231764499a..85fd372dca 100644
--- a/.env.prod.example
+++ b/.env.prod.example
@@ -265,7 +265,7 @@ OTEL_SERVICE_NAME="langfuse"
### END Langfuse Cloud Config
-## START Langfuse V3 Ingestion
+### START Langfuse V3 Ingestion
# Clickhouse
# CLICKHOUSE_MIGRATION_URL=
@@ -280,4 +280,11 @@ OTEL_SERVICE_NAME="langfuse"
# LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=
# LANGFUSE_INGESTION_CLICKHOUSE_MAX_ATTEMPTS=
-## END Langfuse V3 Ingestion
+### END Langfuse V3 Ingestion
+
+
+### START Langfuse CI Config
+
+# LANGFUSE_INIT_ORG_CLOUD_PLAN=
+
+### END Langfuse CI Config
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
index 7f54cc2c69..07fbb15fbe 100644
--- a/.github/workflows/pipeline.yml
+++ b/.github/workflows/pipeline.yml
@@ -134,14 +134,14 @@ jobs:
grep -v -e '^LANGFUSE_S3_BATCH_EXPORT_ENABLED=' -e '^NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT=' .env.dev.example > .env
echo "LANGFUSE_INGESTION_QUEUE_DELAY_MS=1" >> .env
echo "LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=1" >> .env
- - name: Run + migrate
+ - name: Run dev containers
run: |
docker compose -f docker-compose.dev.yml up -d
sleep 5 # Wait for PostgreSQL to accept connections
docker compose ps
env:
POSTGRES_VERSION: ${{ matrix.postgres-version }}
- - name: Seed DB
+ - name: Migrate DB
run: |
pnpm run db:migrate
pnpm --filter=shared ch:up
@@ -152,6 +152,7 @@ jobs:
env:
LANGFUSE_INIT_ORG_ID: "seed-org-id"
LANGFUSE_INIT_ORG_NAME: "Seed Org"
+ LANGFUSE_INIT_ORG_CLOUD_PLAN: "Team"
LANGFUSE_INIT_PROJECT_ID: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a"
LANGFUSE_INIT_PROJECT_NAME: "Seed Project"
LANGFUSE_INIT_PROJECT_PUBLIC_KEY: "pk-lf-1234567890"
@@ -211,14 +212,14 @@ jobs:
grep -v -e '^LANGFUSE_S3_BATCH_EXPORT_ENABLED=' -e '^NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT=' .env.dev${{ matrix.blob-provider }}.example > .env
echo "LANGFUSE_INGESTION_QUEUE_DELAY_MS=1" >> .env
echo "LANGFUSE_INGESTION_CLICKHOUSE_WRITE_INTERVAL_MS=1" >> .env
- - name: Run + migrate
+ - name: Run dev containers
run: |
docker compose -f docker-compose.dev${{ matrix.blob-provider }}.yml up -d
sleep 5 # Wait for PostgreSQL to accept connections
docker compose ps
env:
POSTGRES_VERSION: ${{ matrix.postgres-version }}
- - name: Seed DB
+ - name: Migrate DB
run: |
pnpm run db:migrate
pnpm --filter=shared ch:up
@@ -229,6 +230,7 @@ jobs:
env:
LANGFUSE_INIT_ORG_ID: "seed-org-id"
LANGFUSE_INIT_ORG_NAME: "Seed Org"
+ LANGFUSE_INIT_ORG_CLOUD_PLAN: "Team"
LANGFUSE_INIT_PROJECT_ID: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a"
LANGFUSE_INIT_PROJECT_NAME: "Seed Project"
LANGFUSE_INIT_PROJECT_PUBLIC_KEY: "pk-lf-1234567890"
diff --git a/packages/shared/prisma/seed.ts b/packages/shared/prisma/seed.ts
index 4010485832..a847c9eb0c 100644
--- a/packages/shared/prisma/seed.ts
+++ b/packages/shared/prisma/seed.ts
@@ -72,6 +72,9 @@ async function main() {
where: { id: seedOrgId },
update: {
name: "Seed Org",
+ cloudConfig: {
+ plan: "Team",
+ },
},
create: {
id: seedOrgId,
diff --git a/packages/shared/scripts/load-seed.ts b/packages/shared/scripts/load-seed.ts
index 912dc1f44d..d720cb39c1 100644
--- a/packages/shared/scripts/load-seed.ts
+++ b/packages/shared/scripts/load-seed.ts
@@ -27,6 +27,9 @@ const prepareProjectsAndApiKeys = async (
create: {
id: orgId,
name: `Organization for ${projectId}`,
+ cloudConfig: {
+ plan: "Team",
+ },
},
});
diff --git a/packages/shared/src/features/entitlements/plans.ts b/packages/shared/src/features/entitlements/plans.ts
index 3b1ed8d786..6dbd3d70e2 100644
--- a/packages/shared/src/features/entitlements/plans.ts
+++ b/packages/shared/src/features/entitlements/plans.ts
@@ -1,6 +1,16 @@
+// used on organization.cloudConfig.plan
+export const cloudConfigPlans = [
+ "Hobby",
+ "Core",
+ "Pro",
+ "Team",
+ "Enterprise",
+] as const;
+
export const planLabels = {
oss: "OSS",
"cloud:hobby": "Hobby",
+ "cloud:core": "Core",
"cloud:pro": "Pro",
"cloud:team": "Team",
"cloud:enterprise": "Enterprise",
@@ -13,8 +23,9 @@ export type Plan = keyof typeof planLabels;
export const plans = Object.keys(planLabels) as Plan[];
// These functions are kept here to ensure consistency when updating plan names in the future.
-export const isCloudPlan = (plan: Plan) => plan.startsWith("cloud");
-export const isSelfHostedPlan = (plan: Plan) => plan.startsWith("self-hosted");
+export const isCloudPlan = (plan?: Plan) => plan?.startsWith("cloud");
+export const isSelfHostedPlan = (plan?: Plan) =>
+ plan?.startsWith("self-hosted");
export const isPlan = (value: string): value is Plan =>
plans.includes(value as Plan);
diff --git a/packages/shared/src/interfaces/cloudConfigSchema.ts b/packages/shared/src/interfaces/cloudConfigSchema.ts
index 77742913b9..044ca800d8 100644
--- a/packages/shared/src/interfaces/cloudConfigSchema.ts
+++ b/packages/shared/src/interfaces/cloudConfigSchema.ts
@@ -1,8 +1,9 @@
import { z } from "zod";
import { CloudConfigRateLimit } from "./rate-limits";
+import { cloudConfigPlans } from "../features/entitlements/plans";
export const CloudConfigSchema = z.object({
- plan: z.enum(["Hobby", "Pro", "Team", "Enterprise"]).optional(),
+ plan: z.enum(cloudConfigPlans).optional(),
monthlyObservationLimit: z.number().int().positive().optional(),
// used for table and dashboard queries
defaultLookBackDays: z.number().int().positive().optional(),
diff --git a/packages/shared/src/server/repositories/scores.ts b/packages/shared/src/server/repositories/scores.ts
index abbdf3b66d..ed71420570 100644
--- a/packages/shared/src/server/repositories/scores.ts
+++ b/packages/shared/src/server/repositories/scores.ts
@@ -774,6 +774,37 @@ export const getScoreCountsByProjectInCreationInterval = async ({
}));
};
+export const getScoreCountOfProjectsSinceCreationDate = async ({
+ projectIds,
+ start,
+}: {
+ projectIds: string[];
+ start: Date;
+}) => {
+ const query = `
+ SELECT
+ count(*) as count
+ FROM scores
+ WHERE project_id IN ({projectIds: Array(String)})
+ AND created_at >= {start: DateTime64(3)}
+ `;
+
+ const rows = await queryClickhouse<{ count: string }>({
+ query,
+ params: {
+ projectIds,
+ start: convertDateToClickhouseDateTime(start),
+ },
+ tags: {
+ feature: "tracing",
+ type: "score",
+ kind: "analytic",
+ },
+ });
+
+ return Number(rows[0]?.count ?? 0);
+};
+
export const getDistinctScoreNames = async (
projectId: string,
cutoffCreatedAt: Date,
diff --git a/packages/shared/src/server/repositories/traces.ts b/packages/shared/src/server/repositories/traces.ts
index fb080f8753..1b90e8299f 100644
--- a/packages/shared/src/server/repositories/traces.ts
+++ b/packages/shared/src/server/repositories/traces.ts
@@ -254,6 +254,37 @@ export const getTraceCountsByProjectInCreationInterval = async ({
}));
};
+export const getTraceCountOfProjectsSinceCreationDate = async ({
+ projectIds,
+ start,
+}: {
+ projectIds: string[];
+ start: Date;
+}) => {
+ const query = `
+ SELECT
+ count(*) as count
+ FROM traces
+ WHERE project_id IN ({projectIds: Array(String)})
+ AND created_at >= {start: DateTime64(3)}
+ `;
+
+ const rows = await queryClickhouse<{ count: string }>({
+ query,
+ params: {
+ projectIds,
+ start: convertDateToClickhouseDateTime(start),
+ },
+ tags: {
+ feature: "tracing",
+ type: "trace",
+ kind: "analytic",
+ },
+ });
+
+ return Number(rows[0]?.count ?? 0);
+};
+
export const getTraceById = async (
traceId: string,
projectId: string,
diff --git a/packages/shared/src/server/test-utils/org-factory.ts b/packages/shared/src/server/test-utils/org-factory.ts
index d54e59ff16..8b122b168f 100644
--- a/packages/shared/src/server/test-utils/org-factory.ts
+++ b/packages/shared/src/server/test-utils/org-factory.ts
@@ -1,6 +1,7 @@
import { v4 } from "uuid";
import { prisma } from "../../db";
import { hashSecretKey, getDisplaySecretKey } from "../auth/apiKeys";
+import { CloudConfigSchema } from "../../interfaces/cloudConfigSchema";
export function createBasicAuthHeader(
username: string,
@@ -23,6 +24,9 @@ export const createOrgProjectAndApiKey = async (
data: {
id: v4(),
name: v4(),
+ cloudConfig: CloudConfigSchema.parse({
+ plan: "Team",
+ }),
},
});
await prisma.project.create({
diff --git a/web/src/__tests__/model-definitions.servertest.ts b/web/src/__tests__/model-definitions.servertest.ts
index 293cccf93d..fea86e7b8f 100644
--- a/web/src/__tests__/model-definitions.servertest.ts
+++ b/web/src/__tests__/model-definitions.servertest.ts
@@ -12,10 +12,18 @@ import {
GetModelsV1Response,
PostModelsV1Response,
} from "@/src/features/public-api/types/models";
+import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";
describe("/models API Endpoints", () => {
+ let auth: string;
+
beforeEach(async () => {
await pruneDatabase();
+
+ // Create authentication pairs
+ const { auth: newAuth } = await createOrgProjectAndApiKey();
+ auth = newAuth;
+
// create some default models that do not belong to a project
await prisma.model.create({
data: {
@@ -51,6 +59,8 @@ describe("/models API Endpoints", () => {
GetModelsV1Response,
"GET",
"/api/public/models",
+ undefined,
+ auth,
);
expect(models.status).toBe(200);
expect(models.body.data.length).toBe(2);
@@ -65,6 +75,8 @@ describe("/models API Endpoints", () => {
GetModelsV1Response,
"GET",
"/api/public/models?page=2&limit=1",
+ undefined,
+ auth,
);
expect(models.status).toBe(200);
expect(models.body.data.length).toBe(1);
@@ -90,6 +102,7 @@ describe("/models API Endpoints", () => {
unit: "TOKENS",
tokenizerConfig: { tokensPerMessage: 3, tokensPerName: 1 },
},
+ auth,
);
expect(customModel.body.isLangfuseManaged).toBe(false);
@@ -97,6 +110,8 @@ describe("/models API Endpoints", () => {
GetModelsV1Response,
"GET",
"/api/public/models",
+ undefined,
+ auth,
);
expect(models.body.data.length).toBe(3);
@@ -104,6 +119,8 @@ describe("/models API Endpoints", () => {
GetModelV1Response,
"GET",
`/api/public/models/${customModel.body.id}`,
+ undefined,
+ auth,
);
expect(getModel.body.id).toBe(customModel.body.id);
expect(getModel.body).toMatchObject({
@@ -138,15 +155,20 @@ describe("/models API Endpoints", () => {
});
it("Post model with invalid matchPattern", async () => {
- const customModel = await makeAPICall("POST", "/api/public/models", {
- modelName: "gpt-3.5-turbo",
- matchPattern: "[][", // brackets not balanced
- startDate: "2023-12-01",
- inputPrice: 0.002,
- outputPrice: 0.004,
- unit: "TOKENS",
- tokenizerConfig: { tokensPerMessage: 3, tokensPerName: 1 },
- });
+ const customModel = await makeAPICall(
+ "POST",
+ "/api/public/models",
+ {
+ modelName: "gpt-3.5-turbo",
+ matchPattern: "[][", // brackets not balanced
+ startDate: "2023-12-01",
+ inputPrice: 0.002,
+ outputPrice: 0.004,
+ unit: "TOKENS",
+ tokenizerConfig: { tokensPerMessage: 3, tokensPerName: 1 },
+ },
+ auth,
+ );
expect(customModel.status).toBe(400);
});
@@ -160,29 +182,40 @@ describe("/models API Endpoints", () => {
matchPattern: "(.*)(gpt-)(35|3.5)(-turbo)?(.*)",
unit: "TOKENS",
},
+ auth,
);
});
it("Post model with missing fields", async () => {
- const { status } = await makeAPICall("POST", "/api/public/models", {
- modelName: "gpt-3.5-turbo",
- matchPattern: "(.*)(gpt-)(35|3.5)(-turbo)?(.*)",
- // missing unit
- });
+ const { status } = await makeAPICall(
+ "POST",
+ "/api/public/models",
+ {
+ modelName: "gpt-3.5-turbo",
+ matchPattern: "(.*)(gpt-)(35|3.5)(-turbo)?(.*)",
+ // missing unit
+ },
+ auth,
+ );
expect(status).toBe(400);
});
it("Post model with invalid price (input and total cost)", async () => {
- const customModel = await makeAPICall("POST", "/api/public/models", {
- modelName: "gpt-3.5-turbo",
- matchPattern: "[][", // brackets not balanced
- startDate: "2023-12-01",
- inputPrice: 0.002,
- outputPrice: 0.004,
- totalPrice: 0.1,
- unit: "TOKENS",
- tokenizerConfig: { tokensPerMessage: 3, tokensPerName: 1 },
- });
+ const customModel = await makeAPICall(
+ "POST",
+ "/api/public/models",
+ {
+ modelName: "gpt-3.5-turbo",
+ matchPattern: "[][", // brackets not balanced
+ startDate: "2023-12-01",
+ inputPrice: 0.002,
+ outputPrice: 0.004,
+ totalPrice: 0.1,
+ unit: "TOKENS",
+ tokenizerConfig: { tokensPerMessage: 3, tokensPerName: 1 },
+ },
+ auth,
+ );
expect(customModel.status).toBe(400);
});
@@ -191,12 +224,16 @@ describe("/models API Endpoints", () => {
GetModelsV1Response,
"GET",
"/api/public/models",
+ undefined,
+ auth,
);
expect(models.body.data.length).toBe(2);
const deleteModel = await makeAPICall(
"DELETE",
`/api/public/models/${models.body.data[0].id}`,
+ undefined,
+ auth,
);
expect(deleteModel.status).toBe(404);
});
@@ -215,12 +252,15 @@ describe("/models API Endpoints", () => {
unit: "TOKENS",
tokenizerConfig: { tokensPerMessage: 3, tokensPerName: 1 },
},
+ auth,
);
const models = await makeZodVerifiedAPICall(
GetModelsV1Response,
"GET",
"/api/public/models",
+ undefined,
+ auth,
);
expect(models.body.data.length).toBe(3);
@@ -228,12 +268,16 @@ describe("/models API Endpoints", () => {
DeleteModelV1Response,
"DELETE",
`/api/public/models/${customModel.body.id}`,
+ undefined,
+ auth,
);
const modelsAfterDelete = await makeZodVerifiedAPICall(
GetModelsV1Response,
"GET",
"/api/public/models",
+ undefined,
+ auth,
);
expect(modelsAfterDelete.body.data.length).toBe(2);
});
diff --git a/web/src/__tests__/rate-limit.servertest.ts b/web/src/__tests__/rate-limit.servertest.ts
index feeeb2d2ee..735a4e2ee4 100644
--- a/web/src/__tests__/rate-limit.servertest.ts
+++ b/web/src/__tests__/rate-limit.servertest.ts
@@ -78,8 +78,8 @@ describe("RateLimitService", () => {
expect(result?.res).toEqual({
scope: scope,
resource: "public-api",
- points: 1000,
- remainingPoints: 999,
+ points: 20,
+ remainingPoints: 19,
msBeforeNext: expect.any(Number),
consumedPoints: 1,
isFirstInDuration: true,
@@ -111,8 +111,8 @@ describe("RateLimitService", () => {
expect(result?.res).toEqual({
scope: scope,
resource: "public-api",
- points: 1000,
- remainingPoints: 998,
+ points: 20,
+ remainingPoints: 18,
msBeforeNext: expect.any(Number),
consumedPoints: 2,
isFirstInDuration: false,
diff --git a/web/src/__tests__/score-configs.servertest.ts b/web/src/__tests__/score-configs.servertest.ts
index 0660607768..b0ad2f0f5e 100644
--- a/web/src/__tests__/score-configs.servertest.ts
+++ b/web/src/__tests__/score-configs.servertest.ts
@@ -15,10 +15,11 @@ import {
PostScoreConfigResponse,
GetScoreConfigsResponse,
} from "@langfuse/shared";
+import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";
const configOne = [
{
- projectId: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",
+ projectId: "<to be replaced>",
name: "Test Boolean Config",
description: "Test Description",
dataType: "BOOLEAN" as ScoreDataType,
@@ -32,7 +33,7 @@ const configOne = [
];
const configTwo = [
{
- projectId: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",
+ projectId: "<to be replaced>",
name: "Test Numeric Config",
description: "Test Description",
dataType: "NUMERIC" as ScoreDataType,
@@ -44,7 +45,7 @@ const configTwo = [
const configThree = [
{
- projectId: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",
+ projectId: "<to be replaced>",
name: "Test Categorical Config",
description: "Test Description",
dataType: "CATEGORICAL" as ScoreDataType,
@@ -59,10 +60,24 @@ const configThree = [
];
describe("/api/public/score-configs API Endpoint", () => {
+ let auth: string;
+ let projectId: string;
+
beforeAll(
async () => {
await pruneDatabase();
+ // Create authentication pairs
+ const { auth: newAuth, projectId: newProjectId } =
+ await createOrgProjectAndApiKey();
+ auth = newAuth;
+ projectId = newProjectId;
+
+ // Update the project IDs in configs to use the new project ID
+ configOne[0].projectId = projectId;
+ configTwo[0].projectId = projectId;
+ configThree[0].projectId = projectId;
+
await prisma.scoreConfig.createMany({
data: [...configOne, ...configTwo, ...configThree],
});
@@ -75,7 +90,7 @@ describe("/api/public/score-configs API Endpoint", () => {
it("should GET a score config", async () => {
const { id: configId } = (await prisma.scoreConfig.findFirst({
where: {
- projectId: configOne[0].projectId,
+ projectId,
name: configOne[0].name,
},
})) as ScoreConfig;
@@ -84,6 +99,8 @@ describe("/api/public/score-configs API Endpoint", () => {
GetScoreConfigResponse,
"GET",
`/api/public/score-configs/${configId}`,
+ undefined,
+ auth,
);
expect(getScoreConfig.status).toBe(200);
@@ -100,6 +117,8 @@ describe("/api/public/score-configs API Endpoint", () => {
GetScoreConfigsResponse,
"GET",
`/api/public/score-configs?limit=50&page=1`,
+ undefined,
+ auth,
);
expect(fetchedConfigs.status).toBe(200);
@@ -125,6 +144,8 @@ describe("/api/public/score-configs API Endpoint", () => {
const getScoreConfig = await makeAPICall(
"GET",
`/api/public/score-configs/${configId}`,
+ undefined,
+ auth,
);
expect(getScoreConfig.status).toBe(404);
@@ -147,6 +168,8 @@ describe("/api/public/score-configs API Endpoint", () => {
const getScoreConfig = await makeAPICall(
"GET",
`/api/public/score-configs/${configId}`,
+ undefined,
+ auth,
);
expect(getScoreConfig.status).toBe(500);
@@ -165,12 +188,15 @@ describe("/api/public/score-configs API Endpoint", () => {
dataType: "NUMERIC",
maxValue: 0,
},
+ auth,
);
const scoreConfig = await makeZodVerifiedAPICall(
GetScoreConfigResponse,
"GET",
`/api/public/score-configs/${postScoreConfig.body.id}`,
+ undefined,
+ auth,
);
expect(postScoreConfig.status).toBe(200);
@@ -188,12 +214,15 @@ describe("/api/public/score-configs API Endpoint", () => {
name: "boolean-config-name",
dataType: "BOOLEAN",
},
+ auth,
);
const scoreConfig = await makeZodVerifiedAPICall(
GetScoreConfigResponse,
"GET",
`/api/public/score-configs/${postScoreConfig.body.id}`,
+ undefined,
+ auth,
);
expect(postScoreConfig.status).toBe(200);
@@ -218,12 +247,15 @@ describe("/api/public/score-configs API Endpoint", () => {
{ label: "Bad", value: 0 },
],
},
+ auth,
);
const scoreConfig = await makeZodVerifiedAPICall(
GetScoreConfigResponse,
"GET",
`/api/public/score-configs/${postScoreConfig.body.id}`,
+ undefined,
+ auth,
);
expect(postScoreConfig.status).toBe(200);
@@ -247,6 +279,7 @@ describe("/api/public/score-configs API Endpoint", () => {
maxValue: 0,
minValue: 1,
},
+ auth,
);
} catch (error) {
expect((error as Error).message).toBe(
@@ -267,6 +300,7 @@ describe("/api/public/score-configs API Endpoint", () => {
{ label: "Bad", value: 0 },
],
},
+ auth,
);
expect(postScoreConfig.status).toBe(400);
@@ -283,6 +317,7 @@ describe("/api/public/score-configs API Endpoint", () => {
name: "invalid-categorical-config-name",
dataType: "CATEGORICAL",
},
+ auth,
);
expect(postScoreConfig.status).toBe(400);
@@ -303,6 +338,7 @@ describe("/api/public/score-configs API Endpoint", () => {
{ key: "second", value: 0 },
],
},
+ auth,
);
expect(postScoreConfig.status).toBe(400);
@@ -331,6 +367,7 @@ describe("/api/public/score-configs API Endpoint", () => {
{ label: "first", value: 0 },
],
},
+ auth,
);
expect(postScoreConfig.status).toBe(400);
@@ -359,6 +396,7 @@ describe("/api/public/score-configs API Endpoint", () => {
{ label: "second", value: 1 },
],
},
+ auth,
);
expect(postScoreConfig.status).toBe(400);
diff --git a/web/src/__tests__/test-utils.ts b/web/src/__tests__/test-utils.ts
index 110c5d9df6..458c25d8c3 100644
--- a/web/src/__tests__/test-utils.ts
+++ b/web/src/__tests__/test-utils.ts
@@ -65,7 +65,7 @@ export async function makeAPICall<T = IngestionAPIResponse>(
body?: unknown,
auth?: string,
): Promise<{ body: T; status: number }> {
- const finalUrl = `http://localhost:3000/${url}`;
+ const finalUrl = `http://localhost:3000${url.startsWith("/") ? url : `/${url}`}`;
const authorization =
auth || createBasicAuthHeader("pk-lf-1234567890", "sk-lf-1234567890");
const options = {
@@ -79,8 +79,20 @@ export async function makeAPICall<T = IngestionAPIResponse>(
body !== undefined && { body: JSON.stringify(body) }),
};
const response = await fetch(finalUrl, options);
- const responseBody = (await response.json()) as T;
- return { body: responseBody, status: response.status };
+
+ // Clone the response before attempting to parse JSON
+ const clonedResponse = response.clone();
+
+ try {
+ const responseBody = (await response.json()) as T;
+ return { body: responseBody, status: response.status };
+ } catch (error) {
+ // Handle JSON parsing errors using the cloned response
+ const responseText = await clonedResponse.text();
+ throw new Error(
+ `Failed to parse JSON response: ${error instanceof Error ? error.message : String(error)}. Response status: ${response.status}. Response headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}. Response text: ${responseText}. Method: ${method}, URL: ${finalUrl}, Request body: ${body ? JSON.stringify(body) : "none"}`,
+ );
+ }
}
export async function makeZodVerifiedAPICall<T extends z.ZodTypeAny>(
diff --git a/web/src/ee/features/billing/components/BillingSettings.tsx b/web/src/ee/features/billing/components/BillingSettings.tsx
index 578cba1314..454937d21a 100644
--- a/web/src/ee/features/billing/components/BillingSettings.tsx
+++ b/web/src/ee/features/billing/components/BillingSettings.tsx
@@ -33,6 +33,7 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePos
import { stripeProducts } from "@/src/ee/features/billing/utils/stripeProducts";
import { toast } from "sonner";
import { ActionButton } from "@/src/components/ActionButton";
+import { useState } from "react";
export const BillingSettings = () => {
const router = useRouter();
@@ -163,21 +164,31 @@ const BillingPortalOrPricingPageButton = () => {
},
);
+ const [processingPlanId, setProcessingPlanId] = useState<string | null>(null);
+
const mutCreateCheckoutSession =
api.cloudBilling.createStripeCheckoutSession.useMutation({
onSuccess: (url) => {
router.push(url);
+ setProcessingPlanId(null);
+ },
+ onError: () => {
+ setProcessingPlanId(null);
},
});
const mutChangePlan =
api.cloudBilling.changeStripeSubscriptionProduct.useMutation({
onSuccess: () => {
toast.success("Plan changed successfully");
+ setProcessingPlanId(null);
// wait 1 second before reloading
setTimeout(() => {
window.location.reload();
}, 500);
},
+ onError: () => {
+ setProcessingPlanId(null);
+ },
});
// Do not show checkout or customer portal if manual plan is set in cloud config
@@ -209,7 +220,7 @@ const BillingPortalOrPricingPageButton = () => {
<DialogTrigger asChild>
<Button>Change plan</Button>
</DialogTrigger>
- <DialogContent className="max-w-3xl">
+ <DialogContent className="max-w-5xl">
<DialogHeader>
<Header
title="Plans"
@@ -222,19 +233,45 @@ const BillingPortalOrPricingPageButton = () => {
}
/>
</DialogHeader>
- <div className="mb-3 flex flex-col justify-center gap-10 md:flex-row">
+ <div className="mb-3 grid grid-cols-1 gap-3 md:grid-cols-3">
{stripeProducts
.filter((product) => Boolean(product.checkout))
.map((product) => (
<div
key={product.stripeProductId}
- className="flex flex-1 flex-col"
+ className="relative flex flex-col rounded-xl border bg-card p-4 shadow-sm transition-all hover:shadow-md"
>
- <div className="mb-2 text-lg font-semibold">
- {product.checkout?.title}
+ <div className="mb-4">
+ <h3 className="text-2xl font-bold">
+ {product.checkout?.title}
+ </h3>
+ <div className="mt-4 space-y-1">
+ <div className="text-2xl font-bold text-primary">
+ {product.checkout?.price}
+ </div>
+ <div className="text-sm text-muted-foreground">
+ + {product.checkout?.usagePrice}
+ </div>
+ </div>
</div>
- <div>{product.checkout?.description}</div>
- <div className="mb-6 mt-2">{product.checkout?.price}</div>
+ <div className="mb-4 text-sm text-muted-foreground">
+ {product.checkout?.description}
+ </div>
+ <div className="space-y-2">
+ <div className="text-sm font-medium">Main features:</div>
+ <ul className="list-inside list-disc space-y-1 text-sm text-muted-foreground">
+ {product.checkout?.mainFeatures.map((feature, index) => (
+ <li key={index}>{feature}</li>
+ ))}
+ </ul>
+ </div>
+ <Link
+ href="https://langfuse.com/pricing"
+ target="_blank"
+ className="mt-auto block py-4 text-sm text-muted-foreground hover:text-foreground"
+ >
+ Learn more about plan →
+ </Link>
{organization?.cloudConfig?.stripe?.activeProductId ? (
// Change plan
<Dialog>
@@ -244,7 +281,7 @@ const BillingPortalOrPricingPageButton = () => {
organization?.cloudConfig?.stripe?.activeProductId ===
product.stripeProductId
}
- className="mt-auto"
+ className="w-full"
>
{organization?.cloudConfig?.stripe?.activeProductId ===
product.stripeProductId
@@ -254,12 +291,16 @@ const BillingPortalOrPricingPageButton = () => {
</DialogTrigger>
<DialogContent>
<DialogHeader>
- <DialogTitle>Confirm Plan Change</DialogTitle>
- <DialogDescription>
- Changing your plan will immediately generate an
- invoice for any usage on your current plan. Your new
- plan and billing period will start today. Are you sure
- you want to continue?
+ <DialogTitle>
+ Confirm Change:{" "}
+ {planLabels[organization?.plan ?? "cloud:hobby"]} →{" "}
+ {product.checkout?.title}
+ </DialogTitle>
+ <DialogDescription className="pt-2">
+ This will immediately generate an invoice for any
+ usage on your current plan. Your new plan and billing
+ period will start today. Are you sure you want to
+ continue?
</DialogDescription>
</DialogHeader>
<DialogFooter>
@@ -269,13 +310,14 @@ const BillingPortalOrPricingPageButton = () => {
<ActionButton
onClick={() => {
if (organization) {
+ setProcessingPlanId(product.stripeProductId);
mutChangePlan.mutate({
orgId: organization.id,
stripeProductId: product.stripeProductId,
});
}
}}
- loading={mutChangePlan.isLoading}
+ loading={processingPlanId === product.stripeProductId}
>
Confirm
</ActionButton>
@@ -286,18 +328,20 @@ const BillingPortalOrPricingPageButton = () => {
// Upgrade, no plan yet
<ActionButton
onClick={() => {
- if (organization)
+ if (organization) {
+ setProcessingPlanId(product.stripeProductId);
mutCreateCheckoutSession.mutate({
orgId: organization.id,
stripeProductId: product.stripeProductId,
});
+ }
}}
disabled={
organization?.cloudConfig?.stripe?.activeProductId ===
product.stripeProductId
}
- className="mt-auto"
- loading={mutCreateCheckoutSession.isLoading}
+ className="w-full"
+ loading={processingPlanId === product.stripeProductId}
>
Select plan
</ActionButton>
diff --git a/web/src/ee/features/billing/components/UsageTracker.tsx b/web/src/ee/features/billing/components/UsageTracker.tsx
index 9f6e4c0864..121efc1ee4 100644
--- a/web/src/ee/features/billing/components/UsageTracker.tsx
+++ b/web/src/ee/features/billing/components/UsageTracker.tsx
@@ -10,8 +10,7 @@ import {
CardHeader,
CardTitle,
} from "@/src/components/ui/card";
-import { Button } from "@/src/components/ui/button";
-import Link from "next/link";
+import { ActionButton } from "@/src/components/ActionButton";
export const UsageTracker = () => {
const { organization } = useQueryProjectOrOrganization();
@@ -38,7 +37,6 @@ export const UsageTracker = () => {
if (
usageQuery.isLoading ||
!usageQuery.data ||
- !hasAccess ||
!hasEntitlement ||
plan !== "cloud:hobby"
) {
@@ -62,11 +60,14 @@ export const UsageTracker = () => {
</CardDescription>
</CardHeader>
<CardContent className="p-4 pt-2">
- <Button variant="secondary" size="sm" asChild>
- <Link href={`/organization/${organization?.id}/settings/billing`}>
- Upgrade plan
- </Link>
- </Button>
+ <ActionButton
+ variant="secondary"
+ size="sm"
+ href={`/organization/${organization?.id}/settings/billing`}
+ hasAccess={hasAccess}
+ >
+ Upgrade plan
+ </ActionButton>
</CardContent>
</Card>
);
diff --git a/web/src/ee/features/billing/server/cloudBillingRouter.ts b/web/src/ee/features/billing/server/cloudBillingRouter.ts
index c2e8c469c6..f83b413c9f 100644
--- a/web/src/ee/features/billing/server/cloudBillingRouter.ts
+++ b/web/src/ee/features/billing/server/cloudBillingRouter.ts
@@ -14,6 +14,8 @@ import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrga
import { auditLog } from "@/src/features/audit-logs/auditLog";
import {
getObservationCountOfProjectsSinceCreationDate,
+ getScoreCountOfProjectsSinceCreationDate,
+ getTraceCountOfProjectsSinceCreationDate,
logger,
} from "@langfuse/shared/src/server";
@@ -420,21 +422,30 @@ export const cloudBillingRouter = createTRPCRouter({
}
}
- // Free plan, usage not tracked on Stripe
+ // Free plan, usage not tracked on Stripe, get usage from Clickhouse
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
thirtyDaysAgo.setHours(0, 0, 0, 0);
const projectIds = organization.projects.map((p) => p.id);
- const countObservations =
- await getObservationCountOfProjectsSinceCreationDate({
+ const [countTraces, countObservations, countScores] = await Promise.all([
+ getTraceCountOfProjectsSinceCreationDate({
projectIds,
start: thirtyDaysAgo,
- });
+ }),
+ getObservationCountOfProjectsSinceCreationDate({
+ projectIds,
+ start: thirtyDaysAgo,
+ }),
+ getScoreCountOfProjectsSinceCreationDate({
+ projectIds,
+ start: thirtyDaysAgo,
+ }),
+ ]);
return {
- usageCount: countObservations,
- usageType: "observations",
+ usageCount: countTraces + countObservations + countScores,
+ usageType: "events",
};
}),
});
diff --git a/web/src/ee/features/billing/utils/stripeProducts.ts b/web/src/ee/features/billing/utils/stripeProducts.ts
index ad12ad0019..b1b56b5b50 100644
--- a/web/src/ee/features/billing/utils/stripeProducts.ts
+++ b/web/src/ee/features/billing/utils/stripeProducts.ts
@@ -9,11 +9,34 @@ type StripeProduct = {
title: string;
description: string;
price: string;
+ usagePrice: string;
+ mainFeatures: string[];
} | null;
};
// map of planid to plan name
export const stripeProducts: StripeProduct[] = [
+ {
+ stripeProductId:
+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "DEV" ||
+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "STAGING"
+ ? "prod_RoBuRrXjIUBIJ8" // test
+ : "prod_RoYirvRQ4Kc6po", // live
+ mappedPlan: "cloud:core",
+ checkout: {
+ title: "Core",
+ description:
+ "Great to get started for most projects with unlimited users and 90 days data access.",
+ price: "$59 / month",
+ usagePrice: "$8/100k events (100k included)",
+ mainFeatures: [
+ "90 days data access",
+ "Unlimited users",
+ "Unlimited evaluators",
+ "Support via Email/Chat",
+ ],
+ },
+ },
{
stripeProductId:
env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "DEV" ||
@@ -24,8 +47,17 @@ export const stripeProducts: StripeProduct[] = [
checkout: {
title: "Pro",
description:
- "For serious projects. Includes access to full history, higher usage and access to features.",
- price: "$59 / month + $10/100k observations",
+ "For projects that scale and need unlimited data access, high rate limits, and Slack support.",
+ price: "$199 / month",
+ usagePrice: "$8/100k events (100k included)",
+ mainFeatures: [
+ "Everything in Core",
+ "Unlimited data access",
+ "Unlimited annotation queues",
+ "High rate limits",
+ "SOC2, ISO27001 reports",
+ "Support via Slack",
+ ],
},
},
{
@@ -37,9 +69,16 @@ export const stripeProducts: StripeProduct[] = [
mappedPlan: "cloud:team",
checkout: {
title: "Team",
- description:
- "Dedicated solutions and support for your team. Contact us for additional add-ons listed on the pricing page.",
- price: "$499 / month + $10/100k observations",
+ description: "Organizational and security controls for larger teams.",
+ price: "$499 / month",
+ usagePrice: "$8/100k events (100k included)",
+ mainFeatures: [
+ "Everything in Pro",
+ "Enterprise SSO (e.g. Okta)",
+ "SSO enforcement",
+ "Fine-grained RBAC",
+ "Data retention management",
+ ],
},
},
];
diff --git a/web/src/ee/features/sso-settings/components/SSOSettings.tsx b/web/src/ee/features/sso-settings/components/SSOSettings.tsx
new file mode 100644
index 0000000000..314fc40e5e
--- /dev/null
+++ b/web/src/ee/features/sso-settings/components/SSOSettings.tsx
@@ -0,0 +1,56 @@
+import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";
+import { AlertCircle } from "lucide-react";
+import { useHasEntitlement } from "@/src/features/entitlements/hooks";
+import Header from "@/src/components/layouts/header";
+
+export const SSOSettings = () => {
+ const hasEntitlement = useHasEntitlement("cloud-multi-tenant-sso");
+
+ const commonContent = (
+ <>
+ <Header title="SSO Configuration" />
+ <p className="mb-4 text-sm text-muted-foreground">
+ Configure Single Sign-On (SSO) for your organization. SSO allows your
+ team to use your existing identity provider for authentication, e.g.
+ Okta, AzureAD/EntraID. Alternatively, you can enforce the use of a
+ public provider such as Google, GitHub and Microsoft.
+ </p>
+ </>
+ );
+
+ if (!hasEntitlement) {
+ return (
+ <div>
+ {commonContent}
+ <Alert>
+ <AlertCircle className="h-4 w-4" />
+ <AlertTitle>Not available</AlertTitle>
+ <AlertDescription>
+ Enterprise SSO and SSO Enforcement are not available on your plan.
+ Please upgrade to access this feature.
+ </AlertDescription>
+ </Alert>
+ </div>
+ );
+ }
+
+ return (
+ <div>
+ {commonContent}
+ <Alert>
+ <AlertCircle className="h-4 w-4" />
+ <AlertTitle>Contact Langfuse Support</AlertTitle>
+ <AlertDescription>
+ To set up or change your SSO configuration, please reach out to{" "}
+ <a
+ href="mailto:[email protected]"
+ className="font-medium underline underline-offset-4"
+ >
+ </a>
+ .
+ </AlertDescription>
+ </Alert>
+ </div>
+ );
+};
diff --git a/web/src/env.mjs b/web/src/env.mjs
index d973967eeb..1dfd650892 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -278,6 +278,7 @@ export const env = createEnv({
LANGFUSE_INIT_ORG_ID: z.string().optional(),
LANGFUSE_INIT_ORG_NAME: z.string().optional(),
+ LANGFUSE_INIT_ORG_CLOUD_PLAN: z.string().optional(), // for use in CI
LANGFUSE_INIT_PROJECT_ID: z.string().optional(),
LANGFUSE_INIT_PROJECT_NAME: z.string().optional(),
LANGFUSE_INIT_PROJECT_RETENTION: z.number().int().gte(7).optional(),
@@ -553,6 +554,7 @@ export const env = createEnv({
// provisioning
LANGFUSE_INIT_ORG_ID: process.env.LANGFUSE_INIT_ORG_ID,
LANGFUSE_INIT_ORG_NAME: process.env.LANGFUSE_INIT_ORG_NAME,
+ LANGFUSE_INIT_ORG_CLOUD_PLAN: process.env.LANGFUSE_INIT_ORG_CLOUD_PLAN,
LANGFUSE_INIT_PROJECT_ID: process.env.LANGFUSE_INIT_PROJECT_ID,
LANGFUSE_INIT_PROJECT_NAME: process.env.LANGFUSE_INIT_PROJECT_NAME,
LANGFUSE_INIT_PROJECT_RETENTION:
diff --git a/web/src/features/entitlements/constants/entitlements.ts b/web/src/features/entitlements/constants/entitlements.ts
index 15f5b4665e..b3f012d903 100644
--- a/web/src/features/entitlements/constants/entitlements.ts
+++ b/web/src/features/entitlements/constants/entitlements.ts
@@ -7,6 +7,7 @@ const entitlements = [
"model-based-evaluations",
"rbac-project-roles",
"cloud-billing",
+ "cloud-multi-tenant-sso",
"integration-posthog",
"annotation-queues",
"self-host-ui-customization",
@@ -63,10 +64,20 @@ export const entitlementAccess: Record<
"prompt-management-count-prompts": false,
},
},
- "cloud:pro": {
+ "cloud:core": {
entitlements: [...cloudAllPlansEntitlements],
entitlementLimits: {
+ "organization-member-count": false,
+ "data-access-days": 90,
"annotation-queue-count": 3,
+ "model-based-evaluations-count-evaluators": false,
+ "prompt-management-count-prompts": false,
+ },
+ },
+ "cloud:pro": {
+ entitlements: [...cloudAllPlansEntitlements],
+ entitlementLimits: {
+ "annotation-queue-count": false,
"organization-member-count": false,
"data-access-days": false,
"model-based-evaluations-count-evaluators": false,
@@ -79,6 +90,7 @@ export const entitlementAccess: Record<
"rbac-project-roles",
"audit-logs",
"data-retention",
+ "cloud-multi-tenant-sso",
],
entitlementLimits: {
"annotation-queue-count": false,
@@ -94,6 +106,7 @@ export const entitlementAccess: Record<
"rbac-project-roles",
"audit-logs",
"data-retention",
+ "cloud-multi-tenant-sso",
],
entitlementLimits: {
"annotation-queue-count": false,
diff --git a/web/src/features/entitlements/server/getPlan.ts b/web/src/features/entitlements/server/getPlan.ts
index fe94a71be4..164bd1511a 100644
--- a/web/src/features/entitlements/server/getPlan.ts
+++ b/web/src/features/entitlements/server/getPlan.ts
@@ -20,12 +20,17 @@ export function getOrganizationPlanServerSide(
switch (cloudConfig.plan) {
case "Hobby":
return "cloud:hobby";
+ case "Core":
+ return "cloud:core";
case "Pro":
return "cloud:pro";
case "Team":
return "cloud:team";
case "Enterprise":
return "cloud:enterprise";
+ default:
+ const exhaustiveCheck: never = cloudConfig.plan;
+ throw new Error(`Unhandled plan case: ${exhaustiveCheck}`);
}
}
// stripe plan via product id
diff --git a/web/src/features/public-api/server/RateLimitService.ts b/web/src/features/public-api/server/RateLimitService.ts
index 871ff4e83c..c4037dad4c 100644
--- a/web/src/features/public-api/server/RateLimitService.ts
+++ b/web/src/features/public-api/server/RateLimitService.ts
@@ -221,18 +221,17 @@ const getPlanBasedRateLimitConfig = (
durationInSec: null,
};
case "cloud:hobby":
- case "cloud:pro":
switch (resource) {
case "ingestion":
return {
resource: "ingestion",
- points: 4000,
+ points: 1000,
durationInSec: 60,
};
case "legacy-ingestion":
return {
- resource: "prompts",
- points: 400,
+ resource: "legacy-ingestion",
+ points: 100,
durationInSec: 60,
};
case "prompts":
@@ -244,31 +243,68 @@ const getPlanBasedRateLimitConfig = (
case "public-api":
return {
resource: "public-api",
- points: 1000,
+ points: 20,
durationInSec: 60,
};
case "public-api-metrics":
return {
resource: "public-api-metrics",
points: 10,
+ durationInSec: 86400, // 10 requests per day
+ };
+ default:
+ const exhaustiveCheck: never = resource;
+ throw new Error(`Unhandled resource case: ${exhaustiveCheck}`);
+ }
+ case "cloud:core":
+ switch (resource) {
+ case "ingestion":
+ return {
+ resource: "ingestion",
+ points: 4000,
+ durationInSec: 60,
+ };
+ case "legacy-ingestion":
+ return {
+ resource: "legacy-ingestion",
+ points: 400,
durationInSec: 60,
};
+ case "prompts":
+ return {
+ resource: "prompts",
+ points: null,
+ durationInSec: null,
+ };
+ case "public-api":
+ return {
+ resource: "public-api",
+ points: 100,
+ durationInSec: 60,
+ };
+ case "public-api-metrics":
+ return {
+ resource: "public-api-metrics",
+ points: 20,
+ durationInSec: 86400, // 20 requests per day
+ };
default:
- const exhaustiveCheckDefault: never = resource;
- throw new Error(`Unhandled resource case: ${exhaustiveCheckDefault}`);
+ const exhaustiveCheck: never = resource;
+ throw new Error(`Unhandled resource case: ${exhaustiveCheck}`);
}
+ case "cloud:pro":
case "cloud:team":
case "cloud:enterprise":
switch (resource) {
case "ingestion":
return {
resource: "ingestion",
- points: 20000,
+ points: 20_000,
durationInSec: 60,
};
case "legacy-ingestion":
return {
- resource: "prompts",
+ resource: "legacy-ingestion",
points: 400,
durationInSec: 60,
};
@@ -287,12 +323,12 @@ const getPlanBasedRateLimitConfig = (
case "public-api-metrics":
return {
resource: "public-api-metrics",
- points: 10,
- durationInSec: 60,
+ points: 200,
+ durationInSec: 86400, // 200 requests per day
};
default:
- const exhaustiveCheckTeam: never = resource;
- throw new Error(`Unhandled resource case: ${exhaustiveCheckTeam}`);
+ const exhaustiveCheck: never = resource;
+ throw new Error(`Unhandled resource case: ${exhaustiveCheck}`);
}
default:
const exhaustiveCheck: never = plan;
diff --git a/web/src/initialize.ts b/web/src/initialize.ts
index 10781813c0..fc3434d8b8 100644
--- a/web/src/initialize.ts
+++ b/web/src/initialize.ts
@@ -4,15 +4,23 @@ import { prisma } from "@langfuse/shared/src/db";
import { createAndAddApiKeysToDb } from "@langfuse/shared/src/server/auth/apiKeys";
import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";
import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";
+import { CloudConfigSchema } from "@langfuse/shared";
// Create Organization
if (env.LANGFUSE_INIT_ORG_ID) {
+ const cloudConfig = env.LANGFUSE_INIT_ORG_CLOUD_PLAN
+ ? CloudConfigSchema.parse({
+ plan: env.LANGFUSE_INIT_ORG_CLOUD_PLAN,
+ })
+ : undefined;
+
const org = await prisma.organization.upsert({
where: { id: env.LANGFUSE_INIT_ORG_ID },
update: {},
create: {
id: env.LANGFUSE_INIT_ORG_ID,
name: env.LANGFUSE_INIT_ORG_NAME ?? "Provisioned Org",
+ cloudConfig,
},
});
diff --git a/web/src/pages/organization/[organizationId]/settings/index.tsx b/web/src/pages/organization/[organizationId]/settings/index.tsx
index e59cfc2b29..1817add54c 100644
--- a/web/src/pages/organization/[organizationId]/settings/index.tsx
+++ b/web/src/pages/organization/[organizationId]/settings/index.tsx
@@ -9,8 +9,10 @@ import { useRouter } from "next/router";
import { SettingsDangerZone } from "@/src/components/SettingsDangerZone";
import { DeleteOrganizationButton } from "@/src/features/organizations/components/DeleteOrganizationButton";
import { BillingSettings } from "@/src/ee/features/billing/components/BillingSettings";
-import { useHasEntitlement } from "@/src/features/entitlements/hooks";
+import { useHasEntitlement, usePlan } from "@/src/features/entitlements/hooks";
import ContainerPage from "@/src/components/layouts/container-page";
+import { SSOSettings } from "@/src/ee/features/sso-settings/components/SSOSettings";
+import { isCloudPlan } from "@langfuse/shared";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
type OrganizationSettingsPage = {
@@ -23,21 +25,26 @@ type OrganizationSettingsPage = {
export function useOrganizationSettingsPages(): OrganizationSettingsPage[] {
const { organization } = useQueryProjectOrOrganization();
const showBillingSettings = useHasEntitlement("cloud-billing");
+ const plan = usePlan();
+ const isLangfuseCloud = isCloudPlan(plan) ?? false;
if (!organization) return [];
return getOrganizationSettingsPages({
organization,
showBillingSettings,
+ isLangfuseCloud,
});
}
export const getOrganizationSettingsPages = ({
organization,
showBillingSettings,
+ isLangfuseCloud,
}: {
organization: { id: string; name: string };
showBillingSettings: boolean;
+ isLangfuseCloud: boolean;
}): OrganizationSettingsPage[] => [
{
title: "General",
@@ -89,6 +96,13 @@ export const getOrganizationSettingsPages = ({
content: <BillingSettings />,
show: showBillingSettings,
},
+ {
+ title: "SSO",
+ slug: "sso",
+ cmdKKeywords: ["sso", "login", "auth", "okta", "saml", "azure"],
+ content: <SSOSettings />,
+ show: isLangfuseCloud,
+ },
{
title: "Projects",
slug: "projects",