Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: change free trial control #1639

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ DISABLE_SSO="false"
STRIPE_SECRET_KEY="stripe-secret-key"
STRIPE_PUBLIC_KEY="stripe-public-key"
STRIPE_WEBHOOK_ENDPOINT_SECRET="stripe-endpoint-secret"

FREE_TRIAL_DAYS="14"

SMTP_PWD="super-safe-passw0rd"
SMTP_HOST="mail.example.com"
Expand Down
3 changes: 2 additions & 1 deletion app/components/subscription/price-cta.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useLoaderData } from "@remix-run/react";
import { config } from "~/config/shelf.config";
import type { loader } from "~/routes/_layout+/account-details.subscription";
import { CustomerPortalForm } from "./customer-portal-form";
import type { Price } from "./prices";
Expand Down Expand Up @@ -48,7 +49,7 @@ export const PriceCta = ({
name="intent"
value="trial"
>
Start 14 day free trial
Start {config.freeTrialDays} day free trial
</Button>
)}
</Form>
Expand Down
4 changes: 2 additions & 2 deletions app/components/welcome/choose-purpose.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from "react";
import { useNavigation } from "@remix-run/react";
import { config } from "~/config/shelf.config";
import { isFormProcessing } from "~/utils/form";
import { tw } from "~/utils/tw";
import Icon from "../icons/icon";
Expand All @@ -13,7 +14,6 @@ export function ChoosePurpose() {
);
const navigation = useNavigation();
const disabled = isFormProcessing(navigation.state) || !selectedPlan;

return (
<>
<div className="flex flex-col items-center p-4 sm:p-6">
Expand Down Expand Up @@ -62,7 +62,7 @@ export function ChoosePurpose() {
<span className="text-primary">
<CheckmarkIcon />
</span>{" "}
<span>Free 14-day trial</span>
<span>Free {config.freeTrialDays}-day trial</span>
</div>
<div className="flex items-center gap-3">
<span className="text-primary">
Expand Down
3 changes: 3 additions & 0 deletions app/config/shelf.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import {
DISABLE_SIGNUP,
DISABLE_SSO,
ENABLE_PREMIUM_FEATURES,
FREE_TRIAL_DAYS,
SEND_ONBOARDING_EMAIL,
} from "~/utils/env";
import { Config } from "./types";

console.log("FREE_TRIAL_DAYS", FREE_TRIAL_DAYS);
export const config: Config = {
sendOnboardingEmail: SEND_ONBOARDING_EMAIL || false,
enablePremiumFeatures: ENABLE_PREMIUM_FEATURES || false,
freeTrialDays: Number(FREE_TRIAL_DAYS || 7),
disableSignup: DISABLE_SIGNUP || false,
disableSSO: DISABLE_SSO || false,

Expand Down
5 changes: 5 additions & 0 deletions app/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export interface Config {
* */
sendOnboardingEmail: boolean;

/**
* Number of days for the free trial
*/
freeTrialDays: number;

/**
* Enable premium features
*/
Expand Down
3 changes: 2 additions & 1 deletion app/routes/_welcome+/select-plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CrispButton } from "~/components/marketing/crisp";
import { ShelfSymbolLogo } from "~/components/marketing/logos";
import { Button } from "~/components/shared/button";
import { PriceBox } from "~/components/subscription/price-box";
import { config } from "~/config/shelf.config";
import { getUserByID } from "~/modules/user/service.server";
import { appendToMetaTitle } from "~/utils/append-to-meta-title";
import { makeShelfError } from "~/utils/error";
Expand Down Expand Up @@ -164,7 +165,7 @@ export default function SelectPlan() {
value="trial"
disabled={disabled}
>
Start 14 day free trial
Start {config.freeTrialDays} day free trial
</Button>
</Form>
</div>
Expand Down
9 changes: 9 additions & 0 deletions app/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare global {
MAINTENANCE_MODE: string;
CHROME_EXECUTABLE_PATH: string;
URL_SHORTENER: string;
FREE_TRIAL_DAYS: string;
};
}
}
Expand Down Expand Up @@ -50,6 +51,7 @@ declare global {
ADMIN_EMAIL: string;
CHROME_EXECUTABLE_PATH: string;
FINGERPRINT: string;
FREE_TRIAL_DAYS: string;
}
}
}
Expand Down Expand Up @@ -190,6 +192,12 @@ export const ENABLE_PREMIUM_FEATURES =
isRequired: false,
}) === "true" || false;

export const FREE_TRIAL_DAYS =
getEnv("FREE_TRIAL_DAYS", {
isSecret: false,
isRequired: false,
}) || "14";

export const DISABLE_SIGNUP =
getEnv("DISABLE_SIGNUP", {
isSecret: false,
Expand Down Expand Up @@ -225,5 +233,6 @@ export function getBrowserEnv() {
MAINTENANCE_MODE,
CHROME_EXECUTABLE_PATH,
URL_SHORTENER,
FREE_TRIAL_DAYS,
};
}
2 changes: 1 addition & 1 deletion app/utils/stripe.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export async function createStripeCheckoutSession({
missing_payment_method: "pause",
},
},
trial_period_days: 14,
trial_period_days: config.freeTrialDays,
},
payment_method_collection: "if_required",
}),
Expand Down