mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Track specific items dropped by Armoire (#10977)
* feat(analytics): track specific items dropped by Armoire * fix(lint): remove console log * fix(analytics): address test failures * fix(analytics): add missed if block * fix(analytics): seriously tho actually fix
This commit is contained in:
committed by
Matteo Pagliazzi
parent
b9aaccdf13
commit
4d1b239231
@@ -158,7 +158,7 @@ describe('shared.ops.buyArmoire', () => {
|
||||
|
||||
expect(armoireCount).to.eql(_.size(getFullArmoire()) - 2);
|
||||
expect(user.stats.gp).to.eql(100);
|
||||
expect(analytics.track).to.be.calledOnce;
|
||||
expect(analytics.track).to.be.calledTwice;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -68,6 +68,19 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
];
|
||||
}
|
||||
|
||||
_trackDropAnalytics (userId, key) {
|
||||
this.analytics.track(
|
||||
'dropped item',
|
||||
{
|
||||
uuid: userId,
|
||||
itemKey: key,
|
||||
acquireMethod: 'Armoire',
|
||||
category: 'behavior',
|
||||
headers: this.req.headers,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_gearResult (user, eligibleEquipment) {
|
||||
eligibleEquipment.sort();
|
||||
let drop = randomVal(eligibleEquipment);
|
||||
@@ -89,6 +102,10 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
|
||||
removeItemByPath(user, `gear.flat.${drop.key}`);
|
||||
|
||||
if (this.analytics) {
|
||||
this._trackDropAnalytics(user._id, drop.key);
|
||||
}
|
||||
|
||||
let armoireResp = {
|
||||
type: 'gear',
|
||||
dropKey: drop.key,
|
||||
@@ -109,6 +126,10 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
user.items.food[drop.key] = user.items.food[drop.key] || 0;
|
||||
user.items.food[drop.key] += 1;
|
||||
|
||||
if (this.analytics) {
|
||||
this._trackDropAnalytics(user._id, drop.key);
|
||||
}
|
||||
|
||||
return {
|
||||
message: this.i18n('armoireFood', {
|
||||
image: `<span class="Pet_Food_${drop.key} pull-left"></span>`,
|
||||
|
||||
Reference in New Issue
Block a user