overleaf/services/web/public/coffee/main/account-upgrade.coffee

31 lines
1.1 KiB
CoffeeScript
Raw Normal View History

define [
"base"
], (App) ->
2016-07-12 11:41:22 -04:00
App.controller "FreeTrialModalController", ($scope, abTestManager, sixpack, event_tracking)->
$scope.buttonClass = "btn-primary"
2015-11-16 10:52:47 -05:00
$scope.startFreeTrial = (source, couponCode) ->
w = window.open()
2016-10-27 07:22:58 -04:00
switch source
when "dropbox"
sixpack.participate 'teaser-dropbox-text', ['default', 'dropbox-focused'], (variant) ->
event_tracking.sendMB "subscription-start-trial", { source, variant }
when "history"
sixpack.participate 'teaser-history', ['default', 'focused'], (variant) ->
event_tracking.sendMB "subscription-start-trial", { source, variant }
else
event_tracking.sendMB "subscription-start-trial", { source }
sixpack.convert "track-changes-discount", ->
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