From f6bbae3bebe165409d311c3002e4c7891ff70756 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 27 Jul 2015 15:13:59 -0500 Subject: [PATCH] fix(analytics): Bad comparison Corrects an error caught via test, where the check for intro tour completion would always fail. Also tweaks the updateUser behavior to save an explicit false if tour completion data is not found, including a test for that behavior. --- test/spec/services/analyticsServicesSpec.js | 2 ++ test/spec/services/groupServicesSpec.js | 2 +- website/public/js/services/analyticsServices.js | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/spec/services/analyticsServicesSpec.js b/test/spec/services/analyticsServicesSpec.js index 55071b5679..ca726e37ec 100644 --- a/test/spec/services/analyticsServicesSpec.js +++ b/test/spec/services/analyticsServicesSpec.js @@ -183,6 +183,7 @@ describe('Analytics Service', function () { expectedProperties.Health = 48; expectedProperties.Level = 24; expectedProperties.Mana = 41; + expectedProperties.tutorialComplete = false; beforeEach(function() { user._id = 'unique-user-id'; @@ -192,6 +193,7 @@ describe('Analytics Service', function () { user.stats.hp = 47.8; user.stats.lvl = 24; user.stats.mp = 41; + user.flags.tour.intro = 3; analytics.updateUser(properties); clock.tick(); diff --git a/test/spec/services/groupServicesSpec.js b/test/spec/services/groupServicesSpec.js index f0bfb3a538..0a4534c0c6 100644 --- a/test/spec/services/groupServicesSpec.js +++ b/test/spec/services/groupServicesSpec.js @@ -5,7 +5,7 @@ describe('groupServices', function() { beforeEach(function() { module(function($provide) { - $provide.value('User', {}); + $provide.value('User', {user:user}); }); inject(function(_$httpBackend_, Groups, User) { diff --git a/website/public/js/services/analyticsServices.js b/website/public/js/services/analyticsServices.js index a7016df866..244aec529a 100644 --- a/website/public/js/services/analyticsServices.js +++ b/website/public/js/services/analyticsServices.js @@ -107,7 +107,8 @@ properties.Level = user.stats.lvl; properties.Mana = Math.floor(user.stats.mp); } - if (user.flags.tour && user.flags.tour.intro === '-2') properties.tutorialComplete = true; + if (user.flags && user.flags.tour && user.flags.tour.intro === -2) {properties.tutorialComplete = true} + else {properties.tutorialComplete = false}; if (user.contributor && user.contributor.level) properties.contributorLevel = user.contributor.level; if (user.purchased && user.purchased.plan.planId) properties.subscription = user.purchased.plan.planId; }