Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Custom tiers (#915)

Goldflag5e4aa413b16a
diff --git a/client/messages/cs.json b/client/messages/cs.json
index 68c52998a..404fb646b 100644
--- a/client/messages/cs.json
+++ b/client/messages/cs.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Blížíš se k měsíčnímu limitu událostí. Zvaž upgrade na placený plán pro vyšší limity.",
"wbsq7O": "Využití",
"ja2Zok": "Upgradovat na Pro",
+ "rd5F5r": "",
+ "kdqPM0": "Máš vlastní plán s až {limit} zobrazeními stránek měsíčně.",
+ "kTH3Q2": "Překročil jsi měsíční limit událostí. Pro pomoc prosím kontaktuj podporu.",
+ "ni0MP6": "Blížíš se k měsíčnímu limitu událostí. Pokud potřebuješ více kapacity, kontaktuj prosím podporu.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "Tvá 14denní zkušební verze skončila. Pro pokračování sledování návštěv se musíš přihlásit k odběru.",
"UEl0Sh": "Zkušební verze vypršela",
"LB/Amg": "Tvá zkušební verze vypršela. Pro pokračování sledování návštěv se přihlas k plánu.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Bezplatný plán",
"5yu28t": "Máš bezplatný plán s až {limit} zobrazeními stránek měsíčně.",
"pqJqst": "Plán {plan}",
- "kdqPM0": "Máš vlastní plán s až {limit} zobrazeními stránek měsíčně.",
- "kTH3Q2": "Překročil jsi měsíční limit událostí. Pro pomoc prosím kontaktuj podporu.",
- "ni0MP6": "Blížíš se k měsíčnímu limitu událostí. Pokud potřebuješ více kapacity, kontaktuj prosím podporu.",
"OtO9EF": "Přidej štítky pro organizaci a filtrování tvých webů.",
"ACKiA3": "Zatím žádné štítky",
"B1SDE1": "Napiš nový štítek...",
diff --git a/client/messages/de.json b/client/messages/de.json
index e80ab44d3..1fcd7e5b1 100644
--- a/client/messages/de.json
+++ b/client/messages/de.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Sie nähern sich Ihrem monatlichen Event-Limit. Erwägen Sie ein Upgrade auf einen kostenpflichtigen Plan für höhere Limits.",
"wbsq7O": "Nutzung",
"ja2Zok": "Auf Pro upgraden",
+ "rd5F5r": "",
+ "kdqPM0": "Sie haben einen individuellen Plan mit bis zu {limit} Seitenaufrufen pro Monat.",
+ "kTH3Q2": "Sie haben Ihr monatliches Event-Limit überschritten. Bitte kontaktieren Sie den Support.",
+ "ni0MP6": "Sie nähern sich Ihrem monatlichen Event-Limit. Bitte kontaktieren Sie den Support, falls Sie mehr Kapazität benötigen.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "Ihre 14-tägige kostenlose Testphase ist beendet. Sie müssen abonnieren, um erneut Besuche zu verfolgen.",
"UEl0Sh": "Testphase abgelaufen",
"LB/Amg": "Ihre kostenlose Testphase ist abgelaufen. Abonnieren Sie einen Plan, um erneut Besuche zu verfolgen.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Kostenloser Plan",
"5yu28t": "Sie sind im kostenlosen Plan mit bis zu {limit} Seitenaufrufen pro Monat.",
"pqJqst": "{plan}-Plan",
- "kdqPM0": "Sie haben einen individuellen Plan mit bis zu {limit} Seitenaufrufen pro Monat.",
- "kTH3Q2": "Sie haben Ihr monatliches Event-Limit überschritten. Bitte kontaktieren Sie den Support.",
- "ni0MP6": "Sie nähern sich Ihrem monatlichen Event-Limit. Bitte kontaktieren Sie den Support, falls Sie mehr Kapazität benötigen.",
"OtO9EF": "Fügen Sie Tags hinzu, um Ihre Websites zu organisieren und zu filtern.",
"ACKiA3": "Noch keine Tags hinzugefügt",
"B1SDE1": "Neuen Tag eingeben...",
diff --git a/client/messages/en.json b/client/messages/en.json
index 1434e09a3..69981ea29 100644
--- a/client/messages/en.json
+++ b/client/messages/en.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "You are approaching your monthly event limit. Consider upgrading to a paid plan for higher limits.",
"wbsq7O": "Usage",
"ja2Zok": "Upgrade To Pro",
+ "rd5F5r": "Custom Plan",
+ "kdqPM0": "You have a custom plan with up to {limit} pageviews per month.",
+ "kTH3Q2": "You have exceeded your monthly event limit. Please contact support for assistance.",
+ "ni0MP6": "You are approaching your monthly event limit. Please contact support if you need more capacity.",
+ "5/hIKX": "Plan Limits",
+ "BdV5Om": "Websites",
+ "HCYBYT": "Team Members",
"yBFhF6": "Your 14-day free trial has ended. You need to subscribe to continue tracking visits again.",
"UEl0Sh": "Trial Expired",
"LB/Amg": "Your free trial has expired. Subscribe to a plan to continue tracking visits again.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Free Plan",
"5yu28t": "You are on the Free plan with up to {limit} pageviews per month.",
"pqJqst": "{plan} Plan",
- "kdqPM0": "You have a custom plan with up to {limit} pageviews per month.",
- "kTH3Q2": "You have exceeded your monthly event limit. Please contact support for assistance.",
- "ni0MP6": "You are approaching your monthly event limit. Please contact support if you need more capacity.",
"OtO9EF": "Add tags to organize and filter your sites.",
"ACKiA3": "No tags added yet",
"B1SDE1": "Type a new tag...",
diff --git a/client/messages/es.json b/client/messages/es.json
index 235393731..b854ecd38 100644
--- a/client/messages/es.json
+++ b/client/messages/es.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Te estás acercando a tu límite de eventos mensuales. Considera actualizar a un plan de pago para obtener límites más altos.",
"wbsq7O": "Uso",
"ja2Zok": "Actualizar a Pro",
+ "rd5F5r": "",
+ "kdqPM0": "Tienes un plan personalizado con hasta {limit} visitas por mes.",
+ "kTH3Q2": "Has excedido tu límite mensual de eventos. Por favor, contacta con soporte para obtener ayuda.",
+ "ni0MP6": "Te estás acercando a tu límite mensual de eventos. Por favor, contacta con soporte si necesitas más capacidad.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "Tu prueba gratuita de 14 días ha finalizado. Necesitas suscribirte para continuar rastreando visitas nuevamente.",
"UEl0Sh": "Prueba expirada",
"LB/Amg": "Tu prueba gratuita ha expirado. Suscríbete a un plan para continuar rastreando visitas nuevamente.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Plan Gratuito",
"5yu28t": "Estás en el plan Gratuito con hasta {limit} visitas por mes.",
"pqJqst": "Plan {plan}",
- "kdqPM0": "Tienes un plan personalizado con hasta {limit} visitas por mes.",
- "kTH3Q2": "Has excedido tu límite mensual de eventos. Por favor, contacta con soporte para obtener ayuda.",
- "ni0MP6": "Te estás acercando a tu límite mensual de eventos. Por favor, contacta con soporte si necesitas más capacidad.",
"OtO9EF": "Añade etiquetas para organizar y filtrar tus sitios.",
"ACKiA3": "No se han añadido etiquetas todavía",
"B1SDE1": "Escribe una nueva etiqueta...",
diff --git a/client/messages/fr.json b/client/messages/fr.json
index 8a8596bbf..923101a51 100644
--- a/client/messages/fr.json
+++ b/client/messages/fr.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Vous approchez de votre limite mensuelle d'événements. Envisagez de passer à un plan payant pour des limites plus élevées.",
"wbsq7O": "Utilisation",
"ja2Zok": "Passer à Pro",
+ "rd5F5r": "",
+ "kdqPM0": "Vous avez un plan personnalisé avec jusqu'à {limit} pages vues par mois.",
+ "kTH3Q2": "Vous avez dépassé votre limite mensuelle d'événements. Veuillez contacter le support.",
+ "ni0MP6": "Vous approchez de votre limite mensuelle d'événements. Veuillez contacter le support si vous avez besoin de plus de capacité.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "Votre essai gratuit de 14 jours est terminé. Vous devez vous abonner pour recommencer à suivre les visites.",
"UEl0Sh": "Essai expiré",
"LB/Amg": "Votre essai gratuit a expiré. Abonnez-vous à un plan pour recommencer à suivre les visites.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Plan gratuit",
"5yu28t": "Vous êtes sur le plan gratuit avec jusqu'à {limit} pages vues par mois.",
"pqJqst": "Plan {plan}",
- "kdqPM0": "Vous avez un plan personnalisé avec jusqu'à {limit} pages vues par mois.",
- "kTH3Q2": "Vous avez dépassé votre limite mensuelle d'événements. Veuillez contacter le support.",
- "ni0MP6": "Vous approchez de votre limite mensuelle d'événements. Veuillez contacter le support si vous avez besoin de plus de capacité.",
"OtO9EF": "Ajoutez des tags pour organiser et filtrer vos sites.",
"ACKiA3": "Aucun tag ajouté pour le moment",
"B1SDE1": "Saisir un nouveau tag...",
diff --git a/client/messages/it.json b/client/messages/it.json
index d665ca00c..a82a41a68 100644
--- a/client/messages/it.json
+++ b/client/messages/it.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Ti stai avvicinando al tuo limite di eventi mensili. Considera di passare a un piano a pagamento per limiti superiori.",
"wbsq7O": "Utilizzo",
"ja2Zok": "Passa a Pro",
+ "rd5F5r": "",
+ "kdqPM0": "Hai un piano personalizzato con fino a {limit} visualizzazioni di pagina al mese.",
+ "kTH3Q2": "Hai superato il tuo limite di eventi mensili. Contatta il supporto per assistenza.",
+ "ni0MP6": "Ti stai avvicinando al tuo limite di eventi mensili. Contatta il supporto se hai bisogno di maggiore capacità.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "La tua prova gratuita di 14 giorni è terminata. Devi abbonarti per continuare a tracciare di nuovo le visite.",
"UEl0Sh": "Prova Scaduta",
"LB/Amg": "La tua prova gratuita è scaduta. Abbonati a un piano per continuare a tracciare di nuovo le visite.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Piano Gratuito",
"5yu28t": "Sei sul piano Gratuito con fino a {limit} visualizzazioni di pagina al mese.",
"pqJqst": "Piano {plan}",
- "kdqPM0": "Hai un piano personalizzato con fino a {limit} visualizzazioni di pagina al mese.",
- "kTH3Q2": "Hai superato il tuo limite di eventi mensili. Contatta il supporto per assistenza.",
- "ni0MP6": "Ti stai avvicinando al tuo limite di eventi mensili. Contatta il supporto se hai bisogno di maggiore capacità.",
"OtO9EF": "Aggiungi tag per organizzare e filtrare i tuoi siti.",
"ACKiA3": "Nessun tag aggiunto ancora",
"B1SDE1": "Digita un nuovo tag...",
diff --git a/client/messages/ja.json b/client/messages/ja.json
index 9a923d97c..417f821bf 100644
--- a/client/messages/ja.json
+++ b/client/messages/ja.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "月間イベント上限に近づいています。より高い上限にするには有料プランへのアップグレードをご検討ください。",
"wbsq7O": "使用量",
"ja2Zok": "Proにアップグレード",
+ "rd5F5r": "",
+ "kdqPM0": "カスタムプランで月{limit}ページビューまでご利用いただけます。",
+ "kTH3Q2": "月間イベント上限を超えました。サポートにお問い合わせください。",
+ "ni0MP6": "月間イベント上限に近づいています。容量を増やす必要がある場合はサポートにお問い合わせください。",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "14日間の無料トライアルが終了しました。訪問の追跡を再開するにはサブスクリプションが必要です。",
"UEl0Sh": "トライアル期限切れ",
"LB/Amg": "無料トライアルが期限切れになりました。訪問の追跡を再開するにはプランをサブスクリプションしてください。",
@@ -1133,9 +1140,6 @@
"fKrHaE": "無料プラン",
"5yu28t": "無料プランで月{limit}ページビューまでご利用いただけます。",
"pqJqst": "{plan}プラン",
- "kdqPM0": "カスタムプランで月{limit}ページビューまでご利用いただけます。",
- "kTH3Q2": "月間イベント上限を超えました。サポートにお問い合わせください。",
- "ni0MP6": "月間イベント上限に近づいています。容量を増やす必要がある場合はサポートにお問い合わせください。",
"OtO9EF": "タグを追加してサイトを整理・フィルターしましょう。",
"ACKiA3": "タグがまだ追加されていません",
"B1SDE1": "新しいタグを入力...",
diff --git a/client/messages/ko.json b/client/messages/ko.json
index 17dd0428f..0fcd85756 100644
--- a/client/messages/ko.json
+++ b/client/messages/ko.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "월별 이벤트 한도에 근접하고 있습니다. 더 높은 한도를 위해 유료 플랜으로 업그레이드를 고려하세요.",
"wbsq7O": "사용량",
"ja2Zok": "Pro로 업그레이드",
+ "rd5F5r": "",
+ "kdqPM0": "월 최대 {limit}개 페이지뷰의 사용자 정의 플랜입니다.",
+ "kTH3Q2": "월별 이벤트 한도를 초과했습니다. 지원팀에 문의해 주세요.",
+ "ni0MP6": "월별 이벤트 한도에 근접하고 있습니다. 더 많은 용량이 필요하시면 지원팀에 문의해 주세요.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "14일 무료 체험이 종료되었습니다. 방문 추적을 계속하려면 구독이 필요합니다.",
"UEl0Sh": "체험 만료",
"LB/Amg": "무료 체험이 만료되었습니다. 방문 추적을 계속하려면 플랜을 구독하세요.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "무료 플랜",
"5yu28t": "월 최대 {limit}개 페이지뷰의 무료 플랜을 사용 중입니다.",
"pqJqst": "{plan} 플랜",
- "kdqPM0": "월 최대 {limit}개 페이지뷰의 사용자 정의 플랜입니다.",
- "kTH3Q2": "월별 이벤트 한도를 초과했습니다. 지원팀에 문의해 주세요.",
- "ni0MP6": "월별 이벤트 한도에 근접하고 있습니다. 더 많은 용량이 필요하시면 지원팀에 문의해 주세요.",
"OtO9EF": "사이트를 정리하고 필터링하기 위해 태그를 추가하세요.",
"ACKiA3": "아직 추가된 태그 없음",
"B1SDE1": "새 태그 입력...",
diff --git a/client/messages/pl.json b/client/messages/pl.json
index 88e96f2f6..a65152175 100644
--- a/client/messages/pl.json
+++ b/client/messages/pl.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Zbliżasz się do miesięcznego limitu zdarzeń. Rozważ ulepszenie do płatnego planu dla wyższych limitów.",
"wbsq7O": "Wykorzystanie",
"ja2Zok": "Ulepsz do Pro",
+ "rd5F5r": "",
+ "kdqPM0": "Masz niestandardowy plan z limitem do {limit} odsłon miesięcznie.",
+ "kTH3Q2": "Przekroczyłeś swój miesięczny limit zdarzeń. Skontaktuj się z pomocą techniczną.",
+ "ni0MP6": "Zbliżasz się do miesięcznego limitu zdarzeń. Skontaktuj się z pomocą techniczną, jeśli potrzebujesz większej pojemności.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "Twoja 14-dniowa darmowa wersja próbna się zakończyła. Musisz subskrybować, aby ponownie śledzić odwiedziny.",
"UEl0Sh": "Wersja próbna wygasła",
"LB/Amg": "Twoja darmowa wersja próbna wygasła. Subskrybuj plan, aby ponownie śledzić odwiedziny.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Darmowy plan",
"5yu28t": "Jesteś na darmowym planie z limitem do {limit} odsłon miesięcznie.",
"pqJqst": "Plan {plan}",
- "kdqPM0": "Masz niestandardowy plan z limitem do {limit} odsłon miesięcznie.",
- "kTH3Q2": "Przekroczyłeś swój miesięczny limit zdarzeń. Skontaktuj się z pomocą techniczną.",
- "ni0MP6": "Zbliżasz się do miesięcznego limitu zdarzeń. Skontaktuj się z pomocą techniczną, jeśli potrzebujesz większej pojemności.",
"OtO9EF": "Dodaj tagi, aby organizować i filtrować swoje strony.",
"ACKiA3": "Brak dodanych tagów",
"B1SDE1": "Wpisz nowy tag...",
diff --git a/client/messages/pt.json b/client/messages/pt.json
index 22ac57847..512269ac0 100644
--- a/client/messages/pt.json
+++ b/client/messages/pt.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "Você está se aproximando do seu limite mensal de eventos. Considere atualizar para um plano pago para limites maiores.",
"wbsq7O": "Uso",
"ja2Zok": "Atualizar Para Pro",
+ "rd5F5r": "",
+ "kdqPM0": "Você tem um plano personalizado com até {limit} visualizações de página por mês.",
+ "kTH3Q2": "Você excedeu seu limite mensal de eventos. Por favor, entre em contato com o suporte para assistência.",
+ "ni0MP6": "Você está se aproximando do seu limite mensal de eventos. Por favor, entre em contato com o suporte se precisar de mais capacidade.",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "Seu teste gratuito de 14 dias acabou. Você precisa assinar para continuar rastreando visitas novamente.",
"UEl0Sh": "Teste Expirado",
"LB/Amg": "Seu teste gratuito expirou. Assine um plano para continuar rastreando visitas novamente.",
@@ -1133,9 +1140,6 @@
"fKrHaE": "Plano Gratuito",
"5yu28t": "Você está no plano Gratuito com até {limit} visualizações de página por mês.",
"pqJqst": "Plano {plan}",
- "kdqPM0": "Você tem um plano personalizado com até {limit} visualizações de página por mês.",
- "kTH3Q2": "Você excedeu seu limite mensal de eventos. Por favor, entre em contato com o suporte para assistência.",
- "ni0MP6": "Você está se aproximando do seu limite mensal de eventos. Por favor, entre em contato com o suporte se precisar de mais capacidade.",
"OtO9EF": "Adicione tags para organizar e filtrar seus sites.",
"ACKiA3": "Nenhuma tag adicionada ainda",
"B1SDE1": "Digite uma nova tag...",
diff --git a/client/messages/zh.json b/client/messages/zh.json
index ed36884d3..145174a5b 100644
--- a/client/messages/zh.json
+++ b/client/messages/zh.json
@@ -1126,6 +1126,13 @@
"S7U3Nx": "您正在接近每月的事件限制。考虑升级到付费计划以获得更高的额度。",
"wbsq7O": "使用情况",
"ja2Zok": "升级到 Pro",
+ "rd5F5r": "",
+ "kdqPM0": "您拥有一个定制计划,每月最高可达 {limit} 次页面浏览量。",
+ "kTH3Q2": "您已超出每月的事件限制。请联系支持以获得帮助。",
+ "ni0MP6": "您正在接近每月的事件限制。如果您需要更多容量,请联系支持。",
+ "5/hIKX": "",
+ "BdV5Om": "",
+ "HCYBYT": "",
"yBFhF6": "您的 14 天免费试用已结束。您需要订阅以继续追踪访问情况。",
"UEl0Sh": "试用期满",
"LB/Amg": "您的免费试用已过期。订阅计划以继续追踪访问情况。",
@@ -1133,9 +1140,6 @@
"fKrHaE": "免费计划",
"5yu28t": "您目前处于免费计划,每月最高可达 {limit} 次页面浏览量。",
"pqJqst": "{plan} 计划",
- "kdqPM0": "您拥有一个定制计划,每月最高可达 {limit} 次页面浏览量。",
- "kTH3Q2": "您已超出每月的事件限制。请联系支持以获得帮助。",
- "ni0MP6": "您正在接近每月的事件限制。如果您需要更多容量,请联系支持。",
"OtO9EF": "添加标签以组织和过滤您的网站。",
"ACKiA3": "尚未添加标签",
"B1SDE1": "输入新标签...",
diff --git a/client/src/app/components/AddSite.tsx b/client/src/app/components/AddSite.tsx
index 0f8ca0b4a..f179d3abb 100644
--- a/client/src/app/components/AddSite.tsx
+++ b/client/src/app/components/AddSite.tsx
@@ -1,7 +1,6 @@
"use client";
import { Button } from "@/components/ui/button";
import { AlertCircle, AppWindow, Plus } from "lucide-react";
-import { DateTime } from "luxon";
import { useExtracted } from "next-intl";
import { useRouter } from "next/navigation";
import { useState } from "react";
@@ -22,49 +21,11 @@ import { Label } from "../../components/ui/label";
import { Switch } from "../../components/ui/switch";
import { Tooltip, TooltipContent, TooltipTrigger } from "../../components/ui/tooltip";
import { authClient } from "../../lib/auth";
-import { BASIC_SITE_LIMIT, FREE_SITE_LIMIT, IS_CLOUD, STANDARD_SITE_LIMIT } from "../../lib/const";
+import { IS_CLOUD } from "../../lib/const";
import { resetStore, useStore } from "../../lib/store";
-import { SubscriptionData, useStripeSubscription } from "../../lib/subscription/useStripeSubscription";
+import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";
import { isValidDomain, normalizeDomain } from "../../lib/utils";
-const getSiteLimit = (subscription: SubscriptionData | undefined) => {
- if (subscription?.planName.includes("basic")) {
- return BASIC_SITE_LIMIT;
- }
- if (subscription?.planName.includes("standard")) {
- // grant unlimited sites to organizations created before June 27, 2025
- if (
- subscription?.createdAt &&
- DateTime.fromISO(subscription.createdAt) < DateTime.fromFormat("2025-06-27", "yyyy-MM-dd")
- ) {
- return Infinity;
- }
- return STANDARD_SITE_LIMIT;
- }
- if (subscription?.planName.includes("pro")) {
- return Infinity;
- }
- if (subscription?.planName === "appsumo-1") {
- return 3;
- }
- if (subscription?.planName === "appsumo-2") {
- return 10;
- }
- if (subscription?.planName === "appsumo-3") {
- return 25;
- }
- if (subscription?.planName === "appsumo-4") {
- return 50;
- }
- if (subscription?.planName === "appsumo-5") {
- return 100;
- }
- if (subscription?.planName === "appsumo-6") {
- return Infinity;
- }
- return FREE_SITE_LIMIT;
-};
-
export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disabled?: boolean }) {
const { setSite } = useStore();
const router = useRouter();
@@ -74,7 +35,8 @@ export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disa
const { data: sites, refetch } = useGetSitesFromOrg(activeOrganization?.id);
const { data: subscription } = useStripeSubscription();
- const isOverSiteLimit = getSiteLimit(subscription) <= (sites?.sites?.length || 0) && IS_CLOUD;
+ const siteLimit = subscription?.siteLimit ?? null;
+ const isOverSiteLimit = IS_CLOUD && siteLimit !== null && (sites?.sites?.length || 0) >= siteLimit;
const finalDisabled = disabled || isOverSiteLimit;
@@ -156,7 +118,7 @@ export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disa
)}
</TooltipTrigger>
<TooltipContent>
- {t("You have reached the limit of {limit} websites. Upgrade to add more websites", { limit: String(getSiteLimit(subscription)) })}
+ {t("You have reached the limit of {limit} websites. Upgrade to add more websites", { limit: String(siteLimit) })}
</TooltipContent>
</Tooltip>
);
diff --git a/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx b/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx
index 6317a4e4b..225ba8147 100644
--- a/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx
+++ b/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx
@@ -24,8 +24,8 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { Alert } from "@/components/ui/alert";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { authClient } from "@/lib/auth";
-import { BASIC_TEAM_LIMIT, IS_CLOUD, STANDARD_TEAM_LIMIT } from "@/lib/const";
-import { SubscriptionData, useStripeSubscription } from "@/lib/subscription/useStripeSubscription";
+import { IS_CLOUD } from "@/lib/const";
+import { useStripeSubscription } from "@/lib/subscription/useStripeSubscription";
import { SiteAccessMultiSelect } from "./SiteAccessMultiSelect";
@@ -35,30 +35,17 @@ interface InviteMemberDialogProps {
memberCount: number;
}
-const getMemberLimit = (subscription: SubscriptionData | undefined) => {
- if (subscription?.status !== "active") return 1;
- if (subscription?.planName.includes("pro")) return Infinity;
- if (subscription?.planName.includes("standard")) return STANDARD_TEAM_LIMIT;
- if (subscription?.planName.includes("basic")) return BASIC_TEAM_LIMIT;
- if (subscription?.planName === "appsumo-1") return 1;
- if (subscription?.planName === "appsumo-2") return 3;
- if (subscription?.planName === "appsumo-3") return 10;
- if (subscription?.planName === "appsumo-4") return 25;
- if (subscription?.planName === "appsumo-5") return 50;
- if (subscription?.planName === "appsumo-6") return Infinity;
- return 1;
-};
-
export function InviteMemberDialog({ organizationId, onSuccess, memberCount }: InviteMemberDialogProps) {
const { data: subscription } = useStripeSubscription();
const queryClient = useQueryClient();
const t = useExtracted();
+ const memberLimit = subscription?.memberLimit ?? null;
const isOverMemberLimit = useMemo(() => {
if (!IS_CLOUD) return false;
- const limit = getMemberLimit(subscription);
- return memberCount >= limit;
- }, [subscription, memberCount]);
+ if (memberLimit === null) return false;
+ return memberCount >= memberLimit;
+ }, [memberLimit, memberCount]);
const [email, setEmail] = useState("");
const [role, setRole] = useState<"admin" | "member" | "owner">("member");
@@ -134,7 +121,7 @@ export function InviteMemberDialog({ organizationId, onSuccess, memberCount }: I
</span>
</TooltipTrigger>
<TooltipContent>
- {t("You have reached the limit of {limit} members. Upgrade to add more members", { limit: String(getMemberLimit(subscription)) })}
+ {t("You have reached the limit of {limit} members. Upgrade to add more members", { limit: String(memberLimit) })}
</TooltipContent>
</Tooltip>
);
diff --git a/client/src/app/settings/organization/subscription/page.tsx b/client/src/app/settings/organization/subscription/page.tsx
index d31b20faf..b96be2d16 100644
--- a/client/src/app/settings/organization/subscription/page.tsx
+++ b/client/src/app/settings/organization/subscription/page.tsx
@@ -9,6 +9,7 @@ import { ExpiredTrialPlan } from "../../../../components/subscription/ExpiredTri
import { useSetPageTitle } from "../../../../hooks/useSetPageTitle";
import { FreePlan } from "../../../../components/subscription/FreePlan";
import { OverridePlan } from "../../../../components/subscription/OverridePlan";
+import { CustomPlan } from "../../../../components/subscription/CustomPlan";
import { Building } from "lucide-react";
import { useExtracted } from "next-intl";
import { authClient } from "@/lib/auth";
@@ -70,6 +71,10 @@ export default function OrganizationSubscriptionPage() {
return <FreePlan />;
}
+ if (activeSubscription.planName === "custom") {
+ return <CustomPlan />;
+ }
+
if (activeSubscription.planName.startsWith("appsumo")) {
return <AppSumoPlan />;
}
diff --git a/client/src/components/subscription/CustomPlan.tsx b/client/src/components/subscription/CustomPlan.tsx
new file mode 100644
index 000000000..dcce7fcb6
--- /dev/null
+++ b/client/src/components/subscription/CustomPlan.tsx
@@ -0,0 +1,102 @@
+import { authClient } from "@/lib/auth";
+import { AlertTriangle, Sparkles } from "lucide-react";
+import { useExtracted } from "next-intl";
+import { DEFAULT_EVENT_LIMIT } from "../../lib/subscription/constants";
+import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";
+import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card";
+import { Progress } from "../ui/progress";
+import { UsageChart } from "../UsageChart";
+
+export function CustomPlan() {
+ const t = useExtracted();
+ const { data: subscription } = useStripeSubscription();
+ const { data: activeOrg } = authClient.useActiveOrganization();
+
+ const organizationId = activeOrg?.id;
+
+ if (!subscription) return null;
+
+ const currentUsage = subscription?.monthlyEventCount || 0;
+ const limit = subscription?.eventLimit || DEFAULT_EVENT_LIMIT;
+
+ const percentageUsed = Math.min((currentUsage / limit) * 100, 100);
+ const isNearLimit = percentageUsed > 80;
+ const isLimitExceeded = currentUsage >= limit;
+
+ const formatLimit = (value: number | null) => (value === null ? "Unlimited" : value.toLocaleString());
+
+ return (
+ <div className="space-y-6">
+ <Card>
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Sparkles className="h-5 w-5" />
+ {t("Custom Plan")}
+ </CardTitle>
+ <CardDescription>
+ {t("You have a custom plan with up to {limit} pageviews per month.", {
+ limit: limit.toLocaleString(),
+ })}
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="space-y-6">
+ {isLimitExceeded ? (
+ <Alert className="bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800">
+ <AlertTriangle className="h-4 w-4 text-red-500 dark:text-red-400" />
+ <AlertTitle>{t("Event Limit Exceeded")}</AlertTitle>
+ <AlertDescription>
+ {t("You have exceeded your monthly event limit. Please contact support for assistance.")}
+ </AlertDescription>
+ </Alert>
+ ) : (
+ isNearLimit && (
+ <Alert className="bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800">
+ <AlertTriangle className="h-4 w-4 text-amber-500 dark:text-amber-400" />
+ <AlertTitle>{t("Approaching Limit")}</AlertTitle>
+ <AlertDescription>
+ {t(
+ "You are approaching your monthly event limit. Please contact support if you need more capacity."
+ )}
+ </AlertDescription>
+ </Alert>
+ )
+ )}
+
+ <div className="space-y-2">
+ <h3 className="font-medium mb-2">{t("Usage")}</h3>
+ <div className="space-y-4">
+ <div>
+ <div className="flex justify-between mb-1">
+ <span className="text-sm">{t("Events")}</span>
+ <span className="text-sm">
+ {currentUsage.toLocaleString()} / {limit.toLocaleString()}
+ </span>
+ </div>
+ <Progress value={percentageUsed} className={isNearLimit ? "bg-amber-100 dark:bg-amber-900" : ""} />
+ </div>
+ </div>
+ </div>
+
+ <div className="space-y-2">
+ <h3 className="font-medium mb-2">{t("Plan Limits")}</h3>
+ <div className="grid grid-cols-2 gap-4">
+ <div className="rounded-lg border p-3">
+ <div className="text-sm text-muted-foreground">{t("Websites")}</div>
+ <div className="text-lg font-semibold">{formatLimit(subscription.siteLimit)}</div>
+ </div>
+ <div className="rounded-lg border p-3">
+ <div className="text-sm text-muted-foreground">{t("Team Members")}</div>
+ <div className="text-lg font-semibold">{formatLimit(subscription.memberLimit)}</div>
+ </div>
+ </div>
+ </div>
+
+ {organizationId && <UsageChart organizationId={organizationId} />}
+ </div>
+ </CardContent>
+ </Card>
+ </div>
+ );
+}
diff --git a/client/src/lib/subscription/useStripeSubscription.ts b/client/src/lib/subscription/useStripeSubscription.ts
index 962a5b48f..d67248bf2 100644
--- a/client/src/lib/subscription/useStripeSubscription.ts
+++ b/client/src/lib/subscription/useStripeSubscription.ts
@@ -18,6 +18,8 @@ export interface SubscriptionData {
trialDaysRemaining?: number;
message?: string; // For expired trial message
isOverride?: boolean;
+ memberLimit: number | null;
+ siteLimit: number | null;
}
export function useStripeSubscription(): UseQueryResult<SubscriptionData | undefined, Error> {
diff --git a/docs/src/components/LandingPageTemplate.tsx b/docs/src/components/LandingPageTemplate.tsx
index ca9262bce..b62c7c48f 100644
--- a/docs/src/components/LandingPageTemplate.tsx
+++ b/docs/src/components/LandingPageTemplate.tsx
@@ -28,6 +28,7 @@ import { Funnels } from "@/components/Cards/Funnels";
import { RealTimeAnalytics } from "@/components/Cards/RealTimeAnalytics";
import { SessionReplay } from "@/components/Cards/SessionReplay";
import { UserSessions } from "@/components/Cards/UserSessions";
+import { LandingPricing } from "@/components/LandingPricing";
// FAQ Structured Data
const faqSchema = {
@@ -400,6 +401,9 @@ export function LandingPageTemplate({
</div>
</section>
+ {/* Pricing Section */}
+ <LandingPricing />
+
<CTASection />
</>
);
diff --git a/docs/src/components/LandingPricing.tsx b/docs/src/components/LandingPricing.tsx
new file mode 100644
index 000000000..d4dd94940
--- /dev/null
+++ b/docs/src/components/LandingPricing.tsx
@@ -0,0 +1,9 @@
+"use client";
+
+import { useState } from "react";
+import { PricingSection } from "./PricingSection";
+
+export function LandingPricing() {
+ const [isAnnual, setIsAnnual] = useState(false);
+ return <PricingSection isAnnual={isAnnual} setIsAnnual={setIsAnnual} />;
+}
diff --git a/server/src/api/sites/addSite.ts b/server/src/api/sites/addSite.ts
index cd1c57a76..d126bfbe0 100644
--- a/server/src/api/sites/addSite.ts
+++ b/server/src/api/sites/addSite.ts
@@ -1,4 +1,5 @@
import { randomBytes } from "crypto";
+import { eq } from "drizzle-orm";
import { FastifyReply, FastifyRequest } from "fastify";
import { db } from "../../db/postgres/postgres.js";
import { sites } from "../../db/postgres/schema.js";
@@ -87,6 +88,20 @@ export async function addSite(
error: `The following features require an active subscription: ${requestedStandard.map(([k]) => k).join(", ")}`,
});
}
+
+ // Enforce site limit
+ const siteLimit = subscription?.siteLimit ?? null;
+ if (siteLimit !== null) {
+ const existingSites = await db
+ .select({ siteId: sites.siteId })
+ .from(sites)
+ .where(eq(sites.organizationId, organizationId));
+ if (existingSites.length >= siteLimit) {
+ return reply.status(403).send({
+ error: `You have reached the limit of ${siteLimit} website${siteLimit === 1 ? "" : "s"} for your plan. Please upgrade to add more.`,
+ });
+ }
+ }
}
const id = randomBytes(6).toString("hex");
diff --git a/server/src/api/stripe/getSubscription.ts b/server/src/api/stripe/getSubscription.ts
index 5b5e07a0c..acc24ee4a 100644
--- a/server/src/api/stripe/getSubscription.ts
+++ b/server/src/api/stripe/getSubscription.ts
@@ -4,7 +4,17 @@ import { DateTime } from "luxon";
import Stripe from "stripe";
import { db } from "../../db/postgres/postgres.js";
import { organization, member } from "../../db/postgres/schema.js";
-import { getBestSubscription } from "../../lib/subscriptionUtils.js";
+import {
+ APPSUMO_MEMBER_LIMITS,
+ APPSUMO_SITE_LIMITS,
+ BASIC_MEMBER_LIMIT,
+ BASIC_SITE_LIMIT,
+ FREE_MEMBER_LIMIT,
+ FREE_SITE_LIMIT,
+ STANDARD_MEMBER_LIMIT,
+ STANDARD_SITE_LIMIT,
+} from "../../lib/const.js";
+import { getBestSubscription, SubscriptionInfo } from "../../lib/subscriptionUtils.js";
function getStartOfMonth() {
return DateTime.now().startOf("month").toJSDate();
@@ -14,6 +24,60 @@ function getStartOfNextMonth() {
return DateTime.now().startOf("month").plus({ months: 1 }).toJSDate();
}
+/**
+ * Computes memberLimit and siteLimit from a subscription.
+ * null = unlimited.
+ */
+function computeLimits(
+ subscription: SubscriptionInfo,
+ stripeCreatedAt?: Date
+): { memberLimit: number | null; siteLimit: number | null } {
+ if (subscription.source === "custom") {
+ return {
+ memberLimit: subscription.memberLimit,
+ siteLimit: subscription.siteLimit,
+ };
+ }
+
+ const planName = subscription.planName;
+
+ if (planName.includes("pro")) {
+ return { memberLimit: null, siteLimit: null };
+ }
+
+ if (planName.includes("standard")) {
+ // Legacy standard plans created before 2025-06-27 get unlimited sites
+ const siteLimit =
+ stripeCreatedAt && DateTime.fromJSDate(stripeCreatedAt) < DateTime.fromFormat("2025-06-27", "yyyy-MM-dd")
+ ? null
+ : STANDARD_SITE_LIMIT;
+ return { memberLimit: STANDARD_MEMBER_LIMIT, siteLimit };
+ }
+
+ if (planName.includes("basic")) {
+ return { memberLimit: BASIC_MEMBER_LIMIT, siteLimit: BASIC_SITE_LIMIT };
+ }
+
+ // AppSumo tiers (e.g. "appsumo-1" through "appsumo-6")
+ const appsumoMatch = planName.match(/^appsumo-([123456])$/);
+ if (appsumoMatch) {
+ const tier = appsumoMatch[1];
+ return {
+ memberLimit: APPSUMO_MEMBER_LIMITS[tier] ?? null,
+ siteLimit: APPSUMO_SITE_LIMITS[tier] ?? null,
+ };
+ }
+
+ if (subscription.source === "override") {
+ // Override with a known stripe plan name already handled above.
+ // For unknown override plans, default to unlimited.
+ return { memberLimit: null, siteLimit: null };
+ }
+
+ // Free tier
+ return { memberLimit: FREE_MEMBER_LIMIT, siteLimit: FREE_SITE_LIMIT };
+}
+
export async function getSubscriptionInner(organizationId: string) {
// 1. Find the organization and their Stripe Customer ID
const orgResult = await db
@@ -36,7 +100,26 @@ export async function getSubscriptionInner(organizationId: string) {
// Get the best subscription (highest event limit from AppSumo or Stripe)
const subscription = await getBestSubscription(organizationId, org.stripeCustomerId);
+ // Compute member/site limits
+ const stripeCreatedAt = subscription.source === "stripe" ? subscription.createdAt : undefined;
+ const limits = computeLimits(subscription, stripeCreatedAt);
+
// Format response based on subscription source
+ if (subscription.source === "custom") {
+ return {
+ id: null,
+ planName: subscription.planName,
+ status: subscription.status,
+ currentPeriodEnd: getStartOfNextMonth(),
+ currentPeriodStart: getStartOfMonth(),
+ eventLimit: subscription.eventLimit,
+ monthlyEventCount: org.monthlyEventCount || 0,
+ interval: subscription.interval,
+ cancelAtPeriodEnd: subscription.cancelAtPeriodEnd,
+ ...limits,
+ };
+ }
+
if (subscription.source === "override") {
return {
id: null,
@@ -49,6 +132,7 @@ export async function getSubscriptionInner(organizationId: string) {
interval: subscription.interval,
cancelAtPeriodEnd: subscription.cancelAtPeriodEnd,
isOverride: true,
+ ...limits,
};
}
@@ -63,6 +147,7 @@ export async function getSubscriptionInner(organizationId: string) {
monthlyEventCount: org.monthlyEventCount || 0,
interval: subscription.interval,
cancelAtPeriodEnd: subscription.cancelAtPeriodEnd,
+ ...limits,
};
}
@@ -84,6 +169,7 @@ export async function getSubscriptionInner(organizationId: string) {
interval: subscription.interval,
isTrial: true,
trialDaysRemaining,
+ ...limits,
};
}
return {
@@ -97,6 +183,7 @@ export async function getSubscriptionInner(organizationId: string) {
eventLimit: subscription.eventLimit,
monthlyEventCount: org.monthlyEventCount || 0,
interval: subscription.interval,
+ ...limits,
};
}
@@ -110,6 +197,7 @@ export async function getSubscriptionInner(organizationId: string) {
eventLimit: subscription.eventLimit,
monthlyEventCount: org.monthlyEventCount || 0,
trialDaysRemaining: 0,
+ ...limits,
};
}
diff --git a/server/src/db/postgres/schema.ts b/server/src/db/postgres/schema.ts
index 93345cd34..1fe092648 100644
--- a/server/src/db/postgres/schema.ts
+++ b/server/src/db/postgres/schema.ts
@@ -139,6 +139,11 @@ export const organization = pgTable(
monthlyEventCount: integer().default(0),
overMonthlyLimit: boolean().default(false),
planOverride: text(), // Plan name override (e.g., "pro1m", "standard500k")
+ customPlan: jsonb("custom_plan").$type<{
+ events: number;
+ members: number | null; // null = unlimited
+ websites: number | null; // null = unlimited
+ }>(),
},
table => [unique("organization_slug_unique").on(table.slug)]
);
diff --git a/server/src/lib/auth.ts b/server/src/lib/auth.ts
index d5d58251a..a80c83ef9 100644
--- a/server/src/lib/auth.ts
+++ b/server/src/lib/auth.ts
@@ -1,5 +1,5 @@
import { betterAuth } from "better-auth";
-import { createAuthMiddleware } from "better-auth/api";
+import { APIError, createAuthMiddleware } from "better-auth/api";
import { admin, captcha, emailOTP, organization, apiKey } from "better-auth/plugins";
import dotenv from "dotenv";
import { and, asc, eq } from "drizzle-orm";
@@ -50,6 +50,10 @@ const pluginList = [
type: "string",
required: false,
},
+ customPlan: {
+ type: "string",
+ required: false,
+ },
},
},
},
@@ -175,6 +179,32 @@ export const auth = betterAuth({
},
},
hooks: {
+ before: createAuthMiddleware(async (ctx) => {
+ if (IS_CLOUD && ctx.path === "/organization/invite-member") {
+ const body = ctx.body as { organizationId?: string } | undefined;
+ const organizationId = body?.organizationId;
+
+ if (organizationId) {
+ // Lazy import to avoid circular dependency
+ const { getSubscriptionInner } = await import("../api/stripe/getSubscription.js");
+ const subscription = await getSubscriptionInner(organizationId);
+ const memberLimit = subscription?.memberLimit ?? null;
+
+ if (memberLimit !== null) {
+ const members = await db
+ .select({ id: member.id })
+ .from(member)
+ .where(eq(member.organizationId, organizationId));
+
+ if (members.length >= memberLimit) {
+ throw new APIError("FORBIDDEN", {
+ message: `You have reached the limit of ${memberLimit} member${memberLimit === 1 ? "" : "s"} for your plan. Please upgrade to add more.`,
+ });
+ }
+ }
+ }
+ }
+ }),
after: createAuthMiddleware(async ctx => {
// Handle invitation acceptance - copy site access from invitation to member
if (ctx.path === "/organization/accept-invitation") {
diff --git a/server/src/lib/const.ts b/server/src/lib/const.ts
index 6d53f5b85..0ccb5feb0 100644
--- a/server/src/lib/const.ts
+++ b/server/src/lib/const.ts
@@ -14,6 +14,21 @@ export const MAPBOX_TOKEN = process.env.MAPBOX_TOKEN;
export const DEFAULT_EVENT_LIMIT = 3_000;
+// Site and member limits per plan tier
+export const FREE_SITE_LIMIT = 1;
+export const FREE_MEMBER_LIMIT = 1;
+export const BASIC_SITE_LIMIT = 1;
+export const BASIC_MEMBER_LIMIT = 1;
+export const STANDARD_SITE_LIMIT = 5;
+export const STANDARD_MEMBER_LIMIT = 3;
+
+export const APPSUMO_SITE_LIMITS: Record<string, number | null> = {
+ "1": 3, "2": 10, "3": 25, "4": 50, "5": 100, "6": null,
+};
+export const APPSUMO_MEMBER_LIMITS: Record<string, number | null> = {
+ "1": 1, "2": 3, "3": 10, "4": 25, "5": 50, "6": null,
+};
+
// AppSumo tier limits (lifetime plans with standard features, no replays)
export const APPSUMO_TIER_LIMITS = {
"1": 20_000,
diff --git a/server/src/lib/subscriptionUtils.ts b/server/src/lib/subscriptionUtils.ts
index fa0ab8a4a..7f8a3a65a 100644
--- a/server/src/lib/subscriptionUtils.ts
+++ b/server/src/lib/subscriptionUtils.ts
@@ -52,11 +52,24 @@ export interface OverrideSubscriptionInfo {
cancelAtPeriodEnd: false;
}
+export interface CustomPlanSubscriptionInfo {
+ source: "custom";
+ planName: "custom";
+ eventLimit: number;
+ memberLimit: number | null; // null = unlimited
+ siteLimit: number | null; // null = unlimited
+ periodStart: string;
+ status: "active";
+ interval: "lifetime";
+ cancelAtPeriodEnd: false;
+}
+
export type SubscriptionInfo =
| AppSumoSubscriptionInfo
| StripeSubscriptionInfo
| FreeSubscriptionInfo
- | OverrideSubscriptionInfo;
+ | OverrideSubscriptionInfo
+ | CustomPlanSubscriptionInfo;
/**
* Gets the first day of the current month in YYYY-MM-DD format
@@ -253,16 +266,58 @@ export async function getStripeSubscription(stripeCustomerId: string | null): Pr
}
}
+/**
+ * Gets custom plan subscription info for an organization
+ * @returns Custom plan subscription info or null if no custom plan set
+ */
+export async function getCustomPlanSubscription(organizationId: string): Promise<CustomPlanSubscriptionInfo | null> {
+ try {
+ const orgResult = await db
+ .select({ customPlan: organization.customPlan })
+ .from(organization)
+ .where(eq(organization.id, organizationId))
+ .limit(1);
+
+ const org = orgResult[0];
+ if (!org?.customPlan) {
+ return null;
+ }
+
+ const cp = org.customPlan;
+
+ return {
+ source: "custom",
+ planName: "custom",
+ eventLimit: cp.events,
+ memberLimit: cp.members ?? null,
+ siteLimit: cp.websites ?? null,
+ periodStart: getStartOfMonth(),
+ status: "active",
+ interval: "lifetime",
+ cancelAtPeriodEnd: false,
+ };
+ } catch (error) {
+ console.error("Error checking custom plan:", error);
+ return null;
+ }
+}
+
/**
* Gets the best subscription for an organization
- * Priority: Override > AppSumo/Stripe (highest limit) > Free
+ * Priority: CustomPlan > Override > AppSumo/Stripe (highest limit) > Free
* @returns The active subscription, or free tier if none found
*/
export async function getBestSubscription(
organizationId: string,
stripeCustomerId: string | null
): Promise<SubscriptionInfo> {
- // Check override first - always wins
+ // Check custom plan first - highest priority
+ const customSub = await getCustomPlanSubscription(organizationId);
+ if (customSub) {
+ return customSub;
+ }
+
+ // Check override next
const overrideSub = await getOverrideSubscription(organizationId);
if (overrideSub) {
return overrideSub;