Matomo tracking
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var express = require('express');
|
||||
var MatomoTracker = require('matomo-tracker');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET home page */
|
||||
router.get('/', function(req, res, next) {
|
||||
@@ -93,19 +94,36 @@ router.post('/request/', function(req, res, next) {
|
||||
var app = req.app
|
||||
var mailer = app.get('MAILER')
|
||||
|
||||
const paramStart = req.body.start
|
||||
const paramEnd = req.body.end
|
||||
const paramName = req.body.name
|
||||
const paramContact = req.body.contact
|
||||
const params = {
|
||||
id: req.body.itemID,
|
||||
title: req.body.itemTitle,
|
||||
start: req.body.start,
|
||||
end: req.body.end,
|
||||
name: req.body.name,
|
||||
contact: req.body.contact
|
||||
}
|
||||
|
||||
mailer.mail({
|
||||
name: paramName,
|
||||
contact: paramContact,
|
||||
start: paramStart,
|
||||
end: paramEnd
|
||||
})
|
||||
mailer.mail(params)
|
||||
|
||||
var fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
|
||||
trackAtMatomo(app, fullUrl, 'Anfrage', params)
|
||||
|
||||
res.render('request', { title: 'Dein.Equipment: Anfrage gesendet' })
|
||||
})
|
||||
|
||||
function trackAtMatomo(app, url, actionName, data) {
|
||||
var matomo = new MatomoTracker(app.get('CONF').matomo.site.id, app.get('CONF').matomo.url)
|
||||
|
||||
matomo.on('error', function(err) {
|
||||
app.get('LOG').error('Router | Error tracking request: ' + err);
|
||||
})
|
||||
|
||||
matomo.track({
|
||||
url: url,
|
||||
action_name: actionName, // Action, shown on dashboard
|
||||
ua: 'Dein.Equipment Backend', // UserAgend
|
||||
data: JSON.stringify(data)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user