|
|
@@ -4,6 +4,20 @@ const SessionManager = require('../Authentication/SessionManager')
|
|
|
const GeoIpLookup = require('../../infrastructure/GeoIpLookup')
|
|
|
const Features = require('../../infrastructure/Features')
|
|
|
|
|
|
+const getSegmentation = req => {
|
|
|
+ const segmentation = req.body ? req.body.segmentation : null
|
|
|
+ const cleanedSegmentation = {}
|
|
|
+ if (
|
|
|
+ segmentation &&
|
|
|
+ segmentation.editorType &&
|
|
|
+ typeof segmentation.editorType === 'string' &&
|
|
|
+ segmentation.editorType.length < 100
|
|
|
+ ) {
|
|
|
+ cleanedSegmentation.editorType = segmentation.editorType
|
|
|
+ }
|
|
|
+ return cleanedSegmentation
|
|
|
+}
|
|
|
+
|
|
|
module.exports = {
|
|
|
updateEditingSession(req, res, next) {
|
|
|
if (!Features.hasFeature('analytics')) {
|
|
|
@@ -11,6 +25,7 @@ module.exports = {
|
|
|
}
|
|
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
|
|
const { projectId } = req.params
|
|
|
+ const segmentation = getSegmentation(req)
|
|
|
let countryCode = null
|
|
|
|
|
|
if (userId) {
|
|
|
@@ -20,7 +35,12 @@ module.exports = {
|
|
|
} else if (geoDetails && geoDetails.country_code) {
|
|
|
countryCode = geoDetails.country_code
|
|
|
}
|
|
|
- AnalyticsManager.updateEditingSession(userId, projectId, countryCode)
|
|
|
+ AnalyticsManager.updateEditingSession(
|
|
|
+ userId,
|
|
|
+ projectId,
|
|
|
+ countryCode,
|
|
|
+ segmentation
|
|
|
+ )
|
|
|
})
|
|
|
}
|
|
|
res.sendStatus(202)
|