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?
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()

View file

@ -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.

View file

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

View file

@ -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

View file

@ -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

View file

@ -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) {