Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: gate i18n locale settings behind paid plans (#2010)
Maximilian Kaske48400f907bd4
diff --git a/apps/dashboard/src/components/forms/status-page/form-locale.tsx b/apps/dashboard/src/components/forms/status-page/form-locale.tsxindex 40f9366e1..ac7995998 100644--- a/apps/dashboard/src/components/forms/status-page/form-locale.tsx+++ b/apps/dashboard/src/components/forms/status-page/form-locale.tsx@@ -1,6 +1,7 @@import { useTransition } from "react";import { z } from "zod";+import { Link } from "@/components/common/link";import {FormCard,FormCardContent,@@ -10,6 +11,7 @@ import {FormCardHeader,FormCardSeparator,FormCardTitle,+ FormCardUpgrade,} from "@/components/forms/form-card";import { zodResolver } from "@hookform/resolvers/zod";import { Button } from "@openstatus/ui/components/ui/button";@@ -31,6 +33,7 @@ import {SelectValue,} from "@openstatus/ui/components/ui/select";import { isTRPCClientError } from "@trpc/client";+import { Lock } from "lucide-react";import { useForm } from "react-hook-form";import { toast } from "sonner";@@ -64,9 +67,11 @@ type FormValues = z.infer<typeof schema>;export function FormLocale({defaultValues,onSubmit,+ locked,}: {defaultValues?: FormValues;onSubmit: (values: FormValues) => Promise<void>;+ locked?: boolean;}) {const [isPending, startTransition] = useTransition();const form = useForm<FormValues>({@@ -134,6 +139,7 @@ export function FormLocale({<Form {...form}><form onSubmit={form.handleSubmit(submitAction)}><FormCard>+ {locked ? <FormCardUpgrade /> : null}<FormCardHeader><FormCardTitle>Locales</FormCardTitle><FormCardDescription>@@ -219,9 +225,18 @@ export function FormLocale({When the locale switcher is enabled, visitors can choose theirpreferred language.</FormCardFooterInfo>- <Button type="submit" disabled={isPending}>- {isPending ? "Submitting..." : "Submit"}- </Button>+ {locked ? (+ <Button type="button" asChild>+ <Link href="/settings/billing">+ <Lock className="size-4" />+ Upgrade+ </Link>+ </Button>+ ) : (+ <Button type="submit" disabled={isPending}>+ {isPending ? "Submitting..." : "Submit"}+ </Button>+ )}</FormCardFooter></FormCard></form>diff --git a/apps/dashboard/src/components/forms/status-page/update.tsx b/apps/dashboard/src/components/forms/status-page/update.tsxindex 1277c0129..5bebd7dda 100644--- a/apps/dashboard/src/components/forms/status-page/update.tsx+++ b/apps/dashboard/src/components/forms/status-page/update.tsx@@ -156,6 +156,7 @@ export function FormStatusPageUpdate() {}}/><FormLocale+ locked={workspace.limits.i18n === false}defaultValues={{defaultLocale: statusPage.defaultLocale ?? "en",locales: statusPage.locales,diff --git a/apps/server/src/routes/rpc/services/status-page/__tests__/status-page.test.ts b/apps/server/src/routes/rpc/services/status-page/__tests__/status-page.test.tsindex 050f38d1d..4b9e9bf74 100644--- a/apps/server/src/routes/rpc/services/status-page/__tests__/status-page.test.ts+++ b/apps/server/src/routes/rpc/services/status-page/__tests__/status-page.test.ts@@ -276,6 +276,12 @@ afterAll(async () => {await db.delete(page).where(eq(page.slug, `${TEST_PREFIX}-locale-dedup-slug`));+ await db+ .delete(page)+ .where(eq(page.slug, `${TEST_PREFIX}-i18n-limit-create-slug`));+ await db+ .delete(page)+ .where(eq(page.slug, `${TEST_PREFIX}-i18n-limit-update-slug`));await db.delete(monitor).where(eq(monitor.name, `${TEST_PREFIX}-monitor`));});@@ -829,6 +835,158 @@ describe("StatusPageService locale fields", () => {});});+// ==========================================================================+// i18n Plan Limits+// ==========================================================================++describe("StatusPageService i18n plan limits", () => {+ test("create rejects defaultLocale on free plan", async () => {+ const res = await connectRequest(+ "CreateStatusPage",+ {+ title: `${TEST_PREFIX}-i18n-limit-create`,+ slug: `${TEST_PREFIX}-i18n-limit-create-slug`,+ defaultLocale: "LOCALE_DE",+ },+ { "x-openstatus-key": "2" },+ );++ expect(res.status).toBe(403);++ const data = await res.json();+ expect(data.message).toContain("Upgrade to configure locales");+ });++ test("create rejects locales on free plan", async () => {+ const res = await connectRequest(+ "CreateStatusPage",+ {+ title: `${TEST_PREFIX}-i18n-limit-create`,+ slug: `${TEST_PREFIX}-i18n-limit-create-slug`,+ locales: ["LOCALE_EN", "LOCALE_FR"],+ },+ { "x-openstatus-key": "2" },+ );++ expect(res.status).toBe(403);++ const data = await res.json();+ expect(data.message).toContain("Upgrade to configure locales");+ });++ test("update rejects defaultLocale on free plan", async () => {+ // Create a page for workspace 2+ const testPage = await db+ .insert(page)+ .values({+ workspaceId: 2,+ title: `${TEST_PREFIX}-i18n-limit-update`,+ slug: `${TEST_PREFIX}-i18n-limit-update-slug`,+ description: "",+ customDomain: "",+ })+ .returning()+ .get();++ try {+ const res = await connectRequest(+ "UpdateStatusPage",+ {+ id: String(testPage.id),+ defaultLocale: "LOCALE_FR",+ },+ { "x-openstatus-key": "2" },+ );++ expect(res.status).toBe(403);++ const data = await res.json();+ expect(data.message).toContain("Upgrade to configure locales");+ } finally {+ await db.delete(page).where(eq(page.id, testPage.id));+ }+ });++ test("update rejects locales on free plan", async () => {+ // Create a page for workspace 2+ const testPage = await db+ .insert(page)+ .values({+ workspaceId: 2,+ title: `${TEST_PREFIX}-i18n-limit-update`,+ slug: `${TEST_PREFIX}-i18n-limit-update-slug`,+ description: "",+ customDomain: "",+ })+ .returning()+ .get();++ try {+ const res = await connectRequest(+ "UpdateStatusPage",+ {+ id: String(testPage.id),+ locales: ["LOCALE_EN", "LOCALE_FR"],+ },+ { "x-openstatus-key": "2" },+ );++ expect(res.status).toBe(403);++ const data = await res.json();+ expect(data.message).toContain("Upgrade to configure locales");+ } finally {+ await db.delete(page).where(eq(page.id, testPage.id));+ }+ });++ test("create allows locale settings on paid plan", async () => {+ const res = await connectRequest(+ "CreateStatusPage",+ {+ title: `${TEST_PREFIX}-i18n-limit-create`,+ slug: `${TEST_PREFIX}-i18n-limit-create-slug`,+ defaultLocale: "LOCALE_DE",+ locales: ["LOCALE_EN", "LOCALE_DE"],+ },+ { "x-openstatus-key": "1" },+ );++ expect(res.status).toBe(200);++ const data = await res.json();+ expect(data.statusPage.defaultLocale).toBe("LOCALE_DE");+ expect(data.statusPage.locales).toEqual(["LOCALE_EN", "LOCALE_DE"]);++ // Clean up+ await db.delete(page).where(eq(page.id, Number(data.statusPage.id)));+ });++ test("update allows locale settings on paid plan", async () => {+ const res = await connectRequest(+ "UpdateStatusPage",+ {+ id: String(testPageToUpdateId),+ defaultLocale: "LOCALE_FR",+ locales: ["LOCALE_EN", "LOCALE_FR"],+ },+ { "x-openstatus-key": "1" },+ );++ expect(res.status).toBe(200);++ const data = await res.json();+ expect(data.statusPage.defaultLocale).toBe("LOCALE_FR");+ expect(data.statusPage.locales).toEqual(["LOCALE_EN", "LOCALE_FR"]);++ // Restore defaults+ await db+ .update(page)+ .set({ defaultLocale: "en", locales: null })+ .where(eq(page.id, testPageToUpdateId));+ });+});+describe("StatusPageService.DeleteStatusPage", () => {test("successfully deletes existing status page", async () => {const res = await connectRequest(diff --git a/apps/server/src/routes/rpc/services/status-page/index.ts b/apps/server/src/routes/rpc/services/status-page/index.tsindex 457ecc79f..80d075d3c 100644--- a/apps/server/src/routes/rpc/services/status-page/index.ts+++ b/apps/server/src/routes/rpc/services/status-page/index.ts@@ -158,6 +158,22 @@ export const statusPageServiceImpl: ServiceImpl<typeof StatusPageService> = {throw slugAlreadyExistsError(req.slug);}+ // Check i18n limits+ if (!limits.i18n) {+ if (req.defaultLocale !== undefined && req.defaultLocale !== 0) {+ throw new ConnectError(+ "Upgrade to configure locales.",+ Code.PermissionDenied,+ );+ }+ if (req.locales.length > 0) {+ throw new ConnectError(+ "Upgrade to configure locales.",+ Code.PermissionDenied,+ );+ }+ }+// Resolve locale valuesconst defaultLocale =req.defaultLocale !== undefined && req.defaultLocale !== 0@@ -258,12 +274,29 @@ export const statusPageServiceImpl: ServiceImpl<typeof StatusPageService> = {async updateStatusPage(req, ctx) {const rpcCtx = getRpcContext(ctx);const workspaceId = rpcCtx.workspace.id;+ const limits = rpcCtx.workspace.limits;const id = req.id?.trim();if (!id) {throw statusPageIdRequiredError();}+ // Check i18n limits+ if (!limits.i18n) {+ if (req.defaultLocale !== undefined && req.defaultLocale !== 0) {+ throw new ConnectError(+ "Upgrade to configure locales.",+ Code.PermissionDenied,+ );+ }+ if (req.locales.length > 0) {+ throw new ConnectError(+ "Upgrade to configure locales.",+ Code.PermissionDenied,+ );+ }+ }+const pageData = await getPageById(Number(id), workspaceId);if (!pageData) {throw statusPageNotFoundError(id);diff --git a/apps/web/src/content/pages/unrelated/pricing.mdx b/apps/web/src/content/pages/unrelated/pricing.mdxindex ab8d52388..b7eb08562 100644--- a/apps/web/src/content/pages/unrelated/pricing.mdx+++ b/apps/web/src/content/pages/unrelated/pricing.mdx@@ -32,6 +32,7 @@ faq:| Toggle numbers visibility | + | + | + || Subscribers | | + | + || Custom domain | | + | + |+| Locale switcher | | + | + || Slack Agent | | + | + || White Label | | $300/mo. | $300/mo. || **Audience** | | | |diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.tsindex 227386eeb..4e5442a30 100644--- a/packages/api/src/router/page.ts+++ b/packages/api/src/router/page.ts@@ -592,6 +592,13 @@ export const pageRouter = createTRPCRouter({),).mutation(async (opts) => {+ if (!opts.ctx.workspace.limits.i18n) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "Upgrade to configure locales.",+ });+ }+const whereConditions: SQL[] = [eq(page.workspaceId, opts.ctx.workspace.id),eq(page.id, opts.input.id),diff --git a/packages/db/src/schema/plan/config.ts b/packages/db/src/schema/plan/config.tsindex 07742c564..49737340a 100644--- a/packages/db/src/schema/plan/config.ts+++ b/packages/db/src/schema/plan/config.ts@@ -45,6 +45,7 @@ export const allPlans: Record<WorkspacePlan, PlanConfig> = {otel: false,"status-subscribers": false,"custom-domain": false,+ i18n: false,"password-protection": false,"email-domain-protection": false,"white-label": false,@@ -119,6 +120,7 @@ export const allPlans: Record<WorkspacePlan, PlanConfig> = {otel: false,"status-subscribers": true,"custom-domain": true,+ i18n: true,"password-protection": true,"email-domain-protection": false,"white-label": false,@@ -193,6 +195,7 @@ export const allPlans: Record<WorkspacePlan, PlanConfig> = {otel: true,"status-subscribers": true,"custom-domain": true,+ i18n: true,"password-protection": true,"email-domain-protection": false,"white-label": false,diff --git a/packages/db/src/schema/plan/schema.ts b/packages/db/src/schema/plan/schema.tsindex d7b23eafe..806c9304c 100644--- a/packages/db/src/schema/plan/schema.ts+++ b/packages/db/src/schema/plan/schema.ts@@ -32,6 +32,7 @@ export const limitsSchema = z.object({"monitor-values-visibility": z.boolean().prefault(true),"status-subscribers": z.boolean().prefault(false),"custom-domain": z.boolean().prefault(false),+ i18n: z.boolean().prefault(false),"password-protection": z.boolean().prefault(false),"email-domain-protection": z.boolean().prefault(false), // add-on but required in limits"white-label": z.boolean().prefault(false),