Skip to content

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

Enhance Subscription and Middleware Functionality

Bill Yang478bfd3f76f9
diff --git a/client/src/app/auth/subscription/success/page.tsx b/client/src/app/auth/subscription/success/page.tsx
new file mode 100644
index 000000000..6cde3a9f1
--- /dev/null
+++ b/client/src/app/auth/subscription/success/page.tsx
@@ -0,0 +1,41 @@
+"use client";
+
+import { useEffect } from "react";
+import { useRouter } from "next/navigation";
+import { useSearchParams } from "next/navigation";
+
+export default function StripeSuccessPage() {
+ const router = useRouter();
+ const searchParams = useSearchParams();
+
+ useEffect(() => {
+ // Log the redirect for debugging purposes
+ console.log("Redirecting from Stripe success page");
+
+ // Add a small delay to ensure the page has fully loaded before redirecting
+ const redirectTimer = setTimeout(() => {
+ // Redirect to the subscription settings page
+ router.push("/settings/subscription");
+ }, 1000);
+
+ // Clean up the timer if the component unmounts
+ return () => clearTimeout(redirectTimer);
+ }, [router]);
+
+ return (
+ <div className="min-h-screen flex flex-col items-center justify-center">
+ <div className="text-center">
+ <h1 className="text-2xl font-bold mb-4">Payment Successful!</h1>
+ <div className="mb-4">
+ <div className="inline-block w-12 h-12 border-4 border-emerald-500 border-t-transparent rounded-full animate-spin"></div>
+ </div>
+ <p className="text-lg text-neutral-600 dark:text-neutral-400">
+ Your subscription has been processed successfully.
+ </p>
+ <p className="text-neutral-600 dark:text-neutral-400 mt-2">
+ Redirecting you to your subscription details...
+ </p>
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx b/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx
index fc43082d3..99e2e5ff3 100644
--- a/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx
+++ b/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx
@@ -7,19 +7,33 @@ import {
} from "@/components/ui/card";
import { Check } from "lucide-react";
import { PlanTemplate } from "../utils/planUtils";
+import { Badge } from "@/components/ui/badge";
interface PlanFeaturesCardProps {
currentPlan: PlanTemplate | null;
}
export function PlanFeaturesCard({ currentPlan }: PlanFeaturesCardProps) {
+ // Check if this is an annual plan
+ const isAnnualPlan = currentPlan?.interval === "year";
+
return (
<Card>
<CardHeader>
- <CardTitle>Plan Features</CardTitle>
- <CardDescription>
- What's included in your {currentPlan?.name} plan
- </CardDescription>
+ <div className="flex items-center justify-between">
+ <div>
+ <CardTitle>Plan Features</CardTitle>
+ <CardDescription>
+ What's included in your {currentPlan?.name} plan
+ {isAnnualPlan && <span className="ml-1">(Annual)</span>}
+ </CardDescription>
+ </div>
+ {isAnnualPlan && (
+ <Badge className="bg-emerald-500 text-white font-semibold">
+ Annual Plan
+ </Badge>
+ )}
+ </div>
</CardHeader>
<CardContent>
<ul className="space-y-2">
diff --git a/client/src/app/settings/subscription/page.tsx b/client/src/app/settings/subscription/page.tsx
index 3bd1b1a78..c5fe8b80c 100644
--- a/client/src/app/settings/subscription/page.tsx
+++ b/client/src/app/settings/subscription/page.tsx
@@ -23,8 +23,9 @@ import { ErrorDialog } from "./components/ErrorDialog";
import { HelpSection } from "./components/HelpSection";
import { PlanFeaturesCard } from "./components/PlanFeaturesCard";
import { DEFAULT_EVENT_LIMIT } from "./utils/constants";
-import { getPlanDetails } from "./utils/planUtils";
+import { getPlanDetails, formatDate } from "./utils/planUtils";
import { Progress } from "@/components/ui/progress";
+import { Badge } from "@/components/ui/badge";
export default function SubscriptionPage() {
const router = useRouter();
@@ -36,6 +37,8 @@ export default function SubscriptionPage() {
refetch,
} = useSubscriptionWithUsage();
+ console.info("activeSubscription", activeSubscription);
+
// State variables
const [errorType, setErrorType] = useState<"cancel" | "resume">("cancel");
const [showConfigError, setShowConfigError] = useState(false);
@@ -97,7 +100,7 @@ export default function SubscriptionPage() {
const { error } = await authClient.subscription.upgrade({
plan: planId,
cancelUrl: globalThis.location.origin + "/settings/subscription",
- successUrl: globalThis.location.origin + "/settings/subscription",
+ successUrl: globalThis.location.origin + "/auth/subscription/success",
});
if (error) {
@@ -133,7 +136,7 @@ export default function SubscriptionPage() {
// with the same plan they currently have
const { error } = await authClient.subscription.upgrade({
plan: activeSubscription.plan,
- successUrl: globalThis.location.origin + "/settings/subscription",
+ successUrl: globalThis.location.origin + "/auth/subscription/success",
cancelUrl: globalThis.location.origin + "/settings/subscription",
});
@@ -163,19 +166,27 @@ export default function SubscriptionPage() {
? getPlanDetails(activeSubscription.plan)
: null;
+ // Determine if the current plan is annual
+ const isAnnualPlan = activeSubscription?.plan?.includes("-annual") || false;
+
// Find the next tier plans for upgrade options
const getCurrentTierPrices = () => {
if (!activeSubscription?.plan) return [];
- // Return all available plans for switching
- return STRIPE_PRICES.sort((a, b) => {
- // First sort by plan type (basic first, then pro)
- if (a.name.startsWith("basic") && b.name.startsWith("pro")) return -1;
- if (a.name.startsWith("pro") && b.name.startsWith("basic")) return 1;
+ // Get the current interval
+ const currentInterval = isAnnualPlan ? "year" : "month";
- // Then sort by event limit
- return a.limits.events - b.limits.events;
- });
+ // Return all available plans for switching, matching the current interval
+ return STRIPE_PRICES.filter((p) => p.interval === currentInterval).sort(
+ (a, b) => {
+ // First sort by plan type (basic first, then pro)
+ if (a.name.startsWith("basic") && b.name.startsWith("pro")) return -1;
+ if (a.name.startsWith("pro") && b.name.startsWith("basic")) return 1;
+
+ // Then sort by event limit
+ return a.limits.events - b.limits.events;
+ }
+ );
};
const upgradePlans = getCurrentTierPrices();
@@ -193,6 +204,36 @@ export default function SubscriptionPage() {
const eventLimit = getEventLimit();
const usagePercentage = (currentUsage / eventLimit) * 100;
+ // Format the price with the correct interval
+ const formatPriceWithInterval = (price: number, interval: string) => {
+ return `$${price}/${interval === "year" ? "year" : "month"}`;
+ };
+
+ // Get formatted price for display
+ const getFormattedPrice = () => {
+ if (!activeSubscription?.plan) return "$0/month";
+
+ const plan = STRIPE_PRICES.find((p) => p.name === activeSubscription.plan);
+ if (!plan) return "$0/month";
+
+ return formatPriceWithInterval(plan.price, plan.interval);
+ };
+
+ // Format the renewal date with appropriate text
+ const formatRenewalDate = () => {
+ if (!activeSubscription?.periodEnd) return "N/A";
+
+ const formattedDate = formatDate(activeSubscription.periodEnd);
+
+ if (activeSubscription.status === "canceled") {
+ return `Expires on ${formattedDate}`;
+ }
+
+ return isAnnualPlan
+ ? `Renews annually on ${formattedDate}`
+ : `Renews monthly on ${formattedDate}`;
+ };
+
return (
<div className="container py-10 max-w-5xl mx-auto">
<div className="flex justify-between items-center mb-8">
@@ -282,18 +323,114 @@ export default function SubscriptionPage() {
) : (
<div className="space-y-6">
{/* Current Plan */}
- <CurrentPlanCard
- activeSubscription={activeSubscription}
- currentPlan={currentPlan}
- currentUsage={currentUsage}
- eventLimit={eventLimit}
- usagePercentage={usagePercentage}
- isProcessing={isProcessing}
- handleCancelSubscription={handleCancelSubscription}
- handleResumeSubscription={handleResumeSubscription}
- handleShowUpgradeOptions={handleShowUpgradeOptions}
- upgradePlans={upgradePlans}
- />
+ <Card>
+ <CardHeader>
+ <div className="flex justify-between items-start">
+ <div>
+ <CardTitle>
+ {currentPlan?.name || "Current Plan"}
+ {isAnnualPlan && (
+ <Badge className="ml-2 bg-emerald-500 text-white">
+ Annual
+ </Badge>
+ )}
+ </CardTitle>
+ <CardDescription>
+ {activeSubscription.status === "active"
+ ? "Your subscription is active."
+ : activeSubscription.status === "canceled"
+ ? "Your subscription has been canceled but is still active until the end of the billing period."
+ : "Your subscription is inactive."}
+ </CardDescription>
+ </div>
+ <div>
+ {activeSubscription.status === "active" && (
+ <Button
+ variant="outline"
+ onClick={handleShowUpgradeOptions}
+ disabled={isProcessing}
+ >
+ Change Plan
+ </Button>
+ )}
+ </div>
+ </div>
+ </CardHeader>
+ <CardContent>
+ <div className="space-y-6">
+ <div className="grid gap-4 md:grid-cols-2">
+ <div>
+ <h3 className="font-medium">Plan</h3>
+ <p className="text-lg font-bold">{currentPlan?.name}</p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ {getFormattedPrice()}
+ </p>
+ {isAnnualPlan && (
+ <div className="mt-2 text-sm text-emerald-600 dark:text-emerald-400">
+ <p>You save by paying annually (2 months free)</p>
+ </div>
+ )}
+ </div>
+ <div>
+ <h3 className="font-medium">Renewal Date</h3>
+ <p className="text-lg font-bold">{formatRenewalDate()}</p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ {isAnnualPlan
+ ? "Your plan renews once per year"
+ : "Your plan renews monthly"}
+ </p>
+ </div>
+ </div>
+
+ <div className="space-y-2">
+ <h3 className="font-medium mb-2">Usage</h3>
+ <div className="space-y-4">
+ <div>
+ <div className="flex justify-between mb-1">
+ <span className="text-sm">Events</span>
+ <span className="text-sm">
+ {currentUsage.toLocaleString()} /{" "}
+ {eventLimit.toLocaleString()}
+ </span>
+ </div>
+ <Progress value={usagePercentage} />
+ </div>
+ </div>
+ </div>
+
+ {/* Billing Cycle Explanation */}
+ {isAnnualPlan && (
+ <div className="pt-2 pb-0 px-3 bg-emerald-50 dark:bg-emerald-900/20 rounded-md border border-emerald-100 dark:border-emerald-800">
+ <p className="text-sm text-emerald-700 dark:text-emerald-300 py-2">
+ <strong>Annual Billing:</strong> You're on annual billing
+ which saves you money compared to monthly billing. Your
+ subscription will renew once per year on{" "}
+ {formatDate(activeSubscription.periodEnd)}.
+ </p>
+ </div>
+ )}
+ </div>
+ </CardContent>
+ <CardFooter>
+ {activeSubscription.status === "active" ? (
+ <Button
+ variant="outline"
+ onClick={handleCancelSubscription}
+ disabled={isProcessing}
+ className="text-red-500 hover:text-red-600"
+ >
+ {isProcessing ? "Processing..." : "Cancel Subscription"}
+ </Button>
+ ) : (
+ <Button
+ onClick={handleResumeSubscription}
+ disabled={isProcessing}
+ >
+ {isProcessing ? "Processing..." : "Resume Subscription"}
+ </Button>
+ )}
+ </CardFooter>
+ </Card>
{/* Plan Features */}
<PlanFeaturesCard currentPlan={currentPlan} />
diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsx
index 7a6bdb4f2..00670ca63 100644
--- a/client/src/app/subscribe/page.tsx
+++ b/client/src/app/subscribe/page.tsx
@@ -15,6 +15,8 @@ import {
import { Button } from "@/components/ui/button";
import { STRIPE_PRICES } from "@/lib/stripe";
import { Slider } from "@/components/ui/slider";
+import { Badge } from "@/components/ui/badge";
+import { cn } from "@/lib/utils";
// Available event tiers for the slider
const EVENT_TIERS = [20_000, 100_000, 250_000, 500_000, 1_000_000, 2_000_000];
@@ -34,6 +36,9 @@ interface Plan extends PlanTemplate {
price: string;
interval: string;
features: string[];
+ monthlyPrice?: number;
+ annualPrice?: number;
+ savings?: string;
}
interface StripePrice {
@@ -106,21 +111,102 @@ const PLAN_TEMPLATES: PlanTemplate[] = [
];
// Format price with dollar sign
-function getFormattedPrice(plan: StripePrice): string {
- return `$${plan.price}`;
+function getFormattedPrice(price: number): string {
+ return `$${price}`;
}
// Find the appropriate price for a tier at current event limit
function findPriceForTier(
tier: "basic" | "pro" | "enterprise",
- eventLimit: number
+ eventLimit: number,
+ interval: "month" | "year"
): StripePrice | null {
- const plans = STRIPE_PRICES.filter((plan) => plan.name.startsWith(tier));
- return (
- plans.find((plan) => plan.limits.events >= eventLimit) ||
- plans[plans.length - 1] ||
- null
+ console.log(
+ `Finding price for tier: ${tier}, event limit: ${eventLimit}, interval: ${interval}`
+ );
+
+ // Determine if we need to look for annual plans
+ const isAnnual = interval === "year";
+ const namePattern = isAnnual ? `${tier}-annual` : tier;
+
+ // Filter plans by name pattern (with or without -annual suffix) and interval
+ const plans = STRIPE_PRICES.filter(
+ (plan) =>
+ (isAnnual
+ ? plan.name.startsWith(tier) && plan.name.includes("-annual")
+ : plan.name.startsWith(tier) && !plan.name.includes("-annual")) &&
+ plan.interval === interval
+ );
+
+ console.log(
+ `Filtered plans for ${namePattern} with interval ${interval}:`,
+ plans.map((p) => ({
+ name: p.name,
+ interval: p.interval,
+ events: p.limits.events,
+ price: p.price,
+ }))
);
+
+ if (plans.length === 0) {
+ console.warn(`No plans found for ${namePattern} with interval ${interval}`);
+ return null;
+ }
+
+ // Find a plan that matches or exceeds the event limit
+ const matchingPlan = plans.find((plan) => plan.limits.events >= eventLimit);
+ const selectedPlan = matchingPlan || plans[plans.length - 1] || null;
+
+ if (selectedPlan) {
+ console.log(
+ `Selected plan: ${selectedPlan.name} (${selectedPlan.interval}) - $${selectedPlan.price} - ${selectedPlan.limits.events} events`
+ );
+ } else {
+ console.log(
+ `No plan selected for ${namePattern} with interval ${interval}`
+ );
+ }
+
+ // Return the matching plan or the highest tier available
+ return selectedPlan;
+}
+
+// Calculate savings percentage between monthly and annual plans
+function calculateSavings(monthlyPrice: number, annualPrice: number): string {
+ const monthlyCost = monthlyPrice * 12;
+ const savings = monthlyCost - annualPrice;
+ const savingsPercent = Math.round((savings / monthlyCost) * 100);
+ return `Save ${savingsPercent}%`;
+}
+
+// Function to get the direct plan ID based on criteria
+function getDirectPlanID(
+ tier: "basic" | "pro",
+ eventLimit: number,
+ isAnnual: boolean
+): string {
+ // Base pattern for plan names is like "basic100k" or "pro250k"
+ let planPrefix = tier;
+ let eventSuffix = "";
+
+ // Determine event tier suffix
+ if (eventLimit <= 100_000) {
+ eventSuffix = "100k";
+ } else if (eventLimit <= 250_000) {
+ eventSuffix = "250k";
+ } else if (eventLimit <= 500_000) {
+ eventSuffix = "500k";
+ } else if (eventLimit <= 1_000_000) {
+ eventSuffix = "1m";
+ } else {
+ eventSuffix = "2m";
+ }
+
+ // Construct the plan name with annual suffix if needed
+ const planName = `${planPrefix}${eventSuffix}${isAnnual ? "-annual" : ""}`;
+ console.log(`Constructed plan name: ${planName} for isAnnual=${isAnnual}`);
+
+ return planName;
}
export default function Subscribe() {
@@ -129,6 +215,7 @@ export default function Subscribe() {
>("free");
const [eventLimitIndex, setEventLimitIndex] = useState<number>(0); // Default to 20k (index 0)
const [selectedPrice, setSelectedPrice] = useState<StripePrice | null>(null);
+ const [isAnnual, setIsAnnual] = useState<boolean>(false);
// Get the actual event limit value from the index
const eventLimit = EVENT_TIERS[eventLimitIndex];
@@ -136,31 +223,43 @@ export default function Subscribe() {
// Check if free plan is available based on event limit
const isFreeAvailable = eventLimit <= 20_000;
- // Group plans by type
- const basicPlans = STRIPE_PRICES.filter((plan) =>
- plan.name.startsWith("basic")
+ // Group plans by type and interval
+ const basicMonthlyPlans = STRIPE_PRICES.filter(
+ (plan) => plan.name.startsWith("basic") && !plan.name.includes("-annual")
+ );
+ const basicAnnualPlans = STRIPE_PRICES.filter(
+ (plan) => plan.name.includes("basic") && plan.name.includes("-annual")
+ );
+ const proMonthlyPlans = STRIPE_PRICES.filter(
+ (plan) => plan.name.startsWith("pro") && !plan.name.includes("-annual")
+ );
+ const proAnnualPlans = STRIPE_PRICES.filter(
+ (plan) => plan.name.includes("pro") && plan.name.includes("-annual")
);
- const proPlans = STRIPE_PRICES.filter((plan) => plan.name.startsWith("pro"));
// Update the selected price when tier or event limit changes
useEffect(() => {
- if (selectedTier === "free") {
+ if (selectedTier === "free" || selectedTier === "enterprise") {
setSelectedPrice(null);
return;
}
- if (selectedTier === "enterprise") {
- setSelectedPrice(null);
- return;
+ const interval = isAnnual ? "year" : "month";
+
+ // Get the correct set of plans based on the tier and interval
+ let filteredPlans;
+ if (selectedTier === "basic") {
+ filteredPlans = isAnnual ? basicAnnualPlans : basicMonthlyPlans;
+ } else {
+ filteredPlans = isAnnual ? proAnnualPlans : proMonthlyPlans;
}
- const plans = selectedTier === "basic" ? basicPlans : proPlans;
const matchingPlan =
- plans.find((plan) => plan.limits.events >= eventLimit) ||
- plans[plans.length - 1];
+ filteredPlans.find((plan) => plan.limits.events >= eventLimit) ||
+ filteredPlans[filteredPlans.length - 1];
setSelectedPrice(matchingPlan);
- }, [selectedTier, eventLimit, basicPlans, proPlans]);
+ }, [selectedTier, eventLimit, isAnnual]);
// Handle subscription
function handleSubscribe(
@@ -170,13 +269,52 @@ export default function Subscribe() {
if (planId === "free" || planId === "enterprise") return;
- const price = planId === "basic" ? basicTierPrice : proTierPrice;
- if (!price) return;
+ // Use the direct plan mapping approach with the new naming scheme
+ const planName = getDirectPlanID(
+ planId as "basic" | "pro",
+ eventLimit,
+ isAnnual
+ );
+
+ console.log(
+ `Direct plan mapping selected: ${planName}, interval=${
+ isAnnual ? "year" : "month"
+ }`
+ );
+
+ // Find the specific plan object in STRIPE_PRICES
+ const interval = isAnnual ? "year" : "month";
+
+ // The filter should match the new naming convention for annual plans
+ const matchingPlans = STRIPE_PRICES.filter((p) => {
+ const nameMatches = p.name === planName;
+ const intervalMatches = p.interval === interval;
+ return nameMatches && intervalMatches;
+ });
+
+ console.log(
+ `Found ${matchingPlans.length} matching plans for ${planName} (${interval})`
+ );
+
+ if (matchingPlans.length === 0) {
+ console.error(
+ `No matching plan found for name=${planName}, interval=${interval}`
+ );
+ return;
+ }
+
+ const selectedPlan = matchingPlans[0];
+ console.log(`Selected plan: `, selectedPlan);
+
+ // Log the selected plan to verify
+ console.log(
+ `Subscribing to ${selectedPlan.name} (${selectedPlan.interval}) - $${selectedPlan.price} - ${selectedPlan.limits.events} events`
+ );
authClient.subscription
.upgrade({
- plan: price.name,
- successUrl: globalThis.location.origin + "/",
+ plan: selectedPlan.name,
+ successUrl: globalThis.location.origin + "/auth/subscription/success",
cancelUrl: globalThis.location.origin + "/subscribe",
})
.catch((error) => {
@@ -200,19 +338,40 @@ export default function Subscribe() {
}
// Find the current prices for each tier based on the event limit
- const basicTierPrice = findPriceForTier("basic", eventLimit);
- const proTierPrice = findPriceForTier("pro", eventLimit);
+ const interval = isAnnual ? "year" : "month";
+ const basicTierPrice = findPriceForTier("basic", eventLimit, interval);
+ const proTierPrice = findPriceForTier("pro", eventLimit, interval);
+
+ // Also get monthly prices for savings calculation
+ const basicMonthly = findPriceForTier("basic", eventLimit, "month");
+ const proMonthly = findPriceForTier("pro", eventLimit, "month");
+ const basicAnnual = findPriceForTier("basic", eventLimit, "year");
+ const proAnnual = findPriceForTier("pro", eventLimit, "year");
// Generate plan objects with current state
const plans: Plan[] = PLAN_TEMPLATES.map((template) => {
const plan = { ...template } as Plan;
if (plan.id === "basic") {
- plan.price = basicTierPrice ? getFormattedPrice(basicTierPrice) : "$19+";
- plan.interval = "month";
+ const tierPrice = basicTierPrice;
+ plan.price = tierPrice ? getFormattedPrice(tierPrice.price) : "$19+";
+ plan.interval = isAnnual ? "year" : "month";
+
+ if (basicMonthly && basicAnnual) {
+ plan.monthlyPrice = basicMonthly.price;
+ plan.annualPrice = basicAnnual.price;
+ plan.savings = calculateSavings(basicMonthly.price, basicAnnual.price);
+ }
} else if (plan.id === "pro") {
- plan.price = proTierPrice ? getFormattedPrice(proTierPrice) : "$39+";
- plan.interval = "month";
+ const tierPrice = proTierPrice;
+ plan.price = tierPrice ? getFormattedPrice(tierPrice.price) : "$39+";
+ plan.interval = isAnnual ? "year" : "month";
+
+ if (proMonthly && proAnnual) {
+ plan.monthlyPrice = proMonthly.price;
+ plan.annualPrice = proAnnual.price;
+ plan.savings = calculateSavings(proMonthly.price, proAnnual.price);
+ }
} else if (plan.id === "enterprise") {
plan.price = "Custom";
plan.interval = "";
@@ -236,13 +395,46 @@ export default function Subscribe() {
return (
<div className="container mx-auto py-12">
- <div className="mb-16 text-center max-w-3xl mx-auto">
+ <div className="mb-12 text-center max-w-3xl mx-auto">
<h1 className="text-4xl font-bold tracking-tight mb-4 ">
Choose Your Analytics Plan
</h1>
<p className="text-lg text-neutral-600 dark:text-neutral-400 mb-6">
Find the perfect plan to track your site's performance
</p>
+
+ {/* Billing toggle buttons */}
+ <div className="flex justify-center mb-8 mt-10">
+ <div className="bg-neutral-100 dark:bg-neutral-800 p-1 rounded-full inline-flex relative">
+ <button
+ onClick={() => setIsAnnual(false)}
+ className={cn(
+ "px-6 py-2 rounded-full text-sm font-medium transition-all",
+ !isAnnual
+ ? "bg-white dark:bg-neutral-700 shadow-sm text-black dark:text-white"
+ : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
+ )}
+ >
+ Monthly
+ </button>
+ <div className="relative">
+ <button
+ onClick={() => setIsAnnual(true)}
+ className={cn(
+ "px-6 py-2 rounded-full text-sm font-medium transition-all",
+ isAnnual
+ ? "bg-white dark:bg-neutral-700 shadow-sm text-black dark:text-white"
+ : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
+ )}
+ >
+ Annual
+ </button>
+ <Badge className="absolute -top-2 -right-2 bg-emerald-500 text-white border-0 pointer-events-none">
+ 2 months free
+ </Badge>
+ </div>
+ </div>
+ </div>
</div>
<div className="mb-12 max-w-3xl mx-auto p-6 bg-white dark:bg-neutral-900 rounded-xl shadow-sm border border-neutral-100 dark:border-neutral-800">
@@ -308,6 +500,13 @@ export default function Subscribe() {
</span>
)}
</div>
+ {isAnnual &&
+ plan.id !== "free" &&
+ plan.id !== "enterprise" && (
+ <Badge className="bg-emerald-500 text-white border-0">
+ 2 months free
+ </Badge>
+ )}
<p>{plan.description}</p>
</CardDescription>
</CardHeader>
diff --git a/client/src/lib/stripe.ts b/client/src/lib/stripe.ts
index 8199e238f..15560a99a 100644
--- a/client/src/lib/stripe.ts
+++ b/client/src/lib/stripe.ts
@@ -10,8 +10,8 @@ export const STRIPE_PRICES = [
},
{
priceId: "price_1R2l2KDFVprnAny2iZr5gFLe",
- name: "basic100k",
price: 190,
+ name: "basic100k-annual",
interval: "year",
limits: {
events: 100_000,
@@ -29,7 +29,7 @@ export const STRIPE_PRICES = [
{
priceId: "price_1R2lJIDFVprnAny22zUvjg5o",
price: 290,
- name: "basic250k",
+ name: "basic250k-annual",
interval: "year",
limits: {
events: 250_000,
@@ -45,7 +45,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "basic500k",
+ name: "basic500k-annual",
priceId: "price_1R2lKIDFVprnAny27wXUAy2D",
price: 490,
interval: "year",
@@ -63,7 +63,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "basic1m",
+ name: "basic1m-annual",
priceId: "price_1R2lKtDFVprnAny2Xl98rgu4",
price: 690,
interval: "year",
@@ -81,7 +81,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "basic2m",
+ name: "basic2m-annual",
priceId: "price_1R1fRMDFVprnAny24AMo0Vuu",
price: 990,
interval: "year",
@@ -100,7 +100,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro100k",
+ name: "pro100k-annual",
priceId: "price_1R2niKDFVprnAny2MXTSHxEe",
price: 390,
interval: "year",
@@ -118,7 +118,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro250k",
+ name: "pro250k-annual",
priceId: "price_1R2nixDFVprnAny2GYxz6N2Q",
price: 590,
interval: "year",
@@ -136,7 +136,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro500k",
+ name: "pro500k-annual",
priceId: "price_1R2njbDFVprnAny28XqaBEmG",
price: 990,
interval: "year",
@@ -154,7 +154,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro1m",
+ name: "pro1m-annual",
priceId: "price_1R2nk3DFVprnAny2I6CyyF9f",
price: 1390,
interval: "year",
@@ -172,7 +172,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro2m",
+ name: "pro2m-annual",
priceId: "price_1R2nkfDFVprnAny2EkLPYdAg",
price: 1990,
interval: "year",
diff --git a/client/src/middleware.ts b/client/src/middleware.ts
index bac0141d4..900a3a4af 100644
--- a/client/src/middleware.ts
+++ b/client/src/middleware.ts
@@ -24,6 +24,7 @@ export function middleware(request: NextRequest) {
"signup",
"settings",
"subscribe",
+ "auth",
"_next",
"api",
];
diff --git a/server/src/lib/const.ts b/server/src/lib/const.ts
index c5669f7f1..f23abb020 100644
--- a/server/src/lib/const.ts
+++ b/server/src/lib/const.ts
@@ -15,7 +15,7 @@ export const STRIPE_PRICES = [
},
{
priceId: "price_1R2l2KDFVprnAny2iZr5gFLe",
- name: "basic100k",
+ name: "basic100k-annual",
interval: "year",
limits: {
events: 100_000,
@@ -31,7 +31,7 @@ export const STRIPE_PRICES = [
},
{
priceId: "price_1R2lJIDFVprnAny22zUvjg5o",
- name: "basic250k",
+ name: "basic250k-annual",
interval: "year",
limits: {
events: 250_000,
@@ -46,7 +46,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "basic500k",
+ name: "basic500k-annual",
priceId: "price_1R2lKIDFVprnAny27wXUAy2D",
interval: "year",
limits: {
@@ -62,7 +62,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "basic1m",
+ name: "basic1m-annual",
priceId: "price_1R2lKtDFVprnAny2Xl98rgu4",
interval: "year",
limits: {
@@ -78,7 +78,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "basic2m",
+ name: "basic2m-annual",
priceId: "price_1R1fRMDFVprnAny24AMo0Vuu",
interval: "year",
limits: {
@@ -95,7 +95,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro100k",
+ name: "pro100k-annual",
priceId: "price_1R2niKDFVprnAny2MXTSHxEe",
interval: "year",
limits: {
@@ -111,7 +111,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro250k",
+ name: "pro250k-annual",
priceId: "price_1R2nixDFVprnAny2GYxz6N2Q",
interval: "year",
limits: {
@@ -127,7 +127,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro500k",
+ name: "pro500k-annual",
priceId: "price_1R2njbDFVprnAny28XqaBEmG",
interval: "year",
limits: {
@@ -143,7 +143,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro1m",
+ name: "pro1m-annual",
priceId: "price_1R2nk3DFVprnAny2I6CyyF9f",
interval: "year",
limits: {
@@ -159,7 +159,7 @@ export const STRIPE_PRICES = [
},
},
{
- name: "pro2m",
+ name: "pro2m-annual",
priceId: "price_1R2nkfDFVprnAny2EkLPYdAg",
interval: "year",
limits: {