🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor subscription components to enhance pricing structure and use… (#598)
Bill Yangf4194fc3175a
diff --git a/client/src/api/admin/sites.ts b/client/src/api/admin/sites.tsindex e13f4bf7f..0577ddd49 100644--- a/client/src/api/admin/sites.ts+++ b/client/src/api/admin/sites.ts@@ -60,6 +60,7 @@ export type GetSitesFromOrgResponse = {overMonthlyLimit: boolean;planName: string;status: string;+ isPro: boolean;};};@@ -136,7 +137,6 @@ export function updateSiteConfig(});}-export function useSiteHasData(siteId: string) {return useQuery({queryKey: ["site-has-data", siteId],@@ -172,7 +172,6 @@ export function useGetSite(siteId?: string | number) {});}-export function useGetSiteIsPublic(siteId?: string | number) {return useQuery({queryKey: ["site-is-public", siteId],diff --git a/client/src/app/[site]/components/Header/DemoSignupBanner.tsx b/client/src/app/[site]/components/Header/DemoSignupBanner.tsxindex 7909f21d6..bb1a0f8a5 100644--- a/client/src/app/[site]/components/Header/DemoSignupBanner.tsx+++ b/client/src/app/[site]/components/Header/DemoSignupBanner.tsx@@ -3,10 +3,11 @@import { ArrowRight, Sparkles } from "lucide-react";import Link from "next/link";import { Button } from "../../../../components/ui/button";+import { DEMO_HOSTNAME } from "../../../../lib/const";export function DemoSignupBanner() {// Only show on demo.rybbit.io and not in an iframe- if (typeof window === "undefined" || window.location.host !== "demo.rybbit.io") {+ if (typeof window === "undefined" || window.location.host !== DEMO_HOSTNAME) {return null;}diff --git a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx b/client/src/app/[site]/components/Sidebar/SiteSelector.tsxindex b6bd66a16..4ac2b99d9 100644--- a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx+++ b/client/src/app/[site]/components/Sidebar/SiteSelector.tsx@@ -11,6 +11,7 @@ import { userStore } from "../../../../lib/userStore";import { cn, formatter } from "../../../../lib/utils";import { AddSite } from "../../../components/AddSite";import { useEmbedablePage } from "../../utils";+import { DEMO_HOSTNAME } from "../../../../lib/const";function SiteSelectorContent({ onSiteSelect }: { onSiteSelect: () => void }) {const { data: activeOrganization } = authClient.useActiveOrganization();@@ -28,7 +29,7 @@ function SiteSelectorContent({ onSiteSelect }: { onSiteSelect: () => void }) {if (embed) return null;- if (typeof window !== "undefined" && globalThis.location.hostname === "demo.rybbit.io") {+ if (typeof window !== "undefined" && globalThis.location.hostname === DEMO_HOSTNAME) {return (<PopoverContent align="start" className="w-52 p-2"><div className="max-h-96 overflow-y-auto">diff --git a/client/src/app/[site]/events/components/EventLog.tsx b/client/src/app/[site]/events/components/EventLog.tsxindex 0117796cc..863a56efa 100644--- a/client/src/app/[site]/events/components/EventLog.tsx+++ b/client/src/app/[site]/events/components/EventLog.tsx@@ -15,8 +15,6 @@ export function EventLog() {pageSize: 100,});- // Remove console.log-// Handle scroll for infinite loadingconst handleScroll = useCallback(() => {if (!loadMoreRef.current || !containerRef.current || !hasNextPage || isFetchingNextPage) {diff --git a/client/src/app/[site]/replay/page.tsx b/client/src/app/[site]/replay/page.tsxindex a031b3dcb..9da9b626b 100644--- a/client/src/app/[site]/replay/page.tsx+++ b/client/src/app/[site]/replay/page.tsx@@ -26,7 +26,7 @@ export default function SessionReplayPage() {const [ref, { height: resolvedHeight, width: resolvedWidth }] = useMeasure();return (- <DisabledOverlay message="Replay" featurePath="replay">+ <DisabledOverlay message="Replay" featurePath="replay" requiredPlan="pro"><div className="p-2 md:p-4 max-w-[2000px] mx-auto flex flex-col gap-1 overflow-y-hidden"><SubHeader availableFilters={SESSION_REPLAY_PAGE_FILTERS} /><EnableSessionReplay />diff --git a/client/src/app/auth/subscription/success/page.tsx b/client/src/app/auth/subscription/success/page.tsxindex 042f6c613..80cd8c080 100644--- a/client/src/app/auth/subscription/success/page.tsx+++ b/client/src/app/auth/subscription/success/page.tsx@@ -8,9 +8,6 @@ export default function StripeSuccessPage() {const router = useRouter();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 redirectingconst redirectTimer = setTimeout(() => {// Redirect to the subscription settings pagediff --git a/client/src/app/components/AddSite.tsx b/client/src/app/components/AddSite.tsxindex db2b35150..dcbf84b30 100644--- a/client/src/app/components/AddSite.tsx+++ b/client/src/app/components/AddSite.tsx@@ -1,7 +1,7 @@"use client";import { Button } from "@/components/ui/button";import { AlertCircle, AppWindow, Plus } from "lucide-react";-import { useState } from "react";+import { useMemo, useState } from "react";import { addSite, useGetSitesFromOrg } from "../../api/admin/sites";import { Alert, AlertDescription, AlertTitle } from "../../components/ui/alert";import {@@ -32,9 +32,22 @@ export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disaconst { data: sites, refetch } = useGetSitesFromOrg(activeOrganization?.id);const { data: subscription } = useStripeSubscription();- // Disable if user is on free plan and has 3+ sites- const isDisabledDueToLimit = subscription?.status !== "active" && (sites?.sites?.length || 0) >= 3 && IS_CLOUD;- const finalDisabled = disabled || isDisabledDueToLimit;+ const isOverSiteLimit = useMemo(() => {+ const numberOfSites = sites?.sites?.length || 0;+ if (!IS_CLOUD) {+ return false;+ }+ if (subscription?.status !== "active" && numberOfSites >= 3) {+ return true;+ }+ if (!subscription?.isPro && numberOfSites >= 10) {+ return true;+ }++ return false;+ }, [subscription, sites]);++ const finalDisabled = disabled || isOverSiteLimit;const [open, setOpen] = useState(false);const [domain, setDomain] = useState("");@@ -83,7 +96,7 @@ export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disa};// Show upgrade message if disabled due to limit- if (isDisabledDueToLimit) {+ if (isOverSiteLimit) {return (<Tooltip><TooltipTrigger asChild>@@ -94,7 +107,9 @@ export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disa</Button></span></TooltipTrigger>- <TooltipContent>Upgrade to Pro to add more websites</TooltipContent>+ <TooltipContent>+ You have reached the limit of {subscription?.isPro ? 10 : 3} websites. Upgrade to add more websites+ </TooltipContent></Tooltip>);}diff --git a/client/src/app/settings/organization/members/components/Invitations.tsx b/client/src/app/settings/organization/members/components/Invitations.tsxindex a6fc67df0..e61c1c147 100644--- a/client/src/app/settings/organization/members/components/Invitations.tsx+++ b/client/src/app/settings/organization/members/components/Invitations.tsx@@ -62,7 +62,7 @@ export function Invitations({ organizationId, isOwner }: InvitationsProps) {case "pending":return "secondary";case "accepted":- return "green";+ return "success";case "rejected":return "destructive";case "canceled":diff --git a/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx b/client/src/app/settings/organization/members/components/InviteMemberDialog.tsxindex 7a8937aa0..7408170c1 100644--- a/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx+++ b/client/src/app/settings/organization/members/components/InviteMemberDialog.tsx@@ -14,19 +14,31 @@ import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { UserPlus } from "lucide-react";-import { useState } from "react";+import { useMemo, useState } from "react";import { toast } from "sonner";import { Alert } from "../../../../../components/ui/alert";import { authClient } from "../../../../../lib/auth";+import { useStripeSubscription } from "../../../../../lib/subscription/useStripeSubscription";+import { IS_CLOUD } from "../../../../../lib/const";+import { Tooltip, TooltipContent, TooltipTrigger } from "../../../../../components/ui/tooltip";interface InviteMemberDialogProps {organizationId: string;onSuccess: () => void;+ memberCount: number;}-export function InviteMemberDialog({ organizationId, onSuccess }: InviteMemberDialogProps) {+export function InviteMemberDialog({ organizationId, onSuccess, memberCount }: InviteMemberDialogProps) {+ const { data: subscription } = useStripeSubscription();++ const isOverMemberLimit = useMemo(() => {+ if (!IS_CLOUD) return false;+ const limit = subscription?.status !== "active" ? 1 : subscription?.isPro ? 10 : 3;+ return memberCount >= limit;+ }, [subscription, memberCount]);+const [email, setEmail] = useState("");- const [role, setRole] = useState<"admin" | "member">("member");+ const [role, setRole] = useState<"admin" | "member" | "owner">("member");const [isLoading, setIsLoading] = useState(false);const [open, setOpen] = useState(false);@@ -59,6 +71,23 @@ export function InviteMemberDialog({ organizationId, onSuccess }: InviteMemberDi}};+ if (isOverMemberLimit) {+ return (+ <Tooltip>+ <TooltipTrigger asChild>+ <span>+ <Button disabled size="sm" variant="outline" title="Upgrade to Pro to add more members">+ <UserPlus className="h-4 w-4 mr-1" />+ Invite Member+ </Button>+ </span>+ </TooltipTrigger>+ <TooltipContent>+ You have reached the limit of {subscription?.isPro ? 10 : 3} members. Upgrade to add more members+ </TooltipContent>+ </Tooltip>+ );+ }return (<Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild>diff --git a/client/src/app/settings/organization/members/page.tsx b/client/src/app/settings/organization/members/page.tsxindex 41a7903ea..fab5f5ebc 100644--- a/client/src/app/settings/organization/members/page.tsx+++ b/client/src/app/settings/organization/members/page.tsx@@ -71,7 +71,11 @@ function Organization({{isOwner && (<>{IS_CLOUD ? (- <InviteMemberDialog organizationId={org.id} onSuccess={handleRefresh} />+ <InviteMemberDialog+ organizationId={org.id}+ onSuccess={handleRefresh}+ memberCount={members?.data?.length || 0}+ />) : (<CreateUserDialog organizationId={org.id} onSuccess={handleRefresh} />)}diff --git a/client/src/app/settings/organization/subscription/page.tsx b/client/src/app/settings/organization/subscription/page.tsxindex b99f92031..e11e0ccf4 100644--- a/client/src/app/settings/organization/subscription/page.tsx+++ b/client/src/app/settings/organization/subscription/page.tsx@@ -2,7 +2,7 @@import { Card, CardContent, CardDescription, CardTitle } from "@/components/ui/card";import { Skeleton } from "@/components/ui/skeleton";-import { ProPlan } from "../../../../components/subscription/ProPlan";+import { PaidPlan } from "../../../../components/subscription/PaidPlain/PaidPlan";import { useStripeSubscription } from "../../../../lib/subscription/useStripeSubscription";import { NoOrganization } from "../../../../components/NoOrganization";import { TrialPlan } from "../../../../components/subscription/TrialPlan";@@ -63,7 +63,7 @@ export default function OrganizationSubscriptionPage() {return <TrialPlan />;}- return <ProPlan />;+ return <PaidPlan />;};return (diff --git a/client/src/app/subscribe/components/PricingCard.tsx b/client/src/app/subscribe/components/PricingCard.tsxindex 2968b036f..8ee09490c 100644--- a/client/src/app/subscribe/components/PricingCard.tsx+++ b/client/src/app/subscribe/components/PricingCard.tsx@@ -5,14 +5,11 @@ import { cn } from "@/lib/utils";import { toast } from "sonner";import { BACKEND_URL } from "@/lib/const";import { authClient } from "@/lib/auth";-import { EVENT_TIERS, PRO_FEATURES, StripePrice, findPriceForTier, formatEventTier } from "./utils";+import { EVENT_TIERS, STANDARD_FEATURES, PRO_FEATURES, FREE_FEATURES, findPriceForTier, formatEventTier } from "./utils";+import { getStripePrices } from "../../../lib/stripe";-interface PricingCardProps {- stripePrices: StripePrice[];- isLoggedIn: boolean;-}--export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {+export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {+ const stripePrices = getStripePrices();const [eventLimitIndex, setEventLimitIndex] = useState<number>(0);const [isAnnual, setIsAnnual] = useState<boolean>(false);const [isLoading, setIsLoading] = useState<boolean>(false);@@ -20,8 +17,8 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {const eventLimit = EVENT_TIERS[eventLimitIndex];- // Handle subscription- async function handleSubscribe(): Promise<void> {+ // Handle subscription for a specific plan type+ async function handleSubscribe(planType: "standard" | "pro"): Promise<void> {// Handle custom tier by redirecting to email contactif (eventLimit === "Custom") {window.location.href = "https://www.rybbit.io/contact";@@ -40,7 +37,7 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {return;}- const selectedTierPrice = findPriceForTier(eventLimit, isAnnual ? "year" : "month", stripePrices);+ const selectedTierPrice = findPriceForTier(eventLimit, isAnnual ? "year" : "month", stripePrices, planType);if (!selectedTierPrice) {toast.error("Selected pricing plan not found. Please adjust the slider.");@@ -90,106 +87,203 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {setEventLimitIndex(value[0]);}- // Get pricing information- const monthlyPrice = findPriceForTier(eventLimit, "month", stripePrices)?.price || 0;- const annualPrice = findPriceForTier(eventLimit, "year", stripePrices)?.price || 0;+ // Get pricing information for both plans+ const standardMonthlyPrice = findPriceForTier(eventLimit, "month", stripePrices, "standard")?.price || 0;+ const standardAnnualPrice = findPriceForTier(eventLimit, "year", stripePrices, "standard")?.price || 0;+ const proMonthlyPrice = findPriceForTier(eventLimit, "month", stripePrices, "pro")?.price || 0;+ const proAnnualPrice = findPriceForTier(eventLimit, "year", stripePrices, "pro")?.price || 0;const isCustomTier = eventLimit === "Custom";return (- <div className="max-w-lg mx-auto">- <div className="bg-neutral-800/50 rounded-xl border border-neutral-700 overflow-hidden">- <div className="p-6">- {/* Slider section */}- <div className="mb-6">- <div className="flex justify-between mb-3 items-center">+ <div className="max-w-6xl mx-auto">+ {/* Shared controls section */}+ <div className="max-w-xl mx-auto mb-8">+ {/* Events per month and billing toggle */}+ <div className="flex justify-between mb-6 items-center">+ <div>+ <h3 className="font-semibold mb-2">Events per month</h3>+ <div className="text-3xl font-bold text-emerald-400">+ {typeof eventLimit === "number" ? eventLimit.toLocaleString() : eventLimit}+ </div>+ </div>+ <div className="flex flex-col items-end">+ {/* Billing toggle */}+ <div className="flex gap-3 mb-2 text-sm">+ <button+ onClick={() => setIsAnnual(false)}+ className={cn(+ "px-3 py-1 rounded-full transition-colors cursor-pointer",+ !isAnnual+ ? "bg-emerald-500/20 text-emerald-400 font-medium"+ : "text-neutral-400 hover:text-neutral-200"+ )}+ >+ Monthly+ </button>+ <button+ onClick={() => setIsAnnual(true)}+ className={cn(+ "px-3 py-1 rounded-full transition-colors cursor-pointer",+ isAnnual+ ? "bg-emerald-500/20 text-emerald-400 font-medium"+ : "text-neutral-400 hover:text-neutral-200"+ )}+ >+ Annual+ <span className="ml-1 text-xs text-emerald-500">-17%</span>+ </button>+ </div>+ </div>+ </div>++ {/* Slider */}+ <Slider+ defaultValue={[0]}+ max={EVENT_TIERS.length - 1}+ min={0}+ step={1}+ onValueChange={handleSliderChange}+ className="mb-3"+ />++ <div className="flex justify-between text-xs text-neutral-400">+ {EVENT_TIERS.map((tier, index) => (+ <span key={index} className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}>+ {formatEventTier(tier)}+ </span>+ ))}+ </div>+ </div>++ {/* Cards section */}+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6 max-w-6xl mx-auto">+ {/* Free Plan Card */}+ <div className="bg-neutral-800/15 rounded-xl border border-neutral-700/60 overflow-hidden text-neutral-300">+ <div className="p-6">+ <div className="mb-4">+ <h3 className="text-xl font-bold mb-2">Free</h3>+ <p className="text-sm text-neutral-400">Perfect for getting started</p>+ </div>++ {/* Price display */}+ <div className="mb-6"><div>- <h3 className="font-semibold mb-2">Events per month</h3>- <div className="text-3xl font-bold text-emerald-400">- {typeof eventLimit === "number" ? eventLimit.toLocaleString() : eventLimit}- </div>+ <span className="text-3xl font-bold">10,000</span>+ <span className="ml-1 text-neutral-400">/month events</span></div>- <div className="flex flex-col items-end">- {/* Billing toggle */}- <div className="flex gap-3 mb-2 text-sm">- <button- onClick={() => setIsAnnual(false)}- className={cn(- "px-3 py-1 rounded-full transition-colors cursor-pointer",- !isAnnual- ? "bg-emerald-500/20 text-emerald-400 font-medium"- : "text-neutral-400 hover:text-neutral-200"- )}- >- Monthly- </button>- <button- onClick={() => setIsAnnual(true)}- className={cn(- "px-3 py-1 rounded-full transition-colors cursor-pointer",- isAnnual- ? "bg-emerald-500/20 text-emerald-400 font-medium"- : "text-neutral-400 hover:text-neutral-200"- )}- >- Annual- <span className="ml-1 text-xs text-emerald-500">-17%</span>- </button>+ </div>++ {/* Current plan button */}+ <button+ disabled+ className="w-full bg-neutral-700/50 text-neutral-400 font-medium px-5 py-3 rounded-xl border border-neutral-600/50 cursor-not-allowed opacity-50"+ >+ Current Plan+ </button>++ {/* Features */}+ <div className="space-y-4 mt-6">+ {FREE_FEATURES.map((feature, i) => (+ <div key={i} className="flex items-center">+ <Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />+ <span className="text-sm">{feature}</span></div>- <div className="text-right h-10">- {isCustomTier ? (- <></>- ) : (- <>- <span className="text-3xl font-bold">- ${isAnnual ? Math.round(annualPrice / 12) : monthlyPrice}- </span>- <span className="ml-1 text-neutral-400">/month</span>- </>- )}+ ))}+ </div>+ </div>+ </div>++ {/* Standard Plan Card */}+ <div className="bg-neutral-800/50 rounded-xl border border-neutral-700 overflow-hidden">+ <div className="p-6">+ <div className="mb-4">+ <h3 className="text-xl font-bold mb-2">Standard</h3>+ <p className="text-sm text-neutral-400">Everything you need to get started</p>+ </div>++ {/* Price display */}+ <div className="mb-6">+ {isCustomTier ? (+ <div className="text-3xl font-bold">Custom</div>+ ) : (+ <div>+ <span className="text-3xl font-bold">+ ${isAnnual ? Math.round(standardAnnualPrice / 12) : standardMonthlyPrice}+ </span>+ <span className="ml-1 text-neutral-400">/month</span></div>- </div>+ )}</div>- <Slider- defaultValue={[0]}- max={EVENT_TIERS.length - 1}- min={0}- step={1}- onValueChange={handleSliderChange}- className="mb-3"- />-- <div className="flex justify-between text-xs text-neutral-400">- {EVENT_TIERS.map((tier, index) => (- <span key={index} className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}>- {formatEventTier(tier)}- </span>+ {/* Subscribe button */}+ <button+ onClick={() => handleSubscribe("standard")}+ 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 cursor-pointer"+ disabled={isLoading}+ >+ {isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Get Standard"}+ </button>++ {/* Features */}+ <div className="space-y-4 mt-6">+ {STANDARD_FEATURES.map((feature, i) => (+ <div key={i} className="flex items-center">+ <Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />+ <span className="text-sm">{feature}</span>+ </div>))}</div></div>+ </div>- <div className="space-y-4 mb-6">- {PRO_FEATURES.map((feature, i) => (- <div key={i} className="flex items-center">- <Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />- <span>{feature}</span>- </div>- ))}- </div>+ {/* Pro Plan Card */}+ <div className="bg-neutral-800/50 rounded-xl border border-neutral-700 overflow-hidden">+ <div className="p-6">+ <div className="mb-4">+ <h3 className="text-xl font-bold mb-2">Pro</h3>+ <p className="text-sm text-neutral-400">Advanced features for professional teams</p>+ </div>++ {/* Price display */}+ <div className="mb-6">+ {isCustomTier ? (+ <div className="text-3xl font-bold">Custom</div>+ ) : (+ <div>+ <span className="text-3xl font-bold">+ ${isAnnual ? Math.round(proAnnualPrice / 12) : proMonthlyPrice}+ </span>+ <span className="ml-1 text-neutral-400">/month</span>+ </div>+ )}+ </div>++ {/* Subscribe button */}+ <button+ onClick={() => handleSubscribe("pro")}+ 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 cursor-pointer"+ disabled={isLoading}+ >+ {isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Get Pro"}+ </button>- <button- onClick={handleSubscribe}- 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 cursor-pointer"- disabled={isLoading}- >- {isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Subscribe Now"}- </button>-- <p className="text-center text-sm text-neutral-400 mt-4">- {isCustomTier ? "Email us at [email protected] for custom pricing" : "Secure checkout powered by Stripe."}- </p>+ {/* Features */}+ <div className="space-y-4 mt-6">+ {PRO_FEATURES.map((feature, i) => (+ <div key={i} className="flex items-center">+ <Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />+ <span className="text-sm">{feature}</span>+ </div>+ ))}+ </div>+ </div></div></div>++ {/* Footer text */}+ <p className="text-center text-sm text-neutral-400 mt-6">+ {isCustomTier ? "Email us at [email protected] for custom pricing" : "Secure checkout powered by Stripe."}+ </p></div>);}diff --git a/client/src/app/subscribe/components/utils.ts b/client/src/app/subscribe/components/utils.tsindex 8b453e288..a1a5212c3 100644--- a/client/src/app/subscribe/components/utils.ts+++ b/client/src/app/subscribe/components/utils.ts@@ -12,26 +12,44 @@ 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 PRO_FEATURES = [- "Unlimited websites",- "Unlimited team members",- "Session replays",- "Real-time analytics",+export const STANDARD_FEATURES = [+ "Up to 10 websites",+ "Up to 3 team members","Web vitals",- "Custom events","Funnels","Goals",+ "Error tracking","Journeys","User profiles","Retention",- "All features",+ "2 year data retention",+ "Standard support",+];++export const PRO_FEATURES = [+ "Everything in Standard",+ "Unlimited websites",+ "Unlimited team members",+ "Session replays",+ "5+ year data retention",+ "Priority support",+];++export const FREE_FEATURES = [+ "1 user",+ "Up to 3 websites",+ "Cookieless tracking",+ "Web analytics dashboard",+ "Custom events",+ "6 month data retention",];// Find the appropriate price for a tier at current event limitexport function findPriceForTier(eventLimit: number | string,interval: "month" | "year",- stripePrices: StripePrice[]+ stripePrices: StripePrice[],+ planType: "standard" | "pro" = "standard"): StripePrice | null {// Check if we have a custom tierif (eventLimit === "Custom") {@@ -48,8 +66,8 @@ export function findPriceForTier(const plans = stripePrices.filter(plan =>(isAnnual- ? plan.name.startsWith("pro") && plan.name.includes("-annual")- : plan.name.startsWith("pro") && !plan.name.includes("-annual")) && plan.interval === interval+ ? plan.name.startsWith(planType) && plan.name.includes("-annual")+ : plan.name.startsWith(planType) && !plan.name.includes("-annual")) && plan.interval === interval);// Find a plan that matches or exceeds the event limitdiff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsxindex 10f10ffb1..eba175912 100644--- a/client/src/app/subscribe/page.tsx+++ b/client/src/app/subscribe/page.tsx@@ -1,17 +1,16 @@"use client";import { authClient } from "@/lib/auth";-import { getStripePrices } from "@/lib/stripe";-import { useRouter } from "next/navigation";-import { DateTime } from "luxon";import { TrendingUp } from "lucide-react";-import { StandardPage } from "../../components/StandardPage";-import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";+import { DateTime } from "luxon";+import { useRouter } from "next/navigation";import { useGetOrgEventCount } from "../../api/analytics/useGetOrgEventCount";+import { StandardPage } from "../../components/StandardPage";import { UsageChart } from "../../components/UsageChart";-import { PricingHeader } from "./components/PricingHeader";-import { PricingCard } from "./components/PricingCard";+import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";import { FAQSection } from "./components/FAQSection";+import { PricingCard } from "./components/PricingCard";+import { PricingHeader } from "./components/PricingHeader";export default function Subscribe() {const { data: sessionData } = authClient.useSession();@@ -48,7 +47,7 @@ export default function Subscribe() {<PricingHeader />{/* Pricing Card */}- <PricingCard stripePrices={getStripePrices()} isLoggedIn={!!sessionData?.user} />+ <PricingCard isLoggedIn={!!sessionData?.user} />{/* Usage Stats and Chart */}{organizationId && (diff --git a/client/src/app/uptime/monitors/components/dialog/MonitorDialog.tsx b/client/src/app/uptime/monitors/components/dialog/MonitorDialog.tsxindex d59051104..1996810e0 100644--- a/client/src/app/uptime/monitors/components/dialog/MonitorDialog.tsx+++ b/client/src/app/uptime/monitors/components/dialog/MonitorDialog.tsx@@ -217,11 +217,7 @@ export function MonitorDialog({ monitor, open, onOpenChange }: MonitorDialogProp<Dialog open={open} onOpenChange={onOpenChange}><DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto"><Form {...form}>- <form- onSubmit={form.handleSubmit(onSubmit, errors => {- console.log("Form validation errors:", errors);- })}- >+ <form><DialogHeader><DialogTitle>{isEdit ? "Edit" : "Create New"} Monitor</DialogTitle><DialogDescription>diff --git a/client/src/components/DisabledOverlay.tsx b/client/src/components/DisabledOverlay.tsxindex f4ec5b9b0..9cfa0d75a 100644--- a/client/src/components/DisabledOverlay.tsx+++ b/client/src/components/DisabledOverlay.tsx@@ -1,10 +1,12 @@import { ArrowRight, Crown, ExternalLink } from "lucide-react";import Link from "next/link";-import React, { ReactNode } from "react";+import React, { ReactNode, useMemo } from "react";import { useCurrentSite } from "../api/admin/sites";import { DEFAULT_EVENT_LIMIT } from "../lib/subscription/constants";import { Button } from "./ui/button";import { authClient } from "../lib/auth";+import { DEMO_HOSTNAME } from "../lib/const";+import { DateTime } from "luxon";interface DisabledOverlayProps {children: ReactNode;@@ -14,20 +16,23 @@ interface DisabledOverlayProps {borderRadius?: number;showMessage?: boolean;style?: React.CSSProperties;+ requiredPlan?: "pro" | "standard";}-function ownerMessage(message: string, featurePath?: string) {+function ownerMessage(message: string, featurePath?: string, requiredPlan?: "pro" | "standard") {return (<div className="bg-neutral-900 rounded-lg border border-neutral-700 shadow-xl flex flex-col gap-3 p-4"><div className="flex gap-3"><Crown className="h-5 w-5 text-amber-500 flex-shrink-0" /><div className="flex-1 space-y-1"><p className="text-sm text-muted-foreground">- Upgrade to <span className="font-medium text-foreground">Pro</span> to unlock {message}+ Upgrade to{" "}+ <span className="font-medium text-foreground">{requiredPlan === "pro" ? "Pro" : "Standard"}</span> to unlock{" "}+ {message}</p>{featurePath && (<Link- href={`https://demo.rybbit.io/21/${featurePath}`}+ href={`https://${DEMO_HOSTNAME}/21/${featurePath}`}target="_blank"className="text-sm text-neutral-100 hover:underline flex items-center gap-1">@@ -46,7 +51,7 @@ function ownerMessage(message: string, featurePath?: string) {);}-function userMessage(message: string, featurePath?: string) {+function userMessage(message: string, featurePath?: string, requiredPlan?: "pro" | "standard") {return (<div className="bg-neutral-900 rounded-lg border border-neutral-700 shadow-xl flex flex-col gap-3 p-4"><div className="flex gap-3">@@ -58,7 +63,7 @@ function userMessage(message: string, featurePath?: string) {</p>{featurePath && (<Link- href={`https://demo.rybbit.io/21/${featurePath}`}+ href={`https://${DEMO_HOSTNAME}/21/${featurePath}`}target="_blank"className="text-sm text-neutral-100 hover:underline flex items-center gap-1">@@ -80,14 +85,25 @@ export const DisabledOverlay: React.FC<DisabledOverlayProps> = ({borderRadius = 0,showMessage = true,style,+ requiredPlan = "standard",}) => {const { subscription, site } = useCurrentSite();const { data } = authClient.useSession();- const disabled = subscription?.eventLimit === DEFAULT_EVENT_LIMIT;+ const { data: organization } = authClient.useActiveOrganization();++ const disabled = useMemo(() => {+ if (requiredPlan === "pro") {+ if (organization?.createdAt && DateTime.fromJSDate(organization?.createdAt) < DateTime.fromISO("2025-09-19")) {+ return false;+ }+ return !subscription?.isPro;+ }+ return subscription?.eventLimit === DEFAULT_EVENT_LIMIT;+ }, [subscription, requiredPlan]);- if (!disabled || data?.user?.role === "admin") {+ if (!disabled || data?.user?.role === "admin" || globalThis.location.hostname === DEMO_HOSTNAME) {return <>{children}</>;}@@ -101,7 +117,9 @@ export const DisabledOverlay: React.FC<DisabledOverlayProps> = ({<div className="absolute inset-0 flex items-center justify-center z-10" style={borderRadiusStyle}>{showMessage && (<div className="flex items-center justify-center">- {site?.isOwner ? ownerMessage(message, featurePath) : userMessage(message, featurePath)}+ {site?.isOwner+ ? ownerMessage(message, featurePath, requiredPlan)+ : userMessage(message, featurePath, requiredPlan)}</div>)}</div>diff --git a/client/src/components/SiteSettings/SiteConfiguration.tsx b/client/src/components/SiteSettings/SiteConfiguration.tsxindex 45a823861..f90b8f713 100644--- a/client/src/components/SiteSettings/SiteConfiguration.tsx+++ b/client/src/components/SiteSettings/SiteConfiguration.tsx@@ -2,7 +2,7 @@import { AlertTriangle } from "lucide-react";import { useRouter } from "next/navigation";-import { useState, useCallback } from "react";+import { useState, useCallback, ReactNode } from "react";import { toast } from "sonner";import {@@ -24,6 +24,9 @@ import { Switch } from "@/components/ui/switch";import { deleteSite, SiteResponse, updateSiteConfig, useGetSitesFromOrg } from "@/api/admin/sites";import { normalizeDomain } from "@/lib/utils";import { IPExclusionManager } from "./IPExclusionManager";+import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";+import { Badge } from "../ui/badge";+import { IS_CLOUD } from "../../lib/const";interface SiteConfigurationProps {siteMetadata: SiteResponse;@@ -39,6 +42,8 @@ interface ToggleConfig {key: keyof SiteResponse;enabledMessage?: string;disabledMessage?: string;+ disabled?: boolean;+ badge?: ReactNode;}export function SiteConfiguration({ siteMetadata, disabled = false, onClose }: SiteConfigurationProps) {@@ -162,6 +167,12 @@ export function SiteConfiguration({ siteMetadata, disabled = false, onClose }: S},];+ const { data: subscription } = useStripeSubscription();++ const sessionReplayDisabled = !subscription?.isPro && IS_CLOUD;+ const webVitalsDisabled = subscription?.status !== "active" && IS_CLOUD;+ const trackErrorsDisabled = subscription?.status !== "active" && IS_CLOUD;+// Configuration for analytics feature togglesconst analyticsToggles: ToggleConfig[] = [{@@ -172,6 +183,8 @@ export function SiteConfiguration({ siteMetadata, disabled = false, onClose }: Skey: "sessionReplay",enabledMessage: "Session replay enabled",disabledMessage: "Session replay disabled",+ disabled: sessionReplayDisabled,+ badge: <Badge variant="success">Pro</Badge>,},{id: "webVitals",@@ -181,6 +194,8 @@ export function SiteConfiguration({ siteMetadata, disabled = false, onClose }: Skey: "webVitals",enabledMessage: "Web Vitals enabled",disabledMessage: "Web Vitals disabled",+ disabled: webVitalsDisabled,+ badge: <Badge variant="success">Standard</Badge>,},{id: "trackErrors",@@ -190,6 +205,8 @@ export function SiteConfiguration({ siteMetadata, disabled = false, onClose }: Skey: "trackErrors",enabledMessage: "Error tracking enabled",disabledMessage: "Error tracking disabled",+ disabled: trackErrorsDisabled,+ badge: <Badge variant="success">Standard</Badge>,},{id: "trackOutbound",@@ -235,15 +252,15 @@ export function SiteConfiguration({ siteMetadata, disabled = false, onClose }: S{toggles.map(toggle => (<div key={toggle.id} className="flex items-center justify-between"><div>- <Label htmlFor={toggle.id} className="text-sm font-medium text-foreground block">- {toggle.label}+ <Label htmlFor={toggle.id} className="text-sm font-medium text-foreground flex items-center gap-2">+ {toggle.label} {toggle.badge && IS_CLOUD && toggle.badge}</Label><p className="text-xs text-muted-foreground mt-1">{toggle.description}</p></div><Switchid={toggle.id}checked={toggle.value}- disabled={loadingStates[toggle.key] || disabled}+ disabled={loadingStates[toggle.key] || disabled || toggle.disabled}onCheckedChange={checked =>handleToggle(toggle.key as keyof typeof toggleStates,diff --git a/client/src/components/TopBar.tsx b/client/src/components/TopBar.tsxindex db6172ce3..c0343a785 100644--- a/client/src/components/TopBar.tsx+++ b/client/src/components/TopBar.tsx@@ -9,7 +9,7 @@ import { authClient } from "../lib/auth";import { Button } from "./ui/button";import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./ui/dropdown-menu";import { Skeleton } from "./ui/skeleton";-import { IS_CLOUD } from "../lib/const";+import { DEMO_HOSTNAME, IS_CLOUD } from "../lib/const";export function TopBar() {const { data: session, isPending } = authClient.useSession();@@ -63,7 +63,7 @@ export function TopBar() {) : (<Linkhref={- typeof window !== "undefined" && globalThis.location.hostname === "demo.rybbit.io"+ typeof window !== "undefined" && globalThis.location.hostname === DEMO_HOSTNAME? "https://app.rybbit.io/signup": "/signup"}diff --git a/client/src/components/subscription/ProPlan.tsx b/client/src/components/subscription/PaidPlain/PaidPlan.tsxsimilarity index 80%rename from client/src/components/subscription/ProPlan.tsxrename to client/src/components/subscription/PaidPlain/PaidPlan.tsxindex dd41ec908..ea6fb010f 100644--- a/client/src/components/subscription/ProPlan.tsx+++ b/client/src/components/subscription/PaidPlain/PaidPlan.tsx@@ -2,18 +2,19 @@ import { Shield } from "lucide-react";import { useState } from "react";import { toast } from "sonner";import { DateTime } from "luxon";-import { Alert } from "../ui/alert";-import { Button } from "../ui/button";-import { Card, CardContent } from "../ui/card";-import { Progress } from "../ui/progress";-import { BACKEND_URL } from "../../lib/const";-import { getStripePrices } from "../../lib/stripe";-import { formatDate } from "../../lib/subscription/planUtils";-import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";-import { UsageChart } from "../UsageChart";+import { Alert } from "../../ui/alert";+import { Button } from "../../ui/button";+import { Card, CardContent } from "../../ui/card";+import { Progress } from "../../ui/progress";+import { BACKEND_URL } from "../../../lib/const";+import { getStripePrices } from "../../../lib/stripe";+import { formatDate } from "../../../lib/subscription/planUtils";+import { useStripeSubscription } from "../../../lib/subscription/useStripeSubscription";+import { UsageChart } from "../../UsageChart";import { authClient } from "@/lib/auth";+import { PlanDialog } from "./PlanDialog";-export function ProPlan() {+export function PaidPlan() {const { data: activeSubscription, isLoading, error: subscriptionError, refetch } = useStripeSubscription();const { data: activeOrg } = authClient.useActiveOrganization();@@ -27,6 +28,7 @@ export function ProPlan() {const [isProcessing, setIsProcessing] = useState(false);const [actionError, setActionError] = useState<string | null>(null);+ const [showPlanDialog, setShowPlanDialog] = useState(false);const eventLimit = activeSubscription?.eventLimit || 0;const currentUsage = activeSubscription?.monthlyEventCount || 0;@@ -35,15 +37,27 @@ export function ProPlan() {const stripePlan = getStripePrices().find(p => p.name === activeSubscription?.planName);+ const isPro = activeSubscription?.planName?.startsWith("pro");+const currentPlanDetails = activeSubscription? {- id: "pro",- name: "Pro",+ id: isPro ? "pro" : "standard",+ name: isPro ? "Pro" : "Standard",price: `$${stripePlan?.price}`,interval: stripePlan?.interval,- description: "Advanced analytics for growing projects",- features: ["5 year data retention", "Priority support"],- color: "bg-gradient-to-br from-green-50 to-emerald-100 dark:from-green-800 dark:to-emerald-800",+ description: isPro ? "Premium features for professional teams" : "Advanced analytics for growing projects",+ features: isPro+ ? [+ "5+ year data retention",+ "Session replays",+ "Unlimited team members",+ "Unlimited websites",+ "Priority support",+ ]+ : ["1 year data retention", "Standard support", "Core analytics features"],+ color: isPro+ ? "bg-gradient-to-br from-purple-50 to-indigo-100 dark:from-purple-800 dark:to-indigo-800"+ : "bg-gradient-to-br from-green-50 to-emerald-100 dark:from-green-800 dark:to-emerald-800",icon: <Shield className="h-5 w-5" />,}: null;@@ -90,7 +104,7 @@ export function ProPlan() {}};- const handleChangePlan = () => createPortalSession("subscription_update");+ const handleChangePlan = () => setShowPlanDialog(true);const handleViewSubscription = () => createPortalSession();const handleCancelSubscription = () => createPortalSession("subscription_cancel");@@ -119,6 +133,12 @@ export function ProPlan() {return (<div className="space-y-6">{actionError && <Alert variant="destructive">{actionError}</Alert>}+ <PlanDialog+ open={showPlanDialog}+ onOpenChange={setShowPlanDialog}+ currentPlanName={activeSubscription?.planName}+ hasActiveSubscription={!!activeSubscription}+ /><Card><CardContent><div className="space-y-6 mt-3 p-2">@@ -134,8 +154,8 @@ export function ProPlan() {<p className="text-neutral-400 text-sm">{formatRenewalDate()}</p></div><div className="space-x-2">- <Button variant="success" onClick={handleChangePlan} disabled={isProcessing}>- {isProcessing ? "Processing..." : "Change Plan"}+ <Button variant="success" onClick={handleChangePlan}>+ Change Plan</Button><Button variant="outline" onClick={handleViewSubscription} disabled={isProcessing}>View Details@@ -162,7 +182,7 @@ export function ProPlan() {<p className="text-sm text-amber-700 dark:text-amber-300"><strong>Usage limit reached!</strong> You've exceeded your plan's event limit.</p>- <Button variant="success" size="sm" onClick={handleChangePlan} disabled={isProcessing}>+ <Button variant="success" size="sm" onClick={handleChangePlan}>Upgrade Plan</Button></div>diff --git a/client/src/components/subscription/PaidPlain/PlanChangePreviewDialog.tsx b/client/src/components/subscription/PaidPlain/PlanChangePreviewDialog.tsxnew file mode 100644index 000000000..7b2d76ef2--- /dev/null+++ b/client/src/components/subscription/PaidPlain/PlanChangePreviewDialog.tsx@@ -0,0 +1,116 @@+import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import { Loader2 } from "lucide-react";++interface PreviewData {+ currentPlan: {+ priceId: string;+ amount: number;+ interval: string;+ };+ newPlan: {+ priceId: string;+ amount: number;+ interval: string;+ };+ proration: {+ credit: number;+ charge: number;+ immediatePayment: number;+ nextBillingDate: string | null;+ };+}++interface PlanChangePreviewDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ previewData: PreviewData | null;+ onConfirm: () => Promise<void>;+ onCancel: () => void;+ isUpdating: boolean;+}++export function PlanChangePreviewDialog({+ open,+ onOpenChange,+ previewData,+ onConfirm,+ onCancel,+ isUpdating,+}: PlanChangePreviewDialogProps) {+ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-md">+ <DialogHeader>+ <DialogTitle>Confirm Plan Change</DialogTitle>+ </DialogHeader>++ {previewData && (+ <div className="space-y-4">+ {/* Current Plan */}+ <div className="text-sm">+ <div className="text-neutral-400">Current Plan</div>+ <div className="text-neutral-100 font-medium">+ ${previewData.currentPlan.amount / 100}/{previewData.currentPlan.interval === "year" ? "yr" : "mo"}+ </div>+ </div>++ {/* New Plan */}+ <div className="text-sm">+ <div className="text-neutral-400">New Plan</div>+ <div className="text-neutral-100 font-medium">+ ${previewData.newPlan.amount / 100}/{previewData.newPlan.interval === "year" ? "yr" : "mo"}+ </div>+ </div>++ {/* Proration Details */}+ <div className="pt-1">+ {previewData.proration.charge > 0 && (+ <div className="flex justify-between text-sm mb-2">+ <span className="text-neutral-400">New plan charge (prorated)</span>+ <span className="text-neutral-100">${previewData.proration.charge.toFixed(2)}</span>+ </div>+ )}+ {previewData.proration.credit > 0 && (+ <div className="flex justify-between text-sm mb-2">+ <span className="text-neutral-400">Unused time credit</span>+ <span className="text-emerald-400">-${previewData.proration.credit.toFixed(2)}</span>+ </div>+ )}++ <div className="flex justify-between text-sm font-medium pt-2">+ <span className="text-neutral-100">Due now</span>+ <span className={previewData.proration.immediatePayment > 0 ? "text-neutral-100" : "text-emerald-400"}>+ ${previewData.proration.immediatePayment.toFixed(2)}+ </span>+ </div>+ </div>++ {previewData.proration.nextBillingDate && (+ <div className="text-xs text-neutral-400">+ Your next billing date: {new Date(previewData.proration.nextBillingDate).toLocaleDateString()}+ </div>+ )}++ {/* Action Buttons */}+ <div className="flex justify-end gap-3 pt-2">+ <Button onClick={onCancel} disabled={isUpdating} variant="outline">+ Cancel+ </Button>+ <Button onClick={onConfirm} disabled={isUpdating} variant="success">+ {isUpdating ? (+ <span className="flex items-center justify-center gap-2">+ <Loader2 className="w-4 h-4 animate-spin" />+ Updating...+ </span>+ ) : (+ "Confirm Change"+ )}+ </Button>+ </div>+ </div>+ )}+ </DialogContent>+ </Dialog>+ );+}diff --git a/client/src/components/subscription/PaidPlain/PlanDialog.tsx b/client/src/components/subscription/PaidPlain/PlanDialog.tsxnew file mode 100644index 000000000..e14e8b5c4--- /dev/null+++ b/client/src/components/subscription/PaidPlain/PlanDialog.tsx@@ -0,0 +1,254 @@+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 { usePreviewSubscriptionUpdate, useUpdateSubscription } from "@/lib/subscription/useSubscriptionMutations";+import { cn } from "@/lib/utils";+import { Loader2 } from "lucide-react";+import { useState } from "react";+import { toast } from "sonner";+import { Badge } from "../../ui/badge";+import { PlanChangePreviewDialog } from "./PlanChangePreviewDialog";++interface PlanDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ currentPlanName?: string;+ 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);+ const [pendingPriceId, setPendingPriceId] = useState<string | null>(null);+ const [pendingPlanName, setPendingPlanName] = useState<string | null>(null);+ const stripePrices = getStripePrices();+ const { data: activeOrg } = authClient.useActiveOrganization();+ const previewMutation = usePreviewSubscriptionUpdate();+ const updateMutation = useUpdateSubscription();++ const handlePlanSelection = async (priceId: string, planName: string) => {+ if (!activeOrg) {+ toast.error("Please select an organization");+ return;+ }++ // Don't allow selecting the current plan+ if (isCurrentPlan(planName)) {+ return;+ }++ setPendingPriceId(priceId);+ setPendingPlanName(planName);++ try {+ const baseUrl = window.location.origin;++ if (hasActiveSubscription) {+ // First get proration preview+ const result = await previewMutation.mutateAsync({+ organizationId: activeOrg.id,+ newPriceId: priceId,+ });++ setShowProrationDialog(true);+ } else {+ // For new subscriptions, create a checkout session+ const successUrl = `${baseUrl}/settings/organization/subscription?session_id={CHECKOUT_SESSION_ID}`;+ const cancelUrl = `${baseUrl}/settings/organization/subscription`;++ const response = await fetch(`${BACKEND_URL}/stripe/create-checkout-session`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ credentials: "include",+ body: JSON.stringify({+ priceId,+ successUrl,+ cancelUrl,+ organizationId: activeOrg.id,+ }),+ });++ const data = await response.json();++ if (!response.ok) {+ throw new Error(data.error || "Failed to create checkout session.");+ }++ if (data.checkoutUrl) {+ window.location.href = data.checkoutUrl;+ } else {+ throw new Error("Checkout URL not received.");+ }+ }+ } catch (error: any) {+ toast.error(`${hasActiveSubscription ? "Failed to preview subscription" : "Checkout"} failed: ${error.message}`);+ }+ };++ const getPriceForTier = (events: number, planType: "standard" | "pro") => {+ const suffix = isAnnual ? "-annual" : "";+ const planName = `${planType}${events >= 1_000_000 ? events / 1_000_000 + "m" : events / 1_000 + "k"}${suffix}`;+ const plan = stripePrices.find(p => p.name === planName);+ return plan;+ };++ const isCurrentPlan = (planName: string) => {+ return currentPlanName === planName;+ };++ const confirmSubscriptionUpdate = async (priceId: string, planName: string) => {+ if (!activeOrg) return;++ try {+ await updateMutation.mutateAsync({+ organizationId: activeOrg.id,+ newPriceId: priceId,+ });++ // Reload the page to reflect the new subscription+ window.location.reload();+ } catch (error) {+ // Error is already handled by the mutation+ }+ };++ const handlePreviewCancel = () => {+ setShowProrationDialog(false);+ previewMutation.reset();+ setPendingPriceId(null);+ setPendingPlanName(null);+ };++ const handlePreviewConfirm = async () => {+ setShowProrationDialog(false);+ if (pendingPriceId && pendingPlanName) {+ await confirmSubscriptionUpdate(pendingPriceId, pendingPlanName);+ }+ };++ return (+ <>+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-3xl max-h-[90vh] overflow-y-auto">+ <DialogHeader>+ <DialogTitle>Choose Your Plan</DialogTitle>+ </DialogHeader>++ {/* Billing toggle */}+ <div className="flex justify-center mb-0">+ <div className="flex gap-3 text-sm">+ <button+ onClick={() => setIsAnnual(false)}+ className={cn(+ "px-4 py-2 rounded-full transition-colors cursor-pointer",+ !isAnnual+ ? "bg-emerald-500/20 text-emerald-400 font-medium"+ : "text-neutral-400 hover:text-neutral-200"+ )}+ >+ Monthly+ </button>+ <button+ onClick={() => setIsAnnual(true)}+ className={cn(+ "px-4 py-2 rounded-full transition-colors cursor-pointer",+ isAnnual+ ? "bg-emerald-500/20 text-emerald-400 font-medium"+ : "text-neutral-400 hover:text-neutral-200"+ )}+ >+ Annual+ <span className="ml-1 text-xs text-emerald-500">-17%</span>+ </button>+ </div>+ </div>++ {/* Plan columns */}+ <div className="grid grid-cols-2 gap-6">+ {[+ { type: "standard" as const, title: "Standard", subtitle: "Core analytics features" },+ { type: "pro" as const, title: "Pro", subtitle: "Advanced features + session replays" },+ ].map(({ type, title, subtitle }) => (+ <div key={type} className="space-y-3">+ <div className="text-center mb-4">+ <h3 className="text-xl font-bold">{title}</h3>+ <p className="text-sm text-neutral-400">{subtitle}</p>+ </div>+ <div className="space-y-2">+ {EVENT_TIERS.map(tier => {+ const plan = getPriceForTier(tier.events, type);+ if (!plan) return null;+ const isCurrent = isCurrentPlan(plan.name);+ const isLoading = previewMutation.isPending && pendingPriceId === plan.priceId;++ return (+ <div+ key={plan.name}+ className={cn(+ "flex flex-col gap-2 justify-between p-3 rounded-lg border cursor-pointer",+ isCurrent+ ? "bg-emerald-500/10 border-emerald-500"+ : "bg-neutral-800/20 border-neutral-700/50 hover:bg-neutral-800/30",+ isLoading && "opacity-50"+ )}+ onClick={() => handlePlanSelection(plan.priceId, plan.name)}+ >+ <div className="flex items-center justify-between w-full">+ <Badge variant="success">{type === "pro" ? "Pro" : "Standard"}</Badge>+ <div className="text-xs text-neutral-400">+ <span className="text-neutral-200 font-semibold text-base">+ ${isAnnual ? Math.round(plan.price / 12) : plan.price}+ </span>{" "}+ / month+ </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>+ {isLoading && <Loader2 className="w-4 h-4 animate-spin" />}+ </div>+ </div>+ );+ })}+ </div>+ </div>+ ))}+ </div>++ {/* Features comparison link */}+ <div className="mt-3 text-center">+ <a+ href="https://www.rybbit.io/pricing"+ target="_blank"+ rel="noopener noreferrer"+ className="text-neutral-200 hover:text-neutral-100 text-sm underline"+ >+ View detailed feature comparison →+ </a>+ </div>+ </DialogContent>+ </Dialog>++ <PlanChangePreviewDialog+ open={showProrationDialog}+ onOpenChange={setShowProrationDialog}+ previewData={previewMutation.data?.preview || null}+ onConfirm={handlePreviewConfirm}+ onCancel={handlePreviewCancel}+ isUpdating={updateMutation.isPending}+ />+ </>+ );+}diff --git a/client/src/components/ui/badge.tsx b/client/src/components/ui/badge.tsxindex b0eddf436..79f1492fe 100644--- a/client/src/components/ui/badge.tsx+++ b/client/src/components/ui/badge.tsx@@ -17,17 +17,12 @@ const badgeVariants = cva(warning:"border-transparent bg-yellow-500/10 text-yellow-700 hover:bg-yellow-500/20 dark:bg-yellow-500/20 dark:text-yellow-400 dark:hover:bg-yellow-500/30",success:- "border-transparent bg-green-500/10 text-green-700 hover:bg-green-500/20 dark:bg-green-500/20 dark:text-green-400 dark:hover:bg-green-500/30",+ "border-transparent bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20 dark:bg-emerald-500/20 dark:text-emerald-400 dark:hover:bg-emerald-500/30",info: "border-transparent bg-blue-500/10 text-blue-700 hover:bg-blue-500/20 dark:bg-blue-500/20 dark:text-blue-400 dark:hover:bg-blue-500/30",outline:"border-neutral-300 bg-transparent text-neutral-700 hover:bg-neutral-50 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800",ghost:"border-transparent bg-transparent text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800",- // Legacy variants for backwards compatibility- green:- "border-transparent bg-green-500/10 text-green-700 hover:bg-green-500/20 dark:bg-green-500/20 dark:text-green-400 dark:hover:bg-green-500/30",- red: "border-transparent bg-red-500/10 text-red-600 hover:bg-red-500/20 dark:bg-red-500/20 dark:text-red-400 dark:hover:bg-red-500/30",- minimal: "border-transparent bg-neutral-200/50 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400",},},defaultVariants: {diff --git a/client/src/hooks/useStopImpersonation.ts b/client/src/hooks/useStopImpersonation.tsindex b43395335..e85cda572 100644--- a/client/src/hooks/useStopImpersonation.ts+++ b/client/src/hooks/useStopImpersonation.ts@@ -14,7 +14,6 @@ export function useStopImpersonation() {window.stopImpersonating = async () => {try {await authClient.admin.stopImpersonating();- console.log("Successfully stopped impersonating. Reloading page...");window.location.href = "/admin";return true;} catch (err) {diff --git a/client/src/lib/const.ts b/client/src/lib/const.tsindex 7ce32a792..a9192c366 100644--- a/client/src/lib/const.ts+++ b/client/src/lib/const.ts@@ -6,3 +6,5 @@ export const IS_CLOUD = process.env.NEXT_PUBLIC_CLOUD === "true";// Time constantsexport const MINUTES_IN_24_HOURS = 24 * 60; // 1440 minutes++export const DEMO_HOSTNAME = "demo.rybbit.io";diff --git a/client/src/lib/stripe.ts b/client/src/lib/stripe.tsindex 2b3922b63..77d04d99e 100644--- a/client/src/lib/stripe.ts+++ b/client/src/lib/stripe.ts@@ -1,8 +1,9 @@const STRIPE_PRICES = [+ // Standard tiers{price: 19,priceId: "price_1RKuxUDFVprnAny2xyyWvXNr",- name: "pro100k",+ name: "standard100k",interval: "month",limits: {events: 100_000,@@ -11,7 +12,7 @@ const STRIPE_PRICES = [{price: 190,priceId: "price_1RKuxUDFVprnAny2RkoZyxev",- name: "pro100k-annual",+ name: "standard100k-annual",interval: "year",limits: {events: 100_000,@@ -20,7 +21,7 @@ const STRIPE_PRICES = [{price: 29,priceId: "price_1RKuxTDFVprnAny2TS4Qz0Hi",- name: "pro250k",+ name: "standard250k",interval: "month",limits: {events: 250_000,@@ -29,14 +30,14 @@ const STRIPE_PRICES = [{price: 290,priceId: "price_1RKuxTDFVprnAny2rDcJOwHn",- name: "pro250k-annual",+ name: "standard250k-annual",interval: "year",limits: {events: 250_000,},},{- name: "pro500k",+ name: "standard500k",priceId: "price_1RKuxSDFVprnAny2L7hbJSmO",price: 49,interval: "month",@@ -45,7 +46,7 @@ const STRIPE_PRICES = [},},{- name: "pro500k-annual",+ name: "standard500k-annual",priceId: "price_1RKuxSDFVprnAny2APD1EsL4",price: 490,interval: "year",@@ -54,7 +55,7 @@ const STRIPE_PRICES = [},},{- name: "pro1m",+ name: "standard1m",priceId: "price_1RKuxRDFVprnAny2UnTeUnYl",price: 69,interval: "month",@@ -63,7 +64,7 @@ const STRIPE_PRICES = [},},{- name: "pro1m-annual",+ name: "standard1m-annual",priceId: "price_1RKuxRDFVprnAny2f67uFcwC",price: 690,interval: "year",@@ -72,7 +73,7 @@ const STRIPE_PRICES = [},},{- name: "pro2m",+ name: "standard2m",priceId: "price_1RKuxPDFVprnAny2pvdhKxSL",price: 99,interval: "month",@@ -81,7 +82,7 @@ const STRIPE_PRICES = [},},{- name: "pro2m-annual",+ name: "standard2m-annual",priceId: "price_1RKuxPDFVprnAny2NCYgKQf5",price: 990,interval: "year",@@ -90,7 +91,7 @@ const STRIPE_PRICES = [},},{- name: "pro5m",+ name: "standard5m",priceId: "price_1RKuxKDFVprnAny2pytTqnzP",price: 149,interval: "month",@@ -99,7 +100,7 @@ const STRIPE_PRICES = [},},{- name: "pro5m-annual",+ name: "standard5m-annual",priceId: "price_1RKuxKDFVprnAny2UjJFcvHQ",price: 1490,interval: "year",@@ -108,7 +109,7 @@ const STRIPE_PRICES = [},},{- name: "pro10m",+ name: "standard10m",priceId: "price_1RKuxNDFVprnAny2HkZXUcZN",price: 249,interval: "month",@@ -117,7 +118,7 @@ const STRIPE_PRICES = [},},{- name: "pro10m-annual",+ name: "standard10m-annual",priceId: "price_1RKuxNDFVprnAny2mjFH5swO",price: 2490,interval: "year",@@ -125,23 +126,164 @@ const STRIPE_PRICES = [events: 10_000_000,},},+ // Pro tiers+ {+ price: 39,+ priceId: "price_1S8szIDFVprnAny2Hg7cxG5b",+ name: "pro100k",+ interval: "month",+ limits: {+ events: 100_000,+ },+ },+ {+ price: 390,+ priceId: "price_1S8szIDFVprnAny2MfwmEsD3",+ name: "pro100k-annual",+ interval: "year",+ limits: {+ events: 100_000,+ },+ },+ {+ price: 59,+ priceId: "price_1S8szHDFVprnAny2VyF3ZOuF",+ name: "pro250k",+ interval: "month",+ limits: {+ events: 250_000,+ },+ },+ {+ price: 590,+ priceId: "price_1S8szHDFVprnAny2KbYorj7v",+ name: "pro250k-annual",+ interval: "year",+ limits: {+ events: 250_000,+ },+ },+ {+ price: 99,+ priceId: "price_1S8szEDFVprnAny2hi4ZSoS8",+ name: "pro500k",+ interval: "month",+ limits: {+ events: 500_000,+ },+ },+ {+ price: 990,+ priceId: "price_1S8szEDFVprnAny2z6M7Befa",+ name: "pro500k-annual",+ interval: "year",+ limits: {+ events: 500_000,+ },+ },+ {+ price: 139,+ priceId: "price_1S8szCDFVprnAny28ccBSIDh",+ name: "pro1m",+ interval: "month",+ limits: {+ events: 1_000_000,+ },+ },+ {+ price: 1390,+ priceId: "price_1S8szCDFVprnAny2ujgml5hL",+ name: "pro1m-annual",+ interval: "year",+ limits: {+ events: 1_000_000,+ },+ },+ {+ price: 199,+ priceId: "price_1S8szBDFVprnAny2h8aeoObg",+ name: "pro2m",+ interval: "month",+ limits: {+ events: 2_000_000,+ },+ },+ {+ price: 1990,+ priceId: "price_1S8szBDFVprnAny2So7DIVTb",+ name: "pro2m-annual",+ interval: "year",+ limits: {+ events: 2_000_000,+ },+ },+ {+ price: 299,+ priceId: "price_1S8sz9DFVprnAny2Mjrl9je6",+ name: "pro5m",+ interval: "month",+ limits: {+ events: 5_000_000,+ },+ },+ {+ price: 2990,+ priceId: "price_1S8sz9DFVprnAny2pEnr5hXD",+ name: "pro5m-annual",+ interval: "year",+ limits: {+ events: 5_000_000,+ },+ },+ {+ price: 499,+ priceId: "price_1S8sz5DFVprnAny2PQR4etWx",+ name: "pro10m",+ interval: "month",+ limits: {+ events: 10_000_000,+ },+ },+ {+ price: 4990,+ priceId: "price_1S8sz5DFVprnAny2drMF3d7U",+ name: "pro10m-annual",+ interval: "year",+ limits: {+ events: 10_000_000,+ },+ },];const TEST_TO_PRICE_ID = {- pro100k: "price_1R1fIVDFVprnAny2yJtRRPBm",- "pro100k-annual": "price_1R2l2KDFVprnAny2iZr5gFLe",- pro250k: "price_1R1fKJDFVprnAny2mfiBjkAQ",- "pro250k-annual": "price_1R2lJIDFVprnAny22zUvjg5o",- pro500k: "price_1R1fQlDFVprnAny2WwNdiRgT",- "pro500k-annual": "price_1R2lKIDFVprnAny27wXUAy2D",- pro1m: "price_1R1fR2DFVprnAny28tPEQAwh",- "pro1m-annual": "price_1R2lKtDFVprnAny2Xl98rgu4",- pro2m: "price_1R1fRMDFVprnAny24AMo0Vuu",- "pro2m-annual": "price_1RE1bQDFVprnAny2ELKQS79d",- pro5m: "price_1RKuYJDFVprnAny2apEXvkde",- "pro5m-annual": "price_1RKuYaDFVprnAny2xEoejLRR",- pro10m: "price_1RKuX5DFVprnAny20UMfh10N",- "pro10m-annual": "price_1RKuXODFVprnAny2JUjrCSyY",+ standard100k: "price_1R1fIVDFVprnAny2yJtRRPBm",+ "standard100k-annual": "price_1R2l2KDFVprnAny2iZr5gFLe",+ standard250k: "price_1R1fKJDFVprnAny2mfiBjkAQ",+ "standard250k-annual": "price_1R2lJIDFVprnAny22zUvjg5o",+ standard500k: "price_1R1fQlDFVprnAny2WwNdiRgT",+ "standard500k-annual": "price_1R2lKIDFVprnAny27wXUAy2D",+ standard1m: "price_1R1fR2DFVprnAny28tPEQAwh",+ "standard1m-annual": "price_1R2lKtDFVprnAny2Xl98rgu4",+ standard2m: "price_1R1fRMDFVprnAny24AMo0Vuu",+ "standard2m-annual": "price_1RE1bQDFVprnAny2ELKQS79d",+ standard5m: "price_1RKuYJDFVprnAny2apEXvkde",+ "standard5m-annual": "price_1RKuYaDFVprnAny2xEoejLRR",+ standard10m: "price_1RKuX5DFVprnAny20UMfh10N",+ "standard10m-annual": "price_1RKuXODFVprnAny2JUjrCSyY",+ pro100k: "price_1S8kgSDFVprnAny2LCbjTkNa",+ "pro100k-annual": "price_1S8kmQDFVprnAny2hZqkMgwT",+ pro250k: "price_1S8kgxDFVprnAny2YSAnQMA6",+ "pro250k-annual": "price_1S8kmHDFVprnAny2cvl0p8OM",+ pro500k: "price_1S8khiDFVprnAny2730Lm8xf",+ "pro500k-annual": "price_1S8km1DFVprnAny28WpKikFH",+ pro1m: "price_1S8ki0DFVprnAny2kwXpmQ7M",+ "pro1m-annual": "price_1S8klqDFVprnAny2mkVUdErk",+ pro2m: "price_1S8kiODFVprnAny217jeiSP3",+ "pro2m-annual": "price_1S8klfDFVprnAny24Yk3Y7HD",+ pro5m: "price_1S8kioDFVprnAny2DV8THSQr",+ "pro5m-annual": "price_1S8klTDFVprnAny2Na9XXAEI",+ pro10m: "price_1S8kkKDFVprnAny2WDjO98bN",+ "pro10m-annual": "price_1S8kl3DFVprnAny2Xdhho4F0",};export const getStripePrices = () => {diff --git a/client/src/lib/subscription/useStripeSubscription.ts b/client/src/lib/subscription/useStripeSubscription.tsindex 0cf1a7a7a..4279e8e5e 100644--- a/client/src/lib/subscription/useStripeSubscription.ts+++ b/client/src/lib/subscription/useStripeSubscription.ts@@ -8,6 +8,7 @@ interface SubscriptionData {status: "expired" | "active" | "trialing" | "free";currentPeriodEnd: string;currentPeriodStart: string;+ createdAt: string;monthlyEventCount: number;eventLimit: number;interval: string;@@ -15,6 +16,7 @@ interface SubscriptionData {isTrial?: boolean;trialDaysRemaining?: number;message?: string; // For expired trial message+ isPro?: boolean;}export function useStripeSubscription() {diff --git a/client/src/lib/subscription/useSubscriptionMutations.ts b/client/src/lib/subscription/useSubscriptionMutations.tsnew file mode 100644index 000000000..feeaf3234--- /dev/null+++ b/client/src/lib/subscription/useSubscriptionMutations.ts@@ -0,0 +1,106 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import { BACKEND_URL } from "../const";+import { toast } from "sonner";++interface PreviewSubscriptionParams {+ organizationId: string;+ newPriceId: string;+}++interface PreviewSubscriptionResponse {+ success: boolean;+ preview: {+ currentPlan: {+ priceId: string;+ amount: number;+ interval: string;+ };+ newPlan: {+ priceId: string;+ amount: number;+ interval: string;+ };+ proration: {+ credit: number;+ charge: number;+ immediatePayment: number;+ nextBillingDate: string | null;+ };+ };+}++interface UpdateSubscriptionParams {+ organizationId: string;+ newPriceId: string;+}++interface UpdateSubscriptionResponse {+ success: boolean;+ subscription: {+ id: string;+ status: string;+ currentPeriodEnd: string;+ };+}++export function usePreviewSubscriptionUpdate() {+ return useMutation<PreviewSubscriptionResponse, Error, PreviewSubscriptionParams>({+ mutationFn: async ({ organizationId, newPriceId }) => {+ const response = await fetch(`${BACKEND_URL}/stripe/preview-subscription-update`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ credentials: "include",+ body: JSON.stringify({+ organizationId,+ newPriceId,+ }),+ });++ const data = await response.json();++ if (!response.ok) {+ throw new Error(data.error || "Failed to preview subscription update");+ }++ return data;+ },+ });+}++export function useUpdateSubscription() {+ const queryClient = useQueryClient();++ return useMutation<UpdateSubscriptionResponse, Error, UpdateSubscriptionParams>({+ mutationFn: async ({ organizationId, newPriceId }) => {+ const response = await fetch(`${BACKEND_URL}/stripe/update-subscription`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ credentials: "include",+ body: JSON.stringify({+ organizationId,+ newPriceId,+ }),+ });++ const data = await response.json();++ if (!response.ok) {+ throw new Error(data.error || "Failed to update subscription");+ }++ return data;+ },+ onSuccess: (data, variables) => {+ // Invalidate subscription data to refetch latest info+ queryClient.invalidateQueries({ queryKey: ["stripe-subscription", variables.organizationId] });+ toast.success("Subscription updated successfully!");+ },+ onError: error => {+ toast.error(`Subscription update failed: ${error.message}`);+ },+ });+}diff --git a/docs-v2/src/app/pricing/components/ComparisonSection.tsx b/docs-v2/src/app/pricing/components/ComparisonSection.tsxindex 8c958437e..eab809855 100644--- a/docs-v2/src/app/pricing/components/ComparisonSection.tsx+++ b/docs-v2/src/app/pricing/components/ComparisonSection.tsx@@ -10,16 +10,19 @@ const COMPARISON_FEATURES = [{name: "Monthly events",free: "10,000",+ standard: "100K - 10M+",pro: "100K - 10M+",},{name: "Number of websites",free: "Up to 3",+ standard: "Up to 10",pro: "Unlimited",},{name: "Team members",free: false,+ standard: "Up to 3",pro: "Unlimited",},],@@ -30,81 +33,91 @@ const COMPARISON_FEATURES = [{name: "Core analytics dashboard",free: true,+ standard: true,pro: true,},{name: "Advanced filtering",free: true,+ standard: true,pro: true,},{name: "Custom events",free: true,+ standard: true,pro: true,},{name: "Bot filtering",free: true,+ standard: true,pro: true,},{name: "Real-time globe",free: false,- pro: true,- },- {- name: "Session replays",- free: false,+ standard: true,pro: true,},{name: "Web vitals",free: false,+ standard: true,pro: true,},{name: "Error tracking",free: false,+ standard: true,pro: true,},{name: "Pages view",free: false,+ standard: true,pro: true,},{name: "Sessions",free: false,+ standard: true,pro: true,},{name: "User profiles",free: false,+ standard: true,pro: true,},{name: "Funnels",free: false,+ standard: true,pro: true,},{name: "Goals",free: false,+ standard: true,pro: true,},{name: "Journeys",free: false,+ standard: true,pro: true,},{name: "Retention",free: false,+ standard: true,pro: true,},{- name: "Advanced events view",+ name: "Session replays",free: false,+ standard: false,pro: true,},],@@ -115,22 +128,26 @@ const COMPARISON_FEATURES = [{name: "Privacy-friendly",free: true,+ standard: true,pro: true,},{name: "GDPR compliant",free: true,+ standard: true,pro: true,},{name: "No cookies required",free: true,+ standard: true,pro: true,},{name: "Data retention",free: "6 months",- pro: "3 years",+ standard: "2 years",+ pro: "5+ years",},],},@@ -140,6 +157,7 @@ const COMPARISON_FEATURES = [{name: "Email support",free: "Community",+ standard: "Standard",pro: "Priority",},],@@ -166,16 +184,16 @@ function FeatureCell({ value, isPro = false }: FeatureCellProps) {export function ComparisonSection() {return (<section className="-mt-8 pb-8 w-full">- <div className="max-w-5xl mx-auto px-4">+ <div className="max-w-6xl mx-auto px-4"><div className="w-full border border-neutral-800/50 rounded-lg overflow-hidden">{/* Table Header */}- <div className="grid grid-cols-3 gap-0 py-6 bg-neutral-800/20">+ <div className="grid grid-cols-4 gap-0 py-6 bg-neutral-800/20"><div className="flex items-center px-6 border-r border-neutral-700/50 text-xl font-semibold text-neutral-200">Compare Plans</div><div className="flex flex-col items-center justify-center px-6 border-r border-neutral-700/50"><div className="font-semibold text-lg text-center mb-3">- Free <span className="text-sm text-neutral-400 font-normal">$0/month</span>+ Free <span className="text-sm text-neutral-400 font-normal block">$0/month</span></div><ahref="https://app.rybbit.io/signup"@@ -184,15 +202,26 @@ export function ComparisonSection() {Start Free</a></div>+ <div className="flex flex-col items-center justify-center px-6 border-r border-neutral-700/50">+ <div className="font-semibold text-lg text-center mb-3">+ Standard <span className="text-sm text-neutral-400 font-normal block">From $19/month</span>+ </div>+ <a+ href="https://app.rybbit.io/signup"+ className="inline-flex items-center justify-center px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium rounded-lg shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200"+ >+ Try Free+ </a>+ </div><div className="flex flex-col items-center justify-center px-6"><div className="font-semibold text-lg text-emerald-400 text-center mb-3">- Pro <span className="text-sm text-neutral-400 font-normal">Starting at $19/month</span>+ Pro <span className="text-sm text-neutral-400 font-normal block">From $39/month</span></div><ahref="https://app.rybbit.io/signup"className="inline-flex items-center justify-center px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium rounded-lg shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200">- Try Pro Free+ Try Free</a></div></div>@@ -202,11 +231,12 @@ export function ComparisonSection() {<div key={categoryIndex}>{/* Category Header - Skip for "Usage" category */}{category.category !== "Usage" && (- <div className="grid grid-cols-3 gap-0 py-3 border-b border-neutral-700 bg-neutral-800/10">+ <div className="grid grid-cols-4 gap-0 py-3 border-b border-neutral-700 bg-neutral-800/10"><div className="flex items-center px-6 border-r border-neutral-700/50"><h3 className="font-semibold text-neutral-100 text-base">{category.category}</h3></div><div className="border-r border-neutral-700/50"></div>+ <div className="border-r border-neutral-700/50"></div><div></div></div>)}@@ -215,7 +245,7 @@ export function ComparisonSection() {{category.features.map((feature, featureIndex) => (<divkey={featureIndex}- className="grid grid-cols-3 gap-0 py-3 hover:bg-neutral-800/20 transition-colors border-b border-neutral-800/30 last:border-b-0"+ className="grid grid-cols-4 gap-0 py-3 hover:bg-neutral-800/20 transition-colors border-b border-neutral-800/30 last:border-b-0"><div className="flex items-center px-6 border-r border-neutral-700/50"><span className="text-sm text-neutral-300">{feature.name}</span>@@ -223,6 +253,9 @@ export function ComparisonSection() {<div className="flex items-center justify-center px-6 border-r border-neutral-700/50"><FeatureCell value={feature.free} /></div>+ <div className="flex items-center justify-center px-6 border-r border-neutral-700/50">+ <FeatureCell value={feature.standard} />+ </div><div className="flex items-center justify-center px-6"><FeatureCell value={feature.pro} isPro={true} /></div>@@ -234,4 +267,4 @@ export function ComparisonSection() {</div></section>);-}\ No newline at end of file+}diff --git a/docs-v2/src/components/PricingSection.tsx b/docs-v2/src/components/PricingSection.tsxindex 173b10962..dc2dfe154 100644--- a/docs-v2/src/components/PricingSection.tsx+++ b/docs-v2/src/components/PricingSection.tsx@@ -9,46 +9,74 @@ import { cn } from "@/lib/utils";// Available event tiers for the sliderconst EVENT_TIERS = [100_000, 250_000, 500_000, 1_000_000, 2_000_000, 5_000_000, 10_000_000, "Custom"];-// Define plan features-const PRO_FEATURES = [- "Unlimited websites",- "Unlimited team members",- "Real-time analytics",- "Session replays",+// Define standard plan features+const STANDARD_FEATURES = [+ "Up to 10 websites",+ "Up to 3 team members","Web vitals",- "Custom events","Funnels","Goals",+ "Error tracking","Journeys","User profiles","Retention",- "All features",+ "2 year data retention",+ "Standard support",+];++// Define pro plan features+const PRO_FEATURES = [+ "Everything in Standard",+ "Unlimited websites",+ "Unlimited team members",+ "Session replays",+ "5+ year data retention",+ "Priority support",];// Define free plan featuresconst FREE_FEATURES = [+ { feature: "1 user", included: true },{ feature: "Up to 3 websites", included: true },- { feature: "Basic features", included: true },+ { feature: "Cookieless tracking", included: true },+ { feature: "Web analytics dashboard", included: true },{ feature: "Custom events", included: true },+ { feature: "6 month data retention", included: true },+ { feature: "Advanced features", included: false },+ { feature: "Email support", included: false },];export const formatter = Intl.NumberFormat("en", {notation: "compact",}).format;-// Format price with dollar sign-function getFormattedPrice(eventLimit: number | string) {- // Monthly prices from stripe.ts+// Format price with dollar sign for both Standard and Pro+function getFormattedPrice(eventLimit: number | string, planType: "standard" | "pro") {+ // Monthly priceslet monthlyPrice;if (typeof eventLimit === "string") return { custom: true }; // Custom pricing- if (eventLimit <= 100_000) monthlyPrice = 19;- else if (eventLimit <= 250_000) monthlyPrice = 29;- else if (eventLimit <= 500_000) monthlyPrice = 49;- 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 if (eventLimit <= 10_000_000) monthlyPrice = 249; // 10M events- else return { custom: true }; // 10M+ events - custom pricing++ if (planType === "standard") {+ // Standard tier prices+ if (eventLimit <= 100_000) monthlyPrice = 19;+ else if (eventLimit <= 250_000) monthlyPrice = 29;+ else if (eventLimit <= 500_000) monthlyPrice = 49;+ 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 if (eventLimit <= 10_000_000) monthlyPrice = 249;+ else return { custom: true };+ } else {+ // Pro tier prices (roughly double)+ if (eventLimit <= 100_000) monthlyPrice = 39;+ else if (eventLimit <= 250_000) monthlyPrice = 59;+ else if (eventLimit <= 500_000) monthlyPrice = 99;+ else if (eventLimit <= 1_000_000) monthlyPrice = 139;+ 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 return { custom: true };+ }// Annual prices are 10x monthly (2 months free)const annualPrice = monthlyPrice * 10;@@ -64,7 +92,8 @@ export function PricingSection() {const [isAnnual, setIsAnnual] = useState(false);const eventLimit = EVENT_TIERS[eventLimitIndex];- const prices = getFormattedPrice(eventLimit);+ const standardPrices = getFormattedPrice(eventLimit, "standard");+ const proPrices = getFormattedPrice(eventLimit, "pro");// Handle slider changesfunction handleSliderChange(value: number[]) {@@ -74,29 +103,94 @@ export function PricingSection() {return (<section className="py-16 md:py-24 w-full"><div className="max-w-7xl mx-auto px-4">- <div className="text-center mb-12">- <div className="inline-block bg-emerald-900/30 text-emerald-400 px-3 py-1 rounded-full text-sm font-medium mb-4">- Simple Pricing+ <div className="mb-12 text-center max-w-3xl mx-auto">+ <h2 className="text-4xl md:text-5xl font-bold tracking-tight pb-4 text-transparent bg-clip-text bg-gradient-to-b from-white via-gray-200 to-gray-400">+ Simple, Transparent Pricing+ </h2>+ <p className="text-lg text-neutral-300">Privacy-friendly analytics with all the features you need to grow</p>+ </div>++ {/* Shared controls section */}+ <div className="max-w-xl mx-auto mb-8">+ {/* Events per month and billing toggle */}+ <div className="flex justify-between mb-6 items-center">+ <div>+ <h3 className="font-semibold mb-2">Events per month</h3>+ <div className="text-3xl font-bold text-emerald-400">+ {typeof eventLimit === "number" ? eventLimit.toLocaleString() : eventLimit}+ </div>+ </div>+ <div className="flex flex-col items-end">+ {/* Billing toggle */}+ <div className="flex gap-3 mb-2 text-sm">+ <button+ onClick={() => setIsAnnual(false)}+ className={cn(+ "px-3 py-1 rounded-full transition-colors cursor-pointer",+ !isAnnual+ ? "bg-emerald-500/20 text-emerald-400 font-medium"+ : "text-neutral-400 hover:text-neutral-200"+ )}+ >+ Monthly+ </button>+ <button+ onClick={() => setIsAnnual(true)}+ className={cn(+ "px-3 py-1 rounded-full transition-colors cursor-pointer",+ isAnnual+ ? "bg-emerald-500/20 text-emerald-400 font-medium"+ : "text-neutral-400 hover:text-neutral-200"+ )}+ >+ Annual+ <span className="ml-1 text-xs text-emerald-500">-17%</span>+ </button>+ </div>+ </div>+ </div>++ {/* Slider */}+ <Slider+ defaultValue={[0]}+ max={EVENT_TIERS.length - 1}+ min={0}+ step={1}+ onValueChange={handleSliderChange}+ className="mb-3"+ />++ <div className="flex justify-between text-xs text-neutral-400">+ {EVENT_TIERS.map((tier, index) => (+ <span key={index} className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}>+ {index === EVENT_TIERS.length - 1+ ? "10M+"+ : typeof tier === "number" && tier >= 1_000_000+ ? `${tier / 1_000_000}M`+ : typeof tier === "number"+ ? `${tier / 1_000}K`+ : "Custom"}+ </span>+ ))}</div>- <h2 className="text-3xl md:text-4xl font-bold">Transparent Pricing</h2>- <p className="mt-4 text-neutral-300 max-w-2xl mx-auto font-light">- Privacy-friendly analytics with all the features you need to grow- </p></div>- {/* Two card layout */}- <div className="flex flex-col lg:flex-row gap-6 max-w-6xl mx-auto justify-center items-start">+ {/* Three card layout */}+ <div className="flex flex-col lg:flex-row gap-6 max-w-6xl mx-auto justify-center items-stretch">{/* Free Plan Card */}- <div className="w-full lg:w-70 flex-shrink-0 md:h-[788px] h-full">- <div className="bg-neutral-800/30 rounded-xl border border-neutral-700 overflow-hidden backdrop-blur-sm shadow-lg h-full">+ <div className="w-full lg:w-96 flex-shrink-0 text-neutral-300">+ <div className="bg-neutral-800/15 rounded-xl border border-neutral-700/60 overflow-hidden backdrop-blur-sm shadow-xl h-full"><div className="p-6">- <div className="md:mb-[70px] mb-6">- <div className="flex justify-between mb-3 items-center">- <div>- <h3 className="font-semibold mb-2">Free</h3>- <div className="text-3xl font-semibold text-neutral-200">10,000</div>- <p className="text-neutral-400 text-sm">events/month</p>- </div>+ <div className="mb-4">+ <h3 className="text-xl font-bold mb-2">Free</h3>+ <p className="text-sm text-neutral-400">Perfect for getting started</p>+ </div>++ {/* Price display */}+ <div className="mb-6">+ <div>+ <span className="text-3xl font-bold">10,000</span>+ <span className="ml-1 text-neutral-400">/month events</span></div></div>@@ -115,9 +209,9 @@ export function PricingSection() {{item.included ? (<Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />) : (- <X className="h-4 w-4 text-neutral-500 mr-3 shrink-0" />+ <X className="h-4 w-4 text-neutral-400 mr-3 shrink-0" />)}- <span className={cn(item.included ? "text-white" : "text-neutral-500")}>{item.feature}</span>+ <span className={"text-sm"}>{item.feature}</span></div>))}</div>@@ -125,109 +219,94 @@ export function PricingSection() {</div></div>- {/* Pro Plan Card */}- <div className="relative w-full lg:w-96 flex-shrink-0">- {/* Background gradients - overlapping circles for organic feel */}- <div className="absolute top-0 left-0 w-[400px] h-[400px] bg-emerald-500/30 rounded-full blur-[80px] opacity-60"></div>- <div className="absolute top-20 left-20 w-[300px] h-[300px] bg-emerald-600/20 rounded-full blur-[70px] opacity-40"></div>+ {/* Standard Plan Card */}+ <div className="w-full lg:w-96 flex-shrink-0">+ <div className="bg-neutral-800/50 rounded-xl border border-neutral-700 overflow-hidden backdrop-blur-sm shadow-xl">+ <div className="p-6">+ <div className="mb-4">+ <h3 className="text-xl font-bold mb-2">Standard</h3>+ <p className="text-sm text-neutral-400">Everything you need to get started</p>+ </div>- <div className="absolute bottom-0 right-0 w-[350px] h-[350px] bg-blue-500/30 rounded-full blur-[80px] opacity-50"></div>- <div className="absolute bottom-40 right-20 w-[250px] h-[250px] bg-indigo-500/20 rounded-full blur-[75px] opacity-40"></div>+ {/* Price display */}+ <div className="mb-6">+ {standardPrices.custom ? (+ <div className="text-3xl font-bold">Custom</div>+ ) : (+ <div>+ <span className="text-3xl font-bold">+ ${isAnnual ? Math.round(standardPrices.annual! / 12) : standardPrices.monthly}+ </span>+ <span className="ml-1 text-neutral-400">/month</span>+ </div>+ )}+ </div>- <div className="absolute top-1/4 right-0 w-[200px] h-[200px] bg-purple-500/30 rounded-full blur-[70px] opacity-40"></div>+ {standardPrices.custom ? (+ <Link href="https://www.rybbit.io/contact" 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 cursor-pointer">+ Contact us+ </button>+ </Link>+ ) : (+ <Link href="https://app.rybbit.io/signup" className="w-full block">+ <button+ data-rybbit-event="signup"+ data-rybbit-prop-location="standard"+ 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 cursor-pointer"+ >+ Try for free+ </button>+ </Link>+ )}- <div className="absolute bottom-1/3 left-0 w-[220px] h-[220px] bg-emerald-400/20 rounded-full blur-[70px] opacity-50"></div>+ <div className="space-y-4 my-6">+ {STANDARD_FEATURES.map((feature, i) => (+ <div key={i} className="flex items-center">+ <Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />+ <span className="text-sm">{feature}</span>+ </div>+ ))}+ </div>- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[350px] h-[350px] bg-indigo-400/20 rounded-full blur-[80px] opacity-40"></div>+ <p className="text-center text-sm text-neutral-400 mt-4 flex items-center justify-center gap-2">+ {standardPrices.custom ? (+ "Email us at [email protected] for custom pricing"+ ) : (+ <>+ <CheckCircle className="w-3 h-3" />+ We don't ask for your credit card+ </>+ )}+ </p>+ </div>+ </div>+ </div>- {/* Card with relative positioning and higher z-index */}- <div className="relative z-10 bg-neutral-800/50 rounded-xl border border-neutral-700 overflow-hidden backdrop-blur-sm shadow-xl">+ {/* Pro Plan Card */}+ <div className="w-full lg:w-96 flex-shrink-0">+ <div className="bg-neutral-800/50 rounded-xl border border-neutral-700 overflow-hidden backdrop-blur-sm shadow-xl h-full"><div className="p-6">- {/* Slider section */}+ <div className="mb-4">+ <h3 className="text-xl font-bold mb-2">Pro</h3>+ <p className="text-sm text-neutral-400">Advanced features for professional teams</p>+ </div>++ {/* Price display */}<div className="mb-6">- <div className="flex justify-between mb-3 items-center">+ {proPrices.custom ? (+ <div className="text-3xl font-bold">Custom</div>+ ) : (<div>- <h3 className="font-semibold mb-2">Pro</h3>- <div className="text-3xl font-bold text-emerald-400 hidden md:block">- {typeof eventLimit === "number" ? eventLimit.toLocaleString() : "Custom"}- </div>- <div className="text-3xl font-bold text-emerald-400 md:hidden">- {typeof eventLimit === "string" ? "10M+" : formatter(eventLimit)}- </div>- <p className="text-neutral-400 text-sm">events/month</p>- </div>- <div className="flex flex-col items-end">- {/* Billing toggle */}- <div className="flex gap-3 mb-1 text-sm -mt-5">- <button- onClick={() => setIsAnnual(false)}- className={cn(- "px-3 py-1 rounded-full transition-colors cursor-pointer",- !isAnnual- ? "bg-emerald-500/20 text-emerald-400 font-medium"- : "text-neutral-400 hover:text-neutral-200"- )}- >- Monthly- </button>- <button- onClick={() => setIsAnnual(true)}- className={cn(- "px-3 py-1 rounded-full transition-colors cursor-pointer",- isAnnual- ? "bg-emerald-500/20 text-emerald-400 font-medium"- : "text-neutral-400 hover:text-neutral-200"- )}- >- Annual- <span className="ml-1 text-xs text-emerald-500">-17%</span>- </button>- </div>- <div className="text-right h-10">- {prices.custom ? (- <></>- ) : (- <>- <span className="text-3xl font-bold">- $- {isAnnual && "annual" in prices- ? Math.round(prices?.annual ?? 0 / 12)- : "monthly" in prices- ? prices.monthly- : 0}- </span>- <span className="ml-1 text-neutral-400">{isAnnual ? "/year" : "/month"}</span>- </>- )}- </div>- </div>- </div>-- <Slider- defaultValue={[0]}- max={EVENT_TIERS.length - 1}- min={0}- step={1}- onValueChange={handleSliderChange}- className="mb-3"- />-- <div className="flex justify-between text-xs text-neutral-400">- {EVENT_TIERS.map((tier, index) => (- <span key={index} className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}>- {index === EVENT_TIERS.length - 1- ? "10M+"- : typeof tier === "number" && tier >= 1_000_000- ? `${tier / 1_000_000}M`- : typeof tier === "number"- ? `${tier / 1_000}K`- : "Custom"}+ <span className="text-3xl font-bold">+ ${isAnnual ? Math.round(proPrices.annual! / 12) : proPrices.monthly}</span>- ))}- </div>+ <span className="ml-1 text-neutral-400">/month</span>+ </div>+ )}</div>- {prices.custom ? (+ {proPrices.custom ? (<Link href="https://www.rybbit.io/contact" 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 cursor-pointer">Contact us@@ -244,17 +323,18 @@ export function PricingSection() {</button></Link>)}+<div className="space-y-4 my-6">{PRO_FEATURES.map((feature, i) => (<div key={i} className="flex items-center"><Check className="h-4 w-4 text-emerald-400 mr-3 shrink-0" />- <span>{feature}</span>+ <span className="text-sm">{feature}</span></div>))}</div><p className="text-center text-sm text-neutral-400 mt-4 flex items-center justify-center gap-2">- {prices.custom ? (+ {proPrices.custom ? ("Email us at [email protected] for custom pricing") : (<>diff --git a/docs/src/app/pricing/components/PricingSection.jsx b/docs/src/app/pricing/components/PricingSection.jsxindex 834dc296a..f63a53dc1 100644--- a/docs/src/app/pricing/components/PricingSection.jsx+++ b/docs/src/app/pricing/components/PricingSection.jsx@@ -79,7 +79,7 @@ export function PricingSection() {<div className="inline-block bg-emerald-900/30 text-emerald-400 px-3 py-1 rounded-full text-sm font-medium mb-4">Simple Pricing</div>- <h2 className="text-3xl md:text-4xl font-bold">Transparent Pricing</h2>+ <h2 className="text-3xl md:text-4xl font-bold">Pricing</h2><p className="mt-4 text-neutral-300 max-w-2xl mx-auto">Privacy-friendly analytics with all the features you need to grow</p>diff --git a/server/public/test-replay.html b/server/public/test-replay.htmldeleted file mode 100644index 4f67e36d4..000000000--- a/server/public/test-replay.html+++ /dev/null@@ -1,175 +0,0 @@-<!doctype html>-<html lang="en">- <head>- <meta charset="UTF-8" />- <meta name="viewport" content="width=device-width, initial-scale=1.0" />- <title>Session Replay Test</title>- <style>- body {- font-family: Arial, sans-serif;- padding: 20px;- line-height: 1.6;- }- .test-content {- max-width: 800px;- margin: 0 auto;- }- .button {- background: #007bff;- color: white;- padding: 10px 20px;- border: none;- border-radius: 5px;- cursor: pointer;- margin: 10px 5px;- }- .button:hover {- background: #0056b3;- }- .form-group {- margin: 20px 0;- }- input,- textarea {- width: 100%;- padding: 10px;- border: 1px solid #ddd;- border-radius: 4px;- margin: 5px 0;- }- .status {- padding: 10px;- margin: 10px 0;- border-radius: 4px;- background: #f8f9fa;- border: 1px solid #dee2e6;- }- </style>- </head>- <body>- <div class="test-content">- <h1>Session Replay Test Page</h1>- <p>- This page is used to test session replay functionality. Open browser- developer tools console to see logging output.- </p>-- <div class="status" id="status">Status: Loading analytics script...</div>-- <div class="form-group">- <label>Test Input Field:</label>- <input- type="text"- placeholder="Type something here to test input recording"- />- </div>-- <div class="form-group">- <label>Test Textarea:</label>- <textarea- placeholder="Type in this textarea to test input masking"- ></textarea>- </div>-- <div>- <button class="button" onclick="testEvent()">Click Me</button>- <button class="button" onclick="changeContent()">Change Content</button>- <button class="button" onclick="addElement()">Add Element</button>- </div>-- <div id="dynamic-content">- <p>This content can be dynamically changed to test DOM mutations.</p>- </div>-- <div id="new-elements">- <!-- Elements will be added here dynamically -->- </div>- </div>-- <!-- Analytics Script -->- <script- src="http://localhost:3001/script.js"- data-site-id="21"- data-session-replay="true"- defer- ></script>-- <script>- function updateStatus(message) {- document.getElementById("status").textContent = "Status: " + message;- console.log("[Test Page]", message);- }-- function testEvent() {- updateStatus("Button clicked - custom event triggered");- if (window.rybbit) {- window.rybbit.event("test_button_click", { button: "test" });- }- }-- function changeContent() {- const content = document.getElementById("dynamic-content");- content.innerHTML =- '<p style="color: red;">Content changed at ' +- new Date().toLocaleTimeString() +- "</p>";- updateStatus("Content changed - DOM mutation recorded");- }-- function addElement() {- const container = document.getElementById("new-elements");- const newElement = document.createElement("div");- newElement.style.cssText =- "background: #e7f3ff; padding: 10px; margin: 5px 0; border-radius: 4px;";- newElement.textContent =- "New element added at " + new Date().toLocaleTimeString();- container.appendChild(newElement);- updateStatus("New element added - DOM mutation recorded");- }-- // Wait for analytics script to load- window.addEventListener("load", function () {- setTimeout(function () {- if (window.rybbit) {- updateStatus(- "Analytics script loaded successfully. Session replay should be active."- );- console.log(- "[Test Page] Session replay active:",- window.rybbit.isSessionReplayActive()- );- } else {- updateStatus("ERROR: Analytics script failed to load");- }- }, 1000);- });-- // Monitor for console messages- const originalLog = console.log;- console.log = function (...args) {- if (- args[0] &&- typeof args[0] === "string" &&- args[0].includes("[Session Replay]")- ) {- // Highlight session replay logs- originalLog.apply(console, ["🎬", ...args]);- } else {- originalLog.apply(console, args);- }- };-- const originalError = console.error;- console.error = function (...args) {- if (- args[0] &&- typeof args[0] === "string" &&- args[0].includes("session replay")- ) {- updateStatus("ERROR: " + args.join(" "));- }- originalError.apply(console, args);- };- </script>- </body>-</html>diff --git a/server/src/analytics-script/sessionReplay.ts b/server/src/analytics-script/sessionReplay.tsindex bacf5d4a5..1d4805a18 100644--- a/server/src/analytics-script/sessionReplay.ts+++ b/server/src/analytics-script/sessionReplay.ts@@ -77,10 +77,10 @@ export class SessionReplayRecorder {timestamp: event.timestamp || Date.now(),});},- recordCanvas: true, // Record canvas elements- collectFonts: true, // Collect font info for better replay- checkoutEveryNms: 30000, // Checkout every 30 seconds- checkoutEveryNth: 200, // Checkout every 200 events+ recordCanvas: false, // Disable canvas recording to reduce data+ collectFonts: true, // Disable font collection to reduce data+ checkoutEveryNms: 60000, // Checkout every 60 seconds (was 30)+ checkoutEveryNth: 500, // Checkout every 500 events (was 200)maskAllInputs: true, // Mask all input values for privacymaskInputOptions: {password: true,@@ -99,11 +99,22 @@ export class SessionReplayRecorder {headMetaVerification: true,},sampling: {- // Optional: reduce recording frequency to save bandwidth- mousemove: false, // Don't record every mouse move- mouseInteraction: true,- scroll: 150, // Sample scroll events every 150ms+ // Aggressive sampling to reduce data volume+ mousemove: false, // Don't record mouse moves at all+ mouseInteraction: {+ MouseUp: false,+ MouseDown: false,+ Click: true, // Only record clicks+ ContextMenu: false,+ DblClick: true,+ Focus: true,+ Blur: true,+ TouchStart: false,+ TouchEnd: false,+ },+ scroll: 500, // Sample scroll events every 500ms (was 150)input: "last", // Only record the final input value+ media: 800, // Sample media interactions less frequently},});diff --git a/server/src/api/sites/getSitesFromOrg.ts b/server/src/api/sites/getSitesFromOrg.tsindex 3452ee129..f1ad63a57 100644--- a/server/src/api/sites/getSitesFromOrg.ts+++ b/server/src/api/sites/getSitesFromOrg.ts@@ -104,6 +104,7 @@ export async function getSitesFromOrg(overMonthlyLimit: monthlyEventCount > eventLimit,planName: subscription?.planName || "free",status: subscription?.status || "free",+ isPro: subscription?.planName.includes("pro") || false,},});} catch (err) {diff --git a/server/src/api/stripe/getSubscription.ts b/server/src/api/stripe/getSubscription.tsindex 112538b4c..0f32948d1 100644--- a/server/src/api/stripe/getSubscription.ts+++ b/server/src/api/stripe/getSubscription.ts@@ -1,19 +1,11 @@import { eq } from "drizzle-orm";import { FastifyReply, FastifyRequest } from "fastify";+import { DateTime } from "luxon";import Stripe from "stripe";import { db } from "../../db/postgres/postgres.js";import { organization } from "../../db/postgres/schema.js";-import { DEFAULT_EVENT_LIMIT, getStripePrices, StripePlan } from "../../lib/const.js";+import { DEFAULT_EVENT_LIMIT, getStripePrices } from "../../lib/const.js";import { stripe } from "../../lib/stripe.js";-import { DateTime } from "luxon";--// Function to find plan details by price ID-function findPlanDetails(priceId: string): StripePlan | undefined {- return getStripePrices().find(- (plan: StripePlan) =>- plan.priceId === priceId || (plan.annualDiscountPriceId && plan.annualDiscountPriceId === priceId)- );-}function getStartOfMonth() {return DateTime.now().startOf("month").toJSDate();@@ -62,7 +54,7 @@ export async function getSubscriptionInner(organizationId: string) {}// 3. Find corresponding plan details from your constants- const planDetails = findPlanDetails(priceId);+ const planDetails = getStripePrices().find(plan => plan.priceId === priceId);if (!planDetails) {console.error("Plan details not found for price ID:", priceId);@@ -71,6 +63,7 @@ export async function getSubscriptionInner(organizationId: string) {id: subscription.id,planName: "Unknown Plan", // Indicate missing detailsstatus: subscription.status,+ createdAt: new Date(subscription.created * 1000),currentPeriodStart: new Date(subscriptionItem.current_period_start * 1000),currentPeriodEnd: new Date(subscriptionItem.current_period_end * 1000),cancelAtPeriodEnd: subscription.cancel_at_period_end,@@ -84,7 +77,9 @@ export async function getSubscriptionInner(organizationId: string) {const responseData = {id: subscription.id,planName: planDetails.name,+ isPro: planDetails.name.includes("pro"),status: subscription.status,+ createdAt: new Date(subscription.created * 1000),currentPeriodStart: new Date(subscriptionItem.current_period_start * 1000),currentPeriodEnd: new Date(subscriptionItem.current_period_end * 1000),cancelAtPeriodEnd: subscription.cancel_at_period_end,diff --git a/server/src/api/stripe/previewSubscriptionUpdate.ts b/server/src/api/stripe/previewSubscriptionUpdate.tsnew file mode 100644index 000000000..90f4afc58--- /dev/null+++ b/server/src/api/stripe/previewSubscriptionUpdate.ts@@ -0,0 +1,145 @@+import { FastifyReply, FastifyRequest } from "fastify";+import { stripe } from "../../lib/stripe.js";+import { db } from "../../db/postgres/postgres.js";+import { organization, member } from "../../db/postgres/schema.js";+import { eq, and } from "drizzle-orm";+import Stripe from "stripe";++interface PreviewSubscriptionBody {+ organizationId: string;+ newPriceId: string;+}++export async function previewSubscriptionUpdate(+ request: FastifyRequest<{ Body: PreviewSubscriptionBody }>,+ reply: FastifyReply+) {+ const { organizationId, newPriceId } = request.body;+ const userId = request.user?.id;++ if (!userId) {+ return reply.status(401).send({ error: "Unauthorized" });+ }++ if (!organizationId || !newPriceId) {+ return reply.status(400).send({+ error: "Missing required parameters: organizationId, newPriceId",+ });+ }++ try {+ // 1. Verify user has permission to manage billing for this organization+ const memberResult = await db+ .select({+ role: member.role,+ })+ .from(member)+ .where(and(eq(member.userId, userId), eq(member.organizationId, organizationId)))+ .limit(1);++ if (!memberResult.length || memberResult[0].role !== "owner") {+ return reply.status(403).send({+ error: "Only organization owners can manage billing",+ });+ }++ // 2. Find the organization and its Stripe customer ID+ const orgResult = await db+ .select({+ stripeCustomerId: organization.stripeCustomerId,+ })+ .from(organization)+ .where(eq(organization.id, organizationId))+ .limit(1);++ const org = orgResult[0];++ if (!org || !org.stripeCustomerId) {+ return reply.status(404).send({ error: "Organization or Stripe customer ID not found" });+ }++ // 3. Get the active subscription+ const subscriptions = await stripe!.subscriptions.list({+ customer: org.stripeCustomerId,+ status: "active",+ limit: 1,+ });++ if (subscriptions.data.length === 0) {+ return reply.status(404).send({ error: "No active subscription found" });+ }++ const subscription = subscriptions.data[0];+ const currentItem = subscription.items.data[0];+ const currentPeriodEnd = currentItem.current_period_end;++ // 4. Get price details for both current and new prices+ const [currentPrice, newPrice] = await Promise.all([+ stripe!.prices.retrieve(currentItem.price.id),+ stripe!.prices.retrieve(newPriceId),+ ]);++ // 5. Create a preview of the upcoming invoice with proration+ const upcomingInvoice = await (stripe as Stripe).invoices.createPreview({+ customer: org.stripeCustomerId,+ subscription: subscription.id,+ subscription_details: {+ items: [+ {+ id: currentItem.id,+ price: newPriceId,+ },+ ],+ proration_behavior: "always_invoice",+ },+ });++ // 6. Calculate proration details+ const prorationItems = upcomingInvoice.lines.data.filter(item => {+ // Proration flag is nested in parent.subscription_item_details+ return item.parent?.subscription_item_details?.proration === true;+ });++ let proratedCredit = 0;+ let proratedCharge = 0;++ prorationItems.forEach(item => {+ if (item.amount < 0) {+ proratedCredit += Math.abs(item.amount);+ } else {+ proratedCharge += item.amount;+ }+ });++ const immediateCharge = upcomingInvoice.amount_due;++ // 7. Return preview information+ return reply.send({+ success: true,+ preview: {+ currentPlan: {+ priceId: currentItem.price.id,+ amount: currentPrice.unit_amount || 0,+ interval: currentPrice.recurring?.interval || "month",+ },+ newPlan: {+ priceId: newPriceId,+ amount: newPrice.unit_amount || 0,+ interval: newPrice.recurring?.interval || "month",+ },+ proration: {+ credit: proratedCredit / 100, // Convert from cents to dollars+ charge: proratedCharge / 100,+ immediatePayment: immediateCharge / 100,+ nextBillingDate: currentPeriodEnd ? new Date(currentPeriodEnd * 1000).toISOString() : null,+ },+ },+ });+ } catch (error: any) {+ console.error("Subscription Preview Error:", error);+ return reply.status(500).send({+ error: "Failed to preview subscription update",+ details: error.message,+ });+ }+}diff --git a/server/src/api/stripe/updateSubscription.ts b/server/src/api/stripe/updateSubscription.tsnew file mode 100644index 000000000..d94f81da9--- /dev/null+++ b/server/src/api/stripe/updateSubscription.ts@@ -0,0 +1,114 @@+import { FastifyReply, FastifyRequest } from "fastify";+import { stripe } from "../../lib/stripe.js";+import { db } from "../../db/postgres/postgres.js";+import { organization, member } from "../../db/postgres/schema.js";+import { eq, and } from "drizzle-orm";+import Stripe from "stripe";++interface UpdateSubscriptionBody {+ organizationId: string;+ newPriceId: string;+}++export async function updateSubscription(+ request: FastifyRequest<{ Body: UpdateSubscriptionBody }>,+ reply: FastifyReply+) {+ const { organizationId, newPriceId } = request.body;+ const userId = request.user?.id;++ if (!userId) {+ return reply.status(401).send({ error: "Unauthorized" });+ }++ if (!organizationId || !newPriceId) {+ return reply.status(400).send({+ error: "Missing required parameters: organizationId, newPriceId",+ });+ }++ try {+ // 1. Verify user has permission to manage billing for this organization+ const memberResult = await db+ .select({+ role: member.role,+ })+ .from(member)+ .where(and(eq(member.userId, userId), eq(member.organizationId, organizationId)))+ .limit(1);++ if (!memberResult.length || memberResult[0].role !== "owner") {+ return reply.status(403).send({+ error: "Only organization owners can manage billing",+ });+ }++ // 2. Find the organization and its Stripe customer ID+ const orgResult = await db+ .select({+ stripeCustomerId: organization.stripeCustomerId,+ })+ .from(organization)+ .where(eq(organization.id, organizationId))+ .limit(1);++ const org = orgResult[0];++ if (!org || !org.stripeCustomerId) {+ return reply.status(404).send({ error: "Organization or Stripe customer ID not found" });+ }++ // 3. Get the active subscription+ const subscriptions = await (stripe as Stripe).subscriptions.list({+ customer: org.stripeCustomerId,+ status: "active",+ limit: 1,+ });++ if (subscriptions.data.length === 0) {+ return reply.status(404).send({ error: "No active subscription found" });+ }++ const subscription = subscriptions.data[0];+ const subscriptionItem = subscription.items.data[0];++ // 4. Validate the new price exists+ try {+ await (stripe as Stripe).prices.retrieve(newPriceId);+ } catch (error) {+ return reply.status(400).send({ error: "Invalid price ID" });+ }++ // 5. Update the subscription with the new price+ // Using always_invoice to charge immediately for the proration+ const updatedSubscription = await (stripe as Stripe).subscriptions.update(subscription.id, {+ items: [+ {+ id: subscriptionItem.id,+ price: newPriceId,+ },+ ],+ proration_behavior: "always_invoice", // Immediately invoice the proration amount+ });++ // Get the updated subscription details+ const updatedSubscriptionDetails = await (stripe as Stripe).subscriptions.retrieve(updatedSubscription.id);+ const updatedItem = updatedSubscriptionDetails.items.data[0];++ // 6. Return success response+ return reply.send({+ success: true,+ subscription: {+ id: updatedSubscriptionDetails.id,+ status: updatedSubscriptionDetails.status,+ currentPeriodEnd: new Date(updatedItem.current_period_end * 1000).toISOString(),+ },+ });+ } catch (error: any) {+ console.error("Subscription Update Error:", error);+ return reply.status(500).send({+ error: "Failed to update subscription",+ details: error.message,+ });+ }+}diff --git a/server/src/index.ts b/server/src/index.tsindex 65505cbd3..33de2da1f 100644--- a/server/src/index.ts+++ b/server/src/index.ts@@ -57,6 +57,8 @@ import { updateSiteApiConfig } from "./api/sites/updateSiteApiConfig.js";import { createCheckoutSession } from "./api/stripe/createCheckoutSession.js";import { createPortalSession } from "./api/stripe/createPortalSession.js";import { getSubscription } from "./api/stripe/getSubscription.js";+import { previewSubscriptionUpdate } from "./api/stripe/previewSubscriptionUpdate.js";+import { updateSubscription } from "./api/stripe/updateSubscription.js";import { handleWebhook } from "./api/stripe/webhook.js";import { addUserToOrganization } from "./api/user/addUserToOrganization.js";import { getUserOrganizations } from "./api/user/getUserOrganizations.js";@@ -383,6 +385,8 @@ if (IS_CLOUD) {// Stripe Routesserver.post("/api/stripe/create-checkout-session", createCheckoutSession);server.post("/api/stripe/create-portal-session", createPortalSession);+ server.post("/api/stripe/preview-subscription-update", previewSubscriptionUpdate);+ server.post("/api/stripe/update-subscription", updateSubscription);server.get("/api/stripe/subscription", getSubscription);server.post("/api/stripe/webhook", { config: { rawBody: true } }, handleWebhook); // Use rawBody parser config for webhookdiff --git a/server/src/lib/auth-utils.ts b/server/src/lib/auth-utils.tsindex 69fcb12b8..c92cfb5a3 100644--- a/server/src/lib/auth-utils.ts+++ b/server/src/lib/auth-utils.ts@@ -56,16 +56,9 @@ export async function getSitesUserHasAccessTo(req: FastifyRequest, adminOnly = f// Check if we have a cached promiseconst cached = sitesAccessCache.get<Promise<any[]>>(cacheKey);if (cached) {- // console.log(- // `[Cache HIT] getSitesUserHasAccessTo for userId: ${userId}, adminOnly: ${adminOnly}`- // );return cached;}- // console.log(- // `[Cache MISS] getSitesUserHasAccessTo for userId: ${userId}, adminOnly: ${adminOnly}`- // );-// Create new promise and cache itconst promise = (async () => {try {diff --git a/server/src/lib/auth.ts b/server/src/lib/auth.tsindex ea3cf0437..163111de5 100644--- a/server/src/lib/auth.ts+++ b/server/src/lib/auth.ts@@ -190,24 +190,6 @@ export function initAuth(allowedOrigins: string[]) {required: false,},},- deleteUser: {- enabled: true,- // Add a hook to run before deleting a user- // i dont think this works- beforeDelete: async user => {- // Delete all memberships for this user first- console.log(`Cleaning up memberships for user ${user.id} before deletion`);- try {- // Delete member records for this user- await db.delete(schema.member).where(eq(schema.member.userId, user.id));-- console.log(`Successfully removed memberships for user ${user.id}`);- } catch (error) {- console.error(`Error removing memberships for user ${user.id}:`, error);- throw error; // Re-throw to prevent user deletion if cleanup fails- }- },- },changeEmail: {enabled: true,},diff --git a/server/src/lib/const.ts b/server/src/lib/const.tsindex 2ed27ea37..745d78be9 100644--- a/server/src/lib/const.ts+++ b/server/src/lib/const.ts@@ -22,13 +22,13 @@ export interface StripePlan {events: number;replays: number;};- annualDiscountPriceId?: string; // Make this optional}const STRIPE_PRICES: StripePlan[] = [+ // Standard tiers{priceId: "price_1RKuxUDFVprnAny2xyyWvXNr",- name: "pro100k",+ name: "standard100k",interval: "month",limits: {events: 100_000,@@ -37,7 +37,7 @@ const STRIPE_PRICES: StripePlan[] = [},{priceId: "price_1RKuxUDFVprnAny2RkoZyxev",- name: "pro100k-annual",+ name: "standard100k-annual",interval: "year",limits: {events: 100_000,@@ -46,7 +46,7 @@ const STRIPE_PRICES: StripePlan[] = [},{priceId: "price_1RKuxTDFVprnAny2TS4Qz0Hi",- name: "pro250k",+ name: "standard250k",interval: "month",limits: {events: 250_000,@@ -55,6 +55,133 @@ const STRIPE_PRICES: StripePlan[] = [},{priceId: "price_1RKuxTDFVprnAny2rDcJOwHn",+ name: "standard250k-annual",+ interval: "year",+ limits: {+ events: 250_000,+ replays: 25_000,+ },+ },+ {+ name: "standard500k",+ priceId: "price_1RKuxSDFVprnAny2L7hbJSmO",+ interval: "month",+ limits: {+ events: 500_000,+ replays: 50_000,+ },+ },+ {+ name: "standard500k-annual",+ priceId: "price_1RKuxSDFVprnAny2APD1EsL4",+ interval: "year",+ limits: {+ events: 500_000,+ replays: 50_000,+ },+ },+ {+ name: "standard1m",+ priceId: "price_1RKuxRDFVprnAny2UnTeUnYl",+ interval: "month",+ limits: {+ events: 1_000_000,+ replays: 100_000,+ },+ },+ {+ name: "standard1m-annual",+ priceId: "price_1RKuxRDFVprnAny2f67uFcwC",+ interval: "year",+ limits: {+ events: 1_000_000,+ replays: 100_000,+ },+ },+ {+ name: "standard2m",+ priceId: "price_1RKuxPDFVprnAny2pvdhKxSL",+ interval: "month",+ limits: {+ events: 2_000_000,+ replays: 200_000,+ },+ },+ {+ name: "standard2m-annual",+ priceId: "price_1RKuxPDFVprnAny2NCYgKQf5",+ interval: "year",+ limits: {+ events: 2_000_000,+ replays: 200_000,+ },+ },+ {+ name: "standard5m",+ priceId: "price_1RKuxKDFVprnAny2pytTqnzP",+ interval: "month",+ limits: {+ events: 5_000_000,+ replays: 500_000,+ },+ },+ {+ name: "standard5m-annual",+ priceId: "price_1RKuxKDFVprnAny2UjJFcvHQ",+ interval: "year",+ limits: {+ events: 5_000_000,+ replays: 500_000,+ },+ },+ {+ name: "standard10m",+ priceId: "price_1RKuxNDFVprnAny2HkZXUcZN",+ interval: "month",+ limits: {+ events: 10_000_000,+ replays: 1_000_000,+ },+ },+ {+ name: "standard10m-annual",+ priceId: "price_1RKuxNDFVprnAny2mjFH5swO",+ interval: "year",+ limits: {+ events: 10_000_000,+ replays: 1_000_000,+ },+ },+ // Pro tiers+ {+ priceId: "price_1S8szIDFVprnAny2Hg7cxG5b",+ name: "pro100k",+ interval: "month",+ limits: {+ events: 100_000,+ replays: 10_000,+ },+ },+ {+ priceId: "price_1S8szIDFVprnAny2MfwmEsD3",+ name: "pro100k-annual",+ interval: "year",+ limits: {+ events: 100_000,+ replays: 10_000,+ },+ },+ {+ priceId: "price_1S8szHDFVprnAny2VyF3ZOuF",+ name: "pro250k",+ interval: "month",+ limits: {+ events: 250_000,+ replays: 25_000,+ },+ },+ {+ priceId: "price_1S8szHDFVprnAny2KbYorj7v",name: "pro250k-annual",interval: "year",limits: {@@ -63,8 +190,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8szEDFVprnAny2hi4ZSoS8",name: "pro500k",- priceId: "price_1RKuxSDFVprnAny2L7hbJSmO",interval: "month",limits: {events: 500_000,@@ -72,8 +199,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8szEDFVprnAny2z6M7Befa",name: "pro500k-annual",- priceId: "price_1RKuxSDFVprnAny2APD1EsL4",interval: "year",limits: {events: 500_000,@@ -81,8 +208,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8szCDFVprnAny28ccBSIDh",name: "pro1m",- priceId: "price_1RKuxRDFVprnAny2UnTeUnYl",interval: "month",limits: {events: 1_000_000,@@ -90,8 +217,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8szCDFVprnAny2ujgml5hL",name: "pro1m-annual",- priceId: "price_1RKuxRDFVprnAny2f67uFcwC",interval: "year",limits: {events: 1_000_000,@@ -99,8 +226,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8szBDFVprnAny2h8aeoObg",name: "pro2m",- priceId: "price_1RKuxPDFVprnAny2pvdhKxSL",interval: "month",limits: {events: 2_000_000,@@ -108,8 +235,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8szBDFVprnAny2So7DIVTb",name: "pro2m-annual",- priceId: "price_1RKuxPDFVprnAny2NCYgKQf5",interval: "year",limits: {events: 2_000_000,@@ -117,8 +244,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8sz9DFVprnAny2Mjrl9je6",name: "pro5m",- priceId: "price_1RKuxKDFVprnAny2pytTqnzP",interval: "month",limits: {events: 5_000_000,@@ -126,8 +253,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8sz9DFVprnAny2pEnr5hXD",name: "pro5m-annual",- priceId: "price_1RKuxKDFVprnAny2UjJFcvHQ",interval: "year",limits: {events: 5_000_000,@@ -135,8 +262,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8sz5DFVprnAny2PQR4etWx",name: "pro10m",- priceId: "price_1RKuxNDFVprnAny2HkZXUcZN",interval: "month",limits: {events: 10_000_000,@@ -144,8 +271,8 @@ const STRIPE_PRICES: StripePlan[] = [},},{+ priceId: "price_1S8sz5DFVprnAny2drMF3d7U",name: "pro10m-annual",- priceId: "price_1RKuxNDFVprnAny2mjFH5swO",interval: "year",limits: {events: 10_000_000,@@ -155,20 +282,34 @@ const STRIPE_PRICES: StripePlan[] = [];const TEST_TO_PRICE_ID = {- pro100k: "price_1R1fIVDFVprnAny2yJtRRPBm",- "pro100k-annual": "price_1R2l2KDFVprnAny2iZr5gFLe",- pro250k: "price_1R1fKJDFVprnAny2mfiBjkAQ",- "pro250k-annual": "price_1R2lJIDFVprnAny22zUvjg5o",- pro500k: "price_1R1fQlDFVprnAny2WwNdiRgT",- "pro500k-annual": "price_1R2lKIDFVprnAny27wXUAy2D",- pro1m: "price_1R1fR2DFVprnAny28tPEQAwh",- "pro1m-annual": "price_1R2lKtDFVprnAny2Xl98rgu4",- pro2m: "price_1R1fRMDFVprnAny24AMo0Vuu",- "pro2m-annual": "price_1RE1bQDFVprnAny2ELKQS79d",- pro5m: "price_1RKuYJDFVprnAny2apEXvkde",- "pro5m-annual": "price_1RKuYaDFVprnAny2xEoejLRR",- pro10m: "price_1RKuX5DFVprnAny20UMfh10N",- "pro10m-annual": "price_1RKuXODFVprnAny2JUjrCSyY",+ standard100k: "price_1R1fIVDFVprnAny2yJtRRPBm",+ "standard100k-annual": "price_1R2l2KDFVprnAny2iZr5gFLe",+ standard250k: "price_1R1fKJDFVprnAny2mfiBjkAQ",+ "standard250k-annual": "price_1R2lJIDFVprnAny22zUvjg5o",+ standard500k: "price_1R1fQlDFVprnAny2WwNdiRgT",+ "standard500k-annual": "price_1R2lKIDFVprnAny27wXUAy2D",+ standard1m: "price_1R1fR2DFVprnAny28tPEQAwh",+ "standard1m-annual": "price_1R2lKtDFVprnAny2Xl98rgu4",+ standard2m: "price_1R1fRMDFVprnAny24AMo0Vuu",+ "standard2m-annual": "price_1RE1bQDFVprnAny2ELKQS79d",+ standard5m: "price_1RKuYJDFVprnAny2apEXvkde",+ "standard5m-annual": "price_1RKuYaDFVprnAny2xEoejLRR",+ standard10m: "price_1RKuX5DFVprnAny20UMfh10N",+ "standard10m-annual": "price_1RKuXODFVprnAny2JUjrCSyY",+ pro100k: "price_1S8kgSDFVprnAny2LCbjTkNa",+ "pro100k-annual": "price_1S8kmQDFVprnAny2hZqkMgwT",+ pro250k: "price_1S8kgxDFVprnAny2YSAnQMA6",+ "pro250k-annual": "price_1S8kmHDFVprnAny2cvl0p8OM",+ pro500k: "price_1S8khiDFVprnAny2730Lm8xf",+ "pro500k-annual": "price_1S8km1DFVprnAny28WpKikFH",+ pro1m: "price_1S8ki0DFVprnAny2kwXpmQ7M",+ "pro1m-annual": "price_1S8klqDFVprnAny2mkVUdErk",+ pro2m: "price_1S8kiODFVprnAny217jeiSP3",+ "pro2m-annual": "price_1S8klfDFVprnAny24Yk3Y7HD",+ pro5m: "price_1S8kioDFVprnAny2DV8THSQr",+ "pro5m-annual": "price_1S8klTDFVprnAny2Na9XXAEI",+ pro10m: "price_1S8kkKDFVprnAny2WDjO98bN",+ "pro10m-annual": "price_1S8kl3DFVprnAny2Xdhho4F0",};export const getStripePrices = () => {diff --git a/server/src/services/admin/subscriptionService.ts b/server/src/services/admin/subscriptionService.tsindex ccee2caf7..402f0b0dc 100644--- a/server/src/services/admin/subscriptionService.ts+++ b/server/src/services/admin/subscriptionService.ts@@ -1,6 +1,6 @@-import { getStripePrices, StripePlan, DEFAULT_EVENT_LIMIT } from "../../lib/const.js";-import { stripe } from "../../lib/stripe.js";import { DateTime } from "luxon";+import { DEFAULT_EVENT_LIMIT, getStripePrices } from "../../lib/const.js";+import { stripe } from "../../lib/stripe.js";export interface SubscriptionData {id: string;@@ -13,14 +13,6 @@ export interface SubscriptionData {interval?: string;}-// Function to find plan details by price ID-function findPlanDetails(priceId: string): StripePlan | undefined {- return getStripePrices().find(- (plan: StripePlan) =>- plan.priceId === priceId || (plan.annualDiscountPriceId && plan.annualDiscountPriceId === priceId)- );-}-/*** Fetches subscription data for multiple Stripe customer IDs* @param stripeCustomerIds Set of Stripe customer IDs to fetch subscriptions for@@ -57,7 +49,7 @@ async function fetchSubscriptionsForCustomers(const priceId = subscriptionItem.price.id;if (priceId) {- const planDetails = findPlanDetails(priceId);+ const planDetails = getStripePrices().find(plan => plan.priceId === priceId);const subscriptionData: SubscriptionData = {id: subscription.id,diff --git a/server/src/services/usageService.ts b/server/src/services/usageService.tsindex aa9708653..a2e40193d 100644--- a/server/src/services/usageService.ts+++ b/server/src/services/usageService.ts@@ -6,9 +6,9 @@ import { processResults } from "../api/analytics/utils.js";import { clickhouse } from "../db/clickhouse/clickhouse.js";import { db } from "../db/postgres/postgres.js";import { organization, sites } from "../db/postgres/schema.js";-import { getStripePrices, StripePlan, DEFAULT_EVENT_LIMIT, IS_CLOUD } from "../lib/const.js";-import { stripe } from "../lib/stripe.js";+import { DEFAULT_EVENT_LIMIT, getStripePrices, IS_CLOUD, StripePlan } from "../lib/const.js";import { createServiceLogger } from "../lib/logger/logger.js";+import { stripe } from "../lib/stripe.js";class UsageService {private sitesOverLimit = new Set<number>();@@ -122,10 +122,7 @@ class UsageService {}// Find corresponding plan details from constants- const planDetails = getStripePrices().find(- (plan: StripePlan) =>- plan.priceId === priceId || (plan.annualDiscountPriceId && plan.annualDiscountPriceId === priceId)- );+ const planDetails = getStripePrices().find((plan: StripePlan) => plan.priceId === priceId);// Get the event limit from the planconst eventLimit = planDetails