Added analytics to drop (#9792)

* Added analytics to drop

* Updated tracking category
This commit is contained in:
Keith Holliday
2018-01-22 09:15:23 -07:00
committed by GitHub
parent 38aafb6c7b
commit 90ffe587dd
2 changed files with 12 additions and 2 deletions

View File

@@ -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++;