mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
move category pageview to controllers
so topic views are tracked as category views
This commit is contained in:
@@ -14,8 +14,6 @@ var pageViews = 0;
|
||||
var uniqueIPCount = 0;
|
||||
var uniquevisitors = 0;
|
||||
|
||||
var isCategory = /^(?:\/api)?\/category\/(\d+)/;
|
||||
|
||||
new cronJob('*/10 * * * * *', function () {
|
||||
Analytics.writeData();
|
||||
}, null, true);
|
||||
@@ -52,15 +50,6 @@ Analytics.pageView = function (payload) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (payload.path) {
|
||||
var categoryMatch = payload.path.match(isCategory);
|
||||
var cid = categoryMatch ? parseInt(categoryMatch[1], 10) : null;
|
||||
|
||||
if (cid) {
|
||||
Analytics.increment(['pageviews:byCid:' + cid]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Analytics.writeData = function (callback) {
|
||||
|
||||
@@ -13,6 +13,7 @@ var pagination = require('../pagination');
|
||||
var helpers = require('./helpers');
|
||||
var utils = require('../utils');
|
||||
var translator = require('../translator');
|
||||
var analytics = require('../analytics');
|
||||
|
||||
var categoryController = module.exports;
|
||||
|
||||
@@ -144,6 +145,8 @@ categoryController.get = function (req, res, callback) {
|
||||
res.locals.linkTags.push(rel);
|
||||
});
|
||||
|
||||
analytics.increment(['pageviews:byCid:' + categoryData.cid]);
|
||||
|
||||
res.render('category', categoryData);
|
||||
},
|
||||
], callback);
|
||||
|
||||
@@ -13,6 +13,7 @@ var plugins = require('../plugins');
|
||||
var helpers = require('./helpers');
|
||||
var pagination = require('../pagination');
|
||||
var utils = require('../utils');
|
||||
var analytics = require('../analytics');
|
||||
|
||||
var topicsController = module.exports;
|
||||
|
||||
@@ -178,6 +179,8 @@ topicsController.get = function (req, res, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
analytics.increment(['pageviews:byCid:' + topicData.category.cid]);
|
||||
|
||||
res.render('topic', topicData);
|
||||
},
|
||||
], callback);
|
||||
|
||||
@@ -53,7 +53,6 @@ middleware.stripLeadingSlashes = function (req, res, next) {
|
||||
middleware.pageView = function (req, res, next) {
|
||||
analytics.pageView({
|
||||
ip: req.ip,
|
||||
path: req.path,
|
||||
uid: req.uid,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user