mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 07:52:15 +00: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:
parent
b9aaccdf13
commit
4d1b239231
2 changed files with 22 additions and 1 deletions
|
|
@ -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>`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue