🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor subscription pricing tiers and enhance utility functions
Bill Yang6ffc2a82bc37
diff --git a/client/src/app/subscribe/components/utils.ts b/client/src/app/subscribe/components/utils.tsindex a1a5212c3..f6163bced 100644--- a/client/src/app/subscribe/components/utils.ts+++ b/client/src/app/subscribe/components/utils.ts@@ -1,5 +1,7 @@// Common utility functions and constants for subscription components+import { STRIPE_TIERS } from "../../../lib/stripe";+export interface StripePrice {priceId: string;price: number;@@ -10,7 +12,7 @@ export interface StripePrice {};}-export const EVENT_TIERS = [100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000, "Custom"];+export const EVENT_TIERS = [STRIPE_TIERS.map(tier => tier.events), "Custom"];export const STANDARD_FEATURES = ["Up to 10 websites",diff --git a/client/src/components/subscription/PaidPlain/PlanDialog.tsx b/client/src/components/subscription/PaidPlain/PlanDialog.tsxindex e14e8b5c4..303910c00 100644--- a/client/src/components/subscription/PaidPlain/PlanDialog.tsx+++ b/client/src/components/subscription/PaidPlain/PlanDialog.tsx@@ -1,7 +1,7 @@import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { authClient } from "@/lib/auth";import { BACKEND_URL } from "@/lib/const";-import { getStripePrices } from "@/lib/stripe";+import { getStripePrices, STRIPE_TIERS } from "@/lib/stripe";import { usePreviewSubscriptionUpdate, useUpdateSubscription } from "@/lib/subscription/useSubscriptionMutations";import { cn } from "@/lib/utils";import { Loader2 } from "lucide-react";@@ -17,16 +17,6 @@ interface PlanDialogProps {hasActiveSubscription?: boolean;}-const EVENT_TIERS = [- { events: 100_000, label: "100k" },- { events: 250_000, label: "250k" },- { events: 500_000, label: "500k" },- { events: 1_000_000, label: "1M" },- { events: 2_000_000, label: "2M" },- { events: 5_000_000, label: "5M" },- { events: 10_000_000, label: "10M" },-];-export function PlanDialog({ open, onOpenChange, currentPlanName, hasActiveSubscription }: PlanDialogProps) {const [isAnnual, setIsAnnual] = useState(false);const [showProrationDialog, setShowProrationDialog] = useState(false);@@ -188,7 +178,7 @@ export function PlanDialog({ open, onOpenChange, currentPlanName, hasActiveSubsc<p className="text-sm text-neutral-400">{subtitle}</p></div><div className="space-y-2">- {EVENT_TIERS.map(tier => {+ {STRIPE_TIERS.map(tier => {const plan = getPriceForTier(tier.events, type);if (!plan) return null;const isCurrent = isCurrentPlan(plan.name);@@ -216,7 +206,7 @@ export function PlanDialog({ open, onOpenChange, currentPlanName, hasActiveSubsc</div></div><div className="text-neutral-100 font-medium flex items-center gap-2">- {tier.label} events <span className="text-neutral-400 text-xs font-normal">/ month</span>+ {tier.shortName} events <span className="text-neutral-400 text-xs font-normal">/ month</span>{isLoading && <Loader2 className="w-4 h-4 animate-spin" />}</div></div>diff --git a/client/src/lib/stripe.ts b/client/src/lib/stripe.tsindex 77d04d99e..84321ee19 100644--- a/client/src/lib/stripe.ts+++ b/client/src/lib/stripe.ts@@ -5,126 +5,128 @@ const STRIPE_PRICES = [priceId: "price_1RKuxUDFVprnAny2xyyWvXNr",name: "standard100k",interval: "month",- limits: {- events: 100_000,- },+ shortName: "100k",+ events: 100_000,},{price: 190,priceId: "price_1RKuxUDFVprnAny2RkoZyxev",name: "standard100k-annual",interval: "year",- limits: {- events: 100_000,- },+ shortName: "100k",+ events: 100_000,},{price: 29,priceId: "price_1RKuxTDFVprnAny2TS4Qz0Hi",name: "standard250k",interval: "month",- limits: {- events: 250_000,- },+ shortName: "250k",+ events: 250_000,},{price: 290,priceId: "price_1RKuxTDFVprnAny2rDcJOwHn",name: "standard250k-annual",interval: "year",- limits: {- events: 250_000,- },+ shortName: "250k",+ events: 250_000,},{name: "standard500k",priceId: "price_1RKuxSDFVprnAny2L7hbJSmO",price: 49,interval: "month",- limits: {- events: 500_000,- },+ shortName: "500k",+ events: 500_000,},{name: "standard500k-annual",priceId: "price_1RKuxSDFVprnAny2APD1EsL4",price: 490,interval: "year",- limits: {- events: 500_000,- },+ shortName: "500k",+ events: 500_000,},{name: "standard1m",priceId: "price_1RKuxRDFVprnAny2UnTeUnYl",price: 69,interval: "month",- limits: {- events: 1_000_000,- },+ shortName: "1m",+ events: 1_000_000,},{name: "standard1m-annual",priceId: "price_1RKuxRDFVprnAny2f67uFcwC",price: 690,interval: "year",- limits: {- events: 1_000_000,- },+ shortName: "1m",+ events: 1_000_000,},{name: "standard2m",priceId: "price_1RKuxPDFVprnAny2pvdhKxSL",price: 99,interval: "month",- limits: {- events: 2_000_000,- },+ shortName: "2m",+ events: 2_000_000,},{name: "standard2m-annual",priceId: "price_1RKuxPDFVprnAny2NCYgKQf5",price: 990,interval: "year",- limits: {- events: 2_000_000,- },+ shortName: "2m",+ events: 2_000_000,},{name: "standard5m",priceId: "price_1RKuxKDFVprnAny2pytTqnzP",price: 149,interval: "month",- limits: {- events: 5_000_000,- },+ shortName: "5m",+ events: 5_000_000,},{name: "standard5m-annual",priceId: "price_1RKuxKDFVprnAny2UjJFcvHQ",price: 1490,interval: "year",- limits: {- events: 5_000_000,- },+ shortName: "5m",+ events: 5_000_000,},{name: "standard10m",priceId: "price_1RKuxNDFVprnAny2HkZXUcZN",price: 249,interval: "month",- limits: {- events: 10_000_000,- },+ shortName: "10m",+ events: 10_000_000,},{name: "standard10m-annual",priceId: "price_1RKuxNDFVprnAny2mjFH5swO",price: 2490,interval: "year",- limits: {- events: 10_000_000,- },+ shortName: "10m",+ events: 10_000_000,+ },+ {+ name: "standard20m",+ priceId: "price_1SKXvkDFVprnAny2cnF3yDyB",+ price: 399,+ interval: "month",+ shortName: "20m",+ events: 20_000_000,+ },+ {+ name: "standard20m-annual",+ priceId: "price_1SKXxHDFVprnAny2fHARdc3Z",+ price: 3990,+ interval: "year",+ shortName: "20m",+ events: 20_000_000,},// Pro tiers{@@ -132,129 +134,138 @@ const STRIPE_PRICES = [priceId: "price_1S8szIDFVprnAny2Hg7cxG5b",name: "pro100k",interval: "month",- limits: {- events: 100_000,- },+ shortName: "100k",+ events: 100_000,},{price: 390,priceId: "price_1S8szIDFVprnAny2MfwmEsD3",name: "pro100k-annual",interval: "year",- limits: {- events: 100_000,- },+ shortName: "100k",+ events: 100_000,},{price: 59,priceId: "price_1S8szHDFVprnAny2VyF3ZOuF",name: "pro250k",interval: "month",- limits: {- events: 250_000,- },+ shortName: "250k",+ events: 250_000,},{price: 590,priceId: "price_1S8szHDFVprnAny2KbYorj7v",name: "pro250k-annual",interval: "year",- limits: {- events: 250_000,- },+ shortName: "250k",+ events: 250_000,},{price: 99,priceId: "price_1S8szEDFVprnAny2hi4ZSoS8",name: "pro500k",interval: "month",- limits: {- events: 500_000,- },+ shortName: "500k",+ events: 500_000,},{price: 990,priceId: "price_1S8szEDFVprnAny2z6M7Befa",name: "pro500k-annual",interval: "year",- limits: {- events: 500_000,- },+ shortName: "500k",+ events: 500_000,},{price: 139,priceId: "price_1S8szCDFVprnAny28ccBSIDh",name: "pro1m",interval: "month",- limits: {- events: 1_000_000,- },+ shortName: "1M",+ events: 1_000_000,},{price: 1390,priceId: "price_1S8szCDFVprnAny2ujgml5hL",name: "pro1m-annual",interval: "year",- limits: {- events: 1_000_000,- },+ shortName: "1M",+ events: 1_000_000,},{price: 199,priceId: "price_1S8szBDFVprnAny2h8aeoObg",name: "pro2m",interval: "month",- limits: {- events: 2_000_000,- },+ shortName: "2M",+ events: 2_000_000,},{price: 1990,priceId: "price_1S8szBDFVprnAny2So7DIVTb",name: "pro2m-annual",interval: "year",- limits: {- events: 2_000_000,- },+ shortName: "2M",+ events: 2_000_000,},{price: 299,priceId: "price_1S8sz9DFVprnAny2Mjrl9je6",name: "pro5m",interval: "month",- limits: {- events: 5_000_000,- },+ shortName: "5M",+ events: 5_000_000,},{price: 2990,priceId: "price_1S8sz9DFVprnAny2pEnr5hXD",name: "pro5m-annual",interval: "year",- limits: {- events: 5_000_000,- },+ shortName: "5M",+ events: 5_000_000,},{price: 499,priceId: "price_1S8sz5DFVprnAny2PQR4etWx",name: "pro10m",interval: "month",- limits: {- events: 10_000_000,- },+ shortName: "10M",+ events: 10_000_000,},{price: 4990,priceId: "price_1S8sz5DFVprnAny2drMF3d7U",name: "pro10m-annual",interval: "year",- limits: {- events: 10_000_000,- },+ shortName: "10M",+ events: 10_000_000,+ },+ {+ price: 799,+ priceId: "price_1SKXw0DFVprnAny2Au9JTwnX",+ name: "pro20m",+ interval: "month",+ shortName: "20M",+ events: 20_000_000,+ },+ {+ price: 7990,+ priceId: "price_1SKXwcDFVprnAny2HCEv46PG",+ name: "pro20m-annual",+ interval: "year",+ shortName: "20M",+ events: 20_000_000,},];+export const STRIPE_TIERS = STRIPE_PRICES.filter(+ price => price.interval === "month" && price.name.startsWith("standard")+).map(price => ({+ events: price.events,+ shortName: price.shortName,+}));+const TEST_TO_PRICE_ID = {standard100k: "price_1R1fIVDFVprnAny2yJtRRPBm","standard100k-annual": "price_1R2l2KDFVprnAny2iZr5gFLe",@@ -284,6 +295,10 @@ const TEST_TO_PRICE_ID = {"pro5m-annual": "price_1S8klTDFVprnAny2Na9XXAEI",pro10m: "price_1S8kkKDFVprnAny2WDjO98bN","pro10m-annual": "price_1S8kl3DFVprnAny2Xdhho4F0",+ standard20m: "price_1SKtYyDFVprnAny2ZT1K2gVP",+ "standard20m-annual": "price_1SKtZ8DFVprnAny2HwSpfzS8",+ pro20m: "price_1SKtYZDFVprnAny2WUpCtCzm",+ "pro20m-annual": "price_1SKtYkDFVprnAny2ikpbKAA6",};export const getStripePrices = () => {diff --git a/docs/src/app/pricing/components/ComparisonSection.tsx b/docs/src/app/pricing/components/ComparisonSection.tsxindex f41d45981..bd9af6aec 100644--- a/docs/src/app/pricing/components/ComparisonSection.tsx+++ b/docs/src/app/pricing/components/ComparisonSection.tsx@@ -10,8 +10,8 @@ const COMPARISON_FEATURES = [{name: "Monthly events",free: "10,000",- standard: "100K - 10M+",- pro: "100K - 10M+",+ standard: "100K - 20M+",+ pro: "100K - 20M+",},{name: "Number of websites",diff --git a/docs/src/components/PricingSection.tsx b/docs/src/components/PricingSection.tsxindex c1705dae5..5395d076b 100644--- a/docs/src/components/PricingSection.tsx+++ b/docs/src/components/PricingSection.tsx@@ -8,7 +8,7 @@ import { cn } from "@/lib/utils";import { trackAdEvent } from "@/lib/trackAdEvent";// 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, "Custom"];+const EVENT_TIERS = [100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000, 20_000_000, "Custom"];// Define standard plan featuresconst STANDARD_FEATURES = [@@ -66,6 +66,7 @@ function getFormattedPrice(eventLimit: number | string, planType: "standard" | "else if (eventLimit <= 2_000_000) monthlyPrice = 99;else if (eventLimit <= 5_000_000) monthlyPrice = 149;else if (eventLimit <= 10_000_000) monthlyPrice = 249;+ else if (eventLimit <= 20_000_000) monthlyPrice = 399;else return { custom: true };} else {// Pro tier prices (roughly double)@@ -76,6 +77,7 @@ function getFormattedPrice(eventLimit: number | string, planType: "standard" | "else if (eventLimit <= 2_000_000) monthlyPrice = 199;else if (eventLimit <= 5_000_000) monthlyPrice = 299;else if (eventLimit <= 10_000_000) monthlyPrice = 499;+ else if (eventLimit <= 20_000_000) monthlyPrice = 799;else return { custom: true };}@@ -165,7 +167,7 @@ export function PricingSection() {{EVENT_TIERS.map((tier, index) => (<span key={index} className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}>{index === EVENT_TIERS.length - 1- ? "10M+"+ ? "20M+": typeof tier === "number" && tier >= 1_000_000? `${tier / 1_000_000}M`: typeof tier === "number"@@ -278,7 +280,7 @@ export function PricingSection() {) : (<><CheckCircle className="w-3 h-3" />- We don't ask for your credit card. 60 day money back guarantee.+ We don't ask for your credit card.</>)}</p>@@ -343,7 +345,7 @@ export function PricingSection() {) : (<><CheckCircle className="w-3 h-3" />- We don't ask for your credit card. 60 day money back guarantee.+ We don't ask for your credit card.</>)}</p>