diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 9fd6a3d5d5..61eaf6ef6d 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -92,6 +92,9 @@ module.exports = (app, webRouter, apiRouter)-> if req.query.redir? return "?#{querystring.stringify({redir:req.query.redir})}" return "" + + res.locals.getLoggedInUserId = -> + return req.session.user?._id next() webRouter.use (req, res, next) -> @@ -176,3 +179,4 @@ module.exports = (app, webRouter, apiRouter)-> res.locals.moduleIncludesAvailable = Modules.moduleIncludesAvailable next() + diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index b73470df94..013c8e5a60 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -61,6 +61,7 @@ html(itemscope, itemtype='http://schema.org/Product') }; window.systemMessages = !{JSON.stringify(systemMessages).replace(/\//g, '\\/')}; window.ab = {} + window.user_id = '#{getLoggedInUserId()}' - if (typeof(settings.algolia) != "undefined") script. diff --git a/services/web/public/coffee/base.coffee b/services/web/public/coffee/base.coffee index 6c765af896..98cdb3a871 100644 --- a/services/web/public/coffee/base.coffee +++ b/services/web/public/coffee/base.coffee @@ -21,6 +21,7 @@ define [ sixpackProvider.setOptions({ debug: false baseUrl: window.sharelatex.sixpackDomain + client_id: window.user_id }) return App diff --git a/services/web/public/coffee/main/account-upgrade.coffee b/services/web/public/coffee/main/account-upgrade.coffee index bf879b3ef4..b212f65fc1 100644 --- a/services/web/public/coffee/main/account-upgrade.coffee +++ b/services/web/public/coffee/main/account-upgrade.coffee @@ -8,10 +8,10 @@ define [ $scope.startFreeTrial = (source, couponCode) -> w = window.open() sixpack.convert "track-changes-discount", -> - sixpack.participate 'free-trial-plan', ['student', 'collaborator'], (planName, rawResponse)-> - ga?('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source) - url = "/user/subscription/new?planCode=#{planName}_free_trial_7_days&ssp=#{planName == 'collaborator'}" - if couponCode? - url = "#{url}&cc=#{couponCode}" - $scope.startedFreeTrial = true - w.location = url + sixpack.participate 'in-editor-free-trial-plan', ['student', 'collaborator'], (planName, rawResponse)-> + ga?('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source) + url = "/user/subscription/new?planCode=#{planName}_free_trial_7_days&ssp=#{planName == 'collaborator'}" + if couponCode? + url = "#{url}&cc=#{couponCode}" + $scope.startedFreeTrial = true + w.location = url diff --git a/services/web/public/coffee/main/new-subscription.coffee b/services/web/public/coffee/main/new-subscription.coffee index bb20977272..404b512e7b 100644 --- a/services/web/public/coffee/main/new-subscription.coffee +++ b/services/web/public/coffee/main/new-subscription.coffee @@ -117,7 +117,7 @@ define [ coupon_code:pricing.items?.coupon?.code || "" $http.post("/user/subscription/create", postData) .success (data, status, headers)-> - sixpack.convert "free-trial-plan", pricing.items.plan.code, -> + sixpack.convert "in-editor-free-trial-plan", pricing.items.plan.code, (err)-> window.location.href = "/user/subscription/thank-you" .error (data, status, headers)-> $scope.processing = false diff --git a/services/web/public/js/libs/angular-sixpack.js b/services/web/public/js/libs/angular-sixpack.js index 062143127a..35117c884c 100644 --- a/services/web/public/js/libs/angular-sixpack.js +++ b/services/web/public/js/libs/angular-sixpack.js @@ -56,6 +56,7 @@ _session = new sp.Session({client_id:_clientId, base_url:_opts.baseUrl}); } else { _session = new sp.Session({client_id:undefined, base_url:_opts.baseUrl}); + _session = new sp.Session({client_id:_opts.client_id, base_url:_opts.baseUrl}); $cookies[_cookiePrefix + 'clientId'] = _clientId = _session.client_id; } if (_opts.debug) {