Avoid custom headers to be undefined

This commit is contained in:
Daniel García Aubert 2020-05-29 16:06:16 +02:00
parent f31e8b43b6
commit 6bcf477532
3 changed files with 7 additions and 2 deletions

View File

@ -24,6 +24,7 @@ Announcements:
- Remove `bootstrapFonts` at process startup (now done in `windshaft@6.0.0`) - Remove `bootstrapFonts` at process startup (now done in `windshaft@6.0.0`)
- Stop checking the installed version of some dependencies while testing - Stop checking the installed version of some dependencies while testing
- Send metrics about `map views` (#1162) - Send metrics about `map views` (#1162)
- Add custom headers in responses to allow to other components to be able to get insights about user activity.
Bug Fixes: Bug Fixes:
- Parsing date column in numeric histograms (#1160) - Parsing date column in numeric histograms (#1160)

View File

@ -353,7 +353,9 @@ function incrementMapViews ({ metadataBackend }) {
const statTag = mapConfig.obj().stat_tag; const statTag = mapConfig.obj().stat_tag;
res.set('Carto-Stat-Tag', `${statTag}`); if (statTag) {
res.set('Carto-Stat-Tag', `${statTag}`);
}
metadataBackend.incMapviewCount(user, statTag, (err) => { metadataBackend.incMapviewCount(user, statTag, (err) => {
if (err) { if (err) {

View File

@ -5,7 +5,9 @@ module.exports = function incrementMapViewCount (metadataBackend) {
const { mapConfig, user } = res.locals; const { mapConfig, user } = res.locals;
const statTag = mapConfig.obj().stat_tag; const statTag = mapConfig.obj().stat_tag;
res.set('Carto-Stat-Tag', `${statTag}`); if (statTag) {
res.set('Carto-Stat-Tag', `${statTag}`);
}
// Error won't blow up, just be logged. // Error won't blow up, just be logged.
metadataBackend.incMapviewCount(user, statTag, (err) => { metadataBackend.incMapviewCount(user, statTag, (err) => {