Merge pull request #2636 from appwrite/feat-feedback

Feat: downgrade feedback
This commit is contained in:
Damodar Lohani
2025-11-25 11:03:26 +05:45
committed by GitHub
4 changed files with 18 additions and 33 deletions
+4 -2
View File
@@ -22,7 +22,8 @@ import {
Tokens,
TablesDB,
Domains,
Realtime
Realtime,
Organizations
} from '@appwrite.io/console';
import { Billing } from '../sdk/billing';
import { Backups } from '../sdk/backups';
@@ -95,7 +96,8 @@ function createConsoleSdk(client: Client) {
sites: new Sites(client),
domains: new Domains(client),
storage: new Storage(client),
realtime: new Realtime(client)
realtime: new Realtime(client),
organizations: new Organizations(client)
};
}
@@ -16,7 +16,6 @@
import { sdk } from '$lib/stores/sdk';
import { confirmPayment } from '$lib/stores/stripe';
import { user } from '$lib/stores/user';
import { VARS } from '$lib/system';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import {
Alert,
@@ -140,30 +139,14 @@
}
async function trackDowngradeFeedback() {
const paidInvoices = await sdk.forConsole.billing.listInvoices(data.organization.$id, [
Query.equal('status', 'succeeded'),
Query.greaterThan('grossAmount', 0)
]);
await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: tierToPlan(data.organization.billingPlan).name,
to: tierToPlan(selectedPlan).name,
email: data.account.email,
reason: feedbackDowngradeOptions.find(
(option) => option.value === feedbackDowngradeReason
)?.label,
orgId: data.organization.$id,
userId: data.account.$id,
orgAge: data.organization.$createdAt,
userAge: data.account.$createdAt,
paidInvoices: paidInvoices.total,
message: feedbackMessage ?? ''
})
await sdk.forConsole.organizations.createDowngradeFeedback({
organizationId: data.organization.$id,
reason: feedbackDowngradeOptions.find(
(option) => option.value === feedbackDowngradeReason
)?.label,
message: feedbackMessage ?? '',
fromPlanId: data.organization.billingPlan,
toPlanId: selectedPlan
});
}