Skip to content

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

chore(billing): enable free tier usage threshold enforcement (#9767)

Michael Fröhlich90201a972d0e
diff --git a/packages/shared/src/server/services/email/usageThresholdSuspension/sendUsageThresholdSuspensionEmail.ts b/packages/shared/src/server/services/email/usageThresholdSuspension/sendUsageThresholdSuspensionEmail.ts
index 63c399c8da..cc9d59bbdd 100644
--- a/packages/shared/src/server/services/email/usageThresholdSuspension/sendUsageThresholdSuspensionEmail.ts
+++ b/packages/shared/src/server/services/email/usageThresholdSuspension/sendUsageThresholdSuspensionEmail.ts
@@ -1,7 +1,8 @@
import { createTransport } from "nodemailer";
import { parseConnectionUrl } from "nodemailer/lib/shared/index.js";
import { render } from "@react-email/render";
-import { UsageThresholdUpcomingEnforcementEmailTemplate } from "./UsageThresholdUpcomingEnforcementEmailTemplate";
+// import { UsageThresholdUpcomingEnforcementEmailTemplate } from "./UsageThresholdUpcomingEnforcementEmailTemplate";
+import { UsageThresholdSuspensionEmailTemplate } from "./UsageThresholdSuspensionEmailTemplate";
import { logger } from "../../../logger";
import { z } from "zod/v4";
@@ -42,9 +43,10 @@ export const sendUsageThresholdSuspensionEmail = async ({
try {
const mailer = createTransport(parseConnectionUrl(env.SMTP_CONNECTION_URL));
- const emailSubject = `🚨 URGENT: Action required for ${organizationName} - enforcement begins next week`;
+ // const emailSubject = `🚨 URGENT: Action required for ${organizationName} - enforcement begins next week`;
+ const emailSubject = `🚨 URGENT: Langfuse ingestion suspended for ${organizationName}`;
const emailHtml = await render(
- UsageThresholdUpcomingEnforcementEmailTemplate({
+ UsageThresholdSuspensionEmailTemplate({
organizationName,
currentUsage,
limit,
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.ts
index 3a68c9194e..dba24e4f72 100644
--- a/web/src/pages/api/public/ingestion.ts
+++ b/web/src/pages/api/public/ingestion.ts
@@ -15,6 +15,7 @@ import {
MethodNotAllowedError,
BaseError,
UnauthorizedError,
+ ForbiddenError,
} from "@langfuse/shared";
import { processEventBatch } from "@langfuse/shared/src/server";
import { prisma } from "@langfuse/shared/src/db";
@@ -85,12 +86,12 @@ export default async function handler(
"Missing projectId in scope. Are you using an organization key?",
);
}
- // TODO: Uncomment once we enabled ingestion suspension
- // if (authCheck.scope.isIngestionSuspended) {
- // throw new ForbiddenError(
- // "Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
- // );
- // }
+
+ if (authCheck.scope.isIngestionSuspended) {
+ throw new ForbiddenError(
+ "Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
+ );
+ }
const ctx = contextWithLangfuseProps({
headers: req.headers,
diff --git a/web/src/pages/api/public/media/index.ts b/web/src/pages/api/public/media/index.ts
index e6ac5d8945..07786ba248 100644
--- a/web/src/pages/api/public/media/index.ts
+++ b/web/src/pages/api/public/media/index.ts
@@ -27,12 +27,11 @@ export default withMiddlewares({
rateLimitResource: "ingestion",
fn: async ({ body, auth }) => {
// Check if ingestion is suspended due to usage threshold
- // TODO: Uncomment once we enabled ingestion suspension
- // if (auth.scope.isIngestionSuspended) {
- // throw new ForbiddenError(
- // "Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
- // );
- // }
+ if (auth.scope.isIngestionSuspended) {
+ throw new ForbiddenError(
+ "Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
+ );
+ }
if (auth.scope.accessLevel !== "project") throw new ForbiddenError();
diff --git a/web/src/pages/api/public/otel/v1/traces/index.ts b/web/src/pages/api/public/otel/v1/traces/index.ts
index bc14a10670..0ba0b78df3 100644
--- a/web/src/pages/api/public/otel/v1/traces/index.ts
+++ b/web/src/pages/api/public/otel/v1/traces/index.ts
@@ -4,6 +4,7 @@ import { logger, OtelIngestionProcessor } from "@langfuse/shared/src/server";
import { z } from "zod/v4";
import { $root } from "@/src/pages/api/public/otel/otlp-proto/generated/root";
import { gunzip } from "node:zlib";
+import { ForbiddenError } from "@langfuse/shared";
export const config = {
api: {
@@ -19,12 +20,11 @@ export default withMiddlewares({
rateLimitResource: "ingestion",
fn: async ({ req, res, auth }) => {
// Check if ingestion is suspended due to usage threshold
- // TODO: Uncomment once we enabled ingestion suspension
- // if (auth.scope.isIngestionSuspended) {
- // throw new ForbiddenError(
- // "Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
- // );
- // }
+ if (auth.scope.isIngestionSuspended) {
+ throw new ForbiddenError(
+ "Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
+ );
+ }
let body: Buffer;
try {