diff --git a/test/server_side/analytics.test.js b/test/server_side/analytics.test.js index 059414be23..7bdc7c88a1 100644 --- a/test/server_side/analytics.test.js +++ b/test/server_side/analytics.test.js @@ -222,7 +222,11 @@ describe('analytics', function() { stats: stats, contributor: { level: 1 }, purchased: { plan: { planId: 'foo-plan' } }, - flags: {tour: {intro: -2}} + flags: {tour: {intro: -2}}, + habits: [{_id: 'habit'}], + dailys: [{_id: 'daily'}], + todos: [{_id: 'todo'}], + rewards: [{_id: 'reward'}] }; analyticsData.user = user; @@ -248,7 +252,13 @@ describe('analytics', function() { Mana: 30, contributorLevel: 1, subscription: 'foo-plan', - tutorialComplete: true + tutorialComplete: true, + numberOfTasks: { + todos: 1, + dailys: 1, + habits: 1, + rewards: 1 + } } }); }); diff --git a/test/spec/services/analyticsServicesSpec.js b/test/spec/services/analyticsServicesSpec.js index ca726e37ec..939de37a00 100644 --- a/test/spec/services/analyticsServicesSpec.js +++ b/test/spec/services/analyticsServicesSpec.js @@ -221,7 +221,13 @@ describe('Analytics Service', function () { Mana: 41, contributorLevel: 1, subscription: 'unique-plan-id', - tutorialComplete: true + tutorialComplete: true, + numberOfTasks: { + todos: 1, + dailys: 1, + habits: 1, + rewards: 1 + } }; beforeEach(function() { @@ -235,6 +241,10 @@ describe('Analytics Service', function () { user.contributor.level = 1; user.purchased.plan.planId = 'unique-plan-id'; user.flags.tour.intro = -2; + user.habits = [{_id: 'habit'}]; + user.dailys = [{_id: 'daily'}]; + user.todos = [{_id: 'todo'}]; + user.rewards = [{_id: 'reward'}]; analytics.updateUser(); clock.tick(); diff --git a/website/public/js/services/analyticsServices.js b/website/public/js/services/analyticsServices.js index 135e7a205d..72f5a111f4 100644 --- a/website/public/js/services/analyticsServices.js +++ b/website/public/js/services/analyticsServices.js @@ -108,6 +108,12 @@ properties.Mana = Math.floor(user.stats.mp); } properties.tutorialComplete = user.flags && user.flags.tour && user.flags.tour.intro === -2; + properties.numberOfTasks = { + habits: user.habits.length, + dailys: user.dailys.length, + todos: user.todos.length, + rewards: user.rewards.length + }; if (user.contributor && user.contributor.level) properties.contributorLevel = user.contributor.level; if (user.purchased && user.purchased.plan.planId) properties.subscription = user.purchased.plan.planId; } diff --git a/website/src/analytics.js b/website/src/analytics.js index ad35adb9e7..20de935126 100644 --- a/website/src/analytics.js +++ b/website/src/analytics.js @@ -153,6 +153,12 @@ function _formatUserData(user) { } properties.tutorialComplete = user.flags && user.flags.tour && user.flags.tour.intro === -2; + properties.numberOfTasks = { + habits: user.habits.length, + dailys: user.dailys.length, + todos: user.todos.length, + rewards: user.rewards.length + }; if (user.contributor && user.contributor.level) { properties.contributorLevel = user.contributor.level;