mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Added analytics to drop (#9792)
* Added analytics to drop * Updated tracking category
This commit is contained in:
@@ -25,7 +25,7 @@ function trueRandom () {
|
||||
return Math.random();
|
||||
}
|
||||
|
||||
module.exports = function randomDrop (user, options, req = {}) {
|
||||
module.exports = function randomDrop (user, options, req = {}, analytics) {
|
||||
let acceptableDrops;
|
||||
let drop;
|
||||
let dropMultiplier;
|
||||
@@ -112,6 +112,16 @@ module.exports = function randomDrop (user, options, req = {}) {
|
||||
}, req.language);
|
||||
}
|
||||
|
||||
if (analytics) {
|
||||
analytics.track('dropped item', {
|
||||
uuid: user._id,
|
||||
itemKey: drop.key,
|
||||
acquireMethod: 'Drop',
|
||||
category: 'behavior',
|
||||
headers: req.headers,
|
||||
});
|
||||
}
|
||||
|
||||
user._tmp.drop = drop;
|
||||
user.items.lastDrop.date = Number(new Date());
|
||||
user.items.lastDrop.count++;
|
||||
|
||||
@@ -584,7 +584,7 @@ api.scoreTask = {
|
||||
|
||||
let [delta] = common.ops.scoreTask({task, user, direction}, req);
|
||||
// Drop system (don't run on the client, as it would only be discarded since ops are sent to the API, not the results)
|
||||
if (direction === 'up') user.fns.randomDrop({task, delta}, req);
|
||||
if (direction === 'up') user.fns.randomDrop({task, delta}, req, res.analytics);
|
||||
|
||||
// If a todo was completed or uncompleted move it in or out of the user.tasksOrder.todos list
|
||||
// TODO move to common code?
|
||||
|
||||
Reference in New Issue
Block a user