mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix(billing): gate the SOC-2 request behind eligible plans
The SOC-2 card rendered for every cloud organization owner, so Free and Pro users could fill in the whole request form and only learn it was unavailable from a generic "please try again later" error. BAA, the card directly above it, has always been gated on `supportedAddons.baa`. No SOC-2 entitlement exists on the plan model, so infer it: the Scale group is the lowest one that advertises SOC-2 (the Enterprise column on the pricing page), and contract plans sit above it. Ineligible organizations now get a short explanation and an upgrade CTA instead of a form that cannot succeed, and the modal is no longer mounted for them. Also send the request as multipart form data, the shape the support wizard uses. SOC-2 was the last caller posting JSON to growth's /support: the wizard moved to FormData ine446f7ff8and the BAA request modal, the other JSON caller, went away inbf2166bd3, so if that path has rotted the request was failing on every plan including Enterprise. The billing plan now rides along in metaFields so support can see the tier on the ticket.
This commit is contained in:
1 parent
4d7ffd6550
commit
294c0eb15f
3 files changed
+103
-56
No files matched your search
@@ -134,6 +134,19 @@ export function isStarterPlan(
|
||||
return planHasGroup(billingPlan, BillingPlanGroup.Starter);
|
||||
}
|
||||
|
||||
export function planSupportsSoc2(
|
||||
billingPlanOrId: string | Models.BillingPlan | null | undefined
|
||||
): boolean {
|
||||
const billingPlan = makeBillingPlan(billingPlanOrId);
|
||||
if (!billingPlan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// no SOC-2 entitlement exists on the plan model, so infer it: Scale is the
|
||||
// lowest group that advertises SOC-2, and contract plans sit above it.
|
||||
return planHasGroup(billingPlan, BillingPlanGroup.Scale) || billingPlan.selfService === false;
|
||||
}
|
||||
|
||||
export function canUpgrade(
|
||||
billingPlanOrId: string | Models.BillingPlan | null | undefined
|
||||
): boolean {
|
||||
|
||||
@@ -2,11 +2,22 @@
|
||||
import { Box, CardGrid } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import Soc2Modal from './Soc2Modal.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { getBasePlanFromGroup, getChangePlanUrl, planSupportsSoc2 } from '$lib/stores/billing';
|
||||
import { currentPlan, organization } from '$lib/stores/organization';
|
||||
import { BillingPlanGroup, type Models } from '@appwrite.io/console';
|
||||
|
||||
let show = false;
|
||||
export let locale: Models.Locale;
|
||||
export let countryList: Models.CountryList;
|
||||
let {
|
||||
locale,
|
||||
countryList
|
||||
}: {
|
||||
locale: Models.Locale;
|
||||
countryList: Models.CountryList;
|
||||
} = $props();
|
||||
|
||||
let show = $state(false);
|
||||
|
||||
const supportsSoc2 = $derived(planSupportsSoc2($currentPlan));
|
||||
const upgradePlanName = $derived(getBasePlanFromGroup(BillingPlanGroup.Scale)?.name);
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
@@ -22,16 +33,34 @@
|
||||
compliance with trust service criteria such as security, availability, processing
|
||||
integrity, confidentiality, and privacy.
|
||||
</p>
|
||||
<Button
|
||||
secondary
|
||||
external
|
||||
class="u-margin-block-start-16"
|
||||
on:click={() => (show = true)}
|
||||
event="request_soc-2">
|
||||
<span class="text">Request SOC-2</span>
|
||||
</Button>
|
||||
{#if supportsSoc2}
|
||||
<Button
|
||||
secondary
|
||||
external
|
||||
class="u-margin-block-start-16"
|
||||
on:click={() => (show = true)}
|
||||
event="request_soc-2">
|
||||
<span class="text">Request SOC-2</span>
|
||||
</Button>
|
||||
{:else}
|
||||
<p class="text u-margin-block-start-8">
|
||||
SOC-2 is not available on your current plan.{upgradePlanName
|
||||
? ` Upgrade to ${upgradePlanName} to request a SOC-2 report for your organization.`
|
||||
: ''}
|
||||
</p>
|
||||
{#if upgradePlanName}
|
||||
<Button
|
||||
secondary
|
||||
class="u-margin-block-start-16"
|
||||
href={getChangePlanUrl($organization?.$id)}>
|
||||
<span class="text">Upgrade plan</span>
|
||||
</Button>
|
||||
{/if}
|
||||
{/if}
|
||||
</Box>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<Soc2Modal {locale} {countryList} bind:show />
|
||||
{#if supportsSoc2}
|
||||
<Soc2Modal {locale} {countryList} bind:show />
|
||||
{/if}
|
||||
@@ -7,16 +7,22 @@
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { VARS } from '$lib/system';
|
||||
import { onMount } from 'svelte';
|
||||
import { untrack } from 'svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let show = false;
|
||||
export let locale: Models.Locale;
|
||||
export let countryList: Models.CountryList;
|
||||
let {
|
||||
show = $bindable(false),
|
||||
locale,
|
||||
countryList
|
||||
}: {
|
||||
show?: boolean;
|
||||
locale: Models.Locale;
|
||||
countryList: Models.CountryList;
|
||||
} = $props();
|
||||
|
||||
let email = '';
|
||||
let employees: string = null;
|
||||
let employeesOptions = [
|
||||
let email = $state($user?.email ?? '');
|
||||
let employees = $state<string>(null);
|
||||
const employeesOptions = [
|
||||
{
|
||||
value: '1-5',
|
||||
label: '1-5'
|
||||
@@ -35,50 +41,49 @@
|
||||
}
|
||||
];
|
||||
|
||||
let country = '';
|
||||
let countryOptions = [];
|
||||
|
||||
let role = '';
|
||||
let website = '';
|
||||
|
||||
let error: string;
|
||||
|
||||
onMount(async () => {
|
||||
if (locale.countryCode) {
|
||||
country = locale.countryCode;
|
||||
}
|
||||
countryOptions = countryList.countries.map((country) => {
|
||||
let country = $state(untrack(() => locale?.countryCode ?? ''));
|
||||
const countryOptions = $derived(
|
||||
(countryList?.countries ?? []).map((country) => {
|
||||
return {
|
||||
value: country.code,
|
||||
label: country.name
|
||||
};
|
||||
});
|
||||
email = $user.email;
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
let role = $state('');
|
||||
let website = $state('');
|
||||
|
||||
let error = $state<string>(null);
|
||||
|
||||
async function handleSubmit() {
|
||||
const formData = new FormData();
|
||||
formData.append('subject', 'SOC-2 Request');
|
||||
formData.append('email', email);
|
||||
formData.append('firstName', ($user?.name ?? '').slice(0, 40));
|
||||
formData.append(
|
||||
'message',
|
||||
`SOC-2 request for ${$organization?.name ?? ''} (${$organization?.$id ?? ''})`
|
||||
);
|
||||
formData.append('tags[]', 'cloud');
|
||||
formData.append(
|
||||
'metaFields',
|
||||
JSON.stringify({
|
||||
category: 'SOC-2',
|
||||
userName: $user?.name ?? '',
|
||||
orgId: $organization?.$id ?? '',
|
||||
userId: $user?.$id ?? '',
|
||||
billingPlan: $organization?.billingPlanId ?? '',
|
||||
employees: employees,
|
||||
country: country,
|
||||
role: role,
|
||||
website: website
|
||||
})
|
||||
);
|
||||
|
||||
const response = await fetch(`${VARS.GROWTH_ENDPOINT}/support`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
subject: 'SOC-2 Request',
|
||||
email: email,
|
||||
firstName: ($user?.name ?? '').slice(0, 40),
|
||||
message: `SOC-2 request for ${$organization?.name ?? ''} (${$organization?.$id ?? ''})`,
|
||||
tags: ['cloud'],
|
||||
metaFields: {
|
||||
category: 'SOC-2',
|
||||
userName: $user?.name ?? '',
|
||||
orgId: $organization?.$id ?? '',
|
||||
userId: $user?.$id ?? '',
|
||||
employees: employees,
|
||||
country: country,
|
||||
role: role,
|
||||
website: website
|
||||
}
|
||||
})
|
||||
body: formData
|
||||
});
|
||||
trackEvent(Submit.RequestSoc2);
|
||||
if (response.status !== 200) {
|
||||
|
||||
Reference in new issue
Block a user