From 1b9f6d9b4f27dca05fbd53d7bc69e180a9113c1a Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Tue, 5 Dec 2023 10:09:35 -0500 Subject: [PATCH 1/2] feat: update events when user clicks No donation and enters /bin/zsh in the custom amount box --- .../DonationNudge/DonationNudgeLightbox.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue b/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue index 8902715193..b348d90e7b 100644 --- a/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue +++ b/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue @@ -187,17 +187,20 @@ export default { methods: { setDonationAndClose(amount, source) { const zeroUpsellCookie = this.cookieStore.get('zero_upsell_visible') || true; + if (amount === 0) { + const expires = new Date(); + expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000)); + this.cookieStore.set('zero_upsell_visible', false, { expires }); + this.$kvTrackEvent('basket', 'click', `Update Nudge Donation - ${source}`, amount * 100); + } if (amount === 0 && !this.zeroUpsellVisible && zeroUpsellCookie !== 'false') { this.zeroUpsellVisible = true; } else { - if (amount === 0) { - const expires = new Date(); - expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000)); - this.cookieStore.set('zero_upsell_visible', false, { expires }); + if (amount > 0) { + const clickSource = source ? ` - ${source}` : ''; + this.$kvTrackEvent('basket', 'Update Nudge Donation', `Update Success${clickSource}`, amount * 100); } - const clickSource = source ? ` - ${source}` : ''; this.updateDonationTo(amount); - this.$kvTrackEvent('basket', 'Update Nudge Donation', `Update Success${clickSource}`, amount * 100); this.closeNudgeLightbox(); } }, From 368c8d8abae48026a7b7b8806e9d3ad6a2c2ede9 Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Tue, 5 Dec 2023 16:55:50 -0500 Subject: [PATCH 2/2] refactor: more comprehensible zero_upsell expire calculation --- .../Checkout/DonationNudge/DonationNudgeLightbox.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue b/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue index b348d90e7b..16109007ab 100644 --- a/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue +++ b/src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue @@ -99,6 +99,7 @@ import HeartIcon from '@/assets/icons/inline/heart-icon.svg'; import HowKivaUsesDonation from '@/components/Checkout/HowKivaUsesDonation'; import { gql } from '@apollo/client'; import { readBoolSetting } from '@/util/settingsUtils'; +import { add } from 'date-fns'; import KvButton from '~/@kiva/kv-components/vue/KvButton'; import KvLightbox from '~/@kiva/kv-components/vue/KvLightbox'; import KvMaterialIcon from '~/@kiva/kv-components/vue/KvMaterialIcon'; @@ -188,8 +189,7 @@ export default { setDonationAndClose(amount, source) { const zeroUpsellCookie = this.cookieStore.get('zero_upsell_visible') || true; if (amount === 0) { - const expires = new Date(); - expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000)); + const expires = add(new Date(), { days: 1 }); this.cookieStore.set('zero_upsell_visible', false, { expires }); this.$kvTrackEvent('basket', 'click', `Update Nudge Donation - ${source}`, amount * 100); }