Track publish time #329
2 changed files with 8 additions and 6 deletions
|
@ -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`);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue