Skip to content

Commit 2b15daa

Browse files
Merge pull request #727 from appwrite/fix-missing-events-and-credits
chore: add missing event
2 parents 94d0933 + 7058943 commit 2b15daa

21 files changed

+161
-30
lines changed

src/lib/components/billing/couponInput.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<div>
5656
<span class="icon-exclamation-circle u-color-text-danger" />
5757
<span>
58-
{couponData.code} is not a valid promo code
58+
{couponData.code.toUpperCase()} is not a valid promo code
5959
</span>
6060
</div>
6161
{:else if couponData?.status === 'active'}
@@ -64,11 +64,11 @@
6464
<span class="icon-tag u-color-text-success" />
6565
<slot data={couponData}>
6666
<span>
67-
{couponData.code} applied (-${couponData.credits})
67+
{couponData.code.toUpperCase()} applied (-${couponData.credits})
6868
</span>
6969
</slot>
7070
</div>
71-
<Button text on:click={removeCoupon}>Remove</Button>
71+
<Button round text on:click={removeCoupon}><span class="icon-x"></span></Button>
7272
</div>
7373
{/if}
7474
</FormList>

src/lib/components/radioBoxes.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{#if total}
1414
{#each elements as element}
1515
{@const value = element[variableName]?.toString()}
16-
<div class="box">
16+
<div class="box" data-private>
1717
<InputRadio
1818
id={`${name}-${value}`}
1919
{value}

src/lib/components/support.svelte

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import { isCloud } from '$lib/system';
1212
import { organization } from '$lib/stores/organization';
1313
import { BillingPlan } from '$lib/constants';
14+
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
15+
import { trackEvent } from '$lib/actions/analytics';
1416
1517
export let show = false;
1618
@@ -43,7 +45,16 @@
4345
{/if}
4446
</div>
4547
{#if $organization?.billingPlan === BillingPlan.STARTER}
46-
<Button fullWidth href="https://appwrite.io/pricing" external>
48+
<Button
49+
fullWidth
50+
external
51+
on:click={() => {
52+
wizard.start(ChangeOrganizationTierCloud);
53+
trackEvent('click_organization_upgrade', {
54+
from: 'button',
55+
source: 'support_menu'
56+
});
57+
}}>
4758
<span class="text">Get Premium support</span>
4859
</Button>
4960
{:else}

src/lib/elements/table/body.svelte

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { trackEvent } from '$lib/actions/analytics';
23
import { getServiceLimit, type PlanServices } from '$lib/stores/billing';
34
import { wizard } from '$lib/stores/wizard';
45
import { isCloud } from '$lib/system';
@@ -10,6 +11,7 @@
1011
export let service: PlanServices = null;
1112
export let name = service;
1213
export let total: number = null;
14+
export let event: string = null;
1315
1416
let columns = 0;
1517
@@ -34,7 +36,14 @@
3436
<span class="u-flex u-gap-24 u-main-center u-cross-center">
3537
<slot name="limit" {upgradeMethod} {limit}>
3638
<span class="text">Upgrade your plan to add {name} to your organization</span>
37-
<Button secondary on:click={upgradeMethod}>Upgrade plan</Button>
39+
<Button
40+
secondary
41+
on:click={upgradeMethod}
42+
on:click={() =>
43+
trackEvent('click_organization_upgrade', {
44+
from: 'button',
45+
source: event ?? 'table_row_limit_reached'
46+
})}>Upgrade plan</Button>
3847
</slot>
3948
</span>
4049
</td>

src/lib/layout/containerHeader.svelte

+13-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import { ContainerButton } from '.';
1919
import { Button } from '$lib/elements/forms';
2020
import { BillingPlan } from '$lib/constants';
21+
import { trackEvent } from '$lib/actions/analytics';
2122
2223
export let isFlex = true;
2324
export let title: string;
@@ -92,8 +93,12 @@
9293
<span class="text">
9394
You've reached the {services} limit for the {tier} plan. <Button
9495
link
95-
on:click={upgradeMethod}>Upgrade</Button> your organization for additional
96-
resources.
96+
on:click={upgradeMethod}
97+
on:click={() =>
98+
trackEvent('click_organization_upgrade', {
99+
from: 'button',
100+
source: 'inline_alert'
101+
})}>Upgrade</Button> your organization for additional resources.
97102
</span>
98103
</Alert>
99104
{/if}
@@ -124,7 +129,12 @@
124129
{title.toLocaleLowerCase()} per project on the {tier} plan.
125130
{#if $organization?.billingPlan === BillingPlan.STARTER}<Button
126131
link
127-
on:click={upgradeMethod}>Upgrade</Button>
132+
on:click={upgradeMethod}
133+
on:click={() =>
134+
trackEvent('click_organization_upgrade', {
135+
from: 'button',
136+
source: 'resource_limit_tag'
137+
})}>Upgrade</Button>
128138
for addtional {title.toLocaleLowerCase()}.
129139
{/if}
130140
</p>

src/lib/layout/header.svelte

+7-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@
121121
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER && !$page.url.pathname.startsWith('/console/account')}
122122
<Button
123123
disabled={$organization?.markedForDeletion}
124-
on:click={() => wizard.start(ChangeOrganizationTierCloud)}>
124+
on:click={() => {
125+
wizard.start(ChangeOrganizationTierCloud);
126+
trackEvent('click_organization_upgrade', {
127+
from: 'button',
128+
source: 'top_nav'
129+
});
130+
}}>
125131
Upgrade
126132
</Button>
127133
{/if}

src/lib/layout/notification.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
class={icon ? `icon-${icon}` : ''}
3737
aria-hidden="true" />
3838
</div>
39-
<div class="alert-sticky-content">
39+
<div class="alert-sticky-content" data-private>
4040
{#if title}
4141
<h4 class="alert-sticky-title">{title}</h4>
4242
{/if}

src/routes/console/changeOrganizationTierCloud.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
org.$id,
8989
$changeOrganizationTier.couponCode
9090
);
91+
trackEvent(Submit.CreditRedeem);
9192
}
9293
9394
//Add budget

src/routes/console/createOrganizationCloud.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
);
5757
}
5858
59+
//Add coupon
60+
if ($createOrganization?.couponCode) {
61+
await sdk.forConsole.billing.addCredit(org.$id, $createOrganization.couponCode);
62+
trackEvent(Submit.CreditRedeem);
63+
}
64+
5965
//Add collaborators
6066
if ($createOrganization?.collaborators?.length) {
6167
$createOrganization.collaborators.forEach(async (collaborator) => {
@@ -110,7 +116,8 @@
110116
paymentMethodId: null,
111117
collaborators: [],
112118
billingAddressId: null,
113-
taxId: null
119+
taxId: null,
120+
couponCode: null
114121
};
115122
});
116123

src/routes/console/organization-[organization]/billing/availableCredit.svelte

+4-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@
7171
<p class="text">Appwrite credit will automatically be applied to your next invoice.</p>
7272
<svelte:fragment slot="aside">
7373
<div class="u-flex u-cross-center u-main-space-between">
74-
<h4 class="body-text-1 u-bold">
75-
Credit balance <span class="inline-tag">${balance}</span>
76-
</h4>
74+
<div class="u-flex u-gap-8 u-cross-center">
75+
<h4 class="body-text-1 u-bold">Credit balance</h4>
76+
<span class="inline-tag">${balance}</span>
77+
</div>
7778
{#if creditList?.total}
7879
<Button secondary on:click={handleCredits}>
7980
<span class="icon-plus" aria-hidden="true"></span>

src/routes/console/organization-[organization]/billing/budgetCap.svelte

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import { addNotification } from '$lib/stores/notifications';
99
import { organization } from '$lib/stores/organization';
1010
import { sdk } from '$lib/stores/sdk';
11+
import { wizard } from '$lib/stores/wizard';
12+
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
1113
import { onMount } from 'svelte';
1214
1315
let capActive = false;
@@ -92,7 +94,19 @@
9294
</svelte:fragment>
9395

9496
<svelte:fragment slot="actions">
95-
<Button disabled={$organization?.billingBudget === budget} submit>Update</Button>
97+
{#if $organization?.billingPlan === BillingPlan.STARTER}
98+
<Button
99+
secondary
100+
on:click={() => {
101+
wizard.start(ChangeOrganizationTierCloud);
102+
trackEvent('click_organization_upgrade', {
103+
from: 'button',
104+
source: 'billing_budget_cap'
105+
});
106+
}}>Upgrade to Pro</Button>
107+
{:else}
108+
<Button disabled={$organization?.billingBudget === budget} submit>Update</Button>
109+
{/if}
96110
</svelte:fragment>
97111
</CardGrid>
98112
</Form>

src/routes/console/organization-[organization]/billing/planSummary.svelte

+13-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import { abbreviateNumber, formatNumberWithCommas } from '$lib/helpers/numbers';
1616
import { humanFileSize } from '$lib/helpers/sizeConvertion';
1717
import { BillingPlan } from '$lib/constants';
18+
import { trackEvent } from '$lib/actions/analytics';
1819
1920
let currentInvoice: Invoice;
2021
const today = new Date();
@@ -136,7 +137,12 @@
136137
</Button>
137138
<Button
138139
disabled={$organization?.markedForDeletion}
139-
on:click={() => wizard.start(ChangeOrganizationTierCloud)}>
140+
on:click={() => wizard.start(ChangeOrganizationTierCloud)}
141+
on:click={() =>
142+
trackEvent('click_organization_upgrade', {
143+
from: 'button',
144+
source: 'billing_tab'
145+
})}>
140146
Upgrade
141147
</Button>
142148
</div>
@@ -145,7 +151,12 @@
145151
<Button
146152
text
147153
disabled={$organization?.markedForDeletion}
148-
on:click={() => wizard.start(ChangeOrganizationTierCloud)}>
154+
on:click={() => wizard.start(ChangeOrganizationTierCloud)}
155+
on:click={() =>
156+
trackEvent('click_organization_plan_update', {
157+
from: 'button',
158+
source: 'billing_tab'
159+
})}>
149160
Change plan
150161
</Button>
151162
<Button

src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import type { Coupon } from '$lib/sdk/billing';
55
import { sdk } from '$lib/stores/sdk';
66
import { wizard } from '$lib/stores/wizard';
7+
import { onMount } from 'svelte';
78
import { addCreditWizardStore } from '../store';
89
910
let coupon: string;
@@ -18,6 +19,7 @@
1819
try {
1920
const response = await sdk.forConsole.billing.getCoupon(coupon);
2021
couponData = response;
22+
$addCreditWizardStore.coupon = coupon;
2123
coupon = null;
2224
} catch (error) {
2325
couponData.code = coupon;
@@ -26,6 +28,13 @@
2628
throw new Error(error);
2729
}
2830
}
31+
32+
onMount(() => {
33+
if ($addCreditWizardStore.coupon) {
34+
coupon = $addCreditWizardStore.coupon;
35+
validateCoupon();
36+
}
37+
});
2938
</script>
3039

3140
<WizardStep beforeSubmit={validateCoupon}>
@@ -41,6 +50,6 @@
4150
$addCreditWizardStore.coupon = e.detail.code;
4251
}}
4352
let:data>
44-
<span>{data.code} has been successfully added</span>
53+
<span>{data.code.toUpperCase()} has been successfully added</span>
4554
</CouponInput>
4655
</WizardStep>

src/routes/console/organization-[organization]/excesLimitModal.svelte

+11-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import { goto } from '$app/navigation';
1515
import { last } from '$lib/helpers/array';
1616
import { BillingPlan } from '$lib/constants';
17+
import { trackEvent } from '$lib/actions/analytics';
1718
1819
export let show = false;
1920
const plan = $plansInfo?.get($organization.billingPlan);
@@ -89,13 +90,20 @@
8990
on:click={() => {
9091
show = false;
9192
goto(`/console/organization-${$organization.$id}/usage`);
92-
}}>View usage</Button>
93-
93+
}}>
94+
View usage
95+
</Button>
9496
<Button
9597
on:click={() => {
9698
show = false;
9799
wizard.start(ChangeOrganizationTierCloud);
98-
}}>Upgrade plan</Button>
100+
trackEvent('click_organization_upgrade', {
101+
from: 'button',
102+
source: 'limit_reached_modal'
103+
});
104+
}}>
105+
Upgrade plan
106+
</Button>
99107
</div>
100108
</div>
101109
</svelte:fragment>

src/routes/console/organization-[organization]/members/+page.svelte

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@
7070
<TableCellHead width={90} />
7171
<TableCellHead width={30} />
7272
</TableHeader>
73-
<TableBody service="members" total={data.organizationMembers.total}>
73+
<TableBody
74+
service="members"
75+
total={data.organizationMembers.total}
76+
event="members_list">
7477
{#each data.organizationMembers.memberships as member}
7578
<TableRow>
7679
<TableCell title="Name">

src/routes/console/organization-[organization]/usage/[[invoice]]/+page.svelte

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import { accumulateFromEndingTotal, total } from '$lib/layout/usage.svelte';
1414
import type { OrganizationUsage } from '$lib/sdk/billing';
1515
import { BillingPlan } from '$lib/constants';
16+
import { trackEvent } from '$lib/actions/analytics';
1617
1718
export let data;
1819
@@ -42,7 +43,14 @@
4243
<Heading tag="h2" size="5">Usage</Heading>
4344

4445
{#if $organization?.billingPlan === BillingPlan.STARTER}
45-
<Button on:click={() => wizard.start(ChangeOrganizationTierCloud)}>
46+
<Button
47+
on:click={() => {
48+
wizard.start(ChangeOrganizationTierCloud);
49+
trackEvent('click_organization_upgrade', {
50+
from: 'button',
51+
source: 'organization_usage'
52+
});
53+
}}>
4654
<span class="text">Upgrade</span>
4755
</Button>
4856
{/if}

src/routes/console/wizard/cloudOrganization/addressDetails.svelte

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { createOrganization } from './store';
77
import type { AddressesList } from '$lib/sdk/billing';
88
import { RadioBoxes } from '$lib/components';
9+
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
910
1011
let options = [
1112
{
@@ -33,7 +34,9 @@
3334
addressLine2 ? addressLine2 : undefined
3435
);
3536
$createOrganization.billingAddressId = response.$id;
37+
trackEvent(Submit.BillingAddressCreate);
3638
} catch (error) {
39+
trackError(error, Submit.BillingAddressCreate);
3740
throw new Error(error.message);
3841
}
3942
}

0 commit comments

Comments
 (0)