diff --git a/src/components/Billing/UpdatePlanConfirmation.tsx b/src/components/Billing/UpdatePlanConfirmation.tsx
index 78cc041de..c14952f04 100644
--- a/src/components/Billing/UpdatePlanConfirmation.tsx
+++ b/src/components/Billing/UpdatePlanConfirmation.tsx
@@ -62,8 +62,8 @@ export function UpdatePlanConfirmation(props: UpdatePlanConfirmationProps) {
Subscription Update
Your plan will be updated to the{' '}
- {planDetails.interval} plan, and will
- be charged{' '}
+ {planDetails.interval} plan, and will be
+ charged{' '}
${selectedPrice.amount}/{selectedPrice.interval}
@@ -72,21 +72,21 @@ export function UpdatePlanConfirmation(props: UpdatePlanConfirmationProps) {
diff --git a/src/components/Billing/UpgradeAccountModal.tsx b/src/components/Billing/UpgradeAccountModal.tsx
index b187b7ab3..99cb73ed8 100644
--- a/src/components/Billing/UpgradeAccountModal.tsx
+++ b/src/components/Billing/UpgradeAccountModal.tsx
@@ -136,6 +136,14 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
setSelectedPlan(currentPlan.interval);
}, [currentPlan]);
+ useEffect(() => {
+ window?.fireEvent({
+ action: 'tutor_pricing',
+ category: 'ai_tutor',
+ label: 'Clicked Upgrade to Pro',
+ });
+ }, []);
+
if (!user) {
return null;
}
@@ -262,18 +270,35 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
}
onClick={() => {
setSelectedPlan(plan.interval);
+
if (!currentPlanPriceId) {
const currentUrlPath = window.location.pathname;
- const encodedCurrentUrlPath = encodeURIComponent(
- currentUrlPath,
- );
+ const encodedCurrentUrlPath =
+ encodeURIComponent(currentUrlPath);
const successPage = `/thank-you?next=${encodedCurrentUrlPath}&s=1`;
- createCheckoutSession({
- priceId: plan.priceId,
- success: success || successPage,
- cancel: cancel || `${currentUrlPath}?s=0`,
+ window?.fireEvent({
+ action: 'tutor_checkout',
+ category: 'ai_tutor',
+ label: 'Checkout Started',
});
+
+ createCheckoutSession(
+ {
+ priceId: plan.priceId,
+ success: success || successPage,
+ cancel: cancel || `${currentUrlPath}?s=0`,
+ },
+ {
+ onSuccess: () => {
+ window?.fireEvent({
+ action: `tutor_checkout_${plan.interval === 'month' ? 'mo' : 'an'}`,
+ category: 'ai_tutor',
+ label: `${plan.interval} Plan Checkout Started`,
+ });
+ },
+ },
+ );
return;
}
setIsUpdatingPlan(true);
diff --git a/src/components/Billing/VerifyUpgrade.tsx b/src/components/Billing/VerifyUpgrade.tsx
index f59105fd0..85b0142ab 100644
--- a/src/components/Billing/VerifyUpgrade.tsx
+++ b/src/components/Billing/VerifyUpgrade.tsx
@@ -30,11 +30,40 @@ export function VerifyUpgrade(props: VerifyUpgradeProps) {
userBillingDetails.status === 'active' &&
(newPriceId ? userBillingDetails.priceId === newPriceId : true)
) {
+ if (!newPriceId) {
+ // it means that the user is subscribing for the first time
+ // not changing the plan
+ window?.fireEvent({
+ action: `tutor_purchase_${userBillingDetails.interval === 'month' ? 'mo' : 'an'}`,
+ category: 'ai_tutor',
+ label: `${userBillingDetails.interval} Plan Purchased`,
+ });
+ }
+
deleteUrlParam('s');
window.location.reload();
}
}, [userBillingDetails]);
+ useEffect(() => {
+ // it means that the user is changing the plan
+ // not subscribing for the first time
+ if (newPriceId) {
+ return;
+ }
+
+ window?.fireEvent({
+ action: 'tutor_purchase',
+ category: 'ai_tutor',
+ label: 'Subscription Activated',
+ });
+ window?.fireEvent({
+ action: 'tutor_ty',
+ category: 'ai_tutor',
+ label: 'Thank You Page Visited',
+ });
+ }, [newPriceId]);
+
return (
Subscription Activated
-
+
Your subscription has been activated successfully.
-
+
It might take a minute for the changes to reflect. We will{' '}
reload the page for you.