Skip to content

Commit

Permalink
Merge pull request #5092 from kiva/update-donation-nudge-events-MARS-527
Browse files Browse the repository at this point in the history
feat: update events when user clicks No donation and enters 0 dollars …
  • Loading branch information
christian14b authored Dec 7, 2023
2 parents 678f197 + 368c8d8 commit fa50c50
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/Checkout/DonationNudge/DonationNudgeLightbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -187,17 +188,19 @@ export default {
methods: {
setDonationAndClose(amount, source) {
const zeroUpsellCookie = this.cookieStore.get('zero_upsell_visible') || true;
if (amount === 0) {
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);
}
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();
}
},
Expand Down

0 comments on commit fa50c50

Please sign in to comment.