Revert "Analytics: track generic events through the server (#12735)"

This reverts commit 48dbe547c0.
This commit is contained in:
Sabe Jones
2020-11-05 15:44:30 -06:00
parent b97d514c68
commit 9d6fb2ca26
16 changed files with 17 additions and 120 deletions

View File

@@ -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, {});

View File

@@ -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);
});
},
};

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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, {});