Skip to content

Commit

Permalink
feat: set experiment version in cookie to be read on server
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bedon committed May 23, 2024
1 parent 5aa73f5 commit 262a861
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/auth-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ module.exports = function authRouter(config = {}) {
options.partnerContentId = req.query.partnerContentId;
}

// Opt-In Communication Exp MP-271
if (cookies.opt_in_comms) {
options.optInComms = 'b';
}

info(`LoginUI: attempt login, session id:${req.sessionID}, cookie:${getSyncCookie(req)}, done url:${req.query.doneUrl}`); // eslint-disable-line max-len
passport.authenticate('auth0', options)(req, res, next);
});
Expand Down
13 changes: 13 additions & 0 deletions src/components/WwwFrame/TheHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ import _throttle from 'lodash/throttle';
import numeral from 'numeral';
import TeamsMenu from '@/components/WwwFrame/Header/TeamsMenu';
import { readBoolSetting } from '@/util/settingsUtils';
import experimentVersionFragment from '@/graphql/fragments/experimentVersion.graphql';
import KvButton from '~/@kiva/kv-components/vue/KvButton';
import KvMaterialIcon from '~/@kiva/kv-components/vue/KvMaterialIcon';
import KvPageContainer from '~/@kiva/kv-components/vue/KvPageContainer';
Expand All @@ -587,6 +588,7 @@ import PromoCreditBanner from './PromotionalBanner/Banners/PromoCreditBanner';
const hasLentBeforeCookie = 'kvu_lb';
const hasDepositBeforeCookie = 'kvu_db';
const COMMS_OPT_IN_EXP_KEY = 'opt_in_comms';
const optimizelyUserDataQuery = gql`query optimizelyUserDataQuery {
my {
Expand Down Expand Up @@ -798,6 +800,17 @@ export default {
}
}
if (this.cookieStore.get(COMMS_OPT_IN_EXP_KEY) !== 'true') {
const { version } = this.apollo.readFragment({
id: `Experiment:${COMMS_OPT_IN_EXP_KEY}`,
fragment: experimentVersionFragment,
}) ?? {};
if (version === 'b') {
this.cookieStore.set(COMMS_OPT_IN_EXP_KEY, true, { path: '/' });
}
}
userHasLentBefore(this.cookieStore.get(hasLentBeforeCookie) === 'true');
userHasDepositBefore(this.cookieStore.get(hasLentBeforeCookie) === 'true');
},
Expand Down

0 comments on commit 262a861

Please sign in to comment.