spee.ch/helpers/libraries/analytics.js

22 lines
474 B
JavaScript
Raw Normal View History

const db = require('../../models');
2017-06-28 01:25:35 +02:00
const logger = require('winston');
module.exports = {
2017-06-28 07:41:48 +02:00
postToAnalytics: (action, url, ipAddress, result) => {
logger.silly('creating record for analytics');
if (result && (typeof result !== 'string')) {
result = result.toString();
}
db.Analytics.create({
action,
url,
ipAddress,
result,
})
.then()
.catch(error => {
logger.error('sequelize error', error);
});
},
};