Skip to content

Commit

Permalink
Revert "Redirect FREE_TEST_PLAN to paywall + allow trial (#9147)" (#9165
Browse files Browse the repository at this point in the history
)

This reverts commit 652543b.
  • Loading branch information
aubin-tchoi authored Dec 5, 2024
1 parent 5eae6c6 commit aab1514
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion front/lib/plans/free_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const FREE_PLANS_DATA: PlanAttributes[] = [
maxDataSourcesDocumentsCount: 10,
maxDataSourcesDocumentsSizeMb: 2,
trialPeriodDays: 0,
canUseProduct: false,
canUseProduct: true,
},
{
code: FREE_UPGRADED_PLAN_CODE,
Expand Down
9 changes: 3 additions & 6 deletions front/lib/plans/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import type {
BillingPeriod,
LightWorkspaceType,
Result,
SubscriptionType,
WorkspaceType,
} from "@dust-tt/types";
import type { SubscriptionType } from "@dust-tt/types";
import { Err, isDevelopment, Ok } from "@dust-tt/types";
import { Stripe } from "stripe";

import config from "@app/lib/api/config";
import type { Authenticator } from "@app/lib/auth";
import { Plan, Subscription } from "@app/lib/models/plan";
import {
isOldFreePlan,
PRO_PLAN_SEAT_29_CODE,
} from "@app/lib/plans/plan_codes";
import { PRO_PLAN_SEAT_29_CODE } from "@app/lib/plans/plan_codes";
import { countActiveSeatsInWorkspace } from "@app/lib/plans/usage/seats";
import {
isEnterpriseReportUsage,
Expand Down Expand Up @@ -120,7 +117,7 @@ export const createProPlanCheckoutSession = async ({
workspaceId: owner.id,
},
});
if (existingSubscription && !isOldFreePlan(existingSubscription.plan.code)) {
if (existingSubscription) {
trialAllowed = false;
}

Expand Down
3 changes: 0 additions & 3 deletions front/migrations/20241205_free_test_plan_cant_use_product.sql

This file was deleted.

18 changes: 5 additions & 13 deletions front/pages/w/[wId]/subscribe.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
BarHeader,
Button,
LockIcon,
Page,
useSendNotification,
} from "@dust-tt/sparkle";
import { BarHeader, Button, LockIcon, Page } from "@dust-tt/sparkle";
import { useSendNotification } from "@dust-tt/sparkle";
import type { BillingPeriod, WorkspaceType } from "@dust-tt/types";
import { CreditCardIcon } from "@heroicons/react/20/solid";
import type { InferGetServerSidePropsType } from "next";
Expand All @@ -16,7 +11,6 @@ import { UserMenu } from "@app/components/UserMenu";
import WorkspacePicker from "@app/components/WorkspacePicker";
import { useSubmitFunction } from "@app/lib/client/utils";
import { withDefaultUserAuthPaywallWhitelisted } from "@app/lib/iam/session";
import { isOldFreePlan } from "@app/lib/plans/plan_codes";
import { useUser } from "@app/lib/swr/user";
import { useWorkspaceSubscriptions } from "@app/lib/swr/workspaces";

Expand Down Expand Up @@ -55,11 +49,9 @@ export default function Subscribe({
React.useState<BillingPeriod>("monthly");

// If you had another subscription before, you will not get the free trial again: we use this to show the correct message.
// Current plan is either FREE_NO_PLAN or FREE_TEST_PLAN if you're on this paywall.
//FREE_NO_PLAN is not on the database, checking it comes down to having at least 1 subscription.
const hasPreviouSubscription =
subscriptions?.length > 0 &&
(subscriptions.length > 1 || !isOldFreePlan(subscriptions[0].plan.code)); // FREE_TEST_PLAN did not pay, they should be asked to start instead of resume
// Current plan is always FREE_NO_PLAN if you're on this paywall.
// Since FREE_NO_PLAN is not on the database, we check if there is at least 1 subscription.
const hasPreviouSubscription = subscriptions?.length > 0;

const { submit: handleSubscribePlan } = useSubmitFunction(
async (billingPeriod) => {
Expand Down

0 comments on commit aab1514

Please sign in to comment.