mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Revert "Analytics: track generic events through the server (#12735)"
This reverts commit 48dbe547c0.
This commit is contained in:
@@ -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