diff --git a/src/analytics.js b/src/analytics.js index 1f98beb476..8bf40ffc3c 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -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) { diff --git a/src/controllers/category.js b/src/controllers/category.js index f3e90897cf..9aec649ec3 100644 --- a/src/controllers/category.js +++ b/src/controllers/category.js @@ -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); diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 40299ceb9b..b6ff617c15 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -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); diff --git a/src/middleware/index.js b/src/middleware/index.js index 659724153e..0173ecb3c6 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -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, });