Skip to content

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

Enhance subscription pricing options and custom tier handling

Bill Yang1f782b627468
diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsx
index fc2961948..00df450cc 100644
--- a/client/src/app/subscribe/page.tsx
+++ b/client/src/app/subscribe/page.tsx
@@ -13,7 +13,14 @@ import { useStripeSubscription } from "../settings/subscription/utils/useStripeS
// Available event tiers for the slider
const EVENT_TIERS = [
- 100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000,
+ 100_000,
+ 250_000,
+ 500_000,
+ 1_000_000,
+ 2_000_000,
+ 5_000_000,
+ 10_000_000,
+ "Custom",
];
// Define plan features
@@ -38,9 +45,17 @@ interface StripePrice {
// Find the appropriate price for a tier at current event limit
function findPriceForTier(
- eventLimit: number,
+ eventLimit: number | string,
interval: "month" | "year"
): StripePrice | null {
+ // Check if we have a custom tier
+ if (eventLimit === "Custom") {
+ return null;
+ }
+
+ // Convert eventLimit to number to ensure type safety
+ const eventLimitValue = Number(eventLimit);
+
// Determine if we need to look for annual plans
const isAnnual = interval === "year";
@@ -54,7 +69,9 @@ function findPriceForTier(
);
// Find a plan that matches or exceeds the event limit
- const matchingPlan = plans.find((plan) => plan.limits.events >= eventLimit);
+ const matchingPlan = plans.find(
+ (plan) => plan.limits.events >= eventLimitValue
+ );
const selectedPlan = matchingPlan || plans[plans.length - 1] || null;
// Return the matching plan or the highest tier available
@@ -71,6 +88,13 @@ export default function Subscribe() {
// Handle subscription
async function handleSubscribe(): Promise<void> {
+ // Handle custom tier by redirecting to email contact
+ if (eventLimit === "Custom") {
+ window.location.href =
+ "mailto:[email protected]?subject=Custom%20Pricing%20Plan";
+ return;
+ }
+
// Check if user is logged in directly
if (!sessionData?.user) {
toast.error("Please log in to subscribe.");
@@ -135,12 +159,13 @@ export default function Subscribe() {
// Get pricing information
const monthlyPrice = findPriceForTier(eventLimit, "month")?.price || 0;
const annualPrice = findPriceForTier(eventLimit, "year")?.price || 0;
+ const isCustomTier = eventLimit === "Custom";
const { data: subscription } = useStripeSubscription();
const router = useRouter();
- if (subscription?.status === "active") {
- router.push("/settings/subscription");
- }
+ // if (subscription?.status === "active") {
+ // router.push("/settings/subscription");
+ // }
return (
<StandardPage>
@@ -164,7 +189,9 @@ export default function Subscribe() {
<div>
<h3 className="font-semibold mb-2">Events per month</h3>
<div className="text-3xl font-bold text-emerald-400">
- {eventLimit.toLocaleString()}
+ {typeof eventLimit === "number"
+ ? eventLimit.toLocaleString()
+ : eventLimit}
</div>
</div>
<div className="flex flex-col items-end">
@@ -194,18 +221,16 @@ export default function Subscribe() {
</span>
</button>
</div>
- <div className="text-right">
- {isAnnual ? (
- <>
- <span className="text-3xl font-bold">
- ${Math.round(annualPrice / 12)}
- </span>
- <span className="ml-1 text-neutral-400">/month</span>
- </>
+ <div className="text-right h-10">
+ {isCustomTier ? (
+ <></>
) : (
<>
<span className="text-3xl font-bold">
- ${monthlyPrice}
+ $
+ {isAnnual
+ ? Math.round(annualPrice / 12)
+ : monthlyPrice}
</span>
<span className="ml-1 text-neutral-400">/month</span>
</>
@@ -233,7 +258,9 @@ export default function Subscribe() {
: ""
}
>
- {tier >= 1_000_000
+ {typeof tier === "string"
+ ? tier
+ : tier >= 1_000_000
? `${tier / 1_000_000}M`
: `${tier / 1_000}K`}
</span>
@@ -255,11 +282,17 @@ export default function Subscribe() {
className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-xl shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50 disabled:opacity-50 disabled:pointer-events-none"
disabled={isLoading}
>
- {isLoading ? "Processing..." : "Subscribe Now"}
+ {isLoading
+ ? "Processing..."
+ : isCustomTier
+ ? "Contact us"
+ : "Subscribe Now"}
</button>
<p className="text-center text-sm text-neutral-400 mt-4">
- Secure checkout powered by Stripe.
+ {isCustomTier
+ ? "Email us at [email protected] for custom pricing"
+ : "Secure checkout powered by Stripe."}
</p>
</div>
</div>
diff --git a/docs/src/app/components/PricingSection.jsx b/docs/src/app/components/PricingSection.jsx
index 4c4ab55d5..ff54ada23 100644
--- a/docs/src/app/components/PricingSection.jsx
+++ b/docs/src/app/components/PricingSection.jsx
@@ -7,7 +7,7 @@ import { useState } from "react";
// Available event tiers for the slider
const EVENT_TIERS = [
- 100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000,
+ 100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000, "Custom",
];
// Define plan features
@@ -30,7 +30,8 @@ function getFormattedPrice(eventLimit, isAnnual) {
else if (eventLimit <= 1_000_000) monthlyPrice = 69;
else if (eventLimit <= 2_000_000) monthlyPrice = 99;
else if (eventLimit <= 5_000_000) monthlyPrice = 149;
- else monthlyPrice = 249; // 10M events
+ else if (eventLimit <= 10_000_000) monthlyPrice = 249; // 10M events
+ else return { custom: true }; // 10M+ events - custom pricing
// Annual prices are 10x monthly (2 months free)
const annualPrice = monthlyPrice * 10;
@@ -113,22 +114,11 @@ export function PricingSection() {
<span className="ml-1 text-xs text-emerald-500">-17%</span>
</button>
</div>
- <div className="text-right">
- {isAnnual ? (
- <>
- <span className="text-3xl font-bold">${Math.round(prices.annual / 12)}</span>
- <span className="ml-1 text-neutral-400">
- /month
- </span>
- </>
- ) : (
- <>
- <span className="text-3xl font-bold">${prices.monthly}</span>
- <span className="ml-1 text-neutral-400">
- /month
- </span>
- </>
- )}
+ <div className="text-right h-10">
+ {prices.custom ? <></> : <><span className="text-3xl font-bold">${isAnnual ? Math.round(prices.annual / 12) : prices.monthly}</span>
+ <span className="ml-1 text-neutral-400">
+ /month
+ </span></> }
</div>
</div>
</div>
@@ -148,7 +138,7 @@ export function PricingSection() {
key={index}
className={eventLimitIndex === index ? "font-bold text-emerald-400" : ""}
>
- {tier >= 1_000_000 ? `${tier / 1_000_000}M` : `${tier / 1_000}K`}
+ {index === EVENT_TIERS.length - 1 ? "10M+" : tier >= 1_000_000 ? `${tier / 1_000_000}M` : `${tier / 1_000}K`}
</span>
))}
</div>
@@ -163,14 +153,22 @@ export function PricingSection() {
))}
</div>
- <Link href="https://app.rybbit.io/signup" className="w-full block">
- <button className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-lg shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50">
- Start your 14 day free trial
- </button>
- </Link>
+ {prices.custom ? (
+ <Link href="mailto:[email protected]" className="w-full block">
+ <button className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-lg shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50">
+ Contact us
+ </button>
+ </Link>
+ ) : (
+ <Link href="https://app.rybbit.io/signup" className="w-full block">
+ <button className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-lg shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50">
+ Start your 14 day free trial
+ </button>
+ </Link>
+ )}
<p className="text-center text-sm text-neutral-400 mt-4">
- We don't ask for your credit card
+ {prices.custom ? "Email us at [email protected] for custom pricing" : "We don't ask for your credit card"}
</p>
</div>
</div>
diff --git a/docs/src/app/contact/page.jsx b/docs/src/app/contact/page.jsx
index c175ace72..d34d12b66 100644
--- a/docs/src/app/contact/page.jsx
+++ b/docs/src/app/contact/page.jsx
@@ -25,8 +25,8 @@ export default function Contact() {
</div>
<div>
<h2 className="text-xl font-medium mb-1">Email</h2>
- <a href="mailto:[email protected]" className="text-neutral-300 hover:text-white transition-colors">
+ <a href="mailto:[email protected]" className="text-neutral-300 hover:text-white transition-colors">
</a>
</div>
</div>
diff --git a/docs/src/app/privacy/page.jsx b/docs/src/app/privacy/page.jsx
index d01116902..96b9340d8 100644
--- a/docs/src/app/privacy/page.jsx
+++ b/docs/src/app/privacy/page.jsx
@@ -107,8 +107,8 @@ export default function PrivacyPolicy() {
<h2 className="text-2xl font-semibold mt-8 mb-4">Contact Us</h2>
<p>
If you have questions about this privacy policy or Rybbit's data practices, please contact us at:
- <a href="mailto:[email protected]" className="text-emerald-400 hover:text-emerald-300 ml-1">
+ <a href="mailto:[email protected]" className="text-emerald-400 hover:text-emerald-300 ml-1">
</a>
</p>
</div>