From d69a7577f5cc56b08ba7089a2b3de985800593b7 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 6 Jul 2017 16:35:52 +0100 Subject: [PATCH] Check in Analytics if user has already been informed about per-user TC. --- .../Features/Project/ProjectController.coffee | 21 ++++++++++++++++++- services/web/app/views/project/editor.pug | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Project/ProjectController.coffee b/services/web/app/coffee/Features/Project/ProjectController.coffee index 44aabb97ab..389d623bbd 100644 --- a/services/web/app/coffee/Features/Project/ProjectController.coffee +++ b/services/web/app/coffee/Features/Project/ProjectController.coffee @@ -230,6 +230,24 @@ module.exports = ProjectController = return cb(null, false) else return cb(null, true) + showPerUserTCNotice: (cb) -> + cb = underscore.once(cb) + if !user_id? + return cb() + timestamp = user_id.toString().substring(0,8) + userSignupDate = new Date( parseInt( timestamp, 16 ) * 1000 ) + if userSignupDate > new Date("2018-01-01") # 8th March + # Don't show for users who registered after it was released + return cb(null, false) + timeout = setTimeout cb, 500 + AnalyticsManager.getLastOccurance user_id, "shown-per-user-tc-notice", (error, event) -> + clearTimeout timeout + if error? + return cb(null, false) + else if event? + return cb(null, false) + else + return cb(null, true) }, (err, results)-> if err? logger.err err:err, "error getting details for project page" @@ -237,7 +255,7 @@ module.exports = ProjectController = project = results.project user = results.user subscription = results.subscription - showTrackChangesOnboarding = results.showTrackChangesOnboarding + { showTrackChangesOnboarding, showPerUserTCNotice } = results daysSinceLastUpdated = (new Date() - project.lastUpdated) /86400000 logger.log project_id:project_id, daysSinceLastUpdated:daysSinceLastUpdated, "got db results for loading editor" @@ -280,6 +298,7 @@ module.exports = ProjectController = } trackChangesState: project.track_changes showTrackChangesOnboarding: !!showTrackChangesOnboarding + showPerUserTCNotice: !!showPerUserTCNotice privilegeLevel: privilegeLevel chatUrl: Settings.apis.chat.url anonymous: anonymous diff --git a/services/web/app/views/project/editor.pug b/services/web/app/views/project/editor.pug index 3ccb51ef04..5919c4efc2 100644 --- a/services/web/app/views/project/editor.pug +++ b/services/web/app/views/project/editor.pug @@ -120,6 +120,7 @@ block requirejs window.maxDocLength = #{maxDocLength}; window.trackChangesState = data.trackChangesState; window.showTrackChangesOnboarding = #{!!showTrackChangesOnboarding}; + window.showPerUserTCNotice = #{!!showPerUserTCNotice}; window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)}; window.requirejs = { "paths" : {