Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(signup): open the chosen plan's trial after signup from the pricing page (#8705)
Andrew Huang0568eb009be1
diff --git a/frontend/src/components/auth/signupTrialIntent.ts b/frontend/src/components/auth/signupTrialIntent.tsnew file mode 100644index 0000000000..2b0afce1bd--- /dev/null+++ b/frontend/src/components/auth/signupTrialIntent.ts@@ -0,0 +1,107 @@+import { BillingPlan, BillingProduct } from "@app/components/license/UpgradeGate/upgrade-intents";+import { isInfisicalCloud } from "@app/helpers/platform";+import { ProjectType } from "@app/hooks/api/projects/types";++import { SignupProductType } from "./signupProducts";++const STORAGE_KEY = "signup.trialIntent";+const MAX_AGE_MS = 24 * 60 * 60 * 1000;++const TRIAL_PRODUCTS = {+ "secrets-management": {+ billingProduct: BillingProduct.SecretsManagement,+ projectType: ProjectType.SecretManager,+ plans: [BillingPlan.Pro, BillingPlan.Advanced]+ },+ pam: {+ billingProduct: BillingProduct.Pam,+ projectType: ProjectType.PAM,+ plans: [BillingPlan.Pro]+ }+} as const;++type TrialProductKey = keyof typeof TRIAL_PRODUCTS;++export type SignupTrialIntent = {+ product: TrialProductKey;+ plan: string;+ cycle?: "monthly" | "annual";+ savedAt: number;+ orgId?: string;+};++const parseIntent = (value: {+ product?: unknown;+ plan?: unknown;+ cycle?: unknown;+}): Omit<SignupTrialIntent, "savedAt"> | null => {+ const { product, plan, cycle } = value;+ if (typeof product !== "string" || !Object.keys(TRIAL_PRODUCTS).includes(product)) return null;+ const allowedPlans: readonly string[] = TRIAL_PRODUCTS[product as TrialProductKey].plans;+ if (typeof plan !== "string" || !allowedPlans.includes(plan)) return null;+ return {+ product: product as TrialProductKey,+ plan,+ cycle: cycle === "monthly" || cycle === "annual" ? cycle : undefined+ };+};++export const clearSignupTrialIntent = () => localStorage.removeItem(STORAGE_KEY);++export const getSignupTrialIntent = (): SignupTrialIntent | null => {+ if (!isInfisicalCloud()) return null;+ try {+ const stored = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "null");+ const intent = stored ? parseIntent(stored) : null;+ if (!intent || typeof stored.savedAt !== "number" || Date.now() - stored.savedAt > MAX_AGE_MS) {+ clearSignupTrialIntent();+ return null;+ }+ return {+ ...intent,+ savedAt: stored.savedAt,+ orgId: typeof stored.orgId === "string" ? stored.orgId : undefined+ };+ } catch {+ clearSignupTrialIntent();+ return null;+ }+};++export const captureSignupTrialIntent = (search: string) => {+ if (!isInfisicalCloud()) return null;+ const params = new URLSearchParams(search);+ const intent = parseIntent({+ product: params.get("product"),+ plan: params.get("plan"),+ cycle: params.get("cycle")+ });+ if (!intent) return getSignupTrialIntent();+ const captured = { ...intent, savedAt: Date.now() };+ try {+ localStorage.setItem(STORAGE_KEY, JSON.stringify(captured));+ } catch {+ return null;+ }+ return captured;+};++export const bindSignupTrialIntent = (orgId: string) => {+ const intent = getSignupTrialIntent();+ if (!intent || intent.orgId) return;+ try {+ localStorage.setItem(STORAGE_KEY, JSON.stringify({ ...intent, orgId }));+ } catch {+ clearSignupTrialIntent();+ }+};++export const getSignupTrialProjectType = (intent: SignupTrialIntent | null): SignupProductType[] =>+ intent ? [TRIAL_PRODUCTS[intent.product].projectType] : [];++export const getSignupTrialBillingSearch = (intent: SignupTrialIntent, returnPath: string) => ({+ upgradeProduct: TRIAL_PRODUCTS[intent.product].billingProduct,+ upgradePlan: intent.plan,+ ...(intent.cycle && { upgradeCycle: intent.cycle }),+ upgradeReturnPath: returnPath+});diff --git a/frontend/src/components/navigation/RegionSelect.tsx b/frontend/src/components/navigation/RegionSelect.tsxindex 23e4f52813..4c730cbc9e 100644--- a/frontend/src/components/navigation/RegionSelect.tsx+++ b/frontend/src/components/navigation/RegionSelect.tsx@@ -86,7 +86,16 @@ export const RegionSelect = ({ compact }: RegionSelectProps) => {const location = useLocation();const handleRegionSelect = (value: string) => {- window.location.assign(`https://${value}.infisical.com/${location.pathname}`);+ const currentSearch = new URLSearchParams(window.location.search);+ const trialSearch = new URLSearchParams(+ ["product", "plan", "cycle"].flatMap((key) => {+ const param = currentSearch.get(key);+ return param ? [[key, param]] : [];+ })+ ).toString();+ window.location.assign(+ `https://${value}.infisical.com/${location.pathname}${trialSearch ? `?${trialSearch}` : ""}`+ );};const shouldDisplay =diff --git a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsxindex 2d4d7ae3d3..53161161dd 100644--- a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx+++ b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx@@ -1,11 +1,17 @@+import { useEffect } from "react";import { Outlet, useParams, useRouterState } from "@tanstack/react-router";import { twMerge } from "tailwind-merge";+import {+ clearSignupTrialIntent,+ getSignupTrialBillingSearch,+ getSignupTrialIntent+} from "@app/components/auth/signupTrialIntent";import { CreateOrgModal } from "@app/components/organization/CreateOrgModal";import { Banner } from "@app/components/page-frames/Banner";import { PageBannerStack } from "@app/components/page-frames/PageBannerStack";import { SidebarInset, SidebarProvider } from "@app/components/v3";-import { useServerConfig, useSubscription } from "@app/context";+import { useOrganization, useServerConfig, useSubscription } from "@app/context";import { usePopUp } from "@app/hooks";import { useFetchServerStatus } from "@app/hooks/api";import { ProjectType } from "@app/hooks/api/projects/types";@@ -60,6 +66,22 @@ export const OrganizationLayout = () => {const { data: serverDetails, isLoading } = useFetchServerStatus();const { subscription } = useSubscription();+ const { currentOrg } = useOrganization();+ const billingOrgId = currentOrg.rootOrgId ?? currentOrg.id;++ useEffect(() => {+ const trialIntent = getSignupTrialIntent();+ if (!trialIntent?.orgId) return;+ clearSignupTrialIntent();+ if (trialIntent.orgId !== billingOrgId) return;+ const search = new URLSearchParams(+ getSignupTrialBillingSearch(+ trialIntent,+ `${window.location.pathname}${window.location.search}${window.location.hash}`+ )+ );+ window.location.assign(`/organizations/${billingOrgId}/billing?${search.toString()}`);+ }, [billingOrgId]);return (<>diff --git a/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx b/frontend/src/pages/auth/SignUpPage/SignUpPage.tsxindex 1264f43bb1..6f0886793b 100644--- a/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx+++ b/frontend/src/pages/auth/SignUpPage/SignUpPage.tsx@@ -18,6 +18,12 @@ import { OnboardingStepTransition } from "@app/components/auth/OnboardingStepTraimport ProductSelectionStep from "@app/components/auth/ProductSelectionStep";import SignupCompleteStep from "@app/components/auth/SignupCompleteStep";import { getSignupProduct, SignupProductType } from "@app/components/auth/signupProducts";+import {+ bindSignupTrialIntent,+ captureSignupTrialIntent,+ clearSignupTrialIntent,+ getSignupTrialProjectType+} from "@app/components/auth/signupTrialIntent";import TeamInviteStep from "@app/components/auth/TeamInviteStep";import UserInfoStep from "@app/components/auth/UserInfoStep";import { createNotification } from "@app/components/notifications";@@ -64,7 +70,9 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {const [inviteEmails, setInviteEmails] = useState<string[]>([]);const projectCache = useRef<Partial<Record<SignupProductType, Project>>>({});// An empty selection means "just exploring".- const [selectedProducts, setSelectedProducts] = useState<SignupProductType[]>([]);+ const [selectedProducts, setSelectedProducts] = useState<SignupProductType[]>(() =>+ isInvite ? [] : getSignupTrialProjectType(captureSignupTrialIntent(window.location.search))+ );const [createdProjects, setCreatedProjects] = useState<Partial<Record<SignupProductType, Project>>>({});@@ -120,7 +128,9 @@ export const SignUpPage = ({ invite }: SignUpPageProps) => {};const handleUserInfoComplete = async (newOrgId?: string) => {+ if (newOrgId) bindSignupTrialIntent(newOrgId);if (isInvite) {+ clearSignupTrialIntent();const userOrgs = await fetchOrganizations();const inviteOrgId = userOrgs[0]?.id;diff --git a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsxindex 1e00eb658b..e3fbc6f694 100644--- a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx+++ b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx@@ -46,7 +46,7 @@ const ORG_PAGE_SIZE = 10;// `view` optionally opens the product sheet straight into a sub-view (e.g. the set-commitment flow// from the "commit and save" nudge) instead of the default plans view.type BillingV2Flow =- | { type: "sheet"; prodId: string; view?: "commitment" }+ | { type: "sheet"; prodId: string; view?: "commitment"; trialTier?: string }| { type: "breakdown"; prodId: string; dimensionKey?: string };export const BillingV2Page = () => {@@ -89,7 +89,7 @@ export const BillingV2Page = () => {isError,refetch} = useGetBillingV2Overview(selectedOrgId);- const { data: catalog = [] } = useGetBillingV2Catalog(selectedOrgId);+ const { data: catalog = [], isPending: isCatalogPending } = useGetBillingV2Catalog(selectedOrgId);const createPortalSession = useCreateBillingV2PortalSession();const addPaymentMethod = useAddBillingV2PaymentMethod();const confirmTrialPayment = useConfirmBillingV2TrialPayment();@@ -109,23 +109,30 @@ export const BillingV2Page = () => {const trialApprovalUrl = trialApproval?.orgId === selectedOrgId ? trialApproval.url : null;const deepLinkSearch = new URLSearchParams(window.location.search);const upgradeProduct = deepLinkSearch.get("upgradeProduct");+ const upgradePlan = deepLinkSearch.get("upgradePlan");+ const upgradeCycle = deepLinkSearch.get("upgradeCycle");const upgradeReturnPath = getSafeUpgradeReturnPath(deepLinkSearch.get("upgradeReturnPath"),window.location.origin);useEffect(() => {- if (- flow ||- openedUpgradeProduct.current ||- !upgradeProduct ||- !catalog.some((product) => product.id === upgradeProduct)- ) {+ if (flow || openedUpgradeProduct.current || !upgradeProduct) {+ return;+ }+ const hasProduct = catalog.some((product) => product.id === upgradeProduct);+ if (upgradePlan) {+ if (isCatalogPending || (hasProduct && !overview && !isError)) return;+ if (!hasProduct || isError) {+ if (upgradeReturnPath) window.location.assign(upgradeReturnPath);+ return;+ }+ } else if (!hasProduct) {return;}openedUpgradeProduct.current = true;- setFlow({ type: "sheet", prodId: upgradeProduct });- }, [catalog, flow, upgradeProduct]);+ setFlow({ type: "sheet", prodId: upgradeProduct, trialTier: upgradePlan ?? undefined });+ }, [catalog, flow, upgradeProduct, upgradePlan, isCatalogPending, overview, isError]);// Stripe redirects back with ?checkout=success|canceled; surface the outcome and refresh state.useEffect(() => {@@ -167,10 +174,16 @@ export const BillingV2Page = () => {const close = () => {setFlow(null);+ if (flow?.type === "sheet" && flow.trialTier && upgradeReturnPath) {+ window.location.assign(upgradeReturnPath);+ return;+ }if (openedUpgradeProduct.current) {const url = new URL(window.location.href);url.searchParams.delete("upgradeProduct");url.searchParams.delete("upgradeReturnPath");+ url.searchParams.delete("upgradePlan");+ url.searchParams.delete("upgradeCycle");window.history.replaceState(window.history.state,"",@@ -349,6 +362,8 @@ export const BillingV2Page = () => {entitlement={overview?.entitlements[flow.prodId]}hasActiveSubscription={hasActiveSubscription}initialView={flow.view}+ initialTrialTier={flow.trialTier}+ showAnnualTrialNote={Boolean(flow.trialTier) && upgradeCycle === "annual"}returnPath={upgradeReturnPath ?? window.location.pathname}renewsOn={overview?.entitlements[flow.prodId]?.renewsOn ?? null}selfServe={overview?.selfServe ?? true}diff --git a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsxindex 5e1a980a2d..0f11b9dd3f 100644--- a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx@@ -458,6 +458,10 @@ type ProductSheetProps = {// Optionally open the sheet straight into a sub-view (e.g. "commitment" from the commit-and-save// nudge) instead of the default plans view.initialView?: SheetView;+ // Opens the trial confirmation for this plan tier straight away (the signup trial deep link), when the+ // org may still trial it. Dismissing that confirmation closes the sheet.+ initialTrialTier?: string;+ showAnnualTrialNote?: boolean;returnPath: string;renewsOn: string | null;// capabilities.selfServe: false for an enterprise-managed org. Self-serve CTAs render disabled and a@@ -477,6 +481,8 @@ export const ProductSheet = ({entitlement,hasActiveSubscription,initialView,+ initialTrialTier,+ showAnnualTrialNote,returnPath,renewsOn,selfServe,@@ -491,7 +497,11 @@ export const ProductSheet = ({// The plan tier chosen for the upgrade view.const [upgradePlan, setUpgradePlan] = useState<string | null>(null);// The plan tier awaiting trial confirmation (drives the confirm dialog).- const [trialConfirmTier, setTrialConfirmTier] = useState<string | null>(null);+ const [trialConfirmTier, setTrialConfirmTier] = useState<string | null>(() => {+ const plan = prod?.plans.find((candidate) => candidate.tier === initialTrialTier);+ return selfServe && plan?.selfServe && plan.trialable ? plan.tier : null;+ });+ const [isInitialTrialConfirm, setIsInitialTrialConfirm] = useState(Boolean(trialConfirmTier));// Whether the cancel-trial confirm dialog is open.const [showCancelTrial, setShowCancelTrial] = useState(false);@@ -580,6 +590,7 @@ export const ProductSheet = ({onEntitlementChanged?.();onClose();} catch {+ setIsInitialTrialConfirm(false);setTrialConfirmTier(null);}};@@ -774,6 +785,10 @@ export const ProductSheet = ({open={Boolean(trialConfirmTier)}onOpenChange={(open) => {if (!open && !startTrial.isPending) {+ if (isInitialTrialConfirm) {+ onClose();+ return;+ }setTrialConfirmTier(null);}}}@@ -790,10 +805,15 @@ export const ProductSheet = ({{trialIsUpgrade? `Your ${trialLengthLabel}trial is free and nothing changes about your bill. You'll keep paying for ${basePlanName} until it ends, then move to ${trialConfirmPlan?.name} and be charged the difference. End the trial before then to stay on ${basePlanName}.`: `Your ${trialLengthLabel}trial is free. After it ends, your subscription continues automatically and you'll be billed monthly based on usage. Cancel before the trial ends to avoid charges.`}+ {showAnnualTrialNote &&+ !trialIsUpgrade &&+ " Trials convert to monthly billing, so annual pricing doesn't apply to this trial."}</AlertDialogDescription></AlertDialogHeader><AlertDialogFooter>- <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogCancel>+ {isInitialTrialConfirm ? "Skip for now" : "Cancel"}+ </AlertDialogCancel><AlertDialogActionvariant="org"isDisabled={startTrial.isPending}diff --git a/frontend/src/pages/organization/SignupOnboardingPage/SignupOnboardingPage.tsx b/frontend/src/pages/organization/SignupOnboardingPage/SignupOnboardingPage.tsxindex 12fdf757f1..36dc143338 100644--- a/frontend/src/pages/organization/SignupOnboardingPage/SignupOnboardingPage.tsx+++ b/frontend/src/pages/organization/SignupOnboardingPage/SignupOnboardingPage.tsx@@ -11,6 +11,11 @@ import OrgNameStep from "@app/components/auth/OrgNameStep";import ProductSelectionStep from "@app/components/auth/ProductSelectionStep";import SignupCompleteStep from "@app/components/auth/SignupCompleteStep";import { getSignupProduct, SignupProductType } from "@app/components/auth/signupProducts";+import {+ bindSignupTrialIntent,+ getSignupTrialIntent,+ getSignupTrialProjectType+} from "@app/components/auth/signupTrialIntent";import TeamInviteStep from "@app/components/auth/TeamInviteStep";import { PageLoader } from "@app/components/v3";import { useSelectOrganization } from "@app/hooks/api/auth/queries";@@ -44,7 +49,9 @@ export const SignupOnboardingPage = () => {const [inviteEmails, setInviteEmails] = useState<string[]>([]);const projectCache = useRef<Partial<Record<SignupProductType, Project>>>({});// An empty selection means "just exploring".- const [selectedProducts, setSelectedProducts] = useState<SignupProductType[]>([]);+ const [selectedProducts, setSelectedProducts] = useState<SignupProductType[]>(() =>+ getSignupTrialProjectType(getSignupTrialIntent())+ );const [createdProjects, setCreatedProjects] = useState<Partial<Record<SignupProductType, Project>>>({});@@ -73,6 +80,7 @@ export const SignupOnboardingPage = () => {}const existingOrgId = orgs[0].id;+ bindSignupTrialIntent(existingOrgId);if (callbackPort) {handOffToCli(existingOrgId);return;@@ -98,6 +106,7 @@ export const SignupOnboardingPage = () => {}, [selectOrganization, navigate]);const handleOrgNameComplete = (newOrgId: string) => {+ bindSignupTrialIntent(newOrgId);if (callbackPort) {handOffToCli(newOrgId);return;