mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Revert "Analytics: track generic events through the server (#12735)"
This reverts commit 48dbe547c0.
This commit is contained in:
@@ -221,7 +221,6 @@ api.createChallenge = {
|
||||
groupID: group._id,
|
||||
groupName: group.privacy === 'private' ? null : group.name,
|
||||
groupType: group._id === TAVERN_ID ? 'tavern' : group.type,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(201, response);
|
||||
@@ -287,7 +286,6 @@ api.joinChallenge = {
|
||||
groupID: group._id,
|
||||
groupName: group.privacy === 'private' ? null : group.name,
|
||||
groupType: group._id === TAVERN_ID ? 'tavern' : group.type,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200, response);
|
||||
@@ -337,7 +335,6 @@ api.leaveChallenge = {
|
||||
groupID: challenge.group._id,
|
||||
groupName: challenge.group.privacy === 'private' ? null : challenge.group.name,
|
||||
groupType: challenge.group._id === TAVERN_ID ? 'tavern' : challenge.group.type,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200, {});
|
||||
@@ -751,7 +748,6 @@ api.deleteChallenge = {
|
||||
groupID: challenge.group._id,
|
||||
groupName: challenge.group.privacy === 'private' ? null : challenge.group.name,
|
||||
groupType: challenge.group._id === TAVERN_ID ? 'tavern' : challenge.group.type,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200, {});
|
||||
@@ -802,7 +798,6 @@ api.selectChallengeWinner = {
|
||||
groupID: challenge.group._id,
|
||||
groupName: challenge.group.privacy === 'private' ? null : challenge.group.name,
|
||||
groupType: challenge.group._id === TAVERN_ID ? 'tavern' : challenge.group.type,
|
||||
headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200, {});
|
||||
|
||||
@@ -156,7 +156,7 @@ api.inviteToQuest = {
|
||||
questName: questKey,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
}, true);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -217,7 +217,7 @@ api.acceptQuest = {
|
||||
questName: group.quest.key,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
}, true);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -278,7 +278,7 @@ api.rejectQuest = {
|
||||
questName: group.quest.key,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
}, true);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -338,7 +338,7 @@ api.forceStart = {
|
||||
questName: group.quest.key,
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
}, true);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import {
|
||||
NotAuthorized,
|
||||
} from '../../libs/errors';
|
||||
import {
|
||||
authWithHeaders,
|
||||
} from '../../middlewares/auth';
|
||||
|
||||
const api = {};
|
||||
|
||||
/**
|
||||
* @apiIgnore Analytics are considered part of the private API
|
||||
* @api {post} /analytics/track/:eventName Track a generic analytics event
|
||||
* @apiName AnalyticsTrack
|
||||
* @apiGroup Analytics
|
||||
*
|
||||
* @apiSuccess {Object} data An empty object
|
||||
* */
|
||||
api.trackEvent = {
|
||||
method: 'POST',
|
||||
url: '/analytics/track/:eventName',
|
||||
// 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.');
|
||||
}
|
||||
|
||||
const { user } = res.locals;
|
||||
const eventProperties = req.body;
|
||||
|
||||
res.analytics.track(req.params.eventName, {
|
||||
uuid: user._id,
|
||||
headers: req.headers,
|
||||
category: 'behaviour',
|
||||
gaLabel: 'local',
|
||||
// hitType: 'event', sent from the client
|
||||
...eventProperties,
|
||||
});
|
||||
|
||||
// not using res.respond
|
||||
// because we don't want to send back notifications and other user-related data
|
||||
res.status(200).send({});
|
||||
},
|
||||
};
|
||||
|
||||
export default api;
|
||||
@@ -63,7 +63,7 @@ api.checkoutSuccess = {
|
||||
if (!customerId) throw new BadRequest(apiError('missingCustomerId'));
|
||||
|
||||
await paypalPayments.checkoutSuccess({
|
||||
user, gemsBlock, gift, paymentId, customerId, headers: req.headers,
|
||||
user, gemsBlock, gift, paymentId, customerId,
|
||||
});
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
|
||||
@@ -35,7 +35,7 @@ api.checkout = {
|
||||
const { groupId, coupon, gemsBlock } = req.query;
|
||||
|
||||
await stripePayments.checkout({
|
||||
token, user, gemsBlock, gift, sub, groupId, coupon, headers: req.headers,
|
||||
token, user, gemsBlock, gift, sub, groupId, coupon,
|
||||
});
|
||||
|
||||
res.respond(200, {});
|
||||
|
||||
Reference in New Issue
Block a user