From 66d2c76a756f5ac19b9628ceb974a5d29f94074f Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 15 Jul 2024 15:13:01 +0200 Subject: [PATCH 01/19] refactor plan selection + add scale plan + fix copy and edge cases --- src/lib/components/billing/index.ts | 1 + .../components/billing/planSelection.svelte | 91 +++++++++++++++++++ src/lib/stores/billing.ts | 2 +- .../console/create-organization/+page.svelte | 59 ++---------- .../change-plan/+page.svelte | 75 ++++----------- .../usage/[[invoice]]/totalMembers.svelte | 2 +- 6 files changed, 116 insertions(+), 114 deletions(-) create mode 100644 src/lib/components/billing/planSelection.svelte diff --git a/src/lib/components/billing/index.ts b/src/lib/components/billing/index.ts index b8aac8ada..266d217d8 100644 --- a/src/lib/components/billing/index.ts +++ b/src/lib/components/billing/index.ts @@ -6,3 +6,4 @@ export { default as EstimatedTotalBox } from './estimatedTotalBox.svelte'; export { default as PlanComparisonBox } from './planComparisonBox.svelte'; export { default as EmptyCardCloud } from './emptyCardCloud.svelte'; export { default as CreditsApplied } from './creditsApplied.svelte'; +export { default as PlanSelection } from './planSelection.svelte'; diff --git a/src/lib/components/billing/planSelection.svelte b/src/lib/components/billing/planSelection.svelte new file mode 100644 index 000000000..cc35079dd --- /dev/null +++ b/src/lib/components/billing/planSelection.svelte @@ -0,0 +1,91 @@ + + +{#if billingPlan} + +{/if} diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 5e54db955..0273dd5d0 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -150,7 +150,7 @@ export const tierPro: TierData = { }; export const tierScale: TierData = { name: 'Scale', - description: 'For scaling teams that need dedicated support.' + description: 'For scaling teams and agencies that need dedicated support.' }; export const showUsageRatesModal = writable(false); diff --git a/src/routes/console/create-organization/+page.svelte b/src/routes/console/create-organization/+page.svelte index e7ac26659..b83d5590a 100644 --- a/src/routes/console/create-organization/+page.svelte +++ b/src/routes/console/create-organization/+page.svelte @@ -3,16 +3,15 @@ import { base } from '$app/paths'; import { page } from '$app/stores'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; - import { LabelCard } from '$lib/components'; import { EstimatedTotalBox, PlanComparisonBox, + PlanSelection, SelectPaymentMethod } from '$lib/components/billing'; import ValidateCreditModal from '$lib/components/billing/validateCreditModal.svelte'; import { BillingPlan, Dependencies } from '$lib/constants'; import { Button, Form, FormList, InputTags, InputText, Label } from '$lib/elements/forms'; - import { formatCurrency } from '$lib/helpers/numbers'; import { WizardSecondaryContainer, WizardSecondaryContent, @@ -20,7 +19,7 @@ WizardSecondaryHeader } from '$lib/layout'; import type { Coupon, PaymentList } from '$lib/sdk/billing'; - import { plansInfo, tierFree, tierPro, tierToPlan } from '$lib/stores/billing'; + import { tierToPlan } from '$lib/stores/billing'; import { addNotification } from '$lib/stores/notifications'; import { organizationList, type Organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; @@ -80,7 +79,7 @@ billingPlan = plan as BillingPlan; } } - if (anyOrgFree) { + if (!!anyOrgFree) { billingPlan = BillingPlan.PRO; } }); @@ -175,8 +174,6 @@ } } - $: freePlan = $plansInfo.get(BillingPlan.FREE); - $: proPlan = $plansInfo.get(BillingPlan.PRO); $: if (billingPlan === BillingPlan.PRO) { loadPaymentMethods(); } @@ -205,53 +202,9 @@ For more details on our plans, visit our .

- - {#if billingPlan === BillingPlan.PRO} - + + {#if billingPlan !== BillingPlan.FREE} + $organization.billingPlan; $: isDowngrade = billingPlan < $organization.billingPlan; - $: freePlan = $plansInfo.get(BillingPlan.FREE); - $: proPlan = $plansInfo.get(BillingPlan.PRO); $: if (billingPlan === BillingPlan.PRO) { loadPaymentMethods(); } @@ -261,7 +263,7 @@ For more details on our plans, visit our .

- {#if anyOrgFree && billingPlan === BillingPlan.PRO} + {#if anyOrgFree && billingPlan !== BillingPlan.FREE} You are limited to one {tierToPlan(BillingPlan.FREE).name} organization per account. Consider upgrading or deleting .

- + {#if billingPlan !== BillingPlan.FREE} Date: Mon, 22 Jul 2024 15:26:48 +0200 Subject: [PATCH 13/19] chore: remove vite.config.timestamp --- ....timestamp-1721654588921-f6099944fb288.mjs | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 vite.config.ts.timestamp-1721654588921-f6099944fb288.mjs diff --git a/vite.config.ts.timestamp-1721654588921-f6099944fb288.mjs b/vite.config.ts.timestamp-1721654588921-f6099944fb288.mjs deleted file mode 100644 index 46987eca0..000000000 --- a/vite.config.ts.timestamp-1721654588921-f6099944fb288.mjs +++ /dev/null @@ -1,51 +0,0 @@ -// vite.config.ts -import { defineConfig } from "file:///home/odin/Work/console/node_modules/vitest/dist/config.js"; -import { sveltekit } from "file:///home/odin/Work/console/node_modules/@sveltejs/kit/src/exports/vite/index.js"; -var config = defineConfig({ - plugins: [sveltekit()], - optimizeDeps: { - include: ["echarts", "prismjs"] - }, - ssr: { - noExternal: [ - "@analytics/google-analytics", - "@sentry/browser", - "@sentry-internal/tracing", - "analytics", - "dayjs", - "dotenv", - "echarts", - "prismjs", - "zrender" - ] - }, - server: { - port: 3e3 - } -}); -var testConfig = defineConfig({ - resolve: { - // hotfix for https://github.com/vitest-dev/vitest/issues/2834 - conditions: ["browser"] - }, - test: { - include: ["tests/unit/**/*.test.ts"], - environment: "jsdom", - globals: true, - pool: "threads", - setupFiles: ["./tests/unit/setup.ts"], - server: { - deps: { - inline: ["@analytics/type-utils"] - } - } - } -}); -var vite_config_default = process.env.VITEST ? { - ...config, - ...testConfig -} : config; -export { - vite_config_default as default -}; -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS9vZGluL1dvcmsvY29uc29sZVwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL2hvbWUvb2Rpbi9X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TTtBQUFBLEVBQ1Y7QUFDSixDQUFDO0FBRUQsSUFBTSxhQUFhLGFBQWE7QUFBQSxFQUM1QixTQUFTO0FBQUE7QUFBQSxJQUVMLFlBQVksQ0FBQyxTQUFTO0FBQUEsRUFDMUI7QUFBQSxFQUNBLE1BQU07QUFBQSxJQUNGLFNBQVMsQ0FBQyx5QkFBeUI7QUFBQSxJQUNuQyxhQUFhO0FBQUEsSUFDYixTQUFTO0FBQUEsSUFDVCxNQUFNO0FBQUEsSUFDTixZQUFZLENBQUMsdUJBQXVCO0FBQUEsSUFDcEMsUUFBUTtBQUFBLE1BQ0osTUFBTTtBQUFBLFFBQ0YsUUFBUSxDQUFDLHVCQUF1QjtBQUFBLE1BQ3BDO0FBQUEsSUFDSjtBQUFBLEVBQ0o7QUFDSixDQUFDO0FBRUQsSUFBTyxzQkFBUSxRQUFRLElBQUksU0FDckI7QUFBQSxFQUNJLEdBQUc7QUFBQSxFQUNILEdBQUc7QUFDUCxJQUNBOyIsCiAgIm5hbWVzIjogW10KfQo= From 467f40abd3b2a928ac070b8e0285fdf73ba2e9bd Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 29 Jul 2024 14:53:55 +0200 Subject: [PATCH 14/19] feat: add aggregations --- .../change-plan/+page.svelte | 12 ++---------- .../organization-[organization]/change-plan/+page.ts | 11 ++++++++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index ea2a6b9a5..eb9a222ba 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -62,6 +62,8 @@ if (m.userEmail !== $user.email) return m.userEmail; }) ?.filter(Boolean) ?? []; + let totalExtraMembers = data?.aggregationList; + $: console.log(totalExtraMembers); let couponData: Partial = { code: null, status: null, @@ -264,16 +266,6 @@ For more details on our plans, visit our .

- {#if anyOrgFree && billingPlan !== BillingPlan.FREE} - - You are limited to one {tierToPlan(BillingPlan.FREE).name} organization per account. - Consider upgrading or deleting . - - {/if} { - const { members } = await parent(); - depends(Dependencies.ORGANIZATION); + const { members, organization } = await parent(); + depends(Dependencies.ORGANIZATION); return { - members + members, + aggregationList: await sdk.forConsole.billing.listAggregation(organization?.$id, [ + Query.orderDesc('$createdAt') + ]) }; }; From 7b784ee2d5a9823b73e498806ab5eb4d3a1f73b0 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 30 Jul 2024 12:14:33 +0200 Subject: [PATCH 15/19] chore: revert aggregation change --- .../organization-[organization]/change-plan/+page.svelte | 2 -- .../organization-[organization]/change-plan/+page.ts | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index eb9a222ba..9147d1e51 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -62,8 +62,6 @@ if (m.userEmail !== $user.email) return m.userEmail; }) ?.filter(Boolean) ?? []; - let totalExtraMembers = data?.aggregationList; - $: console.log(totalExtraMembers); let couponData: Partial = { code: null, status: null, diff --git a/src/routes/console/organization-[organization]/change-plan/+page.ts b/src/routes/console/organization-[organization]/change-plan/+page.ts index 55597d910..b10332405 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.ts +++ b/src/routes/console/organization-[organization]/change-plan/+page.ts @@ -1,15 +1,10 @@ import { Dependencies } from '$lib/constants'; -import { sdk } from '$lib/stores/sdk.js'; -import { Query } from '@appwrite.io/console'; export const load = async ({ depends, parent }) => { - const { members, organization } = await parent(); + const { members } = await parent(); depends(Dependencies.ORGANIZATION); return { - members, - aggregationList: await sdk.forConsole.billing.listAggregation(organization?.$id, [ - Query.orderDesc('$createdAt') - ]) + members }; }; From c07941e699f1b5713484d7b6dc9192ac2f342ccb Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 30 Jul 2024 12:31:21 +0200 Subject: [PATCH 16/19] feat: campaigns --- src/lib/stores/campaigns.ts | 10 +++++++--- src/routes/console/apply-credit/+page.svelte | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib/stores/campaigns.ts b/src/lib/stores/campaigns.ts index b74975962..46e25d80b 100644 --- a/src/lib/stores/campaigns.ts +++ b/src/lib/stores/campaigns.ts @@ -1,11 +1,14 @@ //campaign welcome and startup +import { BillingPlan } from '$lib/constants'; + export type CampaignData = { title: string; description: string; template: 'card' | 'review'; data?: Record; onlyNewOrgs?: boolean; + plan?: BillingPlan; footer?: boolean; }; @@ -22,7 +25,7 @@ campaigns template: 'card', title: 'Welcome to the Startups program!', description: - "We're excited to have you on board. Add the coupon code to your Appwrite Pro account to join." + "We're excited to have you on board. Add the coupon code to your Appwrite Scale account to join." }) .set('RenderATL2024', { template: 'card', @@ -52,10 +55,11 @@ campaigns template: 'review', title: 'Welcome to the Startups program', description: - "We're excited to have you on board. Add your credit code to your Appwrite Pro account to join.", + "We're excited to have you on board. Add your credit code to your Appwrite Scale account to join.", onlyNewOrgs: true, + plan: BillingPlan.SCALE, data: { - cta: 'Get everything out of Cloud with Pro', + cta: 'Get everything out of Cloud with Scale', claimed: 'Your credits will be valid for 12 months.', unclaimed: 'Apply your code to join the Startups program.', reviews: [ diff --git a/src/routes/console/apply-credit/+page.svelte b/src/routes/console/apply-credit/+page.svelte index 45489e763..231c8820f 100644 --- a/src/routes/console/apply-credit/+page.svelte +++ b/src/routes/console/apply-credit/+page.svelte @@ -70,6 +70,7 @@ let coupon: string; let couponData = data?.couponData; let campaign = campaigns.get(data?.couponData?.campaign ?? data?.campaign); + let billingPlan = BillingPlan.PRO; onMount(async () => { await loadPaymentMethods(); @@ -80,6 +81,9 @@ selectedOrgId = $page.url.searchParams.get('org'); canSelectOrg = false; } + if (campaign?.plan) { + billingPlan = campaign.plan; + } }); async function loadPaymentMethods() { @@ -101,15 +105,15 @@ org = await sdk.forConsole.billing.createOrganization( newOrgId, name, - BillingPlan.PRO, + billingPlan, paymentMethodId ); } // Upgrade existing org - else if (selectedOrg?.billingPlan !== BillingPlan.PRO) { + else if (selectedOrg?.billingPlan === BillingPlan.FREE) { org = await sdk.forConsole.billing.updatePlan( selectedOrg.$id, - BillingPlan.PRO, + billingPlan, paymentMethodId, null ); From c018205858549de473be26490f9bea9292d1a0e5 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 30 Jul 2024 15:56:35 +0200 Subject: [PATCH 17/19] fix: organization members count --- src/lib/components/billing/planExcess.svelte | 3 ++- src/lib/stores/billing.ts | 4 ++-- src/routes/console/onboarding/+page.svelte | 4 ++++ .../change-plan/+page.svelte | 14 +++++++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/lib/components/billing/planExcess.svelte b/src/lib/components/billing/planExcess.svelte index b2d641cfe..352f0b29b 100644 --- a/src/lib/components/billing/planExcess.svelte +++ b/src/lib/components/billing/planExcess.svelte @@ -23,6 +23,7 @@ import { tooltip } from '$lib/actions/tooltip'; export let tier: Tier; + export let members: number; const plan = $plansInfo?.get(tier); let excess: { @@ -41,7 +42,7 @@ $organization.billingCurrentInvoiceDate, new Date().toISOString() ); - excess = calculateExcess(usage, plan, $organization); + excess = calculateExcess(usage, plan, members); showExcess = Object.values(excess).some((value) => value > 0); }); diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 0273dd5d0..ce7adccf7 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -422,14 +422,14 @@ export const upgradeURL = derived( export const hideBillingHeaderRoutes = ['/console/create-organization', '/console/account']; -export function calculateExcess(usage: OrganizationUsage, plan: Plan, org: Organization) { +export function calculateExcess(usage: OrganizationUsage, plan: Plan, members: number) { const totBandwidth = usage?.bandwidth?.length > 0 ? last(usage.bandwidth).value : 0; return { bandwidth: calculateResourceSurplus(totBandwidth, plan.bandwidth), storage: calculateResourceSurplus(usage?.storageTotal, plan.storage, 'GB'), users: calculateResourceSurplus(usage?.usersTotal, plan.users), executions: calculateResourceSurplus(usage?.executionsTotal, plan.executions, 'GB'), - members: calculateResourceSurplus(org.total, plan.members) + members: calculateResourceSurplus(members, plan.members) }; } diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte index 27b5528b6..bf9a0992b 100644 --- a/src/routes/console/onboarding/+page.svelte +++ b/src/routes/console/onboarding/+page.svelte @@ -32,6 +32,10 @@ { value: BillingPlan.PRO, label: `${tierToPlan(BillingPlan.PRO).name} - ${formatCurrency($plansInfo.get(BillingPlan.PRO).price)}/month + add-ons` + }, + { + value: BillingPlan.SCALE, + label: `${tierToPlan(BillingPlan.SCALE).name} - ${formatCurrency($plansInfo.get(BillingPlan.SCALE).price)}/month + usage` } ] : []; diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index 9147d1e51..e0d81bb37 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -273,9 +273,12 @@ {#if isDowngrade} {#if billingPlan === BillingPlan.FREE} - + {:else if billingPlan === BillingPlan.PRO && $organization.billingPlan === BillingPlan.SCALE} - {@const members = collaborators?.length ?? 0} + {@const extraMembers = collaborators?.length ?? 0} Your monthly payments will be adjusted for the Pro plan @@ -283,9 +286,10 @@ After switching plans, you will be charged {formatCurrency( - members * ($plansInfo?.get(billingPlan)?.addons?.member?.price ?? 0) - )} monthly for {members} team members. This will be reflected in your - next invoice. + extraMembers * + ($plansInfo?.get(billingPlan)?.addons?.member?.price ?? 0) + )} monthly for {extraMembers} team members. This will be reflected in + your next invoice. {/if} {/if} From 065de36d194dd5ba5358a744b4e100fa46295dba Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 30 Jul 2024 18:26:44 +0200 Subject: [PATCH 18/19] fix: padding --- src/lib/components/billing/planComparisonBox.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/billing/planComparisonBox.svelte b/src/lib/components/billing/planComparisonBox.svelte index 5e8e30185..e297d8e75 100644 --- a/src/lib/components/billing/planComparisonBox.svelte +++ b/src/lib/components/billing/planComparisonBox.svelte @@ -10,7 +10,7 @@ $: plan = $plansInfo.get(selectedTab); - +
Date: Mon, 5 Aug 2024 15:16:20 +0200 Subject: [PATCH 19/19] fix: review --- src/lib/stores/organization.ts | 2 +- .../console/organization-[organization]/billing/+page.svelte | 4 ++-- .../organization-[organization]/change-plan/+page.svelte | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/stores/organization.ts b/src/lib/stores/organization.ts index 2beb13b03..f0f363d56 100644 --- a/src/lib/stores/organization.ts +++ b/src/lib/stores/organization.ts @@ -19,7 +19,7 @@ export type Organization = Models.Team> & { billingAddressId?: string; amount: number; billingTaxId?: string; - billingPlanDowngrade?: string; + billingPlanDowngrade?: Tier; }; export type OrganizationList = { diff --git a/src/routes/console/organization-[organization]/billing/+page.svelte b/src/routes/console/organization-[organization]/billing/+page.svelte index 98773c429..30720f912 100644 --- a/src/routes/console/organization-[organization]/billing/+page.svelte +++ b/src/routes/console/organization-[organization]/billing/+page.svelte @@ -111,8 +111,8 @@ {/if} {#if $organization?.billingPlanDowngrade} - Your organization will change to a {tierToPlan(BillingPlan.FREE).name} plan once your current - billing cycle ends and your invoice is paid on {toLocaleDate( + Your organization will change to a {tierToPlan($organization?.billingPlanDowngrade) + .name} plan once your current billing cycle ends and your invoice is paid on {toLocaleDate( $organization.billingNextInvoiceDate )}. diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index e0d81bb37..d3c4d62e1 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -111,9 +111,9 @@ } async function handleSubmit() { - if (billingPlan === BillingPlan.FREE) { + if (isDowngrade) { await downgrade(); - } else { + } else if (isUpgrade) { await upgrade(); } }