added events for publish

This commit is contained in:
bill bittner 2017-06-29 22:26:29 -07:00
parent ad36f26aac
commit 7d701f5b57
8 changed files with 23 additions and 14 deletions

View file

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

View file

@ -128,6 +128,12 @@ uploader.addEventListener('start', function(event){
document.getElementById('publish-active-area').innerHTML = '<div id="publish-status"></div><div id="progress-bar"></div>';
// 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;

View file

@ -108,6 +108,12 @@ uploader.addEventListener('start', function(event){
document.getElementById('publish-active-area').innerHTML = '<div id="publish-status"></div><div id="progress-bar"></div>';
// 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;

View file

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

View file

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

View file

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

View file

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

View file

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