overleaf/services/web/public/coffee/main/account-upgrade.coffee
2018-05-22 16:59:59 +01:00

26 lines
691 B
CoffeeScript

define [
"base"
], (App) ->
App.controller "FreeTrialModalController", ($scope, abTestManager, sixpack, event_tracking)->
$scope.buttonClass = "btn-primary"
$scope.startFreeTrial = (source, couponCode) ->
plan = 'collaborator_free_trial_7_days'
w = window.open()
go = () ->
ga?('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
if window.useV2TrialUrl
url = "/user/trial"
else
url = "/user/subscription/new?planCode=#{plan}&ssp=true"
if couponCode?
url = "#{url}&cc=#{couponCode}"
$scope.startedFreeTrial = true
event_tracking.sendMB "subscription-start-trial", { source, plan }
w.location = url
go()