FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update JTBD ids · devhttps/frontend@e8cd030 · GitHub

Commit e8cd030

Browse files
Regis Kuckaertz
committed
Update JTBD ids
1 parent a8da604 commit e8cd030

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

‎static/src/javascripts/projects/journalism/jtbd-survey.js‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ type Campaign = {
1919
fields: CampaignFields,
2020
};
2121

22-
// campaign settings: most of it will come from the targeting tool
2322
const campaignId: string = 'test-survey';
24-
// survey starts on Aug 23, 2017
25-
const startOfSurvey: Date = new Date('2017-08-23');
26-
const endOfSurvey: number = startOfSurvey.setMonth(
27-
startOfSurvey.getMonth() + 1
28-
);
2923

3024
/* Generate a [from .. to[ range */
3125
const range = (from: number, to: number): number[] => {
@@ -76,14 +70,14 @@ const save = (
7670
as: Answer[],
7771
q: Question,
7872
answer: Answer,
79-
why: ?string
73+
why?: string
8074
) => {
8175
const hasSnippet: boolean = !!document.getElementsByClassName(
8276
'explainer-snippet'
8377
).length;
8478

8579
as[q] = answer;
86-
localStorage.set('gu.jtbd.answers', as, { expires: endOfSurvey });
80+
localStorage.set('gu.jtbd-updated.answers', as);
8781

8882
submitComponentEvent(
8983
'VOTE',
@@ -109,7 +103,7 @@ const shouldIGo = (): boolean => {
109103
// on a 1.5% sample of PVs
110104
rand < 1.5 &&
111105
// if the user hasn't already seen the survey
112-
sessionStorage.get('gu.jtbd.seen') !== true
106+
sessionStorage.get('gu.jtbd-updated.seen') !== true
113107
);
114108
};
115109

@@ -125,11 +119,11 @@ const init = (): void => {
125119
return;
126120
}
127121

128-
sessionStorage.set('gu.jtbd.seen', true);
122+
sessionStorage.set('gu.jtbd-updated.seen', true);
129123

130124
const allQuestions = campaign.fields.questions;
131-
const qs = localStorage.get('gu.jtbd.questions') || draw(allQuestions);
132-
const as = localStorage.get('gu.jtbd.answers') || qs.map(() => -1);
125+
const qs = localStorage.get('gu.jtbd-updated.questions') || draw(allQuestions);
126+
const as = localStorage.get('gu.jtbd-updated.answers') || qs.map(() => -1);
133127
const q = selectQuestion(qs, as);
134128

135129
if (q === -1) {
@@ -139,9 +133,7 @@ const init = (): void => {
139133

140134
mediator.emit('journalism:modules:jtbd', true);
141135

142-
localStorage.setIfNotExists('gu.jtbd.questions', qs, {
143-
expires: endOfSurvey,
144-
});
136+
localStorage.setIfNotExists('gu.jtbd-updated.questions', qs);
145137

146138
initSurvey(allQuestions[qs[q]].question, allQuestions[qs[q]].askWhy)
147139
.then(({ answer, why }) => save(qs, as, q, answer, why))

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL