diff --git a/helpers/statsHelpers.js b/helpers/statsHelpers.js index d6d559a0..b4e486b3 100644 --- a/helpers/statsHelpers.js +++ b/helpers/statsHelpers.js @@ -63,14 +63,14 @@ module.exports = { sendGoogleAnalyticsTiming (action, headers, ip, originalUrl, startTime, endTime) { const visitorId = ip.replace(/\./g, '-'); const visitor = ua(googleApiKey, visitorId, { strictCidFormat: false, https: true }); - const time = endTime - startTime; + const publishDurration = endTime - startTime; let params; switch (action) { case 'PUBLISH': params = { userTimingCategory : 'lbrynet', userTimingVariableName: 'publish', - userTimingTime : time, + userTimingTime : publishDurration, uip : ip, ua : headers['user-agent'], ul : headers['accept-language'], @@ -82,6 +82,7 @@ module.exports = { if (err) { logger.error('Google Analytics Event Error >>', err); } + logger.info(`publish completed successfully in ${publishDurration}ms`); }); }, }; diff --git a/routes/api-routes.js b/routes/api-routes.js index 976e183d..c22f19cb 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -128,7 +128,8 @@ module.exports = (app) => { app.post('/api/claim-publish', multipartMiddleware, ({ body, files, headers, ip, originalUrl, user }, res) => { logger.debug('api/claim-publish body:', body); logger.debug('api/claim-publish files:', files); - const startTime = Date.now(); + const publishStartTime = Date.now(); + logger.debug('publish request started @', publishStartTime); let name, fileName, filePath, fileType, nsfw, license, title, description, thumbnail, channelName, channelPassword; // validate the body and files of the request try { @@ -170,9 +171,9 @@ module.exports = (app) => { lbryTx: result, }, }); - const endTime = Date.now(); - console.log('publish end time', endTime); - sendGoogleAnalyticsTiming('PUBLISH', headers, ip, originalUrl, startTime, endTime); + const publishEndTime = Date.now(); + logger.debug('publish request completed @', publishEndTime); + sendGoogleAnalyticsTiming('PUBLISH', headers, ip, originalUrl, publishStartTime, publishEndTime); }) .catch(error => { errorHandlers.handleApiError(originalUrl, ip, error, res);