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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -212,6 +212,7 @@ api.subscribe = {
|
||||
customerId: billingAgreementId,
|
||||
paymentMethod: 'Amazon Payments',
|
||||
sub,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200);
|
||||
|
||||
@@ -59,6 +59,7 @@ api.iapAndroidVerify = {
|
||||
user,
|
||||
paymentMethod: 'IAP GooglePlay',
|
||||
amount: 5.25,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200, googleRes);
|
||||
@@ -117,17 +118,17 @@ api.iapiOSVerify = {
|
||||
|
||||
switch (purchaseData.productId) {
|
||||
case 'com.habitrpg.ios.Habitica.4gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 1}); // eslint-disable-line babel/no-await-in-loop
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 1, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.8gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 2}); // eslint-disable-line babel/no-await-in-loop
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 2, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.20gems':
|
||||
case 'com.habitrpg.ios.Habitica.21gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 5.25}); // eslint-disable-line babel/no-await-in-loop
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 5.25, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.42gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 10.5}); // eslint-disable-line babel/no-await-in-loop
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 10.5, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
break;
|
||||
default:
|
||||
correctReceipt = false;
|
||||
|
||||
@@ -208,6 +208,7 @@ api.subscribeSuccess = {
|
||||
customerId: result.id,
|
||||
paymentMethod: 'Paypal',
|
||||
sub: block,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.redirect('/');
|
||||
|
||||
@@ -84,6 +84,7 @@ api.checkout = {
|
||||
customerId: response.id,
|
||||
paymentMethod: 'Stripe',
|
||||
sub,
|
||||
headers: req.headers,
|
||||
});
|
||||
} else {
|
||||
let method = 'buyGems';
|
||||
|
||||
Reference in New Issue
Block a user