updated logging
This commit is contained in:
parent
118ff2deb3
commit
a468485d33
2 changed files with 8 additions and 6 deletions
|
@ -63,14 +63,14 @@ module.exports = {
|
||||||
sendGoogleAnalyticsTiming (action, headers, ip, originalUrl, startTime, endTime) {
|
sendGoogleAnalyticsTiming (action, headers, ip, originalUrl, startTime, endTime) {
|
||||||
const visitorId = ip.replace(/\./g, '-');
|
const visitorId = ip.replace(/\./g, '-');
|
||||||
const visitor = ua(googleApiKey, visitorId, { strictCidFormat: false, https: true });
|
const visitor = ua(googleApiKey, visitorId, { strictCidFormat: false, https: true });
|
||||||
const time = endTime - startTime;
|
const publishDurration = endTime - startTime;
|
||||||
let params;
|
let params;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'PUBLISH':
|
case 'PUBLISH':
|
||||||
params = {
|
params = {
|
||||||
userTimingCategory : 'lbrynet',
|
userTimingCategory : 'lbrynet',
|
||||||
userTimingVariableName: 'publish',
|
userTimingVariableName: 'publish',
|
||||||
userTimingTime : time,
|
userTimingTime : publishDurration,
|
||||||
uip : ip,
|
uip : ip,
|
||||||
ua : headers['user-agent'],
|
ua : headers['user-agent'],
|
||||||
ul : headers['accept-language'],
|
ul : headers['accept-language'],
|
||||||
|
@ -82,6 +82,7 @@ module.exports = {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error('Google Analytics Event Error >>', 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) => {
|
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 body:', body);
|
||||||
logger.debug('api/claim-publish files:', files);
|
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;
|
let name, fileName, filePath, fileType, nsfw, license, title, description, thumbnail, channelName, channelPassword;
|
||||||
// validate the body and files of the request
|
// validate the body and files of the request
|
||||||
try {
|
try {
|
||||||
|
@ -170,9 +171,9 @@ module.exports = (app) => {
|
||||||
lbryTx: result,
|
lbryTx: result,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const endTime = Date.now();
|
const publishEndTime = Date.now();
|
||||||
console.log('publish end time', endTime);
|
logger.debug('publish request completed @', publishEndTime);
|
||||||
sendGoogleAnalyticsTiming('PUBLISH', headers, ip, originalUrl, startTime, endTime);
|
sendGoogleAnalyticsTiming('PUBLISH', headers, ip, originalUrl, publishStartTime, publishEndTime);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
errorHandlers.handleApiError(originalUrl, ip, error, res);
|
errorHandlers.handleApiError(originalUrl, ip, error, res);
|
||||||
|
|
Loading…
Reference in a new issue