mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
fix(analytics): allow tracking static pages events when the user is not authenticated
This commit is contained in:
@@ -19,7 +19,7 @@ api.trackEvent = {
|
||||
method: 'POST',
|
||||
url: '/analytics/track/:eventName',
|
||||
// we authenticate these requests to make sure they actually came from a real user
|
||||
middlewares: [authWithHeaders()],
|
||||
middlewares: [authWithHeaders({ optional: true })],
|
||||
async handler (req, res) {
|
||||
// As of now only web can track events using this route
|
||||
if (req.headers['x-client'] !== 'habitica-web') {
|
||||
@@ -30,7 +30,7 @@ api.trackEvent = {
|
||||
const eventProperties = req.body;
|
||||
|
||||
res.analytics.track(req.params.eventName, {
|
||||
uuid: user._id,
|
||||
uuid: user ? user._id : null,
|
||||
headers: req.headers,
|
||||
category: 'behaviour',
|
||||
gaLabel: 'local',
|
||||
|
||||
Reference in New Issue
Block a user