use user_id for client side six pack. also change name of editor free trial test

This commit is contained in:
Henry Oswald 2015-11-17 15:54:59 +00:00
parent 76be671e26
commit 5a9174b1de
6 changed files with 15 additions and 8 deletions

View file

@ -92,6 +92,9 @@ module.exports = (app, webRouter, apiRouter)->
if req.query.redir? if req.query.redir?
return "?#{querystring.stringify({redir:req.query.redir})}" return "?#{querystring.stringify({redir:req.query.redir})}"
return "" return ""
res.locals.getLoggedInUserId = ->
return req.session.user?._id
next() next()
webRouter.use (req, res, next) -> webRouter.use (req, res, next) ->
@ -176,3 +179,4 @@ module.exports = (app, webRouter, apiRouter)->
res.locals.moduleIncludesAvailable = Modules.moduleIncludesAvailable res.locals.moduleIncludesAvailable = Modules.moduleIncludesAvailable
next() next()

View file

@ -61,6 +61,7 @@ html(itemscope, itemtype='http://schema.org/Product')
}; };
window.systemMessages = !{JSON.stringify(systemMessages).replace(/\//g, '\\/')}; window.systemMessages = !{JSON.stringify(systemMessages).replace(/\//g, '\\/')};
window.ab = {} window.ab = {}
window.user_id = '#{getLoggedInUserId()}'
- if (typeof(settings.algolia) != "undefined") - if (typeof(settings.algolia) != "undefined")
script. script.

View file

@ -21,6 +21,7 @@ define [
sixpackProvider.setOptions({ sixpackProvider.setOptions({
debug: false debug: false
baseUrl: window.sharelatex.sixpackDomain baseUrl: window.sharelatex.sixpackDomain
client_id: window.user_id
}) })
return App return App

View file

@ -8,7 +8,7 @@ define [
$scope.startFreeTrial = (source, couponCode) -> $scope.startFreeTrial = (source, couponCode) ->
w = window.open() w = window.open()
sixpack.convert "track-changes-discount", -> sixpack.convert "track-changes-discount", ->
sixpack.participate 'free-trial-plan', ['student', 'collaborator'], (planName, rawResponse)-> sixpack.participate 'in-editor-free-trial-plan', ['student', 'collaborator'], (planName, rawResponse)->
ga?('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source) ga?('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
url = "/user/subscription/new?planCode=#{planName}_free_trial_7_days&ssp=#{planName == 'collaborator'}" url = "/user/subscription/new?planCode=#{planName}_free_trial_7_days&ssp=#{planName == 'collaborator'}"
if couponCode? if couponCode?

View file

@ -117,7 +117,7 @@ define [
coupon_code:pricing.items?.coupon?.code || "" coupon_code:pricing.items?.coupon?.code || ""
$http.post("/user/subscription/create", postData) $http.post("/user/subscription/create", postData)
.success (data, status, headers)-> .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" window.location.href = "/user/subscription/thank-you"
.error (data, status, headers)-> .error (data, status, headers)->
$scope.processing = false $scope.processing = false

View file

@ -56,6 +56,7 @@
_session = new sp.Session({client_id:_clientId, base_url:_opts.baseUrl}); _session = new sp.Session({client_id:_clientId, base_url:_opts.baseUrl});
} else { } else {
_session = new sp.Session({client_id:undefined, base_url:_opts.baseUrl}); _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; $cookies[_cookiePrefix + 'clientId'] = _clientId = _session.client_id;
} }
if (_opts.debug) { if (_opts.debug) {