Fix the visit tracking logic

This commit is contained in:
Kane York 2015-09-15 12:25:12 -07:00
parent 8b37dadec7
commit 62444b9a13

View File

@ -73,13 +73,17 @@ export default {
// Record a visit
const nowVisit = new Date().getTime();
const lastVisit = keyValueStore.getInt('anon-last-visit', nowVisit);
if (nowVisit - lastVisit > ONE_DAY) {
// more than a day
const lastVisit = keyValueStore.getInt('anon-last-visit', 0);
if (!lastVisit) {
// First visit
keyValueStore.setItem('anon-visit-count', 1);
keyValueStore.setItem('anon-last-visit', nowVisit);
} else if (nowVisit - lastVisit > ONE_DAY) {
// More than a day
const visitCount = keyValueStore.getInt('anon-visit-count', 1);
keyValueStore.setItem('anon-visit-count', visitCount + 1);
keyValueStore.setItem('anon-last-visit', nowVisit);
}
keyValueStore.setItem('anon-last-visit', nowVisit);
checkSignupCtaRequirements();
}