added events for publish
This commit is contained in:
parent
ad36f26aac
commit
7d701f5b57
8 changed files with 23 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { postToStats } = require('./statsController.js');
|
const { postToStats } = require('../../controllers/statsController.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
handleRequestError (action, originalUrl, ip, error, res) {
|
handleRequestError (action, originalUrl, ip, error, res) {
|
||||||
|
|
|
@ -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>';
|
document.getElementById('publish-active-area').innerHTML = '<div id="publish-status"></div><div id="progress-bar"></div>';
|
||||||
// start a progress animation
|
// start a progress animation
|
||||||
createProgressBar(document.getElementById('progress-bar'), 12);
|
createProgressBar(document.getElementById('progress-bar'), 12);
|
||||||
|
// google analytics
|
||||||
|
ga('send', {
|
||||||
|
hitType: 'event',
|
||||||
|
eventCategory: 'publish',
|
||||||
|
eventAction: name
|
||||||
|
});
|
||||||
});
|
});
|
||||||
uploader.addEventListener('progress', function(event){
|
uploader.addEventListener('progress', function(event){
|
||||||
var percent = event.bytesLoaded / event.file.size * 100;
|
var percent = event.bytesLoaded / event.file.size * 100;
|
||||||
|
|
|
@ -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>';
|
document.getElementById('publish-active-area').innerHTML = '<div id="publish-status"></div><div id="progress-bar"></div>';
|
||||||
// start a progress animation
|
// start a progress animation
|
||||||
createProgressBar(document.getElementById('progress-bar'), 12);
|
createProgressBar(document.getElementById('progress-bar'), 12);
|
||||||
|
// google analytics
|
||||||
|
ga('send', {
|
||||||
|
hitType: 'event',
|
||||||
|
eventCategory: 'publish',
|
||||||
|
eventAction: nameInput.value
|
||||||
|
});
|
||||||
});
|
});
|
||||||
uploader.addEventListener('progress', function(event){
|
uploader.addEventListener('progress', function(event){
|
||||||
var percent = event.bytesLoaded / event.file.size * 100;
|
var percent = event.bytesLoaded / event.file.size * 100;
|
||||||
|
|
|
@ -5,7 +5,7 @@ const publishController = require('../controllers/publishController.js');
|
||||||
const lbryApi = require('../helpers/libraries/lbryApi.js');
|
const lbryApi = require('../helpers/libraries/lbryApi.js');
|
||||||
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
||||||
const errorHandlers = require('../helpers/libraries/errorHandlers.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 => {
|
module.exports = app => {
|
||||||
// route to run a claim_list request on the daemon
|
// route to run a claim_list request on the daemon
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { postToStats, sendGoogleAnalytics } = require('../helpers/libraries/statsController.js');
|
const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||||
|
|
||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
// route for the home page
|
// route for the home page
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||||
const serveController = require('../controllers/serveController.js');
|
const serveController = require('../controllers/serveController.js');
|
||||||
const logger = require('winston');
|
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) {
|
function serveFile ({ fileName, fileType, filePath }, res) {
|
||||||
logger.info(`serving file ${fileName}`);
|
logger.info(`serving file ${fileName}`);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||||
const showController = require('../controllers/showController.js');
|
const { getAllClaims } = require('../controllers/showController.js');
|
||||||
const { postToStats, sendGoogleAnalytics } = require('../helpers/libraries/statsController.js');
|
const { getStatsSummary, postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||||
const statsController = require('../controllers/statsController.js');
|
|
||||||
|
|
||||||
function sendAnalyticsAndLog (ip, originalUrl) {
|
function sendAnalyticsAndLog (ip, originalUrl) {
|
||||||
// google analytics
|
// google analytics
|
||||||
|
@ -17,8 +16,7 @@ module.exports = (app) => {
|
||||||
app.get('/meme-fodder/play', ({ ip, originalUrl }, res) => {
|
app.get('/meme-fodder/play', ({ ip, originalUrl }, res) => {
|
||||||
sendAnalyticsAndLog(ip, originalUrl);
|
sendAnalyticsAndLog(ip, originalUrl);
|
||||||
// get and render the content
|
// get and render the content
|
||||||
showController
|
getAllClaims('meme-fodder')
|
||||||
.getAllClaims('meme-fodder')
|
|
||||||
.then(orderedFreePublicClaims => {
|
.then(orderedFreePublicClaims => {
|
||||||
postToStats('show', originalUrl, ip, 'success');
|
postToStats('show', originalUrl, ip, 'success');
|
||||||
res.status(200).render('memeFodder', { claims: orderedFreePublicClaims });
|
res.status(200).render('memeFodder', { claims: orderedFreePublicClaims });
|
||||||
|
@ -31,8 +29,7 @@ module.exports = (app) => {
|
||||||
app.get('/stats', ({ ip, originalUrl }, res) => {
|
app.get('/stats', ({ ip, originalUrl }, res) => {
|
||||||
sendAnalyticsAndLog(ip, originalUrl);
|
sendAnalyticsAndLog(ip, originalUrl);
|
||||||
// get and render the content
|
// get and render the content
|
||||||
statsController
|
getStatsSummary()
|
||||||
.getStatsSummary()
|
|
||||||
.then(result => {
|
.then(result => {
|
||||||
postToStats('show', originalUrl, ip, 'success');
|
postToStats('show', originalUrl, ip, 'success');
|
||||||
res.status(200).render('statistics', result);
|
res.status(200).render('statistics', result);
|
||||||
|
@ -45,8 +42,7 @@ module.exports = (app) => {
|
||||||
app.get('/:name/all', ({ ip, originalUrl, params }, res) => {
|
app.get('/:name/all', ({ ip, originalUrl, params }, res) => {
|
||||||
sendAnalyticsAndLog(ip, originalUrl);
|
sendAnalyticsAndLog(ip, originalUrl);
|
||||||
// get and render the content
|
// get and render the content
|
||||||
showController
|
getAllClaims(params.name)
|
||||||
.getAllClaims(params.name)
|
|
||||||
.then(orderedFreePublicClaims => {
|
.then(orderedFreePublicClaims => {
|
||||||
postToStats('show', originalUrl, ip, 'success');
|
postToStats('show', originalUrl, ip, 'success');
|
||||||
res.status(200).render('allClaims', { claims: orderedFreePublicClaims });
|
res.status(200).render('allClaims', { claims: orderedFreePublicClaims });
|
||||||
|
|
|
@ -2,7 +2,7 @@ const logger = require('winston');
|
||||||
const publishController = require('../controllers/publishController.js');
|
const publishController = require('../controllers/publishController.js');
|
||||||
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
||||||
const errorHandlers = require('../helpers/libraries/errorHandlers.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) => {
|
module.exports = (app, siofu, hostedContentPath) => {
|
||||||
const http = require('http').Server(app);
|
const http = require('http').Server(app);
|
||||||
|
@ -16,6 +16,7 @@ module.exports = (app, siofu, hostedContentPath) => {
|
||||||
uploader.listen(socket);
|
uploader.listen(socket);
|
||||||
// listener for when file upload starts
|
// listener for when file upload starts
|
||||||
uploader.on('start', ({ file }) => {
|
uploader.on('start', ({ file }) => {
|
||||||
|
// log
|
||||||
logger.info('client started an upload:', file.name);
|
logger.info('client started an upload:', file.name);
|
||||||
// server side test to make sure file is not a bad file type
|
// server side test to make sure file is not a bad file type
|
||||||
if (/\.exe$/.test(file.name)) {
|
if (/\.exe$/.test(file.name)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue