Skip to content

Commit

Permalink
feat: get iwd experiment data to evaluate whether redirect to the cha…
Browse files Browse the repository at this point in the history
…llenge ty page or the regular
  • Loading branch information
Christian Bedon committed Feb 9, 2024
1 parent 6c6af72 commit 32099ca
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/graphql/query/checkout/initializeCheckout.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ query initializeCheckout($basketId: String) {
... on LoanPartner {
sponsor_name: partnerName
}
gender
}
team {
id
Expand Down
38 changes: 25 additions & 13 deletions src/pages/Checkout/CheckoutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ import { isLoanFundraising } from '@/util/loanUtils';
import MatchedLoansLightbox from '@/components/Checkout/MatchedLoansLightbox';
import experimentAssignmentQuery from '@/graphql/query/experimentAssignment.graphql';
import fiveDollarsTest, { FIVE_DOLLARS_NOTES_EXP } from '@/plugins/five-dollars-test-mixin';
import iwdExperimentMixin from '@/plugins/iwd-experiment-mixin';
import FtdsMessage from '@/components/Checkout/FtdsMessage';
import FtdsDisclaimer from '@/components/Checkout/FtdsDisclaimer';
import { removeLoansFromChallengeCookie } from '@/util/teamChallengeUtils';
Expand Down Expand Up @@ -374,7 +375,7 @@ export default {
FtdsDisclaimer,
},
inject: ['apollo', 'cookieStore', 'kvAuth0'],
mixins: [checkoutUtils, fiveDollarsTest],
mixins: [checkoutUtils, fiveDollarsTest, iwdExperimentMixin],
metaInfo: {
title: 'Checkout'
},
Expand Down Expand Up @@ -422,7 +423,8 @@ export default {
lenderTotalLoans: 0,
isFtdMessageEnable: false,
ftdCreditAmount: '',
ftdValidDate: ''
ftdValidDate: '',
iwdExpEnabled: false
};
},
apollo: {
Expand Down Expand Up @@ -582,6 +584,8 @@ export default {
this.matchedText = matchedLoansWithCredit[0]?.loan?.matchingText ?? '';
this.initializeFiveDollarsNotes();
this.iwdExpEnabled = this.isIwdExperimentEnabled();
},
mounted() {
// update current time every second for reactivity
Expand Down Expand Up @@ -609,16 +613,21 @@ export default {
this.getPromoInformationFromBasket();
this.getUpsellModuleData();
// Fetch Challenge Status
// If a loan in basket makes progress towards an active challenge,
// set query param to redirect to special thank you page
achievementsQuery(this.apollo, this.loanIdsInBasket)
.then(({ data }) => {
const checkoutMilestoneProgresses = data?.achievementMilestonesForCheckout?.checkoutMilestoneProgresses;
const challengeProgressed = achievementProgression(checkoutMilestoneProgresses);
this.challengeRedirectQueryParam = challengeProgressed ? `&challenge=${challengeProgressed}` : '';
});
// end challenge code
// Don't fetch challenge status if IWD2024 experiment is enabled
// to avoid being redirected to the challenge thank you page
if (!this.iwdExpEnabled) {
// Fetch Challenge Status
// If a loan in basket makes progress towards an active challenge,
// set query param to redirect to special thank you page
achievementsQuery(this.apollo, this.loanIdsInBasket)
.then(({ data }) => {
// eslint-disable-next-line max-len
const checkoutMilestoneProgresses = data?.achievementMilestonesForCheckout?.checkoutMilestoneProgresses;
const challengeProgressed = achievementProgression(checkoutMilestoneProgresses);
this.challengeRedirectQueryParam = challengeProgressed ? `&challenge=${challengeProgressed}` : '';
});
// end challenge code
}
},
computed: {
isUpsellUnder100() {
Expand Down Expand Up @@ -738,7 +747,10 @@ export default {
},
showFtdMessage() {
return !this.lenderTotalLoans && this.enableFtdMessage && this.ftdCreditAmount && this.ftdValidDate;
}
},
iwdLoan() {
return (this.loans?.filter(l => l?.loan?.gender?.toUpperCase() === 'FEMALE') ?? [])?.[0];
},
},
methods: {
openMatchedLoansLightbox() {
Expand Down
10 changes: 3 additions & 7 deletions src/pages/Thanks/ThanksPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import { joinArray } from '@/util/joinArray';
import NotifyMe from '@/components/Thanks/NotifyMe';
import experimentVersionFragment from '@/graphql/fragments/experimentVersion.graphql';

Check failure on line 135 in src/pages/Thanks/ThanksPage.vue

View workflow job for this annotation

GitHub Actions / build

'experimentVersionFragment' is defined but never used
import IwdThanksPageVariations, { KIVA_INVITER_ID } from '@/components/Iwd/IwdThanksPageVariations';
import iwdExperimentMixin from '@/plugins/iwd-experiment-mixin';
import KvButton from '~/@kiva/kv-components/vue/KvButton';
import { fetchGoals } from '../../util/teamsUtil';
import teamsGoalsQuery from '../../graphql/query/teamsGoals.graphql';
Expand Down Expand Up @@ -178,6 +179,7 @@ export default {
IwdThanksPageVariations,
},
inject: ['apollo', 'cookieStore'],
mixins: [iwdExperimentMixin],
metaInfo() {
return {
title: 'Thank you!'
Expand Down Expand Up @@ -474,14 +476,8 @@ export default {
}
},
checkForIWD2024Experiment() {
const iwdHeaderExp = this.apollo.readFragment({
id: 'Experiment:iwd_header_2024',
fragment: experimentVersionFragment,
}) || {};
// Only show IWD content and track experiment if: 1) experiment enabled, and 2) "women" loan checked out
const EXPERIMENT_ENABLED_VERSION = 'b';
const womenLoanIncluded = !!this.iwdLoan;
this.iwdHeaderExpEnabled = iwdHeaderExp.version === EXPERIMENT_ENABLED_VERSION && womenLoanIncluded;
this.iwdHeaderExpEnabled = this.isIwdExperimentEnabled();
if (this.iwdHeaderExpEnabled) {
this.getIwdInviter();
this.$kvTrackEvent('Lending', 'EXP-IWDHeader2024', EXPERIMENT_ENABLED_VERSION);
Expand Down
22 changes: 22 additions & 0 deletions src/plugins/iwd-experiment-mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import experimentVersionFragment from '@/graphql/fragments/experimentVersion.graphql';
import checkInjections from '@/util/injectionCheck';

const injections = ['apollo'];

export default {
methods: {
isIwdExperimentEnabled() {
checkInjections(this, injections);

const iwdExperiment = this.apollo.readFragment({
id: 'Experiment:IWD2024',
fragment: experimentVersionFragment,
}) || {};
// Only show IWD content and track experiment if: 1) experiment enabled, and 2) "women" loan checked out
const EXPERIMENT_ENABLED_VERSION = 'b';
const womenLoanIncluded = !!this.iwdLoan;

return iwdExperiment.version === EXPERIMENT_ENABLED_VERSION && womenLoanIncluded;
},
}
};

0 comments on commit 32099ca

Please sign in to comment.