From 6406b55520b8b1e27b60ece31b70679b6577904e Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Tue, 1 Oct 2024 19:48:03 +0530 Subject: [PATCH 1/3] update: hide all alerts on cancel. --- src/lib/components/bottomModalAlert.svelte | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lib/components/bottomModalAlert.svelte b/src/lib/components/bottomModalAlert.svelte index ec070db93..a6c398d8e 100644 --- a/src/lib/components/bottomModalAlert.svelte +++ b/src/lib/components/bottomModalAlert.svelte @@ -50,16 +50,12 @@ $: currentModalAlert = filteredModalAlerts[currentIndex] as BottomModalAlertItem; function handleClose() { - const modalAlert = currentModalAlert; - dismissBottomModalAlert(modalAlert.id); - hideNotification(modalAlert.id, { coolOffPeriod: 24 * 365 }); - if (modalAlert.closed) modalAlert.closed(); - - if (currentIndex === filteredModalAlerts.length - 1 && filteredModalAlerts.length > 1) { - currentIndex = currentIndex - 1; - } else { - currentIndex = currentIndex % filteredModalAlerts.length; - } + filteredModalAlerts.forEach((alert) => { + const modalAlert = alert; + dismissBottomModalAlert(modalAlert.id); + hideNotification(modalAlert.id, { coolOffPeriod: 24 * 365 }); + if (modalAlert.closed) modalAlert.closed(); + }); } function showNext() { From 619c0241d254b6552178ea64b98cc402daa2addf Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Tue, 1 Oct 2024 20:59:12 +0530 Subject: [PATCH 2/3] add: trackEvents for promo modals. --- src/lib/components/bottomModalAlert.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/components/bottomModalAlert.svelte b/src/lib/components/bottomModalAlert.svelte index a6c398d8e..9594731a1 100644 --- a/src/lib/components/bottomModalAlert.svelte +++ b/src/lib/components/bottomModalAlert.svelte @@ -15,10 +15,13 @@ import { addBottomModalAlerts } from '$routes/(console)/bottomAlerts'; import { project } from '$routes/(console)/project-[project]/store'; import { page } from '$app/stores'; + import { trackEvent } from '$lib/actions/analytics'; let currentIndex = 0; let openModalOnMobile = false; + const promoId = (alertId: string) => alertId.replace(/(banner:|modal:)/g, ''); + function getPageScope(pathname: string) { const isProjectPage = pathname.includes('project-[project]'); const isOrganizationPage = pathname.includes('organization-[organization]'); @@ -167,7 +170,13 @@ project: $project })} external={!!currentModalAlert.cta.external} - fullWidthMobile> + fullWidthMobile + on:click={() => { + trackEvent('click_promo', { + promo: promoId(currentModalAlert.id), + type: shouldShowUpgrade ? 'upgrade' : 'try_now' + }); + }}> {currentModalAlert.cta.text} From c85c3b0a413bad136e54263264eb36c61ca1f3f4 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Wed, 2 Oct 2024 16:21:22 +0530 Subject: [PATCH 3/3] address comments. --- src/lib/components/bottomModalAlert.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/components/bottomModalAlert.svelte b/src/lib/components/bottomModalAlert.svelte index 9594731a1..03ace8873 100644 --- a/src/lib/components/bottomModalAlert.svelte +++ b/src/lib/components/bottomModalAlert.svelte @@ -20,8 +20,6 @@ let currentIndex = 0; let openModalOnMobile = false; - const promoId = (alertId: string) => alertId.replace(/(banner:|modal:)/g, ''); - function getPageScope(pathname: string) { const isProjectPage = pathname.includes('project-[project]'); const isOrganizationPage = pathname.includes('organization-[organization]'); @@ -173,7 +171,7 @@ fullWidthMobile on:click={() => { trackEvent('click_promo', { - promo: promoId(currentModalAlert.id), + promo: currentModalAlert.id, type: shouldShowUpgrade ? 'upgrade' : 'try_now' }); }}> @@ -282,7 +280,13 @@ })} external={!!currentModalAlert.cta.external} fullWidthMobile - on:click={() => (openModalOnMobile = false)}> + on:click={() => { + openModalOnMobile = false; + trackEvent('click_promo', { + promo: currentModalAlert.id, + type: shouldShowUpgrade ? 'upgrade' : 'try_now' + }); + }}> {shouldShowUpgrade ? 'Upgrade plan' : currentModalAlert.cta.text}