mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
committed by
Blade Barringer
parent
e3c40aa142
commit
679378331d
@@ -154,6 +154,7 @@ api.registerLocal = {
|
||||
type: 'local',
|
||||
gaLabel: 'local',
|
||||
uuid: savedUser._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -213,6 +214,15 @@ api.loginLocal = {
|
||||
let user = await User.findOne(login, {auth: 1, apiToken: 1}).exec();
|
||||
let isValidPassword = user && user.auth.local.hashed_password === passwordUtils.encrypt(req.body.password, user.auth.local.salt);
|
||||
if (!isValidPassword) throw new NotAuthorized(res.t('invalidLoginCredentialsLong'));
|
||||
|
||||
res.analytics.track('login', {
|
||||
category: 'behaviour',
|
||||
type: 'local',
|
||||
gaLabel: 'local',
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
return _loginRes(user, ...arguments);
|
||||
},
|
||||
};
|
||||
@@ -277,6 +287,7 @@ api.loginSocial = {
|
||||
type: network,
|
||||
gaLabel: network,
|
||||
uuid: savedUser._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
return null;
|
||||
|
||||
@@ -66,6 +66,23 @@ api.createGroup = {
|
||||
_id: user._id,
|
||||
profile: {name: user.profile.name},
|
||||
};
|
||||
|
||||
let analyticsObject = {
|
||||
uuid: user._id,
|
||||
hitType: 'event',
|
||||
category: 'behavior',
|
||||
owner: true,
|
||||
groupType: savedGroup.type,
|
||||
privacy: savedGroup.privacy,
|
||||
headers: req.headers,
|
||||
};
|
||||
|
||||
if (savedGroup.privacy === 'public') {
|
||||
analyticsObject.groupName = savedGroup.name;
|
||||
}
|
||||
|
||||
res.analytics.track('join group', analyticsObject);
|
||||
|
||||
res.respond(201, response); // do not remove chat flags data as we've just created the group
|
||||
},
|
||||
};
|
||||
@@ -276,6 +293,23 @@ api.joinGroup = {
|
||||
if (leader) {
|
||||
response.leader = leader.toJSON({minimize: true});
|
||||
}
|
||||
|
||||
let analyticsObject = {
|
||||
uuid: user._id,
|
||||
hitType: 'event',
|
||||
category: 'behavior',
|
||||
owner: false,
|
||||
groupType: group.type,
|
||||
privacy: group.privacy,
|
||||
headers: req.headers,
|
||||
};
|
||||
|
||||
if (group.privacy === 'public') {
|
||||
analyticsObject.groupName = group.name;
|
||||
}
|
||||
|
||||
res.analytics.track('join group', analyticsObject);
|
||||
|
||||
res.respond(200, response);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -135,6 +135,7 @@ api.inviteToQuest = {
|
||||
gaLabel: 'accept',
|
||||
questName: questKey,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -191,6 +192,7 @@ api.acceptQuest = {
|
||||
gaLabel: 'accept',
|
||||
questName: group.quest.key,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -247,6 +249,7 @@ api.rejectQuest = {
|
||||
gaLabel: 'reject',
|
||||
questName: group.quest.key,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -300,6 +303,7 @@ api.forceStart = {
|
||||
gaLabel: 'force-start',
|
||||
questName: group.quest.key,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -451,6 +451,17 @@ api.scoreTask = {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: enable score task analytics if desired
|
||||
res.analytics.track('score task', {
|
||||
uuid: user._id,
|
||||
hitType: 'event',
|
||||
category: 'behavior',
|
||||
taskType: task.type,
|
||||
direction
|
||||
});
|
||||
*/
|
||||
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user