|
106 | 106 | }
|
107 | 107 | }
|
108 | 108 |
|
| 109 | + async function trackDowngradeFeedback() { |
| 110 | + const paidInvoices = await sdk.forConsole.billing.listInvoices(data.organization.$id, [ |
| 111 | + Query.equal('status', 'succeeded') |
| 112 | + ]); |
| 113 | +
|
| 114 | + await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, { |
| 115 | + method: 'POST', |
| 116 | + headers: { |
| 117 | + 'Content-Type': 'application/json' |
| 118 | + }, |
| 119 | + body: JSON.stringify({ |
| 120 | + from: tierToPlan(data.organization.billingPlan).name, |
| 121 | + to: tierToPlan(selectedPlan).name, |
| 122 | + email: data.account.email, |
| 123 | + reason: feedbackDowngradeOptions.find( |
| 124 | + (option) => option.value === feedbackDowngradeReason |
| 125 | + )?.label, |
| 126 | + orgId: data.organization.$id, |
| 127 | + userId: data.account.$id, |
| 128 | + orgAge: data.organization.$createdAt, |
| 129 | + userAge: data.account.$createdAt, |
| 130 | + paidInvoices: paidInvoices.total, |
| 131 | + message: feedbackMessage ?? '' |
| 132 | + }) |
| 133 | + }); |
| 134 | + } |
| 135 | +
|
109 | 136 | async function downgrade() {
|
110 | 137 | try {
|
111 | 138 | await sdk.forConsole.billing.updatePlan(
|
|
115 | 142 | null
|
116 | 143 | );
|
117 | 144 |
|
118 |
| - const paidInvoices = await sdk.forConsole.billing.listInvoices(data.organization.$id, [ |
119 |
| - Query.equal('status', 'succeeded') |
120 |
| - ]); |
121 |
| -
|
122 |
| - await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, { |
123 |
| - method: 'POST', |
124 |
| - headers: { |
125 |
| - 'Content-Type': 'application/json' |
126 |
| - }, |
127 |
| - body: JSON.stringify({ |
128 |
| - from: tierToPlan(data.organization.billingPlan).name, |
129 |
| - to: tierToPlan(selectedPlan).name, |
130 |
| - email: data.account.email, |
131 |
| - reason: feedbackDowngradeOptions.find( |
132 |
| - (option) => option.value === feedbackDowngradeReason |
133 |
| - )?.label, |
134 |
| - orgId: data.organization.$id, |
135 |
| - userId: data.account.$id, |
136 |
| - orgAge: data.organization.$createdAt, |
137 |
| - userAge: data.account.$createdAt, |
138 |
| - paidInvoices: paidInvoices.total, |
139 |
| - message: feedbackMessage ?? '' |
140 |
| - }) |
141 |
| - }); |
| 145 | + trackDowngradeFeedback(); |
142 | 146 |
|
143 | 147 | await invalidate(Dependencies.ORGANIZATION);
|
144 | 148 |
|
|
0 commit comments