diff --git a/helpers/libraries/errorHandlers.js b/helpers/libraries/errorHandlers.js index f2ab9984..45264a86 100644 --- a/helpers/libraries/errorHandlers.js +++ b/helpers/libraries/errorHandlers.js @@ -1,5 +1,5 @@ const logger = require('winston'); -const { postToStats } = require('./statsController.js'); +const { postToStats } = require('../../controllers/statsController.js'); module.exports = { handleRequestError (action, originalUrl, ip, error, res) { diff --git a/public/assets/js/claimPublish.js b/public/assets/js/claimPublish.js index 6391d8f6..eae7e5c3 100644 --- a/public/assets/js/claimPublish.js +++ b/public/assets/js/claimPublish.js @@ -128,6 +128,12 @@ uploader.addEventListener('start', function(event){ document.getElementById('publish-active-area').innerHTML = '
'; // start a progress animation createProgressBar(document.getElementById('progress-bar'), 12); + // google analytics + ga('send', { + hitType: 'event', + eventCategory: 'publish', + eventAction: name + }); }); uploader.addEventListener('progress', function(event){ var percent = event.bytesLoaded / event.file.size * 100; diff --git a/public/assets/js/memePublish.js b/public/assets/js/memePublish.js index 6cd50171..e2f4798a 100644 --- a/public/assets/js/memePublish.js +++ b/public/assets/js/memePublish.js @@ -108,6 +108,12 @@ uploader.addEventListener('start', function(event){ document.getElementById('publish-active-area').innerHTML = ''; // start a progress animation createProgressBar(document.getElementById('progress-bar'), 12); + // google analytics + ga('send', { + hitType: 'event', + eventCategory: 'publish', + eventAction: nameInput.value + }); }); uploader.addEventListener('progress', function(event){ var percent = event.bytesLoaded / event.file.size * 100; diff --git a/routes/api-routes.js b/routes/api-routes.js index c9aa51a9..747c72de 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -5,7 +5,7 @@ const publishController = require('../controllers/publishController.js'); const lbryApi = require('../helpers/libraries/lbryApi.js'); const publishHelpers = require('../helpers/libraries/publishHelpers.js'); const errorHandlers = require('../helpers/libraries/errorHandlers.js'); -const { postToStats, sendGoogleAnalytics } = require('../helpers/libraries/statsController.js'); +const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js'); module.exports = app => { // route to run a claim_list request on the daemon diff --git a/routes/home-routes.js b/routes/home-routes.js index e475b712..f0891a01 100644 --- a/routes/home-routes.js +++ b/routes/home-routes.js @@ -1,5 +1,5 @@ const logger = require('winston'); -const { postToStats, sendGoogleAnalytics } = require('../helpers/libraries/statsController.js'); +const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js'); module.exports = app => { // route for the home page diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 3d382b88..cfbf11a3 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -1,7 +1,7 @@ const errorHandlers = require('../helpers/libraries/errorHandlers.js'); const serveController = require('../controllers/serveController.js'); const logger = require('winston'); -const { postToStats, sendGoogleAnalytics } = require('../helpers/libraries/statsController.js'); +const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js'); function serveFile ({ fileName, fileType, filePath }, res) { logger.info(`serving file ${fileName}`); diff --git a/routes/show-routes.js b/routes/show-routes.js index da9c5580..945fc162 100644 --- a/routes/show-routes.js +++ b/routes/show-routes.js @@ -1,8 +1,7 @@ const logger = require('winston'); const errorHandlers = require('../helpers/libraries/errorHandlers.js'); -const showController = require('../controllers/showController.js'); -const { postToStats, sendGoogleAnalytics } = require('../helpers/libraries/statsController.js'); -const statsController = require('../controllers/statsController.js'); +const { getAllClaims } = require('../controllers/showController.js'); +const { getStatsSummary, postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js'); function sendAnalyticsAndLog (ip, originalUrl) { // google analytics @@ -17,8 +16,7 @@ module.exports = (app) => { app.get('/meme-fodder/play', ({ ip, originalUrl }, res) => { sendAnalyticsAndLog(ip, originalUrl); // get and render the content - showController - .getAllClaims('meme-fodder') + getAllClaims('meme-fodder') .then(orderedFreePublicClaims => { postToStats('show', originalUrl, ip, 'success'); res.status(200).render('memeFodder', { claims: orderedFreePublicClaims }); @@ -31,8 +29,7 @@ module.exports = (app) => { app.get('/stats', ({ ip, originalUrl }, res) => { sendAnalyticsAndLog(ip, originalUrl); // get and render the content - statsController - .getStatsSummary() + getStatsSummary() .then(result => { postToStats('show', originalUrl, ip, 'success'); res.status(200).render('statistics', result); @@ -45,8 +42,7 @@ module.exports = (app) => { app.get('/:name/all', ({ ip, originalUrl, params }, res) => { sendAnalyticsAndLog(ip, originalUrl); // get and render the content - showController - .getAllClaims(params.name) + getAllClaims(params.name) .then(orderedFreePublicClaims => { postToStats('show', originalUrl, ip, 'success'); res.status(200).render('allClaims', { claims: orderedFreePublicClaims }); diff --git a/routes/sockets-routes.js b/routes/sockets-routes.js index 622a4294..7ca4b092 100644 --- a/routes/sockets-routes.js +++ b/routes/sockets-routes.js @@ -2,7 +2,7 @@ const logger = require('winston'); const publishController = require('../controllers/publishController.js'); const publishHelpers = require('../helpers/libraries/publishHelpers.js'); const errorHandlers = require('../helpers/libraries/errorHandlers.js'); -const { postToStats } = require('../helpers/libraries/statsController.js'); +const { postToStats } = require('../controllers/statsController.js'); module.exports = (app, siofu, hostedContentPath) => { const http = require('http').Server(app); @@ -16,6 +16,7 @@ module.exports = (app, siofu, hostedContentPath) => { uploader.listen(socket); // listener for when file upload starts uploader.on('start', ({ file }) => { + // log logger.info('client started an upload:', file.name); // server side test to make sure file is not a bad file type if (/\.exe$/.test(file.name)) {