mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
allow mobile to send analytics calls
This commit is contained in:
@@ -21,9 +21,10 @@ api.trackEvent = {
|
||||
// we authenticate these requests to make sure they actually came from a real user
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
// As of now only web can track events using this route
|
||||
if (req.headers['x-client'] !== 'habitica-web') {
|
||||
throw new NotAuthorized('Only habitica.com is allowed to track analytics events.');
|
||||
if (req.headers['x-client'] !== 'habitica-web'
|
||||
&& req.headers['x-client'] !== 'habitica-ios'
|
||||
&& req.headers['x-client'] !== 'habitica-android') {
|
||||
throw new NotAuthorized('Only official clients are allowed to track analytics events.');
|
||||
}
|
||||
|
||||
const { user } = res.locals;
|
||||
@@ -49,9 +50,10 @@ api.updateUserProperties = {
|
||||
// we authenticate these requests to make sure they actually came from a real user
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
// As of now only web can track events using this route
|
||||
if (req.headers['x-client'] !== 'habitica-web') {
|
||||
throw new NotAuthorized('Only habitica.com is allowed to track analytics events.');
|
||||
if (req.headers['x-client'] !== 'habitica-web'
|
||||
&& req.headers['x-client'] !== 'habitica-ios'
|
||||
&& req.headers['x-client'] !== 'habitica-android') {
|
||||
throw new NotAuthorized('Only official clients are allowed to track analytics events.');
|
||||
}
|
||||
|
||||
const { user } = res.locals;
|
||||
|
||||
Reference in New Issue
Block a user