mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Add task numbers to analytics
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user