Add 'Carto-Stat-Tag', 'Carto-User-Id', and 'Carto-Client' headers

This commit is contained in:
Daniel García Aubert
2020-05-26 13:15:35 +02:00
parent 4d06fee1e2
commit ddefb1a6ca
4 changed files with 9 additions and 1 deletions
@@ -3,9 +3,12 @@
module.exports = function incrementMapViewCount (metadataBackend) {
return function incrementMapViewCountMiddleware (req, res, next) {
const { mapConfig, user } = res.locals;
const statTag = mapConfig.obj().stat_tag;
res.set('Carto-Stat-Tag', `${statTag}`);
// Error won't blow up, just be logged.
metadataBackend.incMapviewCount(user, mapConfig.obj().stat_tag, (err) => {
metadataBackend.incMapviewCount(user, statTag, (err) => {
req.profiler.done('incMapviewCount');
if (err) {
+1
View File
@@ -14,6 +14,7 @@ module.exports = function user (metadataBackend) {
}
res.locals.userId = userId;
res.set('Carto-User-Id', `${userId}`);
return next();
});
};